documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847
  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. readonly 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. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module BABYLON {
  480. /**
  481. * File request interface
  482. */
  483. export interface IFileRequest {
  484. /**
  485. * Raised when the request is complete (success or error).
  486. */
  487. onCompleteObservable: Observable<IFileRequest>;
  488. /**
  489. * Aborts the request for a file.
  490. */
  491. abort: () => void;
  492. }
  493. }
  494. declare module BABYLON {
  495. /**
  496. * Scalar computation library
  497. */
  498. export class Scalar {
  499. /**
  500. * Two pi constants convenient for computation.
  501. */
  502. static TwoPi: number;
  503. /**
  504. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  505. * @param a number
  506. * @param b number
  507. * @param epsilon (default = 1.401298E-45)
  508. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  509. */
  510. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  511. /**
  512. * Returns a string : the upper case translation of the number i to hexadecimal.
  513. * @param i number
  514. * @returns the upper case translation of the number i to hexadecimal.
  515. */
  516. static ToHex(i: number): string;
  517. /**
  518. * Returns -1 if value is negative and +1 is value is positive.
  519. * @param value the value
  520. * @returns the value itself if it's equal to zero.
  521. */
  522. static Sign(value: number): number;
  523. /**
  524. * Returns the value itself if it's between min and max.
  525. * Returns min if the value is lower than min.
  526. * Returns max if the value is greater than max.
  527. * @param value the value to clmap
  528. * @param min the min value to clamp to (default: 0)
  529. * @param max the max value to clamp to (default: 1)
  530. * @returns the clamped value
  531. */
  532. static Clamp(value: number, min?: number, max?: number): number;
  533. /**
  534. * the log2 of value.
  535. * @param value the value to compute log2 of
  536. * @returns the log2 of value.
  537. */
  538. static Log2(value: number): number;
  539. /**
  540. * Loops the value, so that it is never larger than length and never smaller than 0.
  541. *
  542. * This is similar to the modulo operator but it works with floating point numbers.
  543. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  544. * With t = 5 and length = 2.5, the result would be 0.0.
  545. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  546. * @param value the value
  547. * @param length the length
  548. * @returns the looped value
  549. */
  550. static Repeat(value: number, length: number): number;
  551. /**
  552. * Normalize the value between 0.0 and 1.0 using min and max values
  553. * @param value value to normalize
  554. * @param min max to normalize between
  555. * @param max min to normalize between
  556. * @returns the normalized value
  557. */
  558. static Normalize(value: number, min: number, max: number): number;
  559. /**
  560. * Denormalize the value from 0.0 and 1.0 using min and max values
  561. * @param normalized value to denormalize
  562. * @param min max to denormalize between
  563. * @param max min to denormalize between
  564. * @returns the denormalized value
  565. */
  566. static Denormalize(normalized: number, min: number, max: number): number;
  567. /**
  568. * Calculates the shortest difference between two given angles given in degrees.
  569. * @param current current angle in degrees
  570. * @param target target angle in degrees
  571. * @returns the delta
  572. */
  573. static DeltaAngle(current: number, target: number): number;
  574. /**
  575. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  576. * @param tx value
  577. * @param length length
  578. * @returns The returned value will move back and forth between 0 and length
  579. */
  580. static PingPong(tx: number, length: number): number;
  581. /**
  582. * Interpolates between min and max with smoothing at the limits.
  583. *
  584. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  585. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  586. * @param from from
  587. * @param to to
  588. * @param tx value
  589. * @returns the smooth stepped value
  590. */
  591. static SmoothStep(from: number, to: number, tx: number): number;
  592. /**
  593. * Moves a value current towards target.
  594. *
  595. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  596. * Negative values of maxDelta pushes the value away from target.
  597. * @param current current value
  598. * @param target target value
  599. * @param maxDelta max distance to move
  600. * @returns resulting value
  601. */
  602. static MoveTowards(current: number, target: number, maxDelta: number): number;
  603. /**
  604. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  605. *
  606. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  607. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  608. * @param current current value
  609. * @param target target value
  610. * @param maxDelta max distance to move
  611. * @returns resulting angle
  612. */
  613. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  614. /**
  615. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  616. * @param start start value
  617. * @param end target value
  618. * @param amount amount to lerp between
  619. * @returns the lerped value
  620. */
  621. static Lerp(start: number, end: number, amount: number): number;
  622. /**
  623. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  624. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  625. * @param start start value
  626. * @param end target value
  627. * @param amount amount to lerp between
  628. * @returns the lerped value
  629. */
  630. static LerpAngle(start: number, end: number, amount: number): number;
  631. /**
  632. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  633. * @param a start value
  634. * @param b target value
  635. * @param value value between a and b
  636. * @returns the inverseLerp value
  637. */
  638. static InverseLerp(a: number, b: number, value: number): number;
  639. /**
  640. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  641. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  642. * @param value1 spline value
  643. * @param tangent1 spline value
  644. * @param value2 spline value
  645. * @param tangent2 spline value
  646. * @param amount input value
  647. * @returns hermite result
  648. */
  649. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  650. /**
  651. * Returns a random float number between and min and max values
  652. * @param min min value of random
  653. * @param max max value of random
  654. * @returns random value
  655. */
  656. static RandomRange(min: number, max: number): number;
  657. /**
  658. * This function returns percentage of a number in a given range.
  659. *
  660. * RangeToPercent(40,20,60) will return 0.5 (50%)
  661. * RangeToPercent(34,0,100) will return 0.34 (34%)
  662. * @param number to convert to percentage
  663. * @param min min range
  664. * @param max max range
  665. * @returns the percentage
  666. */
  667. static RangeToPercent(number: number, min: number, max: number): number;
  668. /**
  669. * This function returns number that corresponds to the percentage in a given range.
  670. *
  671. * PercentToRange(0.34,0,100) will return 34.
  672. * @param percent to convert to number
  673. * @param min min range
  674. * @param max max range
  675. * @returns the number
  676. */
  677. static PercentToRange(percent: number, min: number, max: number): number;
  678. /**
  679. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  680. * @param angle The angle to normalize in radian.
  681. * @return The converted angle.
  682. */
  683. static NormalizeRadians(angle: number): number;
  684. }
  685. }
  686. declare module BABYLON {
  687. /**
  688. * Constant used to convert a value to gamma space
  689. * @ignorenaming
  690. */
  691. export const ToGammaSpace: number;
  692. /**
  693. * Constant used to convert a value to linear space
  694. * @ignorenaming
  695. */
  696. export const ToLinearSpace = 2.2;
  697. /**
  698. * Constant used to define the minimal number value in Babylon.js
  699. * @ignorenaming
  700. */
  701. let Epsilon: number;
  702. }
  703. declare module BABYLON {
  704. /**
  705. * Class used to represent a viewport on screen
  706. */
  707. export class Viewport {
  708. /** viewport left coordinate */
  709. x: number;
  710. /** viewport top coordinate */
  711. y: number;
  712. /**viewport width */
  713. width: number;
  714. /** viewport height */
  715. height: number;
  716. /**
  717. * Creates a Viewport object located at (x, y) and sized (width, height)
  718. * @param x defines viewport left coordinate
  719. * @param y defines viewport top coordinate
  720. * @param width defines the viewport width
  721. * @param height defines the viewport height
  722. */
  723. constructor(
  724. /** viewport left coordinate */
  725. x: number,
  726. /** viewport top coordinate */
  727. y: number,
  728. /**viewport width */
  729. width: number,
  730. /** viewport height */
  731. height: number);
  732. /**
  733. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  734. * @param renderWidth defines the rendering width
  735. * @param renderHeight defines the rendering height
  736. * @returns a new Viewport
  737. */
  738. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  739. /**
  740. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  741. * @param renderWidth defines the rendering width
  742. * @param renderHeight defines the rendering height
  743. * @param ref defines the target viewport
  744. * @returns the current viewport
  745. */
  746. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  747. /**
  748. * Returns a new Viewport copied from the current one
  749. * @returns a new Viewport
  750. */
  751. clone(): Viewport;
  752. }
  753. }
  754. declare module BABYLON {
  755. /**
  756. * Class containing a set of static utilities functions for arrays.
  757. */
  758. export class ArrayTools {
  759. /**
  760. * Returns an array of the given size filled with element built from the given constructor and the paramters
  761. * @param size the number of element to construct and put in the array
  762. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  763. * @returns a new array filled with new objects
  764. */
  765. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  766. }
  767. }
  768. declare module BABYLON {
  769. /**
  770. * @hidden
  771. */
  772. export interface IColor4Like {
  773. r: float;
  774. g: float;
  775. b: float;
  776. a: float;
  777. }
  778. /**
  779. * @hidden
  780. */
  781. export interface IColor3Like {
  782. r: float;
  783. g: float;
  784. b: float;
  785. }
  786. /**
  787. * @hidden
  788. */
  789. export interface IVector4Like {
  790. x: float;
  791. y: float;
  792. z: float;
  793. w: float;
  794. }
  795. /**
  796. * @hidden
  797. */
  798. export interface IVector3Like {
  799. x: float;
  800. y: float;
  801. z: float;
  802. }
  803. /**
  804. * @hidden
  805. */
  806. export interface IVector2Like {
  807. x: float;
  808. y: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IMatrixLike {
  814. toArray(): DeepImmutable<Float32Array>;
  815. updateFlag: int;
  816. }
  817. /**
  818. * @hidden
  819. */
  820. export interface IViewportLike {
  821. x: float;
  822. y: float;
  823. width: float;
  824. height: float;
  825. }
  826. /**
  827. * @hidden
  828. */
  829. export interface IPlaneLike {
  830. normal: IVector3Like;
  831. d: float;
  832. normalize(): void;
  833. }
  834. }
  835. declare module BABYLON {
  836. /**
  837. * Class representing a vector containing 2 coordinates
  838. */
  839. export class Vector2 {
  840. /** defines the first coordinate */
  841. x: number;
  842. /** defines the second coordinate */
  843. y: number;
  844. /**
  845. * Creates a new Vector2 from the given x and y coordinates
  846. * @param x defines the first coordinate
  847. * @param y defines the second coordinate
  848. */
  849. constructor(
  850. /** defines the first coordinate */
  851. x?: number,
  852. /** defines the second coordinate */
  853. y?: number);
  854. /**
  855. * Gets a string with the Vector2 coordinates
  856. * @returns a string with the Vector2 coordinates
  857. */
  858. toString(): string;
  859. /**
  860. * Gets class name
  861. * @returns the string "Vector2"
  862. */
  863. getClassName(): string;
  864. /**
  865. * Gets current vector hash code
  866. * @returns the Vector2 hash code as a number
  867. */
  868. getHashCode(): number;
  869. /**
  870. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  871. * @param array defines the source array
  872. * @param index defines the offset in source array
  873. * @returns the current Vector2
  874. */
  875. toArray(array: FloatArray, index?: number): Vector2;
  876. /**
  877. * Copy the current vector to an array
  878. * @returns a new array with 2 elements: the Vector2 coordinates.
  879. */
  880. asArray(): number[];
  881. /**
  882. * Sets the Vector2 coordinates with the given Vector2 coordinates
  883. * @param source defines the source Vector2
  884. * @returns the current updated Vector2
  885. */
  886. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  887. /**
  888. * Sets the Vector2 coordinates with the given floats
  889. * @param x defines the first coordinate
  890. * @param y defines the second coordinate
  891. * @returns the current updated Vector2
  892. */
  893. copyFromFloats(x: number, y: number): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. set(x: number, y: number): Vector2;
  901. /**
  902. * Add another vector with the current one
  903. * @param otherVector defines the other vector
  904. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  905. */
  906. add(otherVector: DeepImmutable<Vector2>): Vector2;
  907. /**
  908. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  909. * @param otherVector defines the other vector
  910. * @param result defines the target vector
  911. * @returns the unmodified current Vector2
  912. */
  913. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  914. /**
  915. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  916. * @param otherVector defines the other vector
  917. * @returns the current updated Vector2
  918. */
  919. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  920. /**
  921. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. addVector3(otherVector: Vector3): Vector2;
  926. /**
  927. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  928. * @param otherVector defines the other vector
  929. * @returns a new Vector2
  930. */
  931. subtract(otherVector: Vector2): Vector2;
  932. /**
  933. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  934. * @param otherVector defines the other vector
  935. * @param result defines the target vector
  936. * @returns the unmodified current Vector2
  937. */
  938. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  939. /**
  940. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Multiplies in place the current Vector2 coordinates by the given ones
  947. * @param otherVector defines the other vector
  948. * @returns the current updated Vector2
  949. */
  950. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns a new Vector2
  955. */
  956. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @param result defines the target vector
  961. * @returns the unmodified current Vector2
  962. */
  963. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  964. /**
  965. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  966. * @param x defines the first coordinate
  967. * @param y defines the second coordinate
  968. * @returns a new Vector2
  969. */
  970. multiplyByFloats(x: number, y: number): Vector2;
  971. /**
  972. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @returns a new Vector2
  975. */
  976. divide(otherVector: Vector2): Vector2;
  977. /**
  978. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  979. * @param otherVector defines the other vector
  980. * @param result defines the target vector
  981. * @returns the unmodified current Vector2
  982. */
  983. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  984. /**
  985. * Divides the current Vector2 coordinates by the given ones
  986. * @param otherVector defines the other vector
  987. * @returns the current updated Vector2
  988. */
  989. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  990. /**
  991. * Gets a new Vector2 with current Vector2 negated coordinates
  992. * @returns a new Vector2
  993. */
  994. negate(): Vector2;
  995. /**
  996. * Multiply the Vector2 coordinates by scale
  997. * @param scale defines the scaling factor
  998. * @returns the current updated Vector2
  999. */
  1000. scaleInPlace(scale: number): Vector2;
  1001. /**
  1002. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1003. * @param scale defines the scaling factor
  1004. * @returns a new Vector2
  1005. */
  1006. scale(scale: number): Vector2;
  1007. /**
  1008. * Scale the current Vector2 values by a factor to a given Vector2
  1009. * @param scale defines the scale factor
  1010. * @param result defines the Vector2 object where to store the result
  1011. * @returns the unmodified current Vector2
  1012. */
  1013. scaleToRef(scale: number, result: Vector2): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Gets a boolean if two vectors are equals
  1023. * @param otherVector defines the other vector
  1024. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1025. */
  1026. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1027. /**
  1028. * Gets a boolean if two vectors are equals (using an epsilon value)
  1029. * @param otherVector defines the other vector
  1030. * @param epsilon defines the minimal distance to consider equality
  1031. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1032. */
  1033. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. floor(): Vector2;
  1039. /**
  1040. * Gets a new Vector2 from current Vector2 floored values
  1041. * @returns a new Vector2
  1042. */
  1043. fract(): Vector2;
  1044. /**
  1045. * Gets the length of the vector
  1046. * @returns the vector length (float)
  1047. */
  1048. length(): number;
  1049. /**
  1050. * Gets the vector squared length
  1051. * @returns the vector squared length (float)
  1052. */
  1053. lengthSquared(): number;
  1054. /**
  1055. * Normalize the vector
  1056. * @returns the current updated Vector2
  1057. */
  1058. normalize(): Vector2;
  1059. /**
  1060. * Gets a new Vector2 copied from the Vector2
  1061. * @returns a new Vector2
  1062. */
  1063. clone(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(0, 0)
  1066. * @returns a new Vector2
  1067. */
  1068. static Zero(): Vector2;
  1069. /**
  1070. * Gets a new Vector2(1, 1)
  1071. * @returns a new Vector2
  1072. */
  1073. static One(): Vector2;
  1074. /**
  1075. * Gets a new Vector2 set from the given index element of the given array
  1076. * @param array defines the data source
  1077. * @param offset defines the offset in the data source
  1078. * @returns a new Vector2
  1079. */
  1080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1081. /**
  1082. * Sets "result" from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @param result defines the target vector
  1086. */
  1087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1088. /**
  1089. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1090. * @param value1 defines 1st point of control
  1091. * @param value2 defines 2nd point of control
  1092. * @param value3 defines 3rd point of control
  1093. * @param value4 defines 4th point of control
  1094. * @param amount defines the interpolation factor
  1095. * @returns a new Vector2
  1096. */
  1097. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1098. /**
  1099. * 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".
  1100. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1101. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1102. * @param value defines the value to clamp
  1103. * @param min defines the lower limit
  1104. * @param max defines the upper limit
  1105. * @returns a new Vector2
  1106. */
  1107. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1108. /**
  1109. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1110. * @param value1 defines the 1st control point
  1111. * @param tangent1 defines the outgoing tangent
  1112. * @param value2 defines the 2nd control point
  1113. * @param tangent2 defines the incoming tangent
  1114. * @param amount defines the interpolation factor
  1115. * @returns a new Vector2
  1116. */
  1117. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1118. /**
  1119. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1120. * @param start defines the start vector
  1121. * @param end defines the end vector
  1122. * @param amount defines the interpolation factor
  1123. * @returns a new Vector2
  1124. */
  1125. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1126. /**
  1127. * Gets the dot product of the vector "left" and the vector "right"
  1128. * @param left defines first vector
  1129. * @param right defines second vector
  1130. * @returns the dot product (float)
  1131. */
  1132. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1133. /**
  1134. * Returns a new Vector2 equal to the normalized given vector
  1135. * @param vector defines the vector to normalize
  1136. * @returns a new Vector2
  1137. */
  1138. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1139. /**
  1140. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1141. * @param left defines 1st vector
  1142. * @param right defines 2nd vector
  1143. * @returns a new Vector2
  1144. */
  1145. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1155. * @param vector defines the vector to transform
  1156. * @param transformation defines the matrix to apply
  1157. * @returns a new Vector2
  1158. */
  1159. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1160. /**
  1161. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @param result defines the target vector
  1165. */
  1166. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1167. /**
  1168. * Determines if a given vector is included in a triangle
  1169. * @param p defines the vector to test
  1170. * @param p0 defines 1st triangle point
  1171. * @param p1 defines 2nd triangle point
  1172. * @param p2 defines 3rd triangle point
  1173. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1174. */
  1175. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1176. /**
  1177. * Gets the distance between the vectors "value1" and "value2"
  1178. * @param value1 defines first vector
  1179. * @param value2 defines second vector
  1180. * @returns the distance between vectors
  1181. */
  1182. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1183. /**
  1184. * Returns the squared distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the squared distance between vectors
  1188. */
  1189. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns a new Vector2
  1195. */
  1196. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1197. /**
  1198. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1199. * @param p defines the middle point
  1200. * @param segA defines one point of the segment
  1201. * @param segB defines the other point of the segment
  1202. * @returns the shortest distance
  1203. */
  1204. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1205. }
  1206. /**
  1207. * Classed used to store (x,y,z) vector representation
  1208. * A Vector3 is the main object used in 3D geometry
  1209. * It can represent etiher the coordinates of a point the space, either a direction
  1210. * Reminder: js uses a left handed forward facing system
  1211. */
  1212. export class Vector3 {
  1213. /**
  1214. * Defines the first coordinates (on X axis)
  1215. */
  1216. x: number;
  1217. /**
  1218. * Defines the second coordinates (on Y axis)
  1219. */
  1220. y: number;
  1221. /**
  1222. * Defines the third coordinates (on Z axis)
  1223. */
  1224. z: number;
  1225. private static _UpReadOnly;
  1226. private static _ZeroReadOnly;
  1227. /**
  1228. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1229. * @param x defines the first coordinates (on X axis)
  1230. * @param y defines the second coordinates (on Y axis)
  1231. * @param z defines the third coordinates (on Z axis)
  1232. */
  1233. constructor(
  1234. /**
  1235. * Defines the first coordinates (on X axis)
  1236. */
  1237. x?: number,
  1238. /**
  1239. * Defines the second coordinates (on Y axis)
  1240. */
  1241. y?: number,
  1242. /**
  1243. * Defines the third coordinates (on Z axis)
  1244. */
  1245. z?: number);
  1246. /**
  1247. * Creates a string representation of the Vector3
  1248. * @returns a string with the Vector3 coordinates.
  1249. */
  1250. toString(): string;
  1251. /**
  1252. * Gets the class name
  1253. * @returns the string "Vector3"
  1254. */
  1255. getClassName(): string;
  1256. /**
  1257. * Creates the Vector3 hash code
  1258. * @returns a number which tends to be unique between Vector3 instances
  1259. */
  1260. getHashCode(): number;
  1261. /**
  1262. * Creates an array containing three elements : the coordinates of the Vector3
  1263. * @returns a new array of numbers
  1264. */
  1265. asArray(): number[];
  1266. /**
  1267. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1268. * @param array defines the destination array
  1269. * @param index defines the offset in the destination array
  1270. * @returns the current Vector3
  1271. */
  1272. toArray(array: FloatArray, index?: number): Vector3;
  1273. /**
  1274. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1275. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1276. */
  1277. toQuaternion(): Quaternion;
  1278. /**
  1279. * Adds the given vector to the current Vector3
  1280. * @param otherVector defines the second operand
  1281. * @returns the current updated Vector3
  1282. */
  1283. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1284. /**
  1285. * Adds the given coordinates to the current Vector3
  1286. * @param x defines the x coordinate of the operand
  1287. * @param y defines the y coordinate of the operand
  1288. * @param z defines the z coordinate of the operand
  1289. * @returns the current updated Vector3
  1290. */
  1291. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1292. /**
  1293. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1294. * @param otherVector defines the second operand
  1295. * @returns the resulting Vector3
  1296. */
  1297. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1300. * @param otherVector defines the second operand
  1301. * @param result defines the Vector3 object where to store the result
  1302. * @returns the current Vector3
  1303. */
  1304. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1305. /**
  1306. * Subtract the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1313. * @param otherVector defines the second operand
  1314. * @returns the resulting Vector3
  1315. */
  1316. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1319. * @param otherVector defines the second operand
  1320. * @param result defines the Vector3 object where to store the result
  1321. * @returns the current Vector3
  1322. */
  1323. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1324. /**
  1325. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1326. * @param x defines the x coordinate of the operand
  1327. * @param y defines the y coordinate of the operand
  1328. * @param z defines the z coordinate of the operand
  1329. * @returns the resulting Vector3
  1330. */
  1331. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1332. /**
  1333. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1334. * @param x defines the x coordinate of the operand
  1335. * @param y defines the y coordinate of the operand
  1336. * @param z defines the z coordinate of the operand
  1337. * @param result defines the Vector3 object where to store the result
  1338. * @returns the current Vector3
  1339. */
  1340. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1341. /**
  1342. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1343. * @returns a new Vector3
  1344. */
  1345. negate(): Vector3;
  1346. /**
  1347. * Multiplies the Vector3 coordinates by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns the current updated Vector3
  1350. */
  1351. scaleInPlace(scale: number): Vector3;
  1352. /**
  1353. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1354. * @param scale defines the multiplier factor
  1355. * @returns a new Vector3
  1356. */
  1357. scale(scale: number): Vector3;
  1358. /**
  1359. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1360. * @param scale defines the multiplier factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the current Vector3
  1363. */
  1364. scaleToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1367. * @param scale defines the scale factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the unmodified current Vector3
  1370. */
  1371. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1374. * @param otherVector defines the second operand
  1375. * @returns true if both vectors are equals
  1376. */
  1377. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1380. * @param otherVector defines the second operand
  1381. * @param epsilon defines the minimal distance to define values as equals
  1382. * @returns true if both vectors are distant less than epsilon
  1383. */
  1384. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 coordinates equals the given floats
  1387. * @param x defines the x coordinate of the operand
  1388. * @param y defines the y coordinate of the operand
  1389. * @param z defines the z coordinate of the operand
  1390. * @returns true if both vectors are equals
  1391. */
  1392. equalsToFloats(x: number, y: number, z: number): boolean;
  1393. /**
  1394. * Multiplies the current Vector3 coordinates by the given ones
  1395. * @param otherVector defines the second operand
  1396. * @returns the current updated Vector3
  1397. */
  1398. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1401. * @param otherVector defines the second operand
  1402. * @returns the new Vector3
  1403. */
  1404. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1405. /**
  1406. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1407. * @param otherVector defines the second operand
  1408. * @param result defines the Vector3 object where to store the result
  1409. * @returns the current Vector3
  1410. */
  1411. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1412. /**
  1413. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns the new Vector3
  1418. */
  1419. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1420. /**
  1421. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the new Vector3
  1424. */
  1425. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1428. * @param otherVector defines the second operand
  1429. * @param result defines the Vector3 object where to store the result
  1430. * @returns the current Vector3
  1431. */
  1432. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones.
  1435. * @param otherVector defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. divideInPlace(otherVector: Vector3): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1447. * @param other defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1453. * @param x defines the x coordinate of the operand
  1454. * @param y defines the y coordinate of the operand
  1455. * @param z defines the z coordinate of the operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1461. * @param x defines the x coordinate of the operand
  1462. * @param y defines the y coordinate of the operand
  1463. * @param z defines the z coordinate of the operand
  1464. * @returns the current updated Vector3
  1465. */
  1466. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1467. /**
  1468. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1469. * Check if is non uniform within a certain amount of decimal places to account for this
  1470. * @param epsilon the amount the values can differ
  1471. * @returns if the the vector is non uniform to a certain number of decimal places
  1472. */
  1473. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1474. /**
  1475. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1476. */
  1477. readonly isNonUniform: boolean;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. floor(): Vector3;
  1483. /**
  1484. * Gets a new Vector3 from current Vector3 floored values
  1485. * @returns a new Vector3
  1486. */
  1487. fract(): Vector3;
  1488. /**
  1489. * Gets the length of the Vector3
  1490. * @returns the length of the Vector3
  1491. */
  1492. length(): number;
  1493. /**
  1494. * Gets the squared length of the Vector3
  1495. * @returns squared length of the Vector3
  1496. */
  1497. lengthSquared(): number;
  1498. /**
  1499. * Normalize the current Vector3.
  1500. * Please note that this is an in place operation.
  1501. * @returns the current updated Vector3
  1502. */
  1503. normalize(): Vector3;
  1504. /**
  1505. * Reorders the x y z properties of the vector in place
  1506. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1507. * @returns the current updated vector
  1508. */
  1509. reorderInPlace(order: string): this;
  1510. /**
  1511. * Rotates the vector around 0,0,0 by a quaternion
  1512. * @param quaternion the rotation quaternion
  1513. * @param result vector to store the result
  1514. * @returns the resulting vector
  1515. */
  1516. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1517. /**
  1518. * Rotates a vector around a given point
  1519. * @param quaternion the rotation quaternion
  1520. * @param point the point to rotate around
  1521. * @param result vector to store the result
  1522. * @returns the resulting vector
  1523. */
  1524. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1525. /**
  1526. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1527. * The cross product is then orthogonal to both current and "other"
  1528. * @param other defines the right operand
  1529. * @returns the cross product
  1530. */
  1531. cross(other: Vector3): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 with the given input length.
  1534. * Please note that this is an in place operation.
  1535. * @param len the length of the vector
  1536. * @returns the current updated Vector3
  1537. */
  1538. normalizeFromLength(len: number): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 to a new vector
  1541. * @returns the new Vector3
  1542. */
  1543. normalizeToNew(): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to the reference
  1546. * @param reference define the Vector3 to update
  1547. * @returns the updated Vector3
  1548. */
  1549. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1550. /**
  1551. * Creates a new Vector3 copied from the current Vector3
  1552. * @returns the new Vector3
  1553. */
  1554. clone(): Vector3;
  1555. /**
  1556. * Copies the given vector coordinates to the current Vector3 ones
  1557. * @param source defines the source Vector3
  1558. * @returns the current updated Vector3
  1559. */
  1560. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1561. /**
  1562. * Copies the given floats to the current Vector3 coordinates
  1563. * @param x defines the x coordinate of the operand
  1564. * @param y defines the y coordinate of the operand
  1565. * @param z defines the z coordinate of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. copyFromFloats(x: number, y: number, z: number): Vector3;
  1569. /**
  1570. * Copies the given floats to the current Vector3 coordinates
  1571. * @param x defines the x coordinate of the operand
  1572. * @param y defines the y coordinate of the operand
  1573. * @param z defines the z coordinate of the operand
  1574. * @returns the current updated Vector3
  1575. */
  1576. set(x: number, y: number, z: number): Vector3;
  1577. /**
  1578. * Copies the given float to the current Vector3 coordinates
  1579. * @param v defines the x, y and z coordinates of the operand
  1580. * @returns the current updated Vector3
  1581. */
  1582. setAll(v: number): Vector3;
  1583. /**
  1584. * Get the clip factor between two vectors
  1585. * @param vector0 defines the first operand
  1586. * @param vector1 defines the second operand
  1587. * @param axis defines the axis to use
  1588. * @param size defines the size along the axis
  1589. * @returns the clip factor
  1590. */
  1591. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1592. /**
  1593. * Get angle between two vectors
  1594. * @param vector0 angle between vector0 and vector1
  1595. * @param vector1 angle between vector0 and vector1
  1596. * @param normal direction of the normal
  1597. * @return the angle between vector0 and vector1
  1598. */
  1599. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1600. /**
  1601. * Returns a new Vector3 set from the index "offset" of the given array
  1602. * @param array defines the source array
  1603. * @param offset defines the offset in the source array
  1604. * @returns the new Vector3
  1605. */
  1606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1609. * This function is deprecated. Use FromArray instead
  1610. * @param array defines the source array
  1611. * @param offset defines the offset in the source array
  1612. * @returns the new Vector3
  1613. */
  1614. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1615. /**
  1616. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @param result defines the Vector3 where to store the result
  1620. */
  1621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1624. * This function is deprecated. Use FromArrayToRef instead.
  1625. * @param array defines the source array
  1626. * @param offset defines the offset in the source array
  1627. * @param result defines the Vector3 where to store the result
  1628. */
  1629. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1630. /**
  1631. * Sets the given vector "result" with the given floats.
  1632. * @param x defines the x coordinate of the source
  1633. * @param y defines the y coordinate of the source
  1634. * @param z defines the z coordinate of the source
  1635. * @param result defines the Vector3 where to store the result
  1636. */
  1637. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1638. /**
  1639. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1640. * @returns a new empty Vector3
  1641. */
  1642. static Zero(): Vector3;
  1643. /**
  1644. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1645. * @returns a new unit Vector3
  1646. */
  1647. static One(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1650. * @returns a new up Vector3
  1651. */
  1652. static Up(): Vector3;
  1653. /**
  1654. * Gets a up Vector3 that must not be updated
  1655. */
  1656. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1657. /**
  1658. * Gets a zero Vector3 that must not be updated
  1659. */
  1660. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1661. /**
  1662. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1663. * @returns a new down Vector3
  1664. */
  1665. static Down(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1668. * @returns a new forward Vector3
  1669. */
  1670. static Forward(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Backward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1678. * @returns a new right Vector3
  1679. */
  1680. static Right(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1683. * @returns a new left Vector3
  1684. */
  1685. static Left(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1688. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @returns the transformed Vector3
  1692. */
  1693. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1694. /**
  1695. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @param result defines the Vector3 where to store the result
  1700. */
  1701. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1702. /**
  1703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1704. * This method computes tranformed coordinates only, not transformed direction vectors
  1705. * @param x define the x coordinate of the source vector
  1706. * @param y define the y coordinate of the source vector
  1707. * @param z define the z coordinate of the source vector
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @returns the new Vector3
  1718. */
  1719. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1720. /**
  1721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1723. * @param vector defines the Vector3 to transform
  1724. * @param transformation defines the transformation matrix
  1725. * @param result defines the Vector3 where to store the result
  1726. */
  1727. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1728. /**
  1729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1731. * @param x define the x coordinate of the source vector
  1732. * @param y define the y coordinate of the source vector
  1733. * @param z define the z coordinate of the source vector
  1734. * @param transformation defines the transformation matrix
  1735. * @param result defines the Vector3 where to store the result
  1736. */
  1737. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1738. /**
  1739. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1740. * @param value1 defines the first control point
  1741. * @param value2 defines the second control point
  1742. * @param value3 defines the third control point
  1743. * @param value4 defines the fourth control point
  1744. * @param amount defines the amount on the spline to use
  1745. * @returns the new Vector3
  1746. */
  1747. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1748. /**
  1749. * 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"
  1750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1752. * @param value defines the current value
  1753. * @param min defines the lower range value
  1754. * @param max defines the upper range value
  1755. * @returns the new Vector3
  1756. */
  1757. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1758. /**
  1759. * 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"
  1760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1762. * @param value defines the current value
  1763. * @param min defines the lower range value
  1764. * @param max defines the upper range value
  1765. * @param result defines the Vector3 where to store the result
  1766. */
  1767. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1768. /**
  1769. * Checks if a given vector is inside a specific range
  1770. * @param v defines the vector to test
  1771. * @param min defines the minimum range
  1772. * @param max defines the maximum range
  1773. */
  1774. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Class used to store quaternion data
  2363. * @see https://en.wikipedia.org/wiki/Quaternion
  2364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2365. */
  2366. export class Quaternion {
  2367. /** defines the first component (0 by default) */
  2368. x: number;
  2369. /** defines the second component (0 by default) */
  2370. y: number;
  2371. /** defines the third component (0 by default) */
  2372. z: number;
  2373. /** defines the fourth component (1.0 by default) */
  2374. w: number;
  2375. /**
  2376. * Creates a new Quaternion from the given floats
  2377. * @param x defines the first component (0 by default)
  2378. * @param y defines the second component (0 by default)
  2379. * @param z defines the third component (0 by default)
  2380. * @param w defines the fourth component (1.0 by default)
  2381. */
  2382. constructor(
  2383. /** defines the first component (0 by default) */
  2384. x?: number,
  2385. /** defines the second component (0 by default) */
  2386. y?: number,
  2387. /** defines the third component (0 by default) */
  2388. z?: number,
  2389. /** defines the fourth component (1.0 by default) */
  2390. w?: number);
  2391. /**
  2392. * Gets a string representation for the current quaternion
  2393. * @returns a string with the Quaternion coordinates
  2394. */
  2395. toString(): string;
  2396. /**
  2397. * Gets the class name of the quaternion
  2398. * @returns the string "Quaternion"
  2399. */
  2400. getClassName(): string;
  2401. /**
  2402. * Gets a hash code for this quaternion
  2403. * @returns the quaternion hash code
  2404. */
  2405. getHashCode(): number;
  2406. /**
  2407. * Copy the quaternion to an array
  2408. * @returns a new array populated with 4 elements from the quaternion coordinates
  2409. */
  2410. asArray(): number[];
  2411. /**
  2412. * Check if two quaternions are equals
  2413. * @param otherQuaternion defines the second operand
  2414. * @return true if the current quaternion and the given one coordinates are strictly equals
  2415. */
  2416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2417. /**
  2418. * Clone the current quaternion
  2419. * @returns a new quaternion copied from the current one
  2420. */
  2421. clone(): Quaternion;
  2422. /**
  2423. * Copy a quaternion to the current one
  2424. * @param other defines the other quaternion
  2425. * @returns the updated current quaternion
  2426. */
  2427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2428. /**
  2429. * Updates the current quaternion with the given float coordinates
  2430. * @param x defines the x coordinate
  2431. * @param y defines the y coordinate
  2432. * @param z defines the z coordinate
  2433. * @param w defines the w coordinate
  2434. * @returns the updated current quaternion
  2435. */
  2436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2437. /**
  2438. * Updates the current quaternion from the given float coordinates
  2439. * @param x defines the x coordinate
  2440. * @param y defines the y coordinate
  2441. * @param z defines the z coordinate
  2442. * @param w defines the w coordinate
  2443. * @returns the updated current quaternion
  2444. */
  2445. set(x: number, y: number, z: number, w: number): Quaternion;
  2446. /**
  2447. * Adds two quaternions
  2448. * @param other defines the second operand
  2449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2450. */
  2451. add(other: DeepImmutable<Quaternion>): Quaternion;
  2452. /**
  2453. * Add a quaternion to the current one
  2454. * @param other defines the quaternion to add
  2455. * @returns the current quaternion
  2456. */
  2457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2458. /**
  2459. * Subtract two quaternions
  2460. * @param other defines the second operand
  2461. * @returns a new quaternion as the subtraction result of the given one from the current one
  2462. */
  2463. subtract(other: Quaternion): Quaternion;
  2464. /**
  2465. * Multiplies the current quaternion by a scale factor
  2466. * @param value defines the scale factor
  2467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2468. */
  2469. scale(value: number): Quaternion;
  2470. /**
  2471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2472. * @param scale defines the scale factor
  2473. * @param result defines the Quaternion object where to store the result
  2474. * @returns the unmodified current quaternion
  2475. */
  2476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2477. /**
  2478. * Multiplies in place the current quaternion by a scale factor
  2479. * @param value defines the scale factor
  2480. * @returns the current modified quaternion
  2481. */
  2482. scaleInPlace(value: number): Quaternion;
  2483. /**
  2484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2485. * @param scale defines the scale factor
  2486. * @param result defines the Quaternion object where to store the result
  2487. * @returns the unmodified current quaternion
  2488. */
  2489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2490. /**
  2491. * Multiplies two quaternions
  2492. * @param q1 defines the second operand
  2493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2494. */
  2495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2496. /**
  2497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2498. * @param q1 defines the second operand
  2499. * @param result defines the target quaternion
  2500. * @returns the current quaternion
  2501. */
  2502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2503. /**
  2504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @returns the currentupdated quaternion
  2507. */
  2508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2509. /**
  2510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2511. * @param ref defines the target quaternion
  2512. * @returns the current quaternion
  2513. */
  2514. conjugateToRef(ref: Quaternion): Quaternion;
  2515. /**
  2516. * Conjugates in place (1-q) the current quaternion
  2517. * @returns the current updated quaternion
  2518. */
  2519. conjugateInPlace(): Quaternion;
  2520. /**
  2521. * Conjugates in place (1-q) the current quaternion
  2522. * @returns a new quaternion
  2523. */
  2524. conjugate(): Quaternion;
  2525. /**
  2526. * Gets length of current quaternion
  2527. * @returns the quaternion length (float)
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Normalize in place the current quaternion
  2532. * @returns the current updated quaternion
  2533. */
  2534. normalize(): Quaternion;
  2535. /**
  2536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2537. * @param order is a reserved parameter and is ignore for now
  2538. * @returns a new Vector3 containing the Euler angles
  2539. */
  2540. toEulerAngles(order?: string): Vector3;
  2541. /**
  2542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2543. * @param result defines the vector which will be filled with the Euler angles
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns the current unchanged quaternion
  2546. */
  2547. toEulerAnglesToRef(result: Vector3): Quaternion;
  2548. /**
  2549. * Updates the given rotation matrix with the current quaternion values
  2550. * @param result defines the target matrix
  2551. * @returns the current unchanged quaternion
  2552. */
  2553. toRotationMatrix(result: Matrix): Quaternion;
  2554. /**
  2555. * Updates the current quaternion from the given rotation matrix values
  2556. * @param matrix defines the source matrix
  2557. * @returns the current updated quaternion
  2558. */
  2559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2560. /**
  2561. * Creates a new quaternion from a rotation matrix
  2562. * @param matrix defines the source matrix
  2563. * @returns a new quaternion created from the given rotation matrix values
  2564. */
  2565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2566. /**
  2567. * Updates the given quaternion with the given rotation matrix values
  2568. * @param matrix defines the source matrix
  2569. * @param result defines the target quaternion
  2570. */
  2571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2572. /**
  2573. * Returns the dot product (float) between the quaternions "left" and "right"
  2574. * @param left defines the left operand
  2575. * @param right defines the right operand
  2576. * @returns the dot product
  2577. */
  2578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2579. /**
  2580. * Checks if the two quaternions are close to each other
  2581. * @param quat0 defines the first quaternion to check
  2582. * @param quat1 defines the second quaternion to check
  2583. * @returns true if the two quaternions are close to each other
  2584. */
  2585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2586. /**
  2587. * Creates an empty quaternion
  2588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2589. */
  2590. static Zero(): Quaternion;
  2591. /**
  2592. * Inverse a given quaternion
  2593. * @param q defines the source quaternion
  2594. * @returns a new quaternion as the inverted current quaternion
  2595. */
  2596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Inverse a given quaternion
  2599. * @param q defines the source quaternion
  2600. * @param result the quaternion the result will be stored in
  2601. * @returns the result quaternion
  2602. */
  2603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2604. /**
  2605. * Creates an identity quaternion
  2606. * @returns the identity quaternion
  2607. */
  2608. static Identity(): Quaternion;
  2609. /**
  2610. * Gets a boolean indicating if the given quaternion is identity
  2611. * @param quaternion defines the quaternion to check
  2612. * @returns true if the quaternion is identity
  2613. */
  2614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2615. /**
  2616. * Creates a quaternion from a rotation around an axis
  2617. * @param axis defines the axis to use
  2618. * @param angle defines the angle to use
  2619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2620. */
  2621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2622. /**
  2623. * Creates a rotation around an axis and stores it into the given quaternion
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @param result defines the target quaternion
  2627. * @returns the target quaternion
  2628. */
  2629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2630. /**
  2631. * Creates a new quaternion from data stored into an array
  2632. * @param array defines the data source
  2633. * @param offset defines the offset in the source array where the data starts
  2634. * @returns a new quaternion
  2635. */
  2636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2637. /**
  2638. * Create a quaternion from Euler rotation angles
  2639. * @param x Pitch
  2640. * @param y Yaw
  2641. * @param z Roll
  2642. * @returns the new Quaternion
  2643. */
  2644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2645. /**
  2646. * Updates a quaternion from Euler rotation angles
  2647. * @param x Pitch
  2648. * @param y Yaw
  2649. * @param z Roll
  2650. * @param result the quaternion to store the result
  2651. * @returns the updated quaternion
  2652. */
  2653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2654. /**
  2655. * Create a quaternion from Euler rotation vector
  2656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2657. * @returns the new Quaternion
  2658. */
  2659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2660. /**
  2661. * Updates a quaternion from Euler rotation vector
  2662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2663. * @param result the quaternion to store the result
  2664. * @returns the updated quaternion
  2665. */
  2666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2667. /**
  2668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2669. * @param yaw defines the rotation around Y axis
  2670. * @param pitch defines the rotation around X axis
  2671. * @param roll defines the rotation around Z axis
  2672. * @returns the new quaternion
  2673. */
  2674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2675. /**
  2676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2677. * @param yaw defines the rotation around Y axis
  2678. * @param pitch defines the rotation around X axis
  2679. * @param roll defines the rotation around Z axis
  2680. * @param result defines the target quaternion
  2681. */
  2682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2683. /**
  2684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2685. * @param alpha defines the rotation around first axis
  2686. * @param beta defines the rotation around second axis
  2687. * @param gamma defines the rotation around third axis
  2688. * @returns the new quaternion
  2689. */
  2690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2691. /**
  2692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2693. * @param alpha defines the rotation around first axis
  2694. * @param beta defines the rotation around second axis
  2695. * @param gamma defines the rotation around third axis
  2696. * @param result defines the target quaternion
  2697. */
  2698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2699. /**
  2700. * 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)
  2701. * @param axis1 defines the first axis
  2702. * @param axis2 defines the second axis
  2703. * @param axis3 defines the third axis
  2704. * @returns the new quaternion
  2705. */
  2706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2707. /**
  2708. * 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
  2709. * @param axis1 defines the first axis
  2710. * @param axis2 defines the second axis
  2711. * @param axis3 defines the third axis
  2712. * @param ref defines the target quaternion
  2713. */
  2714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2715. /**
  2716. * Interpolates between two quaternions
  2717. * @param left defines first quaternion
  2718. * @param right defines second quaternion
  2719. * @param amount defines the gradient to use
  2720. * @returns the new interpolated quaternion
  2721. */
  2722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2723. /**
  2724. * Interpolates between two quaternions and stores it into a target quaternion
  2725. * @param left defines first quaternion
  2726. * @param right defines second quaternion
  2727. * @param amount defines the gradient to use
  2728. * @param result defines the target quaternion
  2729. */
  2730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2731. /**
  2732. * Interpolate between two quaternions using Hermite interpolation
  2733. * @param value1 defines first quaternion
  2734. * @param tangent1 defines the incoming tangent
  2735. * @param value2 defines second quaternion
  2736. * @param tangent2 defines the outgoing tangent
  2737. * @param amount defines the target quaternion
  2738. * @returns the new interpolated quaternion
  2739. */
  2740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2741. }
  2742. /**
  2743. * Class used to store matrix data (4x4)
  2744. */
  2745. export class Matrix {
  2746. private static _updateFlagSeed;
  2747. private static _identityReadOnly;
  2748. private _isIdentity;
  2749. private _isIdentityDirty;
  2750. private _isIdentity3x2;
  2751. private _isIdentity3x2Dirty;
  2752. /**
  2753. * Gets the update flag of the matrix which is an unique number for the matrix.
  2754. * It will be incremented every time the matrix data change.
  2755. * You can use it to speed the comparison between two versions of the same matrix.
  2756. */
  2757. updateFlag: number;
  2758. private readonly _m;
  2759. /**
  2760. * Gets the internal data of the matrix
  2761. */
  2762. readonly m: DeepImmutable<Float32Array>;
  2763. /** @hidden */
  2764. _markAsUpdated(): void;
  2765. /** @hidden */
  2766. private _updateIdentityStatus;
  2767. /**
  2768. * Creates an empty matrix (filled with zeros)
  2769. */
  2770. constructor();
  2771. /**
  2772. * Check if the current matrix is identity
  2773. * @returns true is the matrix is the identity matrix
  2774. */
  2775. isIdentity(): boolean;
  2776. /**
  2777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2778. * @returns true is the matrix is the identity matrix
  2779. */
  2780. isIdentityAs3x2(): boolean;
  2781. /**
  2782. * Gets the determinant of the matrix
  2783. * @returns the matrix determinant
  2784. */
  2785. determinant(): number;
  2786. /**
  2787. * Returns the matrix as a Float32Array
  2788. * @returns the matrix underlying array
  2789. */
  2790. toArray(): DeepImmutable<Float32Array>;
  2791. /**
  2792. * Returns the matrix as a Float32Array
  2793. * @returns the matrix underlying array.
  2794. */
  2795. asArray(): DeepImmutable<Float32Array>;
  2796. /**
  2797. * Inverts the current matrix in place
  2798. * @returns the current inverted matrix
  2799. */
  2800. invert(): Matrix;
  2801. /**
  2802. * Sets all the matrix elements to zero
  2803. * @returns the current matrix
  2804. */
  2805. reset(): Matrix;
  2806. /**
  2807. * Adds the current matrix with a second one
  2808. * @param other defines the matrix to add
  2809. * @returns a new matrix as the addition of the current matrix and the given one
  2810. */
  2811. add(other: DeepImmutable<Matrix>): Matrix;
  2812. /**
  2813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2814. * @param other defines the matrix to add
  2815. * @param result defines the target matrix
  2816. * @returns the current matrix
  2817. */
  2818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2819. /**
  2820. * Adds in place the given matrix to the current matrix
  2821. * @param other defines the second operand
  2822. * @returns the current updated matrix
  2823. */
  2824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2825. /**
  2826. * Sets the given matrix to the current inverted Matrix
  2827. * @param other defines the target matrix
  2828. * @returns the unmodified current matrix
  2829. */
  2830. invertToRef(other: Matrix): Matrix;
  2831. /**
  2832. * add a value at the specified position in the current Matrix
  2833. * @param index the index of the value within the matrix. between 0 and 15.
  2834. * @param value the value to be added
  2835. * @returns the current updated matrix
  2836. */
  2837. addAtIndex(index: number, value: number): Matrix;
  2838. /**
  2839. * mutiply the specified position in the current Matrix by a value
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. multiplyAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * Inserts the translation vector (using 3 floats) in the current matrix
  2847. * @param x defines the 1st component of the translation
  2848. * @param y defines the 2nd component of the translation
  2849. * @param z defines the 3rd component of the translation
  2850. * @returns the current updated matrix
  2851. */
  2852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2853. /**
  2854. * Adds the translation vector (using 3 floats) in the current matrix
  2855. * @param x defines the 1st component of the translation
  2856. * @param y defines the 2nd component of the translation
  2857. * @param z defines the 3rd component of the translation
  2858. * @returns the current updated matrix
  2859. */
  2860. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2861. /**
  2862. * Inserts the translation vector in the current matrix
  2863. * @param vector3 defines the translation to insert
  2864. * @returns the current updated matrix
  2865. */
  2866. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2867. /**
  2868. * Gets the translation value of the current matrix
  2869. * @returns a new Vector3 as the extracted translation from the matrix
  2870. */
  2871. getTranslation(): Vector3;
  2872. /**
  2873. * Fill a Vector3 with the extracted translation from the matrix
  2874. * @param result defines the Vector3 where to store the translation
  2875. * @returns the current matrix
  2876. */
  2877. getTranslationToRef(result: Vector3): Matrix;
  2878. /**
  2879. * Remove rotation and scaling part from the matrix
  2880. * @returns the updated matrix
  2881. */
  2882. removeRotationAndScaling(): Matrix;
  2883. /**
  2884. * Multiply two matrices
  2885. * @param other defines the second operand
  2886. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2887. */
  2888. multiply(other: DeepImmutable<Matrix>): Matrix;
  2889. /**
  2890. * Copy the current matrix from the given one
  2891. * @param other defines the source matrix
  2892. * @returns the current updated matrix
  2893. */
  2894. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2895. /**
  2896. * Populates the given array from the starting index with the current matrix values
  2897. * @param array defines the target array
  2898. * @param offset defines the offset in the target array where to start storing values
  2899. * @returns the current matrix
  2900. */
  2901. copyToArray(array: Float32Array, offset?: number): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2904. * @param other defines the second operand
  2905. * @param result defines the matrix where to store the multiplication
  2906. * @returns the current matrix
  2907. */
  2908. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the array where to store the multiplication
  2913. * @param offset defines the offset in the target array where to start storing values
  2914. * @returns the current matrix
  2915. */
  2916. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2917. /**
  2918. * Check equality between this matrix and a second one
  2919. * @param value defines the second matrix to compare
  2920. * @returns true is the current matrix and the given one values are strictly equal
  2921. */
  2922. equals(value: DeepImmutable<Matrix>): boolean;
  2923. /**
  2924. * Clone the current matrix
  2925. * @returns a new matrix from the current matrix
  2926. */
  2927. clone(): Matrix;
  2928. /**
  2929. * Returns the name of the current matrix class
  2930. * @returns the string "Matrix"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets the hash code of the current matrix
  2935. * @returns the hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Decomposes the current Matrix into a translation, rotation and scaling components
  2940. * @param scale defines the scale vector3 given as a reference to update
  2941. * @param rotation defines the rotation quaternion given as a reference to update
  2942. * @param translation defines the translation vector3 given as a reference to update
  2943. * @returns true if operation was successful
  2944. */
  2945. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2946. /**
  2947. * Gets specific row of the matrix
  2948. * @param index defines the number of the row to get
  2949. * @returns the index-th row of the current matrix as a new Vector4
  2950. */
  2951. getRow(index: number): Nullable<Vector4>;
  2952. /**
  2953. * Sets the index-th row of the current matrix to the vector4 values
  2954. * @param index defines the number of the row to set
  2955. * @param row defines the target vector4
  2956. * @returns the updated current matrix
  2957. */
  2958. setRow(index: number, row: Vector4): Matrix;
  2959. /**
  2960. * Compute the transpose of the matrix
  2961. * @returns the new transposed matrix
  2962. */
  2963. transpose(): Matrix;
  2964. /**
  2965. * Compute the transpose of the matrix and store it in a given matrix
  2966. * @param result defines the target matrix
  2967. * @returns the current matrix
  2968. */
  2969. transposeToRef(result: Matrix): Matrix;
  2970. /**
  2971. * Sets the index-th row of the current matrix with the given 4 x float values
  2972. * @param index defines the row index
  2973. * @param x defines the x component to set
  2974. * @param y defines the y component to set
  2975. * @param z defines the z component to set
  2976. * @param w defines the w component to set
  2977. * @returns the updated current matrix
  2978. */
  2979. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2980. /**
  2981. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2982. * @param scale defines the scale factor
  2983. * @returns a new matrix
  2984. */
  2985. scale(scale: number): Matrix;
  2986. /**
  2987. * Scale the current matrix values by a factor to a given result matrix
  2988. * @param scale defines the scale factor
  2989. * @param result defines the matrix to store the result
  2990. * @returns the current matrix
  2991. */
  2992. scaleToRef(scale: number, result: Matrix): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor and add the result to a given matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the Matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3002. * @param ref matrix to store the result
  3003. */
  3004. toNormalMatrix(ref: Matrix): void;
  3005. /**
  3006. * Gets only rotation part of the current matrix
  3007. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3008. */
  3009. getRotationMatrix(): Matrix;
  3010. /**
  3011. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3012. * @param result defines the target matrix to store data to
  3013. * @returns the current matrix
  3014. */
  3015. getRotationMatrixToRef(result: Matrix): Matrix;
  3016. /**
  3017. * Toggles model matrix from being right handed to left handed in place and vice versa
  3018. */
  3019. toggleModelMatrixHandInPlace(): void;
  3020. /**
  3021. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3022. */
  3023. toggleProjectionMatrixHandInPlace(): void;
  3024. /**
  3025. * Creates a matrix from an array
  3026. * @param array defines the source array
  3027. * @param offset defines an offset in the source array
  3028. * @returns a new Matrix set from the starting index of the given array
  3029. */
  3030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3031. /**
  3032. * Copy the content of an array into a given matrix
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @param result defines the target matrix
  3036. */
  3037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3038. /**
  3039. * Stores an array into a matrix after having multiplied each component by a given factor
  3040. * @param array defines the source array
  3041. * @param offset defines the offset in the source array
  3042. * @param scale defines the scaling factor
  3043. * @param result defines the target matrix
  3044. */
  3045. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3046. /**
  3047. * Gets an identity matrix that must not be updated
  3048. */
  3049. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3050. /**
  3051. * Stores a list of values (16) inside a given matrix
  3052. * @param initialM11 defines 1st value of 1st row
  3053. * @param initialM12 defines 2nd value of 1st row
  3054. * @param initialM13 defines 3rd value of 1st row
  3055. * @param initialM14 defines 4th value of 1st row
  3056. * @param initialM21 defines 1st value of 2nd row
  3057. * @param initialM22 defines 2nd value of 2nd row
  3058. * @param initialM23 defines 3rd value of 2nd row
  3059. * @param initialM24 defines 4th value of 2nd row
  3060. * @param initialM31 defines 1st value of 3rd row
  3061. * @param initialM32 defines 2nd value of 3rd row
  3062. * @param initialM33 defines 3rd value of 3rd row
  3063. * @param initialM34 defines 4th value of 3rd row
  3064. * @param initialM41 defines 1st value of 4th row
  3065. * @param initialM42 defines 2nd value of 4th row
  3066. * @param initialM43 defines 3rd value of 4th row
  3067. * @param initialM44 defines 4th value of 4th row
  3068. * @param result defines the target matrix
  3069. */
  3070. 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;
  3071. /**
  3072. * Creates new matrix from a list of values (16)
  3073. * @param initialM11 defines 1st value of 1st row
  3074. * @param initialM12 defines 2nd value of 1st row
  3075. * @param initialM13 defines 3rd value of 1st row
  3076. * @param initialM14 defines 4th value of 1st row
  3077. * @param initialM21 defines 1st value of 2nd row
  3078. * @param initialM22 defines 2nd value of 2nd row
  3079. * @param initialM23 defines 3rd value of 2nd row
  3080. * @param initialM24 defines 4th value of 2nd row
  3081. * @param initialM31 defines 1st value of 3rd row
  3082. * @param initialM32 defines 2nd value of 3rd row
  3083. * @param initialM33 defines 3rd value of 3rd row
  3084. * @param initialM34 defines 4th value of 3rd row
  3085. * @param initialM41 defines 1st value of 4th row
  3086. * @param initialM42 defines 2nd value of 4th row
  3087. * @param initialM43 defines 3rd value of 4th row
  3088. * @param initialM44 defines 4th value of 4th row
  3089. * @returns the new matrix
  3090. */
  3091. 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;
  3092. /**
  3093. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3094. * @param scale defines the scale vector3
  3095. * @param rotation defines the rotation quaternion
  3096. * @param translation defines the translation vector3
  3097. * @returns a new matrix
  3098. */
  3099. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3100. /**
  3101. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3102. * @param scale defines the scale vector3
  3103. * @param rotation defines the rotation quaternion
  3104. * @param translation defines the translation vector3
  3105. * @param result defines the target matrix
  3106. */
  3107. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3108. /**
  3109. * Creates a new identity matrix
  3110. * @returns a new identity matrix
  3111. */
  3112. static Identity(): Matrix;
  3113. /**
  3114. * Creates a new identity matrix and stores the result in a given matrix
  3115. * @param result defines the target matrix
  3116. */
  3117. static IdentityToRef(result: Matrix): void;
  3118. /**
  3119. * Creates a new zero matrix
  3120. * @returns a new zero matrix
  3121. */
  3122. static Zero(): Matrix;
  3123. /**
  3124. * Creates a new rotation matrix for "angle" radians around the X axis
  3125. * @param angle defines the angle (in radians) to use
  3126. * @return the new matrix
  3127. */
  3128. static RotationX(angle: number): Matrix;
  3129. /**
  3130. * Creates a new matrix as the invert of a given matrix
  3131. * @param source defines the source matrix
  3132. * @returns the new matrix
  3133. */
  3134. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3135. /**
  3136. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3137. * @param angle defines the angle (in radians) to use
  3138. * @param result defines the target matrix
  3139. */
  3140. static RotationXToRef(angle: number, result: Matrix): void;
  3141. /**
  3142. * Creates a new rotation matrix for "angle" radians around the Y axis
  3143. * @param angle defines the angle (in radians) to use
  3144. * @return the new matrix
  3145. */
  3146. static RotationY(angle: number): Matrix;
  3147. /**
  3148. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3149. * @param angle defines the angle (in radians) to use
  3150. * @param result defines the target matrix
  3151. */
  3152. static RotationYToRef(angle: number, result: Matrix): void;
  3153. /**
  3154. * Creates a new rotation matrix for "angle" radians around the Z axis
  3155. * @param angle defines the angle (in radians) to use
  3156. * @return the new matrix
  3157. */
  3158. static RotationZ(angle: number): Matrix;
  3159. /**
  3160. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3161. * @param angle defines the angle (in radians) to use
  3162. * @param result defines the target matrix
  3163. */
  3164. static RotationZToRef(angle: number, result: Matrix): void;
  3165. /**
  3166. * Creates a new rotation matrix for "angle" radians around the given axis
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle (in radians) to use
  3169. * @return the new matrix
  3170. */
  3171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @param result defines the target matrix
  3177. */
  3178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3179. /**
  3180. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3181. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3182. * @param from defines the vector to align
  3183. * @param to defines the vector to align to
  3184. * @param result defines the target matrix
  3185. */
  3186. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3187. /**
  3188. * Creates a rotation matrix
  3189. * @param yaw defines the yaw angle in radians (Y axis)
  3190. * @param pitch defines the pitch angle in radians (X axis)
  3191. * @param roll defines the roll angle in radians (X axis)
  3192. * @returns the new rotation matrix
  3193. */
  3194. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3195. /**
  3196. * Creates a rotation matrix and stores it in a given matrix
  3197. * @param yaw defines the yaw angle in radians (Y axis)
  3198. * @param pitch defines the pitch angle in radians (X axis)
  3199. * @param roll defines the roll angle in radians (X axis)
  3200. * @param result defines the target matrix
  3201. */
  3202. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3203. /**
  3204. * Creates a scaling matrix
  3205. * @param x defines the scale factor on X axis
  3206. * @param y defines the scale factor on Y axis
  3207. * @param z defines the scale factor on Z axis
  3208. * @returns the new matrix
  3209. */
  3210. static Scaling(x: number, y: number, z: number): Matrix;
  3211. /**
  3212. * Creates a scaling matrix and stores it in a given matrix
  3213. * @param x defines the scale factor on X axis
  3214. * @param y defines the scale factor on Y axis
  3215. * @param z defines the scale factor on Z axis
  3216. * @param result defines the target matrix
  3217. */
  3218. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3219. /**
  3220. * Creates a translation matrix
  3221. * @param x defines the translation on X axis
  3222. * @param y defines the translation on Y axis
  3223. * @param z defines the translationon Z axis
  3224. * @returns the new matrix
  3225. */
  3226. static Translation(x: number, y: number, z: number): Matrix;
  3227. /**
  3228. * Creates a translation matrix and stores it in a given matrix
  3229. * @param x defines the translation on X axis
  3230. * @param y defines the translation on Y axis
  3231. * @param z defines the translationon Z axis
  3232. * @param result defines the target matrix
  3233. */
  3234. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3235. /**
  3236. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3237. * @param startValue defines the start value
  3238. * @param endValue defines the end value
  3239. * @param gradient defines the gradient factor
  3240. * @returns the new matrix
  3241. */
  3242. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3243. /**
  3244. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3245. * @param startValue defines the start value
  3246. * @param endValue defines the end value
  3247. * @param gradient defines the gradient factor
  3248. * @param result defines the Matrix object where to store data
  3249. */
  3250. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3251. /**
  3252. * Builds a new matrix whose values are computed by:
  3253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3256. * @param startValue defines the first matrix
  3257. * @param endValue defines the second matrix
  3258. * @param gradient defines the gradient between the two matrices
  3259. * @returns the new matrix
  3260. */
  3261. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3262. /**
  3263. * Update a matrix to values which are computed by:
  3264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3267. * @param startValue defines the first matrix
  3268. * @param endValue defines the second matrix
  3269. * @param gradient defines the gradient between the two matrices
  3270. * @param result defines the target matrix
  3271. */
  3272. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3273. /**
  3274. * 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"
  3275. * This function works in left handed mode
  3276. * @param eye defines the final position of the entity
  3277. * @param target defines where the entity should look at
  3278. * @param up defines the up vector for the entity
  3279. * @returns the new matrix
  3280. */
  3281. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3282. /**
  3283. * 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".
  3284. * This function works in left handed mode
  3285. * @param eye defines the final position of the entity
  3286. * @param target defines where the entity should look at
  3287. * @param up defines the up vector for the entity
  3288. * @param result defines the target matrix
  3289. */
  3290. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3291. /**
  3292. * 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"
  3293. * This function works in right handed mode
  3294. * @param eye defines the final position of the entity
  3295. * @param target defines where the entity should look at
  3296. * @param up defines the up vector for the entity
  3297. * @returns the new matrix
  3298. */
  3299. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3300. /**
  3301. * 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".
  3302. * This function works in right handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @param result defines the target matrix
  3307. */
  3308. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3309. /**
  3310. * Create a left-handed orthographic projection matrix
  3311. * @param width defines the viewport width
  3312. * @param height defines the viewport height
  3313. * @param znear defines the near clip plane
  3314. * @param zfar defines the far clip plane
  3315. * @returns a new matrix as a left-handed orthographic projection matrix
  3316. */
  3317. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3318. /**
  3319. * Store a left-handed orthographic projection to a given matrix
  3320. * @param width defines the viewport width
  3321. * @param height defines the viewport height
  3322. * @param znear defines the near clip plane
  3323. * @param zfar defines the far clip plane
  3324. * @param result defines the target matrix
  3325. */
  3326. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3327. /**
  3328. * Create a left-handed orthographic projection matrix
  3329. * @param left defines the viewport left coordinate
  3330. * @param right defines the viewport right coordinate
  3331. * @param bottom defines the viewport bottom coordinate
  3332. * @param top defines the viewport top coordinate
  3333. * @param znear defines the near clip plane
  3334. * @param zfar defines the far clip plane
  3335. * @returns a new matrix as a left-handed orthographic projection matrix
  3336. */
  3337. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3338. /**
  3339. * Stores a left-handed orthographic projection into a given matrix
  3340. * @param left defines the viewport left coordinate
  3341. * @param right defines the viewport right coordinate
  3342. * @param bottom defines the viewport bottom coordinate
  3343. * @param top defines the viewport top coordinate
  3344. * @param znear defines the near clip plane
  3345. * @param zfar defines the far clip plane
  3346. * @param result defines the target matrix
  3347. */
  3348. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3349. /**
  3350. * Creates a right-handed orthographic projection matrix
  3351. * @param left defines the viewport left coordinate
  3352. * @param right defines the viewport right coordinate
  3353. * @param bottom defines the viewport bottom coordinate
  3354. * @param top defines the viewport top coordinate
  3355. * @param znear defines the near clip plane
  3356. * @param zfar defines the far clip plane
  3357. * @returns a new matrix as a right-handed orthographic projection matrix
  3358. */
  3359. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3360. /**
  3361. * Stores a right-handed orthographic projection into a given matrix
  3362. * @param left defines the viewport left coordinate
  3363. * @param right defines the viewport right coordinate
  3364. * @param bottom defines the viewport bottom coordinate
  3365. * @param top defines the viewport top coordinate
  3366. * @param znear defines the near clip plane
  3367. * @param zfar defines the far clip plane
  3368. * @param result defines the target matrix
  3369. */
  3370. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3371. /**
  3372. * Creates a left-handed perspective projection matrix
  3373. * @param width defines the viewport width
  3374. * @param height defines the viewport height
  3375. * @param znear defines the near clip plane
  3376. * @param zfar defines the far clip plane
  3377. * @returns a new matrix as a left-handed perspective projection matrix
  3378. */
  3379. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3380. /**
  3381. * Creates a left-handed perspective projection matrix
  3382. * @param fov defines the horizontal field of view
  3383. * @param aspect defines the aspect ratio
  3384. * @param znear defines the near clip plane
  3385. * @param zfar defines the far clip plane
  3386. * @returns a new matrix as a left-handed perspective projection matrix
  3387. */
  3388. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3389. /**
  3390. * Stores a left-handed perspective projection into a given matrix
  3391. * @param fov defines the horizontal field of view
  3392. * @param aspect defines the aspect ratio
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3397. */
  3398. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3399. /**
  3400. * Creates a right-handed perspective projection matrix
  3401. * @param fov defines the horizontal field of view
  3402. * @param aspect defines the aspect ratio
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a right-handed perspective projection matrix
  3406. */
  3407. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a right-handed perspective projection into a given matrix
  3410. * @param fov defines the horizontal field of view
  3411. * @param aspect defines the aspect ratio
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3416. */
  3417. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3418. /**
  3419. * Stores a perspective projection for WebVR info a given matrix
  3420. * @param fov defines the field of view
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @param result defines the target matrix
  3424. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3425. */
  3426. static PerspectiveFovWebVRToRef(fov: {
  3427. upDegrees: number;
  3428. downDegrees: number;
  3429. leftDegrees: number;
  3430. rightDegrees: number;
  3431. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3432. /**
  3433. * Computes a complete transformation matrix
  3434. * @param viewport defines the viewport to use
  3435. * @param world defines the world matrix
  3436. * @param view defines the view matrix
  3437. * @param projection defines the projection matrix
  3438. * @param zmin defines the near clip plane
  3439. * @param zmax defines the far clip plane
  3440. * @returns the transformation matrix
  3441. */
  3442. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3443. /**
  3444. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3445. * @param matrix defines the matrix to use
  3446. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3447. */
  3448. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3449. /**
  3450. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3451. * @param matrix defines the matrix to use
  3452. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3453. */
  3454. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3455. /**
  3456. * Compute the transpose of a given matrix
  3457. * @param matrix defines the matrix to transpose
  3458. * @returns the new matrix
  3459. */
  3460. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3461. /**
  3462. * Compute the transpose of a matrix and store it in a target matrix
  3463. * @param matrix defines the matrix to transpose
  3464. * @param result defines the target matrix
  3465. */
  3466. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3467. /**
  3468. * Computes a reflection matrix from a plane
  3469. * @param plane defines the reflection plane
  3470. * @returns a new matrix
  3471. */
  3472. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3473. /**
  3474. * Computes a reflection matrix from a plane
  3475. * @param plane defines the reflection plane
  3476. * @param result defines the target matrix
  3477. */
  3478. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3479. /**
  3480. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3481. * @param xaxis defines the value of the 1st axis
  3482. * @param yaxis defines the value of the 2nd axis
  3483. * @param zaxis defines the value of the 3rd axis
  3484. * @param result defines the target matrix
  3485. */
  3486. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3487. /**
  3488. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3489. * @param quat defines the quaternion to use
  3490. * @param result defines the target matrix
  3491. */
  3492. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3493. }
  3494. /**
  3495. * @hidden
  3496. */
  3497. export class TmpVectors {
  3498. static Vector2: Vector2[];
  3499. static Vector3: Vector3[];
  3500. static Vector4: Vector4[];
  3501. static Quaternion: Quaternion[];
  3502. static Matrix: Matrix[];
  3503. }
  3504. }
  3505. declare module BABYLON {
  3506. /**
  3507. * Class used to hold a RBG color
  3508. */
  3509. export class Color3 {
  3510. /**
  3511. * Defines the red component (between 0 and 1, default is 0)
  3512. */
  3513. r: number;
  3514. /**
  3515. * Defines the green component (between 0 and 1, default is 0)
  3516. */
  3517. g: number;
  3518. /**
  3519. * Defines the blue component (between 0 and 1, default is 0)
  3520. */
  3521. b: number;
  3522. /**
  3523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3524. * @param r defines the red component (between 0 and 1, default is 0)
  3525. * @param g defines the green component (between 0 and 1, default is 0)
  3526. * @param b defines the blue component (between 0 and 1, default is 0)
  3527. */
  3528. constructor(
  3529. /**
  3530. * Defines the red component (between 0 and 1, default is 0)
  3531. */
  3532. r?: number,
  3533. /**
  3534. * Defines the green component (between 0 and 1, default is 0)
  3535. */
  3536. g?: number,
  3537. /**
  3538. * Defines the blue component (between 0 and 1, default is 0)
  3539. */
  3540. b?: number);
  3541. /**
  3542. * Creates a string with the Color3 current values
  3543. * @returns the string representation of the Color3 object
  3544. */
  3545. toString(): string;
  3546. /**
  3547. * Returns the string "Color3"
  3548. * @returns "Color3"
  3549. */
  3550. getClassName(): string;
  3551. /**
  3552. * Compute the Color3 hash code
  3553. * @returns an unique number that can be used to hash Color3 objects
  3554. */
  3555. getHashCode(): number;
  3556. /**
  3557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3558. * @param array defines the array where to store the r,g,b components
  3559. * @param index defines an optional index in the target array to define where to start storing values
  3560. * @returns the current Color3 object
  3561. */
  3562. toArray(array: FloatArray, index?: number): Color3;
  3563. /**
  3564. * Returns a new Color4 object from the current Color3 and the given alpha
  3565. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3566. * @returns a new Color4 object
  3567. */
  3568. toColor4(alpha?: number): Color4;
  3569. /**
  3570. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3571. * @returns the new array
  3572. */
  3573. asArray(): number[];
  3574. /**
  3575. * Returns the luminance value
  3576. * @returns a float value
  3577. */
  3578. toLuminance(): number;
  3579. /**
  3580. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3581. * @param otherColor defines the second operand
  3582. * @returns the new Color3 object
  3583. */
  3584. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3585. /**
  3586. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3587. * @param otherColor defines the second operand
  3588. * @param result defines the Color3 object where to store the result
  3589. * @returns the current Color3
  3590. */
  3591. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3592. /**
  3593. * Determines equality between Color3 objects
  3594. * @param otherColor defines the second operand
  3595. * @returns true if the rgb values are equal to the given ones
  3596. */
  3597. equals(otherColor: DeepImmutable<Color3>): boolean;
  3598. /**
  3599. * Determines equality between the current Color3 object and a set of r,b,g values
  3600. * @param r defines the red component to check
  3601. * @param g defines the green component to check
  3602. * @param b defines the blue component to check
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equalsFloats(r: number, g: number, b: number): boolean;
  3606. /**
  3607. * Multiplies in place each rgb value by scale
  3608. * @param scale defines the scaling factor
  3609. * @returns the updated Color3
  3610. */
  3611. scale(scale: number): Color3;
  3612. /**
  3613. * Multiplies the rgb values by scale and stores the result into "result"
  3614. * @param scale defines the scaling factor
  3615. * @param result defines the Color3 object where to store the result
  3616. * @returns the unmodified current Color3
  3617. */
  3618. scaleToRef(scale: number, result: Color3): Color3;
  3619. /**
  3620. * Scale the current Color3 values by a factor and add the result to a given Color3
  3621. * @param scale defines the scale factor
  3622. * @param result defines color to store the result into
  3623. * @returns the unmodified current Color3
  3624. */
  3625. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3626. /**
  3627. * Clamps the rgb values by the min and max values and stores the result into "result"
  3628. * @param min defines minimum clamping value (default is 0)
  3629. * @param max defines maximum clamping value (default is 1)
  3630. * @param result defines color to store the result into
  3631. * @returns the original Color3
  3632. */
  3633. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3634. /**
  3635. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3636. * @param otherColor defines the second operand
  3637. * @returns the new Color3
  3638. */
  3639. add(otherColor: DeepImmutable<Color3>): Color3;
  3640. /**
  3641. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3642. * @param otherColor defines the second operand
  3643. * @param result defines Color3 object to store the result into
  3644. * @returns the unmodified current Color3
  3645. */
  3646. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3647. /**
  3648. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3649. * @param otherColor defines the second operand
  3650. * @returns the new Color3
  3651. */
  3652. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3653. /**
  3654. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3655. * @param otherColor defines the second operand
  3656. * @param result defines Color3 object to store the result into
  3657. * @returns the unmodified current Color3
  3658. */
  3659. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3660. /**
  3661. * Copy the current object
  3662. * @returns a new Color3 copied the current one
  3663. */
  3664. clone(): Color3;
  3665. /**
  3666. * Copies the rgb values from the source in the current Color3
  3667. * @param source defines the source Color3 object
  3668. * @returns the updated Color3 object
  3669. */
  3670. copyFrom(source: DeepImmutable<Color3>): Color3;
  3671. /**
  3672. * Updates the Color3 rgb values from the given floats
  3673. * @param r defines the red component to read from
  3674. * @param g defines the green component to read from
  3675. * @param b defines the blue component to read from
  3676. * @returns the current Color3 object
  3677. */
  3678. copyFromFloats(r: number, g: number, b: number): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. set(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Compute the Color3 hexadecimal code as a string
  3689. * @returns a string containing the hexadecimal representation of the Color3 object
  3690. */
  3691. toHexString(): string;
  3692. /**
  3693. * Computes a new Color3 converted from the current one to linear space
  3694. * @returns a new Color3 object
  3695. */
  3696. toLinearSpace(): Color3;
  3697. /**
  3698. * Converts current color in rgb space to HSV values
  3699. * @returns a new color3 representing the HSV values
  3700. */
  3701. toHSV(): Color3;
  3702. /**
  3703. * Converts current color in rgb space to HSV values
  3704. * @param result defines the Color3 where to store the HSV values
  3705. */
  3706. toHSVToRef(result: Color3): void;
  3707. /**
  3708. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3709. * @param convertedColor defines the Color3 object where to store the linear space version
  3710. * @returns the unmodified Color3
  3711. */
  3712. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3713. /**
  3714. * Computes a new Color3 converted from the current one to gamma space
  3715. * @returns a new Color3 object
  3716. */
  3717. toGammaSpace(): Color3;
  3718. /**
  3719. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3720. * @param convertedColor defines the Color3 object where to store the gamma space version
  3721. * @returns the unmodified Color3
  3722. */
  3723. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3724. private static _BlackReadOnly;
  3725. /**
  3726. * Convert Hue, saturation and value to a Color3 (RGB)
  3727. * @param hue defines the hue
  3728. * @param saturation defines the saturation
  3729. * @param value defines the value
  3730. * @param result defines the Color3 where to store the RGB values
  3731. */
  3732. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3733. /**
  3734. * Creates a new Color3 from the string containing valid hexadecimal values
  3735. * @param hex defines a string containing valid hexadecimal values
  3736. * @returns a new Color3 object
  3737. */
  3738. static FromHexString(hex: string): Color3;
  3739. /**
  3740. * Creates a new Color3 from the starting index of the given array
  3741. * @param array defines the source array
  3742. * @param offset defines an offset in the source array
  3743. * @returns a new Color3 object
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3746. /**
  3747. * Creates a new Color3 from integer values (< 256)
  3748. * @param r defines the red component to read from (value between 0 and 255)
  3749. * @param g defines the green component to read from (value between 0 and 255)
  3750. * @param b defines the blue component to read from (value between 0 and 255)
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromInts(r: number, g: number, b: number): Color3;
  3754. /**
  3755. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3756. * @param start defines the start Color3 value
  3757. * @param end defines the end Color3 value
  3758. * @param amount defines the gradient value between start and end
  3759. * @returns a new Color3 object
  3760. */
  3761. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param left defines the start value
  3765. * @param right defines the end value
  3766. * @param amount defines the gradient factor
  3767. * @param result defines the Color3 object where to store the result
  3768. */
  3769. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3770. /**
  3771. * Returns a Color3 value containing a red color
  3772. * @returns a new Color3 object
  3773. */
  3774. static Red(): Color3;
  3775. /**
  3776. * Returns a Color3 value containing a green color
  3777. * @returns a new Color3 object
  3778. */
  3779. static Green(): Color3;
  3780. /**
  3781. * Returns a Color3 value containing a blue color
  3782. * @returns a new Color3 object
  3783. */
  3784. static Blue(): Color3;
  3785. /**
  3786. * Returns a Color3 value containing a black color
  3787. * @returns a new Color3 object
  3788. */
  3789. static Black(): Color3;
  3790. /**
  3791. * Gets a Color3 value containing a black color that must not be updated
  3792. */
  3793. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3794. /**
  3795. * Returns a Color3 value containing a white color
  3796. * @returns a new Color3 object
  3797. */
  3798. static White(): Color3;
  3799. /**
  3800. * Returns a Color3 value containing a purple color
  3801. * @returns a new Color3 object
  3802. */
  3803. static Purple(): Color3;
  3804. /**
  3805. * Returns a Color3 value containing a magenta color
  3806. * @returns a new Color3 object
  3807. */
  3808. static Magenta(): Color3;
  3809. /**
  3810. * Returns a Color3 value containing a yellow color
  3811. * @returns a new Color3 object
  3812. */
  3813. static Yellow(): Color3;
  3814. /**
  3815. * Returns a Color3 value containing a gray color
  3816. * @returns a new Color3 object
  3817. */
  3818. static Gray(): Color3;
  3819. /**
  3820. * Returns a Color3 value containing a teal color
  3821. * @returns a new Color3 object
  3822. */
  3823. static Teal(): Color3;
  3824. /**
  3825. * Returns a Color3 value containing a random color
  3826. * @returns a new Color3 object
  3827. */
  3828. static Random(): Color3;
  3829. }
  3830. /**
  3831. * Class used to hold a RBGA color
  3832. */
  3833. export class Color4 {
  3834. /**
  3835. * Defines the red component (between 0 and 1, default is 0)
  3836. */
  3837. r: number;
  3838. /**
  3839. * Defines the green component (between 0 and 1, default is 0)
  3840. */
  3841. g: number;
  3842. /**
  3843. * Defines the blue component (between 0 and 1, default is 0)
  3844. */
  3845. b: number;
  3846. /**
  3847. * Defines the alpha component (between 0 and 1, default is 1)
  3848. */
  3849. a: number;
  3850. /**
  3851. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3852. * @param r defines the red component (between 0 and 1, default is 0)
  3853. * @param g defines the green component (between 0 and 1, default is 0)
  3854. * @param b defines the blue component (between 0 and 1, default is 0)
  3855. * @param a defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. constructor(
  3858. /**
  3859. * Defines the red component (between 0 and 1, default is 0)
  3860. */
  3861. r?: number,
  3862. /**
  3863. * Defines the green component (between 0 and 1, default is 0)
  3864. */
  3865. g?: number,
  3866. /**
  3867. * Defines the blue component (between 0 and 1, default is 0)
  3868. */
  3869. b?: number,
  3870. /**
  3871. * Defines the alpha component (between 0 and 1, default is 1)
  3872. */
  3873. a?: number);
  3874. /**
  3875. * Adds in place the given Color4 values to the current Color4 object
  3876. * @param right defines the second operand
  3877. * @returns the current updated Color4 object
  3878. */
  3879. addInPlace(right: DeepImmutable<Color4>): Color4;
  3880. /**
  3881. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3882. * @returns the new array
  3883. */
  3884. asArray(): number[];
  3885. /**
  3886. * Stores from the starting index in the given array the Color4 successive values
  3887. * @param array defines the array where to store the r,g,b components
  3888. * @param index defines an optional index in the target array to define where to start storing values
  3889. * @returns the current Color4 object
  3890. */
  3891. toArray(array: number[], index?: number): Color4;
  3892. /**
  3893. * Determines equality between Color4 objects
  3894. * @param otherColor defines the second operand
  3895. * @returns true if the rgba values are equal to the given ones
  3896. */
  3897. equals(otherColor: DeepImmutable<Color4>): boolean;
  3898. /**
  3899. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3900. * @param right defines the second operand
  3901. * @returns a new Color4 object
  3902. */
  3903. add(right: DeepImmutable<Color4>): Color4;
  3904. /**
  3905. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3906. * @param right defines the second operand
  3907. * @returns a new Color4 object
  3908. */
  3909. subtract(right: DeepImmutable<Color4>): Color4;
  3910. /**
  3911. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3912. * @param right defines the second operand
  3913. * @param result defines the Color4 object where to store the result
  3914. * @returns the current Color4 object
  3915. */
  3916. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3917. /**
  3918. * Creates a new Color4 with the current Color4 values multiplied by scale
  3919. * @param scale defines the scaling factor to apply
  3920. * @returns a new Color4 object
  3921. */
  3922. scale(scale: number): Color4;
  3923. /**
  3924. * Multiplies the current Color4 values by scale and stores the result in "result"
  3925. * @param scale defines the scaling factor to apply
  3926. * @param result defines the Color4 object where to store the result
  3927. * @returns the current unmodified Color4
  3928. */
  3929. scaleToRef(scale: number, result: Color4): Color4;
  3930. /**
  3931. * Scale the current Color4 values by a factor and add the result to a given Color4
  3932. * @param scale defines the scale factor
  3933. * @param result defines the Color4 object where to store the result
  3934. * @returns the unmodified current Color4
  3935. */
  3936. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3937. /**
  3938. * Clamps the rgb values by the min and max values and stores the result into "result"
  3939. * @param min defines minimum clamping value (default is 0)
  3940. * @param max defines maximum clamping value (default is 1)
  3941. * @param result defines color to store the result into.
  3942. * @returns the cuurent Color4
  3943. */
  3944. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3945. /**
  3946. * Multipy an Color4 value by another and return a new Color4 object
  3947. * @param color defines the Color4 value to multiply by
  3948. * @returns a new Color4 object
  3949. */
  3950. multiply(color: Color4): Color4;
  3951. /**
  3952. * Multipy a Color4 value by another and push the result in a reference value
  3953. * @param color defines the Color4 value to multiply by
  3954. * @param result defines the Color4 to fill the result in
  3955. * @returns the result Color4
  3956. */
  3957. multiplyToRef(color: Color4, result: Color4): Color4;
  3958. /**
  3959. * Creates a string with the Color4 current values
  3960. * @returns the string representation of the Color4 object
  3961. */
  3962. toString(): string;
  3963. /**
  3964. * Returns the string "Color4"
  3965. * @returns "Color4"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Compute the Color4 hash code
  3970. * @returns an unique number that can be used to hash Color4 objects
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Creates a new Color4 copied from the current one
  3975. * @returns a new Color4 object
  3976. */
  3977. clone(): Color4;
  3978. /**
  3979. * Copies the given Color4 values into the current one
  3980. * @param source defines the source Color4 object
  3981. * @returns the current updated Color4 object
  3982. */
  3983. copyFrom(source: Color4): Color4;
  3984. /**
  3985. * Copies the given float values into the current one
  3986. * @param r defines the red component to read from
  3987. * @param g defines the green component to read from
  3988. * @param b defines the blue component to read from
  3989. * @param a defines the alpha component to read from
  3990. * @returns the current updated Color4 object
  3991. */
  3992. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3993. /**
  3994. * Copies the given float values into the current one
  3995. * @param r defines the red component to read from
  3996. * @param g defines the green component to read from
  3997. * @param b defines the blue component to read from
  3998. * @param a defines the alpha component to read from
  3999. * @returns the current updated Color4 object
  4000. */
  4001. set(r: number, g: number, b: number, a: number): Color4;
  4002. /**
  4003. * Compute the Color4 hexadecimal code as a string
  4004. * @returns a string containing the hexadecimal representation of the Color4 object
  4005. */
  4006. toHexString(): string;
  4007. /**
  4008. * Computes a new Color4 converted from the current one to linear space
  4009. * @returns a new Color4 object
  4010. */
  4011. toLinearSpace(): Color4;
  4012. /**
  4013. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4014. * @param convertedColor defines the Color4 object where to store the linear space version
  4015. * @returns the unmodified Color4
  4016. */
  4017. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4018. /**
  4019. * Computes a new Color4 converted from the current one to gamma space
  4020. * @returns a new Color4 object
  4021. */
  4022. toGammaSpace(): Color4;
  4023. /**
  4024. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4025. * @param convertedColor defines the Color4 object where to store the gamma space version
  4026. * @returns the unmodified Color4
  4027. */
  4028. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4029. /**
  4030. * Creates a new Color4 from the string containing valid hexadecimal values
  4031. * @param hex defines a string containing valid hexadecimal values
  4032. * @returns a new Color4 object
  4033. */
  4034. static FromHexString(hex: string): Color4;
  4035. /**
  4036. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4037. * @param left defines the start value
  4038. * @param right defines the end value
  4039. * @param amount defines the gradient factor
  4040. * @returns a new Color4 object
  4041. */
  4042. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4043. /**
  4044. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @param result defines the Color4 object where to store data
  4049. */
  4050. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4051. /**
  4052. * Creates a new Color4 from a Color3 and an alpha value
  4053. * @param color3 defines the source Color3 to read from
  4054. * @param alpha defines the alpha component (1.0 by default)
  4055. * @returns a new Color4 object
  4056. */
  4057. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4058. /**
  4059. * Creates a new Color4 from the starting index element of the given array
  4060. * @param array defines the source array to read from
  4061. * @param offset defines the offset in the source array
  4062. * @returns a new Color4 object
  4063. */
  4064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4065. /**
  4066. * Creates a new Color3 from integer values (< 256)
  4067. * @param r defines the red component to read from (value between 0 and 255)
  4068. * @param g defines the green component to read from (value between 0 and 255)
  4069. * @param b defines the blue component to read from (value between 0 and 255)
  4070. * @param a defines the alpha component to read from (value between 0 and 255)
  4071. * @returns a new Color3 object
  4072. */
  4073. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4074. /**
  4075. * Check the content of a given array and convert it to an array containing RGBA data
  4076. * If the original array was already containing count * 4 values then it is returned directly
  4077. * @param colors defines the array to check
  4078. * @param count defines the number of RGBA data to expect
  4079. * @returns an array containing count * 4 values (RGBA)
  4080. */
  4081. static CheckColors4(colors: number[], count: number): number[];
  4082. }
  4083. /**
  4084. * @hidden
  4085. */
  4086. export class TmpColors {
  4087. static Color3: Color3[];
  4088. static Color4: Color4[];
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. /**
  4093. * Class representing spherical harmonics coefficients to the 3rd degree
  4094. */
  4095. export class SphericalHarmonics {
  4096. /**
  4097. * Defines whether or not the harmonics have been prescaled for rendering.
  4098. */
  4099. preScaled: boolean;
  4100. /**
  4101. * The l0,0 coefficients of the spherical harmonics
  4102. */
  4103. l00: Vector3;
  4104. /**
  4105. * The l1,-1 coefficients of the spherical harmonics
  4106. */
  4107. l1_1: Vector3;
  4108. /**
  4109. * The l1,0 coefficients of the spherical harmonics
  4110. */
  4111. l10: Vector3;
  4112. /**
  4113. * The l1,1 coefficients of the spherical harmonics
  4114. */
  4115. l11: Vector3;
  4116. /**
  4117. * The l2,-2 coefficients of the spherical harmonics
  4118. */
  4119. l2_2: Vector3;
  4120. /**
  4121. * The l2,-1 coefficients of the spherical harmonics
  4122. */
  4123. l2_1: Vector3;
  4124. /**
  4125. * The l2,0 coefficients of the spherical harmonics
  4126. */
  4127. l20: Vector3;
  4128. /**
  4129. * The l2,1 coefficients of the spherical harmonics
  4130. */
  4131. l21: Vector3;
  4132. /**
  4133. * The l2,2 coefficients of the spherical harmonics
  4134. */
  4135. l22: Vector3;
  4136. /**
  4137. * Adds a light to the spherical harmonics
  4138. * @param direction the direction of the light
  4139. * @param color the color of the light
  4140. * @param deltaSolidAngle the delta solid angle of the light
  4141. */
  4142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4143. /**
  4144. * Scales the spherical harmonics by the given amount
  4145. * @param scale the amount to scale
  4146. */
  4147. scaleInPlace(scale: number): void;
  4148. /**
  4149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4150. *
  4151. * ```
  4152. * E_lm = A_l * L_lm
  4153. * ```
  4154. *
  4155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4157. * the scaling factors are given in equation 9.
  4158. */
  4159. convertIncidentRadianceToIrradiance(): void;
  4160. /**
  4161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4162. *
  4163. * ```
  4164. * L = (1/pi) * E * rho
  4165. * ```
  4166. *
  4167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4168. */
  4169. convertIrradianceToLambertianRadiance(): void;
  4170. /**
  4171. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4172. * required operations at run time.
  4173. *
  4174. * This is simply done by scaling back the SH with Ylm constants parameter.
  4175. * The trigonometric part being applied by the shader at run time.
  4176. */
  4177. preScaleForRendering(): void;
  4178. /**
  4179. * Constructs a spherical harmonics from an array.
  4180. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4181. * @returns the spherical harmonics
  4182. */
  4183. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4184. /**
  4185. * Gets the spherical harmonics from polynomial
  4186. * @param polynomial the spherical polynomial
  4187. * @returns the spherical harmonics
  4188. */
  4189. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4190. }
  4191. /**
  4192. * Class representing spherical polynomial coefficients to the 3rd degree
  4193. */
  4194. export class SphericalPolynomial {
  4195. private _harmonics;
  4196. /**
  4197. * The spherical harmonics used to create the polynomials.
  4198. */
  4199. readonly preScaledHarmonics: SphericalHarmonics;
  4200. /**
  4201. * The x coefficients of the spherical polynomial
  4202. */
  4203. x: Vector3;
  4204. /**
  4205. * The y coefficients of the spherical polynomial
  4206. */
  4207. y: Vector3;
  4208. /**
  4209. * The z coefficients of the spherical polynomial
  4210. */
  4211. z: Vector3;
  4212. /**
  4213. * The xx coefficients of the spherical polynomial
  4214. */
  4215. xx: Vector3;
  4216. /**
  4217. * The yy coefficients of the spherical polynomial
  4218. */
  4219. yy: Vector3;
  4220. /**
  4221. * The zz coefficients of the spherical polynomial
  4222. */
  4223. zz: Vector3;
  4224. /**
  4225. * The xy coefficients of the spherical polynomial
  4226. */
  4227. xy: Vector3;
  4228. /**
  4229. * The yz coefficients of the spherical polynomial
  4230. */
  4231. yz: Vector3;
  4232. /**
  4233. * The zx coefficients of the spherical polynomial
  4234. */
  4235. zx: Vector3;
  4236. /**
  4237. * Adds an ambient color to the spherical polynomial
  4238. * @param color the color to add
  4239. */
  4240. addAmbient(color: Color3): void;
  4241. /**
  4242. * Scales the spherical polynomial by the given amount
  4243. * @param scale the amount to scale
  4244. */
  4245. scaleInPlace(scale: number): void;
  4246. /**
  4247. * Gets the spherical polynomial from harmonics
  4248. * @param harmonics the spherical harmonics
  4249. * @returns the spherical polynomial
  4250. */
  4251. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4252. /**
  4253. * Constructs a spherical polynomial from an array.
  4254. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4255. * @returns the spherical polynomial
  4256. */
  4257. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4258. }
  4259. }
  4260. declare module BABYLON {
  4261. /**
  4262. * Define options used to create a render target texture
  4263. */
  4264. export class RenderTargetCreationOptions {
  4265. /**
  4266. * Specifies is mipmaps must be generated
  4267. */
  4268. generateMipMaps?: boolean;
  4269. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4270. generateDepthBuffer?: boolean;
  4271. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4272. generateStencilBuffer?: boolean;
  4273. /** Defines texture type (int by default) */
  4274. type?: number;
  4275. /** Defines sampling mode (trilinear by default) */
  4276. samplingMode?: number;
  4277. /** Defines format (RGBA by default) */
  4278. format?: number;
  4279. }
  4280. }
  4281. declare module BABYLON {
  4282. /**
  4283. * @hidden
  4284. **/
  4285. export class _TimeToken {
  4286. _startTimeQuery: Nullable<WebGLQuery>;
  4287. _endTimeQuery: Nullable<WebGLQuery>;
  4288. _timeElapsedQuery: Nullable<WebGLQuery>;
  4289. _timeElapsedQueryEnded: boolean;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /** Defines the cross module used constants to avoid circular dependncies */
  4294. export class Constants {
  4295. /** Defines that alpha blending is disabled */
  4296. static readonly ALPHA_DISABLE: number;
  4297. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4298. static readonly ALPHA_ADD: number;
  4299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4300. static readonly ALPHA_COMBINE: number;
  4301. /** Defines that alpha blending to DEST - SRC * DEST */
  4302. static readonly ALPHA_SUBTRACT: number;
  4303. /** Defines that alpha blending to SRC * DEST */
  4304. static readonly ALPHA_MULTIPLY: number;
  4305. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4306. static readonly ALPHA_MAXIMIZED: number;
  4307. /** Defines that alpha blending to SRC + DEST */
  4308. static readonly ALPHA_ONEONE: number;
  4309. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4310. static readonly ALPHA_PREMULTIPLIED: number;
  4311. /**
  4312. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4313. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4314. */
  4315. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4316. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4317. static readonly ALPHA_INTERPOLATE: number;
  4318. /**
  4319. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4320. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4321. */
  4322. static readonly ALPHA_SCREENMODE: number;
  4323. /**
  4324. * Defines that alpha blending to SRC + DST
  4325. * Alpha will be set to SRC ALPHA + DST ALPHA
  4326. */
  4327. static readonly ALPHA_ONEONE_ONEONE: number;
  4328. /**
  4329. * Defines that alpha blending to SRC * DST ALPHA + DST
  4330. * Alpha will be set to 0
  4331. */
  4332. static readonly ALPHA_ALPHATOCOLOR: number;
  4333. /**
  4334. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4335. */
  4336. static readonly ALPHA_REVERSEONEMINUS: number;
  4337. /**
  4338. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4339. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4340. */
  4341. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + DST
  4344. * Alpha will be set to SRC ALPHA
  4345. */
  4346. static readonly ALPHA_ONEONE_ONEZERO: number;
  4347. /** Defines that alpha blending equation a SUM */
  4348. static readonly ALPHA_EQUATION_ADD: number;
  4349. /** Defines that alpha blending equation a SUBSTRACTION */
  4350. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4351. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4352. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4353. /** Defines that alpha blending equation a MAX operation */
  4354. static readonly ALPHA_EQUATION_MAX: number;
  4355. /** Defines that alpha blending equation a MIN operation */
  4356. static readonly ALPHA_EQUATION_MIN: number;
  4357. /**
  4358. * Defines that alpha blending equation a DARKEN operation:
  4359. * It takes the min of the src and sums the alpha channels.
  4360. */
  4361. static readonly ALPHA_EQUATION_DARKEN: number;
  4362. /** Defines that the ressource is not delayed*/
  4363. static readonly DELAYLOADSTATE_NONE: number;
  4364. /** Defines that the ressource was successfully delay loaded */
  4365. static readonly DELAYLOADSTATE_LOADED: number;
  4366. /** Defines that the ressource is currently delay loading */
  4367. static readonly DELAYLOADSTATE_LOADING: number;
  4368. /** Defines that the ressource is delayed and has not started loading */
  4369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4371. static readonly NEVER: number;
  4372. /** 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 */
  4373. static readonly ALWAYS: number;
  4374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4375. static readonly LESS: number;
  4376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4377. static readonly EQUAL: number;
  4378. /** 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 */
  4379. static readonly LEQUAL: number;
  4380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4381. static readonly GREATER: number;
  4382. /** 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 */
  4383. static readonly GEQUAL: number;
  4384. /** 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 */
  4385. static readonly NOTEQUAL: number;
  4386. /** Passed to stencilOperation to specify that stencil value must be kept */
  4387. static readonly KEEP: number;
  4388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4389. static readonly REPLACE: number;
  4390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4391. static readonly INCR: number;
  4392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4393. static readonly DECR: number;
  4394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4395. static readonly INVERT: number;
  4396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4397. static readonly INCR_WRAP: number;
  4398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4399. static readonly DECR_WRAP: number;
  4400. /** Texture is not repeating outside of 0..1 UVs */
  4401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4402. /** Texture is repeating outside of 0..1 UVs */
  4403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4404. /** Texture is repeating and mirrored */
  4405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4406. /** ALPHA */
  4407. static readonly TEXTUREFORMAT_ALPHA: number;
  4408. /** LUMINANCE */
  4409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4410. /** LUMINANCE_ALPHA */
  4411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4412. /** RGB */
  4413. static readonly TEXTUREFORMAT_RGB: number;
  4414. /** RGBA */
  4415. static readonly TEXTUREFORMAT_RGBA: number;
  4416. /** RED */
  4417. static readonly TEXTUREFORMAT_RED: number;
  4418. /** RED (2nd reference) */
  4419. static readonly TEXTUREFORMAT_R: number;
  4420. /** RG */
  4421. static readonly TEXTUREFORMAT_RG: number;
  4422. /** RED_INTEGER */
  4423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4424. /** RED_INTEGER (2nd reference) */
  4425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4426. /** RG_INTEGER */
  4427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4428. /** RGB_INTEGER */
  4429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4430. /** RGBA_INTEGER */
  4431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4432. /** UNSIGNED_BYTE */
  4433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4434. /** UNSIGNED_BYTE (2nd reference) */
  4435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4436. /** FLOAT */
  4437. static readonly TEXTURETYPE_FLOAT: number;
  4438. /** HALF_FLOAT */
  4439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4440. /** BYTE */
  4441. static readonly TEXTURETYPE_BYTE: number;
  4442. /** SHORT */
  4443. static readonly TEXTURETYPE_SHORT: number;
  4444. /** UNSIGNED_SHORT */
  4445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4446. /** INT */
  4447. static readonly TEXTURETYPE_INT: number;
  4448. /** UNSIGNED_INT */
  4449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4450. /** UNSIGNED_SHORT_4_4_4_4 */
  4451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4452. /** UNSIGNED_SHORT_5_5_5_1 */
  4453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4454. /** UNSIGNED_SHORT_5_6_5 */
  4455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4456. /** UNSIGNED_INT_2_10_10_10_REV */
  4457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4458. /** UNSIGNED_INT_24_8 */
  4459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4460. /** UNSIGNED_INT_10F_11F_11F_REV */
  4461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4462. /** UNSIGNED_INT_5_9_9_9_REV */
  4463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4466. /** nearest is mag = nearest and min = nearest and mip = linear */
  4467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4470. /** Trilinear is mag = linear and min = linear and mip = linear */
  4471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4472. /** nearest is mag = nearest and min = nearest and mip = linear */
  4473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4476. /** Trilinear is mag = linear and min = linear and mip = linear */
  4477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4478. /** mag = nearest and min = nearest and mip = nearest */
  4479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4480. /** mag = nearest and min = linear and mip = nearest */
  4481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4482. /** mag = nearest and min = linear and mip = linear */
  4483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4484. /** mag = nearest and min = linear and mip = none */
  4485. static readonly TEXTURE_NEAREST_LINEAR: number;
  4486. /** mag = nearest and min = nearest and mip = none */
  4487. static readonly TEXTURE_NEAREST_NEAREST: number;
  4488. /** mag = linear and min = nearest and mip = nearest */
  4489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4490. /** mag = linear and min = nearest and mip = linear */
  4491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4492. /** mag = linear and min = linear and mip = none */
  4493. static readonly TEXTURE_LINEAR_LINEAR: number;
  4494. /** mag = linear and min = nearest and mip = none */
  4495. static readonly TEXTURE_LINEAR_NEAREST: number;
  4496. /** Explicit coordinates mode */
  4497. static readonly TEXTURE_EXPLICIT_MODE: number;
  4498. /** Spherical coordinates mode */
  4499. static readonly TEXTURE_SPHERICAL_MODE: number;
  4500. /** Planar coordinates mode */
  4501. static readonly TEXTURE_PLANAR_MODE: number;
  4502. /** Cubic coordinates mode */
  4503. static readonly TEXTURE_CUBIC_MODE: number;
  4504. /** Projection coordinates mode */
  4505. static readonly TEXTURE_PROJECTION_MODE: number;
  4506. /** Skybox coordinates mode */
  4507. static readonly TEXTURE_SKYBOX_MODE: number;
  4508. /** Inverse Cubic coordinates mode */
  4509. static readonly TEXTURE_INVCUBIC_MODE: number;
  4510. /** Equirectangular coordinates mode */
  4511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4512. /** Equirectangular Fixed coordinates mode */
  4513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4514. /** Equirectangular Fixed Mirrored coordinates mode */
  4515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4517. static readonly SCALEMODE_FLOOR: number;
  4518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4519. static readonly SCALEMODE_NEAREST: number;
  4520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4521. static readonly SCALEMODE_CEILING: number;
  4522. /**
  4523. * The dirty texture flag value
  4524. */
  4525. static readonly MATERIAL_TextureDirtyFlag: number;
  4526. /**
  4527. * The dirty light flag value
  4528. */
  4529. static readonly MATERIAL_LightDirtyFlag: number;
  4530. /**
  4531. * The dirty fresnel flag value
  4532. */
  4533. static readonly MATERIAL_FresnelDirtyFlag: number;
  4534. /**
  4535. * The dirty attribute flag value
  4536. */
  4537. static readonly MATERIAL_AttributesDirtyFlag: number;
  4538. /**
  4539. * The dirty misc flag value
  4540. */
  4541. static readonly MATERIAL_MiscDirtyFlag: number;
  4542. /**
  4543. * The all dirty flag value
  4544. */
  4545. static readonly MATERIAL_AllDirtyFlag: number;
  4546. /**
  4547. * Returns the triangle fill mode
  4548. */
  4549. static readonly MATERIAL_TriangleFillMode: number;
  4550. /**
  4551. * Returns the wireframe mode
  4552. */
  4553. static readonly MATERIAL_WireFrameFillMode: number;
  4554. /**
  4555. * Returns the point fill mode
  4556. */
  4557. static readonly MATERIAL_PointFillMode: number;
  4558. /**
  4559. * Returns the point list draw mode
  4560. */
  4561. static readonly MATERIAL_PointListDrawMode: number;
  4562. /**
  4563. * Returns the line list draw mode
  4564. */
  4565. static readonly MATERIAL_LineListDrawMode: number;
  4566. /**
  4567. * Returns the line loop draw mode
  4568. */
  4569. static readonly MATERIAL_LineLoopDrawMode: number;
  4570. /**
  4571. * Returns the line strip draw mode
  4572. */
  4573. static readonly MATERIAL_LineStripDrawMode: number;
  4574. /**
  4575. * Returns the triangle strip draw mode
  4576. */
  4577. static readonly MATERIAL_TriangleStripDrawMode: number;
  4578. /**
  4579. * Returns the triangle fan draw mode
  4580. */
  4581. static readonly MATERIAL_TriangleFanDrawMode: number;
  4582. /**
  4583. * Stores the clock-wise side orientation
  4584. */
  4585. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4586. /**
  4587. * Stores the counter clock-wise side orientation
  4588. */
  4589. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4590. /**
  4591. * Nothing
  4592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4593. */
  4594. static readonly ACTION_NothingTrigger: number;
  4595. /**
  4596. * On pick
  4597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4598. */
  4599. static readonly ACTION_OnPickTrigger: number;
  4600. /**
  4601. * On left pick
  4602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4603. */
  4604. static readonly ACTION_OnLeftPickTrigger: number;
  4605. /**
  4606. * On right pick
  4607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4608. */
  4609. static readonly ACTION_OnRightPickTrigger: number;
  4610. /**
  4611. * On center pick
  4612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4613. */
  4614. static readonly ACTION_OnCenterPickTrigger: number;
  4615. /**
  4616. * On pick down
  4617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4618. */
  4619. static readonly ACTION_OnPickDownTrigger: number;
  4620. /**
  4621. * On double pick
  4622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4623. */
  4624. static readonly ACTION_OnDoublePickTrigger: number;
  4625. /**
  4626. * On pick up
  4627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4628. */
  4629. static readonly ACTION_OnPickUpTrigger: number;
  4630. /**
  4631. * On pick out.
  4632. * This trigger will only be raised if you also declared a OnPickDown
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnPickOutTrigger: number;
  4636. /**
  4637. * On long press
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnLongPressTrigger: number;
  4641. /**
  4642. * On pointer over
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnPointerOverTrigger: number;
  4646. /**
  4647. * On pointer out
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPointerOutTrigger: number;
  4651. /**
  4652. * On every frame
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnEveryFrameTrigger: number;
  4656. /**
  4657. * On intersection enter
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4661. /**
  4662. * On intersection exit
  4663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4664. */
  4665. static readonly ACTION_OnIntersectionExitTrigger: number;
  4666. /**
  4667. * On key down
  4668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4669. */
  4670. static readonly ACTION_OnKeyDownTrigger: number;
  4671. /**
  4672. * On key up
  4673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4674. */
  4675. static readonly ACTION_OnKeyUpTrigger: number;
  4676. /**
  4677. * Billboard mode will only apply to Y axis
  4678. */
  4679. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4680. /**
  4681. * Billboard mode will apply to all axes
  4682. */
  4683. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4684. /**
  4685. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4686. */
  4687. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4688. /**
  4689. * Gets or sets base Assets URL
  4690. */
  4691. static PARTICLES_BaseAssetsUrl: string;
  4692. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4693. * Test order :
  4694. * Is the bounding sphere outside the frustum ?
  4695. * If not, are the bounding box vertices outside the frustum ?
  4696. * It not, then the cullable object is in the frustum.
  4697. */
  4698. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4699. /** Culling strategy : Bounding Sphere Only.
  4700. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4701. * It's also less accurate than the standard because some not visible objects can still be selected.
  4702. * Test : is the bounding sphere outside the frustum ?
  4703. * If not, then the cullable object is in the frustum.
  4704. */
  4705. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4706. /** Culling strategy : Optimistic Inclusion.
  4707. * This in an inclusion test first, then the standard exclusion test.
  4708. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4709. * 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.
  4710. * Anyway, it's as accurate as the standard strategy.
  4711. * Test :
  4712. * Is the cullable object bounding sphere center in the frustum ?
  4713. * If not, apply the default culling strategy.
  4714. */
  4715. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4716. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4717. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4718. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4719. * 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.
  4720. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4721. * Test :
  4722. * Is the cullable object bounding sphere center in the frustum ?
  4723. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4724. */
  4725. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4726. /**
  4727. * No logging while loading
  4728. */
  4729. static readonly SCENELOADER_NO_LOGGING: number;
  4730. /**
  4731. * Minimal logging while loading
  4732. */
  4733. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4734. /**
  4735. * Summary logging while loading
  4736. */
  4737. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4738. /**
  4739. * Detailled logging while loading
  4740. */
  4741. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4742. }
  4743. }
  4744. declare module BABYLON {
  4745. /**
  4746. * This represents the required contract to create a new type of texture loader.
  4747. */
  4748. export interface IInternalTextureLoader {
  4749. /**
  4750. * Defines wether the loader supports cascade loading the different faces.
  4751. */
  4752. supportCascades: boolean;
  4753. /**
  4754. * This returns if the loader support the current file information.
  4755. * @param extension defines the file extension of the file being loaded
  4756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4757. * @param fallback defines the fallback internal texture if any
  4758. * @param isBase64 defines whether the texture is encoded as a base64
  4759. * @param isBuffer defines whether the texture data are stored as a buffer
  4760. * @returns true if the loader can load the specified file
  4761. */
  4762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4763. /**
  4764. * Transform the url before loading if required.
  4765. * @param rootUrl the url of the texture
  4766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4767. * @returns the transformed texture
  4768. */
  4769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4770. /**
  4771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4772. * @param rootUrl the url of the texture
  4773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4774. * @returns the fallback texture
  4775. */
  4776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4777. /**
  4778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4779. * @param data contains the texture data
  4780. * @param texture defines the BabylonJS internal texture
  4781. * @param createPolynomials will be true if polynomials have been requested
  4782. * @param onLoad defines the callback to trigger once the texture is ready
  4783. * @param onError defines the callback to trigger in case of error
  4784. */
  4785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4786. /**
  4787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4788. * @param data contains the texture data
  4789. * @param texture defines the BabylonJS internal texture
  4790. * @param callback defines the method to call once ready to upload
  4791. */
  4792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. /**
  4797. * Class used to store and describe the pipeline context associated with an effect
  4798. */
  4799. export interface IPipelineContext {
  4800. /**
  4801. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4802. */
  4803. isAsync: boolean;
  4804. /**
  4805. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4806. */
  4807. isReady: boolean;
  4808. /** @hidden */
  4809. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4810. }
  4811. }
  4812. declare module BABYLON {
  4813. /**
  4814. * Class used to store gfx data (like WebGLBuffer)
  4815. */
  4816. export class DataBuffer {
  4817. /**
  4818. * Gets or sets the number of objects referencing this buffer
  4819. */
  4820. references: number;
  4821. /** Gets or sets the size of the underlying buffer */
  4822. capacity: number;
  4823. /**
  4824. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4825. */
  4826. is32Bits: boolean;
  4827. /**
  4828. * Gets the underlying buffer
  4829. */
  4830. readonly underlyingResource: any;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. /** @hidden */
  4835. export interface IShaderProcessor {
  4836. attributeProcessor?: (attribute: string) => string;
  4837. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4838. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4839. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4840. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4841. lineProcessor?: (line: string, isFragment: boolean) => string;
  4842. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4843. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4844. }
  4845. }
  4846. declare module BABYLON {
  4847. /** @hidden */
  4848. export interface ProcessingOptions {
  4849. defines: string[];
  4850. indexParameters: any;
  4851. isFragment: boolean;
  4852. shouldUseHighPrecisionShader: boolean;
  4853. supportsUniformBuffers: boolean;
  4854. shadersRepository: string;
  4855. includesShadersStore: {
  4856. [key: string]: string;
  4857. };
  4858. processor?: IShaderProcessor;
  4859. version: string;
  4860. platformName: string;
  4861. lookForClosingBracketForUniformBuffer?: boolean;
  4862. }
  4863. }
  4864. declare module BABYLON {
  4865. /**
  4866. * Helper to manipulate strings
  4867. */
  4868. export class StringTools {
  4869. /**
  4870. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4871. * @param str Source string
  4872. * @param suffix Suffix to search for in the source string
  4873. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4874. */
  4875. static EndsWith(str: string, suffix: string): boolean;
  4876. /**
  4877. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4878. * @param str Source string
  4879. * @param suffix Suffix to search for in the source string
  4880. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4881. */
  4882. static StartsWith(str: string, suffix: string): boolean;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /** @hidden */
  4887. export class ShaderCodeNode {
  4888. line: string;
  4889. children: ShaderCodeNode[];
  4890. additionalDefineKey?: string;
  4891. additionalDefineValue?: string;
  4892. isValid(preprocessors: {
  4893. [key: string]: string;
  4894. }): boolean;
  4895. process(preprocessors: {
  4896. [key: string]: string;
  4897. }, options: ProcessingOptions): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /** @hidden */
  4902. export class ShaderCodeCursor {
  4903. private _lines;
  4904. lineIndex: number;
  4905. readonly currentLine: string;
  4906. readonly canRead: boolean;
  4907. lines: string[];
  4908. }
  4909. }
  4910. declare module BABYLON {
  4911. /** @hidden */
  4912. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4913. process(preprocessors: {
  4914. [key: string]: string;
  4915. }, options: ProcessingOptions): string;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class ShaderDefineExpression {
  4921. isTrue(preprocessors: {
  4922. [key: string]: string;
  4923. }): boolean;
  4924. }
  4925. }
  4926. declare module BABYLON {
  4927. /** @hidden */
  4928. export class ShaderCodeTestNode extends ShaderCodeNode {
  4929. testExpression: ShaderDefineExpression;
  4930. isValid(preprocessors: {
  4931. [key: string]: string;
  4932. }): boolean;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /** @hidden */
  4937. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4938. define: string;
  4939. not: boolean;
  4940. constructor(define: string, not?: boolean);
  4941. isTrue(preprocessors: {
  4942. [key: string]: string;
  4943. }): boolean;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /** @hidden */
  4948. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4949. leftOperand: ShaderDefineExpression;
  4950. rightOperand: ShaderDefineExpression;
  4951. isTrue(preprocessors: {
  4952. [key: string]: string;
  4953. }): boolean;
  4954. }
  4955. }
  4956. declare module BABYLON {
  4957. /** @hidden */
  4958. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4959. leftOperand: ShaderDefineExpression;
  4960. rightOperand: ShaderDefineExpression;
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module BABYLON {
  4967. /** @hidden */
  4968. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4969. define: string;
  4970. operand: string;
  4971. testValue: string;
  4972. constructor(define: string, operand: string, testValue: string);
  4973. isTrue(preprocessors: {
  4974. [key: string]: string;
  4975. }): boolean;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * @ignore
  4981. * Application error to support additional information when loading a file
  4982. */
  4983. export class LoadFileError extends Error {
  4984. /** defines the optional web request */
  4985. request?: WebRequest | undefined;
  4986. private static _setPrototypeOf;
  4987. /**
  4988. * Creates a new LoadFileError
  4989. * @param message defines the message of the error
  4990. * @param request defines the optional web request
  4991. */
  4992. constructor(message: string,
  4993. /** defines the optional web request */
  4994. request?: WebRequest | undefined);
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class used to enable access to offline support
  5000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5001. */
  5002. export interface IOfflineProvider {
  5003. /**
  5004. * Gets a boolean indicating if scene must be saved in the database
  5005. */
  5006. enableSceneOffline: boolean;
  5007. /**
  5008. * Gets a boolean indicating if textures must be saved in the database
  5009. */
  5010. enableTexturesOffline: boolean;
  5011. /**
  5012. * Open the offline support and make it available
  5013. * @param successCallback defines the callback to call on success
  5014. * @param errorCallback defines the callback to call on error
  5015. */
  5016. open(successCallback: () => void, errorCallback: () => void): void;
  5017. /**
  5018. * Loads an image from the offline support
  5019. * @param url defines the url to load from
  5020. * @param image defines the target DOM image
  5021. */
  5022. loadImage(url: string, image: HTMLImageElement): void;
  5023. /**
  5024. * Loads a file from offline support
  5025. * @param url defines the URL to load from
  5026. * @param sceneLoaded defines a callback to call on success
  5027. * @param progressCallBack defines a callback to call when progress changed
  5028. * @param errorCallback defines a callback to call on error
  5029. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5030. */
  5031. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5032. }
  5033. }
  5034. declare module BABYLON {
  5035. /**
  5036. * Class used to help managing file picking and drag'n'drop
  5037. * File Storage
  5038. */
  5039. export class FilesInputStore {
  5040. /**
  5041. * List of files ready to be loaded
  5042. */
  5043. static FilesToLoad: {
  5044. [key: string]: File;
  5045. };
  5046. }
  5047. }
  5048. declare module BABYLON {
  5049. /**
  5050. * Class used to define a retry strategy when error happens while loading assets
  5051. */
  5052. export class RetryStrategy {
  5053. /**
  5054. * Function used to defines an exponential back off strategy
  5055. * @param maxRetries defines the maximum number of retries (3 by default)
  5056. * @param baseInterval defines the interval between retries
  5057. * @returns the strategy function to use
  5058. */
  5059. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5060. }
  5061. }
  5062. declare module BABYLON {
  5063. /**
  5064. * @hidden
  5065. */
  5066. export class FileTools {
  5067. /**
  5068. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5069. */
  5070. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5071. /**
  5072. * Gets or sets the base URL to use to load assets
  5073. */
  5074. static BaseUrl: string;
  5075. /**
  5076. * Default behaviour for cors in the application.
  5077. * It can be a string if the expected behavior is identical in the entire app.
  5078. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5079. */
  5080. static CorsBehavior: string | ((url: string | string[]) => string);
  5081. /**
  5082. * Gets or sets a function used to pre-process url before using them to load assets
  5083. */
  5084. static PreprocessUrl: (url: string) => string;
  5085. /**
  5086. * Removes unwanted characters from an url
  5087. * @param url defines the url to clean
  5088. * @returns the cleaned url
  5089. */
  5090. private static _CleanUrl;
  5091. /**
  5092. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5093. * @param url define the url we are trying
  5094. * @param element define the dom element where to configure the cors policy
  5095. */
  5096. static SetCorsBehavior(url: string | string[], element: {
  5097. crossOrigin: string | null;
  5098. }): void;
  5099. /**
  5100. * Loads an image as an HTMLImageElement.
  5101. * @param input url string, ArrayBuffer, or Blob to load
  5102. * @param onLoad callback called when the image successfully loads
  5103. * @param onError callback called when the image fails to load
  5104. * @param offlineProvider offline provider for caching
  5105. * @returns the HTMLImageElement of the loaded image
  5106. */
  5107. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5108. /**
  5109. * Loads a file
  5110. * @param fileToLoad defines the file to load
  5111. * @param callback defines the callback to call when data is loaded
  5112. * @param progressCallBack defines the callback to call during loading process
  5113. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5114. * @returns a file request object
  5115. */
  5116. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5117. /**
  5118. * Loads a file
  5119. * @param url url string, ArrayBuffer, or Blob to load
  5120. * @param onSuccess callback called when the file successfully loads
  5121. * @param onProgress callback called while file is loading (if the server supports this mode)
  5122. * @param offlineProvider defines the offline provider for caching
  5123. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5124. * @param onError callback called when the file fails to load
  5125. * @returns a file request object
  5126. */
  5127. 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;
  5128. /**
  5129. * Checks if the loaded document was accessed via `file:`-Protocol.
  5130. * @returns boolean
  5131. */
  5132. static IsFileURL(): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /** @hidden */
  5137. export class ShaderProcessor {
  5138. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5139. private static _ProcessPrecision;
  5140. private static _ExtractOperation;
  5141. private static _BuildSubExpression;
  5142. private static _BuildExpression;
  5143. private static _MoveCursorWithinIf;
  5144. private static _MoveCursor;
  5145. private static _EvaluatePreProcessors;
  5146. private static _PreparePreProcessors;
  5147. private static _ProcessShaderConversion;
  5148. private static _ProcessIncludes;
  5149. }
  5150. }
  5151. declare module BABYLON {
  5152. /**
  5153. * Interface used to define common properties for effect fallbacks
  5154. */
  5155. export interface IEffectFallbacks {
  5156. /**
  5157. * Removes the defines that should be removed when falling back.
  5158. * @param currentDefines defines the current define statements for the shader.
  5159. * @param effect defines the current effect we try to compile
  5160. * @returns The resulting defines with defines of the current rank removed.
  5161. */
  5162. reduce(currentDefines: string, effect: Effect): string;
  5163. /**
  5164. * Removes the fallback from the bound mesh.
  5165. */
  5166. unBindMesh(): void;
  5167. /**
  5168. * Checks to see if more fallbacks are still availible.
  5169. */
  5170. hasMoreFallbacks: boolean;
  5171. }
  5172. }
  5173. declare module BABYLON {
  5174. /**
  5175. * Class used to evalaute queries containing `and` and `or` operators
  5176. */
  5177. export class AndOrNotEvaluator {
  5178. /**
  5179. * Evaluate a query
  5180. * @param query defines the query to evaluate
  5181. * @param evaluateCallback defines the callback used to filter result
  5182. * @returns true if the query matches
  5183. */
  5184. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5185. private static _HandleParenthesisContent;
  5186. private static _SimplifyNegation;
  5187. }
  5188. }
  5189. declare module BABYLON {
  5190. /**
  5191. * Class used to store custom tags
  5192. */
  5193. export class Tags {
  5194. /**
  5195. * Adds support for tags on the given object
  5196. * @param obj defines the object to use
  5197. */
  5198. static EnableFor(obj: any): void;
  5199. /**
  5200. * Removes tags support
  5201. * @param obj defines the object to use
  5202. */
  5203. static DisableFor(obj: any): void;
  5204. /**
  5205. * Gets a boolean indicating if the given object has tags
  5206. * @param obj defines the object to use
  5207. * @returns a boolean
  5208. */
  5209. static HasTags(obj: any): boolean;
  5210. /**
  5211. * Gets the tags available on a given object
  5212. * @param obj defines the object to use
  5213. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5214. * @returns the tags
  5215. */
  5216. static GetTags(obj: any, asString?: boolean): any;
  5217. /**
  5218. * Adds tags to an object
  5219. * @param obj defines the object to use
  5220. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5221. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5222. */
  5223. static AddTagsTo(obj: any, tagsString: string): void;
  5224. /**
  5225. * @hidden
  5226. */
  5227. static _AddTagTo(obj: any, tag: string): void;
  5228. /**
  5229. * Removes specific tags from a specific object
  5230. * @param obj defines the object to use
  5231. * @param tagsString defines the tags to remove
  5232. */
  5233. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5234. /**
  5235. * @hidden
  5236. */
  5237. static _RemoveTagFrom(obj: any, tag: string): void;
  5238. /**
  5239. * Defines if tags hosted on an object match a given query
  5240. * @param obj defines the object to use
  5241. * @param tagsQuery defines the tag query
  5242. * @returns a boolean
  5243. */
  5244. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Defines potential orientation for back face culling
  5250. */
  5251. export enum Orientation {
  5252. /**
  5253. * Clockwise
  5254. */
  5255. CW = 0,
  5256. /** Counter clockwise */
  5257. CCW = 1
  5258. }
  5259. /** Class used to represent a Bezier curve */
  5260. export class BezierCurve {
  5261. /**
  5262. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5263. * @param t defines the time
  5264. * @param x1 defines the left coordinate on X axis
  5265. * @param y1 defines the left coordinate on Y axis
  5266. * @param x2 defines the right coordinate on X axis
  5267. * @param y2 defines the right coordinate on Y axis
  5268. * @returns the interpolated value
  5269. */
  5270. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5271. }
  5272. /**
  5273. * Defines angle representation
  5274. */
  5275. export class Angle {
  5276. private _radians;
  5277. /**
  5278. * Creates an Angle object of "radians" radians (float).
  5279. * @param radians the angle in radians
  5280. */
  5281. constructor(radians: number);
  5282. /**
  5283. * Get value in degrees
  5284. * @returns the Angle value in degrees (float)
  5285. */
  5286. degrees(): number;
  5287. /**
  5288. * Get value in radians
  5289. * @returns the Angle value in radians (float)
  5290. */
  5291. radians(): number;
  5292. /**
  5293. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5294. * @param a defines first vector
  5295. * @param b defines second vector
  5296. * @returns a new Angle
  5297. */
  5298. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5299. /**
  5300. * Gets a new Angle object from the given float in radians
  5301. * @param radians defines the angle value in radians
  5302. * @returns a new Angle
  5303. */
  5304. static FromRadians(radians: number): Angle;
  5305. /**
  5306. * Gets a new Angle object from the given float in degrees
  5307. * @param degrees defines the angle value in degrees
  5308. * @returns a new Angle
  5309. */
  5310. static FromDegrees(degrees: number): Angle;
  5311. }
  5312. /**
  5313. * This represents an arc in a 2d space.
  5314. */
  5315. export class Arc2 {
  5316. /** Defines the start point of the arc */
  5317. startPoint: Vector2;
  5318. /** Defines the mid point of the arc */
  5319. midPoint: Vector2;
  5320. /** Defines the end point of the arc */
  5321. endPoint: Vector2;
  5322. /**
  5323. * Defines the center point of the arc.
  5324. */
  5325. centerPoint: Vector2;
  5326. /**
  5327. * Defines the radius of the arc.
  5328. */
  5329. radius: number;
  5330. /**
  5331. * Defines the angle of the arc (from mid point to end point).
  5332. */
  5333. angle: Angle;
  5334. /**
  5335. * Defines the start angle of the arc (from start point to middle point).
  5336. */
  5337. startAngle: Angle;
  5338. /**
  5339. * Defines the orientation of the arc (clock wise/counter clock wise).
  5340. */
  5341. orientation: Orientation;
  5342. /**
  5343. * Creates an Arc object from the three given points : start, middle and end.
  5344. * @param startPoint Defines the start point of the arc
  5345. * @param midPoint Defines the midlle point of the arc
  5346. * @param endPoint Defines the end point of the arc
  5347. */
  5348. constructor(
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2,
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2,
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2);
  5355. }
  5356. /**
  5357. * Represents a 2D path made up of multiple 2D points
  5358. */
  5359. export class Path2 {
  5360. private _points;
  5361. private _length;
  5362. /**
  5363. * If the path start and end point are the same
  5364. */
  5365. closed: boolean;
  5366. /**
  5367. * Creates a Path2 object from the starting 2D coordinates x and y.
  5368. * @param x the starting points x value
  5369. * @param y the starting points y value
  5370. */
  5371. constructor(x: number, y: number);
  5372. /**
  5373. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5374. * @param x the added points x value
  5375. * @param y the added points y value
  5376. * @returns the updated Path2.
  5377. */
  5378. addLineTo(x: number, y: number): Path2;
  5379. /**
  5380. * 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.
  5381. * @param midX middle point x value
  5382. * @param midY middle point y value
  5383. * @param endX end point x value
  5384. * @param endY end point y value
  5385. * @param numberOfSegments (default: 36)
  5386. * @returns the updated Path2.
  5387. */
  5388. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5389. /**
  5390. * Closes the Path2.
  5391. * @returns the Path2.
  5392. */
  5393. close(): Path2;
  5394. /**
  5395. * Gets the sum of the distance between each sequential point in the path
  5396. * @returns the Path2 total length (float).
  5397. */
  5398. length(): number;
  5399. /**
  5400. * Gets the points which construct the path
  5401. * @returns the Path2 internal array of points.
  5402. */
  5403. getPoints(): Vector2[];
  5404. /**
  5405. * Retreives the point at the distance aways from the starting point
  5406. * @param normalizedLengthPosition the length along the path to retreive the point from
  5407. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5408. */
  5409. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5410. /**
  5411. * Creates a new path starting from an x and y position
  5412. * @param x starting x value
  5413. * @param y starting y value
  5414. * @returns a new Path2 starting at the coordinates (x, y).
  5415. */
  5416. static StartingAt(x: number, y: number): Path2;
  5417. }
  5418. /**
  5419. * Represents a 3D path made up of multiple 3D points
  5420. */
  5421. export class Path3D {
  5422. /**
  5423. * an array of Vector3, the curve axis of the Path3D
  5424. */
  5425. path: Vector3[];
  5426. private _curve;
  5427. private _distances;
  5428. private _tangents;
  5429. private _normals;
  5430. private _binormals;
  5431. private _raw;
  5432. /**
  5433. * new Path3D(path, normal, raw)
  5434. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5435. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5436. * @param path an array of Vector3, the curve axis of the Path3D
  5437. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5438. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5439. */
  5440. constructor(
  5441. /**
  5442. * an array of Vector3, the curve axis of the Path3D
  5443. */
  5444. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5445. /**
  5446. * Returns the Path3D array of successive Vector3 designing its curve.
  5447. * @returns the Path3D array of successive Vector3 designing its curve.
  5448. */
  5449. getCurve(): Vector3[];
  5450. /**
  5451. * Returns an array populated with tangent vectors on each Path3D curve point.
  5452. * @returns an array populated with tangent vectors on each Path3D curve point.
  5453. */
  5454. getTangents(): Vector3[];
  5455. /**
  5456. * Returns an array populated with normal vectors on each Path3D curve point.
  5457. * @returns an array populated with normal vectors on each Path3D curve point.
  5458. */
  5459. getNormals(): Vector3[];
  5460. /**
  5461. * Returns an array populated with binormal vectors on each Path3D curve point.
  5462. * @returns an array populated with binormal vectors on each Path3D curve point.
  5463. */
  5464. getBinormals(): Vector3[];
  5465. /**
  5466. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5467. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. */
  5469. getDistances(): number[];
  5470. /**
  5471. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5472. * @param path path which all values are copied into the curves points
  5473. * @param firstNormal which should be projected onto the curve
  5474. * @returns the same object updated.
  5475. */
  5476. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5477. private _compute;
  5478. private _getFirstNonNullVector;
  5479. private _getLastNonNullVector;
  5480. private _normalVector;
  5481. }
  5482. /**
  5483. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5484. * A Curve3 is designed from a series of successive Vector3.
  5485. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5486. */
  5487. export class Curve3 {
  5488. private _points;
  5489. private _length;
  5490. /**
  5491. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5492. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5493. * @param v1 (Vector3) the control point
  5494. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5495. * @param nbPoints (integer) the wanted number of points in the curve
  5496. * @returns the created Curve3
  5497. */
  5498. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5499. /**
  5500. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5501. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5502. * @param v1 (Vector3) the first control point
  5503. * @param v2 (Vector3) the second control point
  5504. * @param v3 (Vector3) the end point of the Cubic Bezier
  5505. * @param nbPoints (integer) the wanted number of points in the curve
  5506. * @returns the created Curve3
  5507. */
  5508. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5509. /**
  5510. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5511. * @param p1 (Vector3) the origin point of the Hermite Spline
  5512. * @param t1 (Vector3) the tangent vector at the origin point
  5513. * @param p2 (Vector3) the end point of the Hermite Spline
  5514. * @param t2 (Vector3) the tangent vector at the end point
  5515. * @param nbPoints (integer) the wanted number of points in the curve
  5516. * @returns the created Curve3
  5517. */
  5518. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5519. /**
  5520. * Returns a Curve3 object along a CatmullRom Spline curve :
  5521. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5522. * @param nbPoints (integer) the wanted number of points between each curve control points
  5523. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5524. * @returns the created Curve3
  5525. */
  5526. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5527. /**
  5528. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5529. * A Curve3 is designed from a series of successive Vector3.
  5530. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5531. * @param points points which make up the curve
  5532. */
  5533. constructor(points: Vector3[]);
  5534. /**
  5535. * @returns the Curve3 stored array of successive Vector3
  5536. */
  5537. getPoints(): Vector3[];
  5538. /**
  5539. * @returns the computed length (float) of the curve.
  5540. */
  5541. length(): number;
  5542. /**
  5543. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5544. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5545. * curveA and curveB keep unchanged.
  5546. * @param curve the curve to continue from this curve
  5547. * @returns the newly constructed curve
  5548. */
  5549. continue(curve: DeepImmutable<Curve3>): Curve3;
  5550. private _computeLength;
  5551. }
  5552. }
  5553. declare module BABYLON {
  5554. /**
  5555. * This represents the main contract an easing function should follow.
  5556. * Easing functions are used throughout the animation system.
  5557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5558. */
  5559. export interface IEasingFunction {
  5560. /**
  5561. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5562. * of the easing function.
  5563. * The link below provides some of the most common examples of easing functions.
  5564. * @see https://easings.net/
  5565. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5566. * @returns the corresponding value on the curve defined by the easing function
  5567. */
  5568. ease(gradient: number): number;
  5569. }
  5570. /**
  5571. * Base class used for every default easing function.
  5572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5573. */
  5574. export class EasingFunction implements IEasingFunction {
  5575. /**
  5576. * Interpolation follows the mathematical formula associated with the easing function.
  5577. */
  5578. static readonly EASINGMODE_EASEIN: number;
  5579. /**
  5580. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5581. */
  5582. static readonly EASINGMODE_EASEOUT: number;
  5583. /**
  5584. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5585. */
  5586. static readonly EASINGMODE_EASEINOUT: number;
  5587. private _easingMode;
  5588. /**
  5589. * Sets the easing mode of the current function.
  5590. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5591. */
  5592. setEasingMode(easingMode: number): void;
  5593. /**
  5594. * Gets the current easing mode.
  5595. * @returns the easing mode
  5596. */
  5597. getEasingMode(): number;
  5598. /**
  5599. * @hidden
  5600. */
  5601. easeInCore(gradient: number): number;
  5602. /**
  5603. * Given an input gradient between 0 and 1, this returns the corresponding value
  5604. * of the easing function.
  5605. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5606. * @returns the corresponding value on the curve defined by the easing function
  5607. */
  5608. ease(gradient: number): number;
  5609. }
  5610. /**
  5611. * Easing function with a circle shape (see link below).
  5612. * @see https://easings.net/#easeInCirc
  5613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5614. */
  5615. export class CircleEase extends EasingFunction implements IEasingFunction {
  5616. /** @hidden */
  5617. easeInCore(gradient: number): number;
  5618. }
  5619. /**
  5620. * Easing function with a ease back shape (see link below).
  5621. * @see https://easings.net/#easeInBack
  5622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5623. */
  5624. export class BackEase extends EasingFunction implements IEasingFunction {
  5625. /** Defines the amplitude of the function */
  5626. amplitude: number;
  5627. /**
  5628. * Instantiates a back ease easing
  5629. * @see https://easings.net/#easeInBack
  5630. * @param amplitude Defines the amplitude of the function
  5631. */
  5632. constructor(
  5633. /** Defines the amplitude of the function */
  5634. amplitude?: number);
  5635. /** @hidden */
  5636. easeInCore(gradient: number): number;
  5637. }
  5638. /**
  5639. * Easing function with a bouncing shape (see link below).
  5640. * @see https://easings.net/#easeInBounce
  5641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5642. */
  5643. export class BounceEase extends EasingFunction implements IEasingFunction {
  5644. /** Defines the number of bounces */
  5645. bounces: number;
  5646. /** Defines the amplitude of the bounce */
  5647. bounciness: number;
  5648. /**
  5649. * Instantiates a bounce easing
  5650. * @see https://easings.net/#easeInBounce
  5651. * @param bounces Defines the number of bounces
  5652. * @param bounciness Defines the amplitude of the bounce
  5653. */
  5654. constructor(
  5655. /** Defines the number of bounces */
  5656. bounces?: number,
  5657. /** Defines the amplitude of the bounce */
  5658. bounciness?: number);
  5659. /** @hidden */
  5660. easeInCore(gradient: number): number;
  5661. }
  5662. /**
  5663. * Easing function with a power of 3 shape (see link below).
  5664. * @see https://easings.net/#easeInCubic
  5665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5666. */
  5667. export class CubicEase extends EasingFunction implements IEasingFunction {
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with an elastic shape (see link below).
  5673. * @see https://easings.net/#easeInElastic
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of oscillations*/
  5678. oscillations: number;
  5679. /** Defines the amplitude of the oscillations*/
  5680. springiness: number;
  5681. /**
  5682. * Instantiates an elastic easing function
  5683. * @see https://easings.net/#easeInElastic
  5684. * @param oscillations Defines the number of oscillations
  5685. * @param springiness Defines the amplitude of the oscillations
  5686. */
  5687. constructor(
  5688. /** Defines the number of oscillations*/
  5689. oscillations?: number,
  5690. /** Defines the amplitude of the oscillations*/
  5691. springiness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with an exponential shape (see link below).
  5697. * @see https://easings.net/#easeInExpo
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5701. /** Defines the exponent of the function */
  5702. exponent: number;
  5703. /**
  5704. * Instantiates an exponential easing function
  5705. * @see https://easings.net/#easeInExpo
  5706. * @param exponent Defines the exponent of the function
  5707. */
  5708. constructor(
  5709. /** Defines the exponent of the function */
  5710. exponent?: number);
  5711. /** @hidden */
  5712. easeInCore(gradient: number): number;
  5713. }
  5714. /**
  5715. * Easing function with a power shape (see link below).
  5716. * @see https://easings.net/#easeInQuad
  5717. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5718. */
  5719. export class PowerEase extends EasingFunction implements IEasingFunction {
  5720. /** Defines the power of the function */
  5721. power: number;
  5722. /**
  5723. * Instantiates an power base easing function
  5724. * @see https://easings.net/#easeInQuad
  5725. * @param power Defines the power of the function
  5726. */
  5727. constructor(
  5728. /** Defines the power of the function */
  5729. power?: number);
  5730. /** @hidden */
  5731. easeInCore(gradient: number): number;
  5732. }
  5733. /**
  5734. * Easing function with a power of 2 shape (see link below).
  5735. * @see https://easings.net/#easeInQuad
  5736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5737. */
  5738. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5739. /** @hidden */
  5740. easeInCore(gradient: number): number;
  5741. }
  5742. /**
  5743. * Easing function with a power of 4 shape (see link below).
  5744. * @see https://easings.net/#easeInQuart
  5745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5746. */
  5747. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5748. /** @hidden */
  5749. easeInCore(gradient: number): number;
  5750. }
  5751. /**
  5752. * Easing function with a power of 5 shape (see link below).
  5753. * @see https://easings.net/#easeInQuint
  5754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5755. */
  5756. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a sin shape (see link below).
  5762. * @see https://easings.net/#easeInSine
  5763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class SineEase extends EasingFunction implements IEasingFunction {
  5766. /** @hidden */
  5767. easeInCore(gradient: number): number;
  5768. }
  5769. /**
  5770. * Easing function with a bezier shape (see link below).
  5771. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5773. */
  5774. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5775. /** Defines the x component of the start tangent in the bezier curve */
  5776. x1: number;
  5777. /** Defines the y component of the start tangent in the bezier curve */
  5778. y1: number;
  5779. /** Defines the x component of the end tangent in the bezier curve */
  5780. x2: number;
  5781. /** Defines the y component of the end tangent in the bezier curve */
  5782. y2: number;
  5783. /**
  5784. * Instantiates a bezier function
  5785. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5786. * @param x1 Defines the x component of the start tangent in the bezier curve
  5787. * @param y1 Defines the y component of the start tangent in the bezier curve
  5788. * @param x2 Defines the x component of the end tangent in the bezier curve
  5789. * @param y2 Defines the y component of the end tangent in the bezier curve
  5790. */
  5791. constructor(
  5792. /** Defines the x component of the start tangent in the bezier curve */
  5793. x1?: number,
  5794. /** Defines the y component of the start tangent in the bezier curve */
  5795. y1?: number,
  5796. /** Defines the x component of the end tangent in the bezier curve */
  5797. x2?: number,
  5798. /** Defines the y component of the end tangent in the bezier curve */
  5799. y2?: number);
  5800. /** @hidden */
  5801. easeInCore(gradient: number): number;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. /**
  5806. * Defines an interface which represents an animation key frame
  5807. */
  5808. export interface IAnimationKey {
  5809. /**
  5810. * Frame of the key frame
  5811. */
  5812. frame: number;
  5813. /**
  5814. * Value at the specifies key frame
  5815. */
  5816. value: any;
  5817. /**
  5818. * The input tangent for the cubic hermite spline
  5819. */
  5820. inTangent?: any;
  5821. /**
  5822. * The output tangent for the cubic hermite spline
  5823. */
  5824. outTangent?: any;
  5825. /**
  5826. * The animation interpolation type
  5827. */
  5828. interpolation?: AnimationKeyInterpolation;
  5829. }
  5830. /**
  5831. * Enum for the animation key frame interpolation type
  5832. */
  5833. export enum AnimationKeyInterpolation {
  5834. /**
  5835. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5836. */
  5837. STEP = 1
  5838. }
  5839. }
  5840. declare module BABYLON {
  5841. /**
  5842. * Represents the range of an animation
  5843. */
  5844. export class AnimationRange {
  5845. /**The name of the animation range**/
  5846. name: string;
  5847. /**The starting frame of the animation */
  5848. from: number;
  5849. /**The ending frame of the animation*/
  5850. to: number;
  5851. /**
  5852. * Initializes the range of an animation
  5853. * @param name The name of the animation range
  5854. * @param from The starting frame of the animation
  5855. * @param to The ending frame of the animation
  5856. */
  5857. constructor(
  5858. /**The name of the animation range**/
  5859. name: string,
  5860. /**The starting frame of the animation */
  5861. from: number,
  5862. /**The ending frame of the animation*/
  5863. to: number);
  5864. /**
  5865. * Makes a copy of the animation range
  5866. * @returns A copy of the animation range
  5867. */
  5868. clone(): AnimationRange;
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Composed of a frame, and an action function
  5874. */
  5875. export class AnimationEvent {
  5876. /** The frame for which the event is triggered **/
  5877. frame: number;
  5878. /** The event to perform when triggered **/
  5879. action: (currentFrame: number) => void;
  5880. /** Specifies if the event should be triggered only once**/
  5881. onlyOnce?: boolean | undefined;
  5882. /**
  5883. * Specifies if the animation event is done
  5884. */
  5885. isDone: boolean;
  5886. /**
  5887. * Initializes the animation event
  5888. * @param frame The frame for which the event is triggered
  5889. * @param action The event to perform when triggered
  5890. * @param onlyOnce Specifies if the event should be triggered only once
  5891. */
  5892. constructor(
  5893. /** The frame for which the event is triggered **/
  5894. frame: number,
  5895. /** The event to perform when triggered **/
  5896. action: (currentFrame: number) => void,
  5897. /** Specifies if the event should be triggered only once**/
  5898. onlyOnce?: boolean | undefined);
  5899. /** @hidden */
  5900. _clone(): AnimationEvent;
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Interface used to define a behavior
  5906. */
  5907. export interface Behavior<T> {
  5908. /** gets or sets behavior's name */
  5909. name: string;
  5910. /**
  5911. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5912. */
  5913. init(): void;
  5914. /**
  5915. * Called when the behavior is attached to a target
  5916. * @param target defines the target where the behavior is attached to
  5917. */
  5918. attach(target: T): void;
  5919. /**
  5920. * Called when the behavior is detached from its target
  5921. */
  5922. detach(): void;
  5923. }
  5924. /**
  5925. * Interface implemented by classes supporting behaviors
  5926. */
  5927. export interface IBehaviorAware<T> {
  5928. /**
  5929. * Attach a behavior
  5930. * @param behavior defines the behavior to attach
  5931. * @returns the current host
  5932. */
  5933. addBehavior(behavior: Behavior<T>): T;
  5934. /**
  5935. * Remove a behavior from the current object
  5936. * @param behavior defines the behavior to detach
  5937. * @returns the current host
  5938. */
  5939. removeBehavior(behavior: Behavior<T>): T;
  5940. /**
  5941. * Gets a behavior using its name to search
  5942. * @param name defines the name to search
  5943. * @returns the behavior or null if not found
  5944. */
  5945. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Defines an array and its length.
  5951. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5952. */
  5953. export interface ISmartArrayLike<T> {
  5954. /**
  5955. * The data of the array.
  5956. */
  5957. data: Array<T>;
  5958. /**
  5959. * The active length of the array.
  5960. */
  5961. length: number;
  5962. }
  5963. /**
  5964. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5965. */
  5966. export class SmartArray<T> implements ISmartArrayLike<T> {
  5967. /**
  5968. * The full set of data from the array.
  5969. */
  5970. data: Array<T>;
  5971. /**
  5972. * The active length of the array.
  5973. */
  5974. length: number;
  5975. protected _id: number;
  5976. /**
  5977. * Instantiates a Smart Array.
  5978. * @param capacity defines the default capacity of the array.
  5979. */
  5980. constructor(capacity: number);
  5981. /**
  5982. * Pushes a value at the end of the active data.
  5983. * @param value defines the object to push in the array.
  5984. */
  5985. push(value: T): void;
  5986. /**
  5987. * Iterates over the active data and apply the lambda to them.
  5988. * @param func defines the action to apply on each value.
  5989. */
  5990. forEach(func: (content: T) => void): void;
  5991. /**
  5992. * Sorts the full sets of data.
  5993. * @param compareFn defines the comparison function to apply.
  5994. */
  5995. sort(compareFn: (a: T, b: T) => number): void;
  5996. /**
  5997. * Resets the active data to an empty array.
  5998. */
  5999. reset(): void;
  6000. /**
  6001. * Releases all the data from the array as well as the array.
  6002. */
  6003. dispose(): void;
  6004. /**
  6005. * Concats the active data with a given array.
  6006. * @param array defines the data to concatenate with.
  6007. */
  6008. concat(array: any): void;
  6009. /**
  6010. * Returns the position of a value in the active data.
  6011. * @param value defines the value to find the index for
  6012. * @returns the index if found in the active data otherwise -1
  6013. */
  6014. indexOf(value: T): number;
  6015. /**
  6016. * Returns whether an element is part of the active data.
  6017. * @param value defines the value to look for
  6018. * @returns true if found in the active data otherwise false
  6019. */
  6020. contains(value: T): boolean;
  6021. private static _GlobalId;
  6022. }
  6023. /**
  6024. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6025. * The data in this array can only be present once
  6026. */
  6027. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6028. private _duplicateId;
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6032. * @param value defines the object to push in the array.
  6033. */
  6034. push(value: T): void;
  6035. /**
  6036. * Pushes a value at the end of the active data.
  6037. * If the data is already present, it won t be added again
  6038. * @param value defines the object to push in the array.
  6039. * @returns true if added false if it was already present
  6040. */
  6041. pushNoDuplicate(value: T): boolean;
  6042. /**
  6043. * Resets the active data to an empty array.
  6044. */
  6045. reset(): void;
  6046. /**
  6047. * Concats the active data with a given array.
  6048. * This ensures no dupplicate will be present in the result.
  6049. * @param array defines the data to concatenate with.
  6050. */
  6051. concatWithNoDuplicate(array: any): void;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. /**
  6056. * @ignore
  6057. * This is a list of all the different input types that are available in the application.
  6058. * Fo instance: ArcRotateCameraGamepadInput...
  6059. */
  6060. export var CameraInputTypes: {};
  6061. /**
  6062. * This is the contract to implement in order to create a new input class.
  6063. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6064. */
  6065. export interface ICameraInput<TCamera extends Camera> {
  6066. /**
  6067. * Defines the camera the input is attached to.
  6068. */
  6069. camera: Nullable<TCamera>;
  6070. /**
  6071. * Gets the class name of the current intput.
  6072. * @returns the class name
  6073. */
  6074. getClassName(): string;
  6075. /**
  6076. * Get the friendly name associated with the input class.
  6077. * @returns the input friendly name
  6078. */
  6079. getSimpleName(): string;
  6080. /**
  6081. * Attach the input controls to a specific dom element to get the input from.
  6082. * @param element Defines the element the controls should be listened from
  6083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6084. */
  6085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6086. /**
  6087. * Detach the current controls from the specified dom element.
  6088. * @param element Defines the element to stop listening the inputs from
  6089. */
  6090. detachControl(element: Nullable<HTMLElement>): void;
  6091. /**
  6092. * Update the current camera state depending on the inputs that have been used this frame.
  6093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6094. */
  6095. checkInputs?: () => void;
  6096. }
  6097. /**
  6098. * Represents a map of input types to input instance or input index to input instance.
  6099. */
  6100. export interface CameraInputsMap<TCamera extends Camera> {
  6101. /**
  6102. * Accessor to the input by input type.
  6103. */
  6104. [name: string]: ICameraInput<TCamera>;
  6105. /**
  6106. * Accessor to the input by input index.
  6107. */
  6108. [idx: number]: ICameraInput<TCamera>;
  6109. }
  6110. /**
  6111. * This represents the input manager used within a camera.
  6112. * It helps dealing with all the different kind of input attached to a camera.
  6113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6114. */
  6115. export class CameraInputsManager<TCamera extends Camera> {
  6116. /**
  6117. * Defines the list of inputs attahed to the camera.
  6118. */
  6119. attached: CameraInputsMap<TCamera>;
  6120. /**
  6121. * Defines the dom element the camera is collecting inputs from.
  6122. * This is null if the controls have not been attached.
  6123. */
  6124. attachedElement: Nullable<HTMLElement>;
  6125. /**
  6126. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6127. */
  6128. noPreventDefault: boolean;
  6129. /**
  6130. * Defined the camera the input manager belongs to.
  6131. */
  6132. camera: TCamera;
  6133. /**
  6134. * Update the current camera state depending on the inputs that have been used this frame.
  6135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6136. */
  6137. checkInputs: () => void;
  6138. /**
  6139. * Instantiate a new Camera Input Manager.
  6140. * @param camera Defines the camera the input manager blongs to
  6141. */
  6142. constructor(camera: TCamera);
  6143. /**
  6144. * Add an input method to a camera
  6145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6146. * @param input camera input method
  6147. */
  6148. add(input: ICameraInput<TCamera>): void;
  6149. /**
  6150. * Remove a specific input method from a camera
  6151. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6152. * @param inputToRemove camera input method
  6153. */
  6154. remove(inputToRemove: ICameraInput<TCamera>): void;
  6155. /**
  6156. * Remove a specific input type from a camera
  6157. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6158. * @param inputType the type of the input to remove
  6159. */
  6160. removeByType(inputType: string): void;
  6161. private _addCheckInputs;
  6162. /**
  6163. * Attach the input controls to the currently attached dom element to listen the events from.
  6164. * @param input Defines the input to attach
  6165. */
  6166. attachInput(input: ICameraInput<TCamera>): void;
  6167. /**
  6168. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6169. * @param element Defines the dom element to collect the events from
  6170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6173. /**
  6174. * Detach the current manager inputs controls from a specific dom element.
  6175. * @param element Defines the dom element to collect the events from
  6176. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6177. */
  6178. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6179. /**
  6180. * Rebuild the dynamic inputCheck function from the current list of
  6181. * defined inputs in the manager.
  6182. */
  6183. rebuildInputCheck(): void;
  6184. /**
  6185. * Remove all attached input methods from a camera
  6186. */
  6187. clear(): void;
  6188. /**
  6189. * Serialize the current input manager attached to a camera.
  6190. * This ensures than once parsed,
  6191. * the input associated to the camera will be identical to the current ones
  6192. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6193. */
  6194. serialize(serializedCamera: any): void;
  6195. /**
  6196. * Parses an input manager serialized JSON to restore the previous list of inputs
  6197. * and states associated to a camera.
  6198. * @param parsedCamera Defines the JSON to parse
  6199. */
  6200. parse(parsedCamera: any): void;
  6201. }
  6202. }
  6203. declare module BABYLON {
  6204. /**
  6205. * Class used to store data that will be store in GPU memory
  6206. */
  6207. export class Buffer {
  6208. private _engine;
  6209. private _buffer;
  6210. /** @hidden */
  6211. _data: Nullable<DataArray>;
  6212. private _updatable;
  6213. private _instanced;
  6214. /**
  6215. * Gets the byte stride.
  6216. */
  6217. readonly byteStride: number;
  6218. /**
  6219. * Constructor
  6220. * @param engine the engine
  6221. * @param data the data to use for this buffer
  6222. * @param updatable whether the data is updatable
  6223. * @param stride the stride (optional)
  6224. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6225. * @param instanced whether the buffer is instanced (optional)
  6226. * @param useBytes set to true if the stride in in bytes (optional)
  6227. */
  6228. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6229. /**
  6230. * Create a new VertexBuffer based on the current buffer
  6231. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6232. * @param offset defines offset in the buffer (0 by default)
  6233. * @param size defines the size in floats of attributes (position is 3 for instance)
  6234. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6235. * @param instanced defines if the vertex buffer contains indexed data
  6236. * @param useBytes defines if the offset and stride are in bytes
  6237. * @returns the new vertex buffer
  6238. */
  6239. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6240. /**
  6241. * Gets a boolean indicating if the Buffer is updatable?
  6242. * @returns true if the buffer is updatable
  6243. */
  6244. isUpdatable(): boolean;
  6245. /**
  6246. * Gets current buffer's data
  6247. * @returns a DataArray or null
  6248. */
  6249. getData(): Nullable<DataArray>;
  6250. /**
  6251. * Gets underlying native buffer
  6252. * @returns underlying native buffer
  6253. */
  6254. getBuffer(): Nullable<DataBuffer>;
  6255. /**
  6256. * Gets the stride in float32 units (i.e. byte stride / 4).
  6257. * May not be an integer if the byte stride is not divisible by 4.
  6258. * DEPRECATED. Use byteStride instead.
  6259. * @returns the stride in float32 units
  6260. */
  6261. getStrideSize(): number;
  6262. /**
  6263. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6264. * @param data defines the data to store
  6265. */
  6266. create(data?: Nullable<DataArray>): void;
  6267. /** @hidden */
  6268. _rebuild(): void;
  6269. /**
  6270. * Update current buffer data
  6271. * @param data defines the data to store
  6272. */
  6273. update(data: DataArray): void;
  6274. /**
  6275. * Updates the data directly.
  6276. * @param data the new data
  6277. * @param offset the new offset
  6278. * @param vertexCount the vertex count (optional)
  6279. * @param useBytes set to true if the offset is in bytes
  6280. */
  6281. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6282. /**
  6283. * Release all resources
  6284. */
  6285. dispose(): void;
  6286. }
  6287. /**
  6288. * Specialized buffer used to store vertex data
  6289. */
  6290. export class VertexBuffer {
  6291. /** @hidden */
  6292. _buffer: Buffer;
  6293. private _kind;
  6294. private _size;
  6295. private _ownsBuffer;
  6296. private _instanced;
  6297. private _instanceDivisor;
  6298. /**
  6299. * The byte type.
  6300. */
  6301. static readonly BYTE: number;
  6302. /**
  6303. * The unsigned byte type.
  6304. */
  6305. static readonly UNSIGNED_BYTE: number;
  6306. /**
  6307. * The short type.
  6308. */
  6309. static readonly SHORT: number;
  6310. /**
  6311. * The unsigned short type.
  6312. */
  6313. static readonly UNSIGNED_SHORT: number;
  6314. /**
  6315. * The integer type.
  6316. */
  6317. static readonly INT: number;
  6318. /**
  6319. * The unsigned integer type.
  6320. */
  6321. static readonly UNSIGNED_INT: number;
  6322. /**
  6323. * The float type.
  6324. */
  6325. static readonly FLOAT: number;
  6326. /**
  6327. * Gets or sets the instance divisor when in instanced mode
  6328. */
  6329. instanceDivisor: number;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Gets the byte offset.
  6336. */
  6337. readonly byteOffset: number;
  6338. /**
  6339. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6340. */
  6341. readonly normalized: boolean;
  6342. /**
  6343. * Gets the data type of each component in the array.
  6344. */
  6345. readonly type: number;
  6346. /**
  6347. * Constructor
  6348. * @param engine the engine
  6349. * @param data the data to use for this vertex buffer
  6350. * @param kind the vertex buffer kind
  6351. * @param updatable whether the data is updatable
  6352. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6353. * @param stride the stride (optional)
  6354. * @param instanced whether the buffer is instanced (optional)
  6355. * @param offset the offset of the data (optional)
  6356. * @param size the number of components (optional)
  6357. * @param type the type of the component (optional)
  6358. * @param normalized whether the data contains normalized data (optional)
  6359. * @param useBytes set to true if stride and offset are in bytes (optional)
  6360. */
  6361. 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);
  6362. /** @hidden */
  6363. _rebuild(): void;
  6364. /**
  6365. * Returns the kind of the VertexBuffer (string)
  6366. * @returns a string
  6367. */
  6368. getKind(): string;
  6369. /**
  6370. * Gets a boolean indicating if the VertexBuffer is updatable?
  6371. * @returns true if the buffer is updatable
  6372. */
  6373. isUpdatable(): boolean;
  6374. /**
  6375. * Gets current buffer's data
  6376. * @returns a DataArray or null
  6377. */
  6378. getData(): Nullable<DataArray>;
  6379. /**
  6380. * Gets underlying native buffer
  6381. * @returns underlying native buffer
  6382. */
  6383. getBuffer(): Nullable<DataBuffer>;
  6384. /**
  6385. * Gets the stride in float32 units (i.e. byte stride / 4).
  6386. * May not be an integer if the byte stride is not divisible by 4.
  6387. * DEPRECATED. Use byteStride instead.
  6388. * @returns the stride in float32 units
  6389. */
  6390. getStrideSize(): number;
  6391. /**
  6392. * Returns the offset as a multiple of the type byte length.
  6393. * DEPRECATED. Use byteOffset instead.
  6394. * @returns the offset in bytes
  6395. */
  6396. getOffset(): number;
  6397. /**
  6398. * Returns the number of components per vertex attribute (integer)
  6399. * @returns the size in float
  6400. */
  6401. getSize(): number;
  6402. /**
  6403. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6404. * @returns true if this buffer is instanced
  6405. */
  6406. getIsInstanced(): boolean;
  6407. /**
  6408. * Returns the instancing divisor, zero for non-instanced (integer).
  6409. * @returns a number
  6410. */
  6411. getInstanceDivisor(): number;
  6412. /**
  6413. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6414. * @param data defines the data to store
  6415. */
  6416. create(data?: DataArray): void;
  6417. /**
  6418. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6419. * This function will create a new buffer if the current one is not updatable
  6420. * @param data defines the data to store
  6421. */
  6422. update(data: DataArray): void;
  6423. /**
  6424. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6425. * Returns the directly updated WebGLBuffer.
  6426. * @param data the new data
  6427. * @param offset the new offset
  6428. * @param useBytes set to true if the offset is in bytes
  6429. */
  6430. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6431. /**
  6432. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6433. */
  6434. dispose(): void;
  6435. /**
  6436. * Enumerates each value of this vertex buffer as numbers.
  6437. * @param count the number of values to enumerate
  6438. * @param callback the callback function called for each value
  6439. */
  6440. forEach(count: number, callback: (value: number, index: number) => void): void;
  6441. /**
  6442. * Positions
  6443. */
  6444. static readonly PositionKind: string;
  6445. /**
  6446. * Normals
  6447. */
  6448. static readonly NormalKind: string;
  6449. /**
  6450. * Tangents
  6451. */
  6452. static readonly TangentKind: string;
  6453. /**
  6454. * Texture coordinates
  6455. */
  6456. static readonly UVKind: string;
  6457. /**
  6458. * Texture coordinates 2
  6459. */
  6460. static readonly UV2Kind: string;
  6461. /**
  6462. * Texture coordinates 3
  6463. */
  6464. static readonly UV3Kind: string;
  6465. /**
  6466. * Texture coordinates 4
  6467. */
  6468. static readonly UV4Kind: string;
  6469. /**
  6470. * Texture coordinates 5
  6471. */
  6472. static readonly UV5Kind: string;
  6473. /**
  6474. * Texture coordinates 6
  6475. */
  6476. static readonly UV6Kind: string;
  6477. /**
  6478. * Colors
  6479. */
  6480. static readonly ColorKind: string;
  6481. /**
  6482. * Matrix indices (for bones)
  6483. */
  6484. static readonly MatricesIndicesKind: string;
  6485. /**
  6486. * Matrix weights (for bones)
  6487. */
  6488. static readonly MatricesWeightsKind: string;
  6489. /**
  6490. * Additional matrix indices (for bones)
  6491. */
  6492. static readonly MatricesIndicesExtraKind: string;
  6493. /**
  6494. * Additional matrix weights (for bones)
  6495. */
  6496. static readonly MatricesWeightsExtraKind: string;
  6497. /**
  6498. * Deduces the stride given a kind.
  6499. * @param kind The kind string to deduce
  6500. * @returns The deduced stride
  6501. */
  6502. static DeduceStride(kind: string): number;
  6503. /**
  6504. * Gets the byte length of the given type.
  6505. * @param type the type
  6506. * @returns the number of bytes
  6507. */
  6508. static GetTypeByteLength(type: number): number;
  6509. /**
  6510. * Enumerates each value of the given parameters as numbers.
  6511. * @param data the data to enumerate
  6512. * @param byteOffset the byte offset of the data
  6513. * @param byteStride the byte stride of the data
  6514. * @param componentCount the number of components per element
  6515. * @param componentType the type of the component
  6516. * @param count the number of values to enumerate
  6517. * @param normalized whether the data is normalized
  6518. * @param callback the callback function called for each value
  6519. */
  6520. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6521. private static _GetFloatValue;
  6522. }
  6523. }
  6524. declare module BABYLON {
  6525. /**
  6526. * @hidden
  6527. */
  6528. export class IntersectionInfo {
  6529. bu: Nullable<number>;
  6530. bv: Nullable<number>;
  6531. distance: number;
  6532. faceId: number;
  6533. subMeshId: number;
  6534. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * Represens a plane by the equation ax + by + cz + d = 0
  6540. */
  6541. export class Plane {
  6542. private static _TmpMatrix;
  6543. /**
  6544. * Normal of the plane (a,b,c)
  6545. */
  6546. normal: Vector3;
  6547. /**
  6548. * d component of the plane
  6549. */
  6550. d: number;
  6551. /**
  6552. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6553. * @param a a component of the plane
  6554. * @param b b component of the plane
  6555. * @param c c component of the plane
  6556. * @param d d component of the plane
  6557. */
  6558. constructor(a: number, b: number, c: number, d: number);
  6559. /**
  6560. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6561. */
  6562. asArray(): number[];
  6563. /**
  6564. * @returns a new plane copied from the current Plane.
  6565. */
  6566. clone(): Plane;
  6567. /**
  6568. * @returns the string "Plane".
  6569. */
  6570. getClassName(): string;
  6571. /**
  6572. * @returns the Plane hash code.
  6573. */
  6574. getHashCode(): number;
  6575. /**
  6576. * Normalize the current Plane in place.
  6577. * @returns the updated Plane.
  6578. */
  6579. normalize(): Plane;
  6580. /**
  6581. * Applies a transformation the plane and returns the result
  6582. * @param transformation the transformation matrix to be applied to the plane
  6583. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6584. */
  6585. transform(transformation: DeepImmutable<Matrix>): Plane;
  6586. /**
  6587. * Calcualtte the dot product between the point and the plane normal
  6588. * @param point point to calculate the dot product with
  6589. * @returns the dot product (float) of the point coordinates and the plane normal.
  6590. */
  6591. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6592. /**
  6593. * Updates the current Plane from the plane defined by the three given points.
  6594. * @param point1 one of the points used to contruct the plane
  6595. * @param point2 one of the points used to contruct the plane
  6596. * @param point3 one of the points used to contruct the plane
  6597. * @returns the updated Plane.
  6598. */
  6599. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6600. /**
  6601. * Checks if the plane is facing a given direction
  6602. * @param direction the direction to check if the plane is facing
  6603. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6604. * @returns True is the vector "direction" is the same side than the plane normal.
  6605. */
  6606. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6607. /**
  6608. * Calculates the distance to a point
  6609. * @param point point to calculate distance to
  6610. * @returns the signed distance (float) from the given point to the Plane.
  6611. */
  6612. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6613. /**
  6614. * Creates a plane from an array
  6615. * @param array the array to create a plane from
  6616. * @returns a new Plane from the given array.
  6617. */
  6618. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6619. /**
  6620. * Creates a plane from three points
  6621. * @param point1 point used to create the plane
  6622. * @param point2 point used to create the plane
  6623. * @param point3 point used to create the plane
  6624. * @returns a new Plane defined by the three given points.
  6625. */
  6626. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6627. /**
  6628. * Creates a plane from an origin point and a normal
  6629. * @param origin origin of the plane to be constructed
  6630. * @param normal normal of the plane to be constructed
  6631. * @returns a new Plane the normal vector to this plane at the given origin point.
  6632. * Note : the vector "normal" is updated because normalized.
  6633. */
  6634. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6635. /**
  6636. * Calculates the distance from a plane and a point
  6637. * @param origin origin of the plane to be constructed
  6638. * @param normal normal of the plane to be constructed
  6639. * @param point point to calculate distance to
  6640. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6641. */
  6642. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6643. }
  6644. }
  6645. declare module BABYLON {
  6646. /**
  6647. * Class used to store bounding sphere information
  6648. */
  6649. export class BoundingSphere {
  6650. /**
  6651. * Gets the center of the bounding sphere in local space
  6652. */
  6653. readonly center: Vector3;
  6654. /**
  6655. * Radius of the bounding sphere in local space
  6656. */
  6657. radius: number;
  6658. /**
  6659. * Gets the center of the bounding sphere in world space
  6660. */
  6661. readonly centerWorld: Vector3;
  6662. /**
  6663. * Radius of the bounding sphere in world space
  6664. */
  6665. radiusWorld: number;
  6666. /**
  6667. * Gets the minimum vector in local space
  6668. */
  6669. readonly minimum: Vector3;
  6670. /**
  6671. * Gets the maximum vector in local space
  6672. */
  6673. readonly maximum: Vector3;
  6674. private _worldMatrix;
  6675. private static readonly TmpVector3;
  6676. /**
  6677. * Creates a new bounding sphere
  6678. * @param min defines the minimum vector (in local space)
  6679. * @param max defines the maximum vector (in local space)
  6680. * @param worldMatrix defines the new world matrix
  6681. */
  6682. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6683. /**
  6684. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6685. * @param min defines the new minimum vector (in local space)
  6686. * @param max defines the new maximum vector (in local space)
  6687. * @param worldMatrix defines the new world matrix
  6688. */
  6689. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6690. /**
  6691. * Scale the current bounding sphere by applying a scale factor
  6692. * @param factor defines the scale factor to apply
  6693. * @returns the current bounding box
  6694. */
  6695. scale(factor: number): BoundingSphere;
  6696. /**
  6697. * Gets the world matrix of the bounding box
  6698. * @returns a matrix
  6699. */
  6700. getWorldMatrix(): DeepImmutable<Matrix>;
  6701. /** @hidden */
  6702. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6703. /**
  6704. * Tests if the bounding sphere is intersecting the frustum planes
  6705. * @param frustumPlanes defines the frustum planes to test
  6706. * @returns true if there is an intersection
  6707. */
  6708. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6709. /**
  6710. * Tests if the bounding sphere center is in between the frustum planes.
  6711. * Used for optimistic fast inclusion.
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if the sphere center is in between the frustum planes
  6714. */
  6715. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding sphere
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding sphere
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Checks if two sphere intersct
  6724. * @param sphere0 sphere 0
  6725. * @param sphere1 sphere 1
  6726. * @returns true if the speres intersect
  6727. */
  6728. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6729. }
  6730. }
  6731. declare module BABYLON {
  6732. /**
  6733. * Class used to store bounding box information
  6734. */
  6735. export class BoundingBox implements ICullable {
  6736. /**
  6737. * Gets the 8 vectors representing the bounding box in local space
  6738. */
  6739. readonly vectors: Vector3[];
  6740. /**
  6741. * Gets the center of the bounding box in local space
  6742. */
  6743. readonly center: Vector3;
  6744. /**
  6745. * Gets the center of the bounding box in world space
  6746. */
  6747. readonly centerWorld: Vector3;
  6748. /**
  6749. * Gets the extend size in local space
  6750. */
  6751. readonly extendSize: Vector3;
  6752. /**
  6753. * Gets the extend size in world space
  6754. */
  6755. readonly extendSizeWorld: Vector3;
  6756. /**
  6757. * Gets the OBB (object bounding box) directions
  6758. */
  6759. readonly directions: Vector3[];
  6760. /**
  6761. * Gets the 8 vectors representing the bounding box in world space
  6762. */
  6763. readonly vectorsWorld: Vector3[];
  6764. /**
  6765. * Gets the minimum vector in world space
  6766. */
  6767. readonly minimumWorld: Vector3;
  6768. /**
  6769. * Gets the maximum vector in world space
  6770. */
  6771. readonly maximumWorld: Vector3;
  6772. /**
  6773. * Gets the minimum vector in local space
  6774. */
  6775. readonly minimum: Vector3;
  6776. /**
  6777. * Gets the maximum vector in local space
  6778. */
  6779. readonly maximum: Vector3;
  6780. private _worldMatrix;
  6781. private static readonly TmpVector3;
  6782. /**
  6783. * @hidden
  6784. */
  6785. _tag: number;
  6786. /**
  6787. * Creates a new bounding box
  6788. * @param min defines the minimum vector (in local space)
  6789. * @param max defines the maximum vector (in local space)
  6790. * @param worldMatrix defines the new world matrix
  6791. */
  6792. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6793. /**
  6794. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6795. * @param min defines the new minimum vector (in local space)
  6796. * @param max defines the new maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6800. /**
  6801. * Scale the current bounding box by applying a scale factor
  6802. * @param factor defines the scale factor to apply
  6803. * @returns the current bounding box
  6804. */
  6805. scale(factor: number): BoundingBox;
  6806. /**
  6807. * Gets the world matrix of the bounding box
  6808. * @returns a matrix
  6809. */
  6810. getWorldMatrix(): DeepImmutable<Matrix>;
  6811. /** @hidden */
  6812. _update(world: DeepImmutable<Matrix>): void;
  6813. /**
  6814. * Tests if the bounding box is intersecting the frustum planes
  6815. * @param frustumPlanes defines the frustum planes to test
  6816. * @returns true if there is an intersection
  6817. */
  6818. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6819. /**
  6820. * Tests if the bounding box is entirely inside the frustum planes
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @returns true if there is an inclusion
  6823. */
  6824. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a point is inside the bounding box
  6827. * @param point defines the point to test
  6828. * @returns true if the point is inside the bounding box
  6829. */
  6830. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6831. /**
  6832. * Tests if the bounding box intersects with a bounding sphere
  6833. * @param sphere defines the sphere to test
  6834. * @returns true if there is an intersection
  6835. */
  6836. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6837. /**
  6838. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6839. * @param min defines the min vector to use
  6840. * @param max defines the max vector to use
  6841. * @returns true if there is an intersection
  6842. */
  6843. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6844. /**
  6845. * Tests if two bounding boxes are intersections
  6846. * @param box0 defines the first box to test
  6847. * @param box1 defines the second box to test
  6848. * @returns true if there is an intersection
  6849. */
  6850. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6851. /**
  6852. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6853. * @param minPoint defines the minimum vector of the bounding box
  6854. * @param maxPoint defines the maximum vector of the bounding box
  6855. * @param sphereCenter defines the sphere center
  6856. * @param sphereRadius defines the sphere radius
  6857. * @returns true if there is an intersection
  6858. */
  6859. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6860. /**
  6861. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6862. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6863. * @param frustumPlanes defines the frustum planes to test
  6864. * @return true if there is an inclusion
  6865. */
  6866. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6867. /**
  6868. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6869. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @return true if there is an intersection
  6872. */
  6873. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. }
  6875. }
  6876. declare module BABYLON {
  6877. /** @hidden */
  6878. export class Collider {
  6879. /** Define if a collision was found */
  6880. collisionFound: boolean;
  6881. /**
  6882. * Define last intersection point in local space
  6883. */
  6884. intersectionPoint: Vector3;
  6885. /**
  6886. * Define last collided mesh
  6887. */
  6888. collidedMesh: Nullable<AbstractMesh>;
  6889. private _collisionPoint;
  6890. private _planeIntersectionPoint;
  6891. private _tempVector;
  6892. private _tempVector2;
  6893. private _tempVector3;
  6894. private _tempVector4;
  6895. private _edge;
  6896. private _baseToVertex;
  6897. private _destinationPoint;
  6898. private _slidePlaneNormal;
  6899. private _displacementVector;
  6900. /** @hidden */
  6901. _radius: Vector3;
  6902. /** @hidden */
  6903. _retry: number;
  6904. private _velocity;
  6905. private _basePoint;
  6906. private _epsilon;
  6907. /** @hidden */
  6908. _velocityWorldLength: number;
  6909. /** @hidden */
  6910. _basePointWorld: Vector3;
  6911. private _velocityWorld;
  6912. private _normalizedVelocity;
  6913. /** @hidden */
  6914. _initialVelocity: Vector3;
  6915. /** @hidden */
  6916. _initialPosition: Vector3;
  6917. private _nearestDistance;
  6918. private _collisionMask;
  6919. collisionMask: number;
  6920. /**
  6921. * Gets the plane normal used to compute the sliding response (in local space)
  6922. */
  6923. readonly slidePlaneNormal: Vector3;
  6924. /** @hidden */
  6925. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6926. /** @hidden */
  6927. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6928. /** @hidden */
  6929. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6930. /** @hidden */
  6931. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6932. /** @hidden */
  6933. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6934. /** @hidden */
  6935. _getResponse(pos: Vector3, vel: Vector3): void;
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Interface for cullable objects
  6941. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6942. */
  6943. export interface ICullable {
  6944. /**
  6945. * Checks if the object or part of the object is in the frustum
  6946. * @param frustumPlanes Camera near/planes
  6947. * @returns true if the object is in frustum otherwise false
  6948. */
  6949. isInFrustum(frustumPlanes: Plane[]): boolean;
  6950. /**
  6951. * Checks if a cullable object (mesh...) is in the camera frustum
  6952. * Unlike isInFrustum this cheks the full bounding box
  6953. * @param frustumPlanes Camera near/planes
  6954. * @returns true if the object is in frustum otherwise false
  6955. */
  6956. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6957. }
  6958. /**
  6959. * Info for a bounding data of a mesh
  6960. */
  6961. export class BoundingInfo implements ICullable {
  6962. /**
  6963. * Bounding box for the mesh
  6964. */
  6965. readonly boundingBox: BoundingBox;
  6966. /**
  6967. * Bounding sphere for the mesh
  6968. */
  6969. readonly boundingSphere: BoundingSphere;
  6970. private _isLocked;
  6971. private static readonly TmpVector3;
  6972. /**
  6973. * Constructs bounding info
  6974. * @param minimum min vector of the bounding box/sphere
  6975. * @param maximum max vector of the bounding box/sphere
  6976. * @param worldMatrix defines the new world matrix
  6977. */
  6978. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6979. /**
  6980. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6981. * @param min defines the new minimum vector (in local space)
  6982. * @param max defines the new maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6986. /**
  6987. * min vector of the bounding box/sphere
  6988. */
  6989. readonly minimum: Vector3;
  6990. /**
  6991. * max vector of the bounding box/sphere
  6992. */
  6993. readonly maximum: Vector3;
  6994. /**
  6995. * If the info is locked and won't be updated to avoid perf overhead
  6996. */
  6997. isLocked: boolean;
  6998. /**
  6999. * Updates the bounding sphere and box
  7000. * @param world world matrix to be used to update
  7001. */
  7002. update(world: DeepImmutable<Matrix>): void;
  7003. /**
  7004. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7005. * @param center New center of the bounding info
  7006. * @param extend New extend of the bounding info
  7007. * @returns the current bounding info
  7008. */
  7009. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7010. /**
  7011. * Scale the current bounding info by applying a scale factor
  7012. * @param factor defines the scale factor to apply
  7013. * @returns the current bounding info
  7014. */
  7015. scale(factor: number): BoundingInfo;
  7016. /**
  7017. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7018. * @param frustumPlanes defines the frustum to test
  7019. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7020. * @returns true if the bounding info is in the frustum planes
  7021. */
  7022. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7023. /**
  7024. * Gets the world distance between the min and max points of the bounding box
  7025. */
  7026. readonly diagonalLength: number;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7034. /** @hidden */
  7035. _checkCollision(collider: Collider): boolean;
  7036. /**
  7037. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7038. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7039. * @param point the point to check intersection with
  7040. * @returns if the point intersects
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7045. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7046. * @param boundingInfo the bounding info to check intersection with
  7047. * @param precise if the intersection should be done using OBB
  7048. * @returns if the bounding info intersects
  7049. */
  7050. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /**
  7055. * Extracts minimum and maximum values from a list of indexed positions
  7056. * @param positions defines the positions to use
  7057. * @param indices defines the indices to the positions
  7058. * @param indexStart defines the start index
  7059. * @param indexCount defines the end index
  7060. * @param bias defines bias value to add to the result
  7061. * @return minimum and maximum values
  7062. */
  7063. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7064. minimum: Vector3;
  7065. maximum: Vector3;
  7066. };
  7067. /**
  7068. * Extracts minimum and maximum values from a list of positions
  7069. * @param positions defines the positions to use
  7070. * @param start defines the start index in the positions array
  7071. * @param count defines the number of positions to handle
  7072. * @param bias defines bias value to add to the result
  7073. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7074. * @return minimum and maximum values
  7075. */
  7076. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7077. minimum: Vector3;
  7078. maximum: Vector3;
  7079. };
  7080. }
  7081. declare module BABYLON {
  7082. /** @hidden */
  7083. export class WebGLDataBuffer extends DataBuffer {
  7084. private _buffer;
  7085. constructor(resource: WebGLBuffer);
  7086. readonly underlyingResource: any;
  7087. }
  7088. }
  7089. declare module BABYLON {
  7090. /** @hidden */
  7091. export class WebGLPipelineContext implements IPipelineContext {
  7092. engine: ThinEngine;
  7093. program: Nullable<WebGLProgram>;
  7094. context?: WebGLRenderingContext;
  7095. vertexShader?: WebGLShader;
  7096. fragmentShader?: WebGLShader;
  7097. isParallelCompiled: boolean;
  7098. onCompiled?: () => void;
  7099. transformFeedback?: WebGLTransformFeedback | null;
  7100. readonly isAsync: boolean;
  7101. readonly isReady: boolean;
  7102. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. interface ThinEngine {
  7107. /**
  7108. * Create an uniform buffer
  7109. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7110. * @param elements defines the content of the uniform buffer
  7111. * @returns the webGL uniform buffer
  7112. */
  7113. createUniformBuffer(elements: FloatArray): DataBuffer;
  7114. /**
  7115. * Create a dynamic uniform buffer
  7116. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7117. * @param elements defines the content of the uniform buffer
  7118. * @returns the webGL uniform buffer
  7119. */
  7120. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7121. /**
  7122. * Update an existing uniform buffer
  7123. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7124. * @param uniformBuffer defines the target uniform buffer
  7125. * @param elements defines the content to update
  7126. * @param offset defines the offset in the uniform buffer where update should start
  7127. * @param count defines the size of the data to update
  7128. */
  7129. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7130. /**
  7131. * Bind an uniform buffer to the current webGL context
  7132. * @param buffer defines the buffer to bind
  7133. */
  7134. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7135. /**
  7136. * Bind a buffer to the current webGL context at a given location
  7137. * @param buffer defines the buffer to bind
  7138. * @param location defines the index where to bind the buffer
  7139. */
  7140. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7141. /**
  7142. * Bind a specific block at a given index in a specific shader program
  7143. * @param pipelineContext defines the pipeline context to use
  7144. * @param blockName defines the block name
  7145. * @param index defines the index where to bind the block
  7146. */
  7147. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7148. }
  7149. }
  7150. declare module BABYLON {
  7151. /**
  7152. * Uniform buffer objects.
  7153. *
  7154. * Handles blocks of uniform on the GPU.
  7155. *
  7156. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7157. *
  7158. * For more information, please refer to :
  7159. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7160. */
  7161. export class UniformBuffer {
  7162. private _engine;
  7163. private _buffer;
  7164. private _data;
  7165. private _bufferData;
  7166. private _dynamic?;
  7167. private _uniformLocations;
  7168. private _uniformSizes;
  7169. private _uniformLocationPointer;
  7170. private _needSync;
  7171. private _noUBO;
  7172. private _currentEffect;
  7173. private static _MAX_UNIFORM_SIZE;
  7174. private static _tempBuffer;
  7175. /**
  7176. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7177. * This is dynamic to allow compat with webgl 1 and 2.
  7178. * You will need to pass the name of the uniform as well as the value.
  7179. */
  7180. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7181. /**
  7182. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a single float in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateFloat: (name: string, x: number) => void;
  7193. /**
  7194. * Lambda to Update a vec2 of float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7199. /**
  7200. * Lambda to Update a vec3 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec4 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateMatrix: (name: string, mat: Matrix) => void;
  7217. /**
  7218. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateVector3: (name: string, vector: Vector3) => void;
  7223. /**
  7224. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector4: (name: string, vector: Vector4) => void;
  7229. /**
  7230. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7235. /**
  7236. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7241. /**
  7242. * Instantiates a new Uniform buffer objects.
  7243. *
  7244. * Handles blocks of uniform on the GPU.
  7245. *
  7246. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7247. *
  7248. * For more information, please refer to :
  7249. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7250. * @param engine Define the engine the buffer is associated with
  7251. * @param data Define the data contained in the buffer
  7252. * @param dynamic Define if the buffer is updatable
  7253. */
  7254. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7255. /**
  7256. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7257. * or just falling back on setUniformXXX calls.
  7258. */
  7259. readonly useUbo: boolean;
  7260. /**
  7261. * Indicates if the WebGL underlying uniform buffer is in sync
  7262. * with the javascript cache data.
  7263. */
  7264. readonly isSync: boolean;
  7265. /**
  7266. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7267. * Also, a dynamic UniformBuffer will disable cache verification and always
  7268. * update the underlying WebGL uniform buffer to the GPU.
  7269. * @returns if Dynamic, otherwise false
  7270. */
  7271. isDynamic(): boolean;
  7272. /**
  7273. * The data cache on JS side.
  7274. * @returns the underlying data as a float array
  7275. */
  7276. getData(): Float32Array;
  7277. /**
  7278. * The underlying WebGL Uniform buffer.
  7279. * @returns the webgl buffer
  7280. */
  7281. getBuffer(): Nullable<DataBuffer>;
  7282. /**
  7283. * std140 layout specifies how to align data within an UBO structure.
  7284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7285. * for specs.
  7286. */
  7287. private _fillAlignment;
  7288. /**
  7289. * Adds an uniform in the buffer.
  7290. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7291. * for the layout to be correct !
  7292. * @param name Name of the uniform, as used in the uniform block in the shader.
  7293. * @param size Data size, or data directly.
  7294. */
  7295. addUniform(name: string, size: number | number[]): void;
  7296. /**
  7297. * Adds a Matrix 4x4 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param mat A 4x4 matrix.
  7300. */
  7301. addMatrix(name: string, mat: Matrix): void;
  7302. /**
  7303. * Adds a vec2 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param x Define the x component value of the vec2
  7306. * @param y Define the y component value of the vec2
  7307. */
  7308. addFloat2(name: string, x: number, y: number): void;
  7309. /**
  7310. * Adds a vec3 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param x Define the x component value of the vec3
  7313. * @param y Define the y component value of the vec3
  7314. * @param z Define the z component value of the vec3
  7315. */
  7316. addFloat3(name: string, x: number, y: number, z: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param color Define the vec3 from a Color
  7321. */
  7322. addColor3(name: string, color: Color3): void;
  7323. /**
  7324. * Adds a vec4 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the rgb components from a Color
  7327. * @param alpha Define the a component of the vec4
  7328. */
  7329. addColor4(name: string, color: Color3, alpha: number): void;
  7330. /**
  7331. * Adds a vec3 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param vector Define the vec3 components from a Vector
  7334. */
  7335. addVector3(name: string, vector: Vector3): void;
  7336. /**
  7337. * Adds a Matrix 3x3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. */
  7340. addMatrix3x3(name: string): void;
  7341. /**
  7342. * Adds a Matrix 2x2 to the uniform buffer.
  7343. * @param name Name of the uniform, as used in the uniform block in the shader.
  7344. */
  7345. addMatrix2x2(name: string): void;
  7346. /**
  7347. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7348. */
  7349. create(): void;
  7350. /** @hidden */
  7351. _rebuild(): void;
  7352. /**
  7353. * Updates the WebGL Uniform Buffer on the GPU.
  7354. * If the `dynamic` flag is set to true, no cache comparison is done.
  7355. * Otherwise, the buffer will be updated only if the cache differs.
  7356. */
  7357. update(): void;
  7358. /**
  7359. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7360. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7361. * @param data Define the flattened data
  7362. * @param size Define the size of the data.
  7363. */
  7364. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7365. private _valueCache;
  7366. private _cacheMatrix;
  7367. private _updateMatrix3x3ForUniform;
  7368. private _updateMatrix3x3ForEffect;
  7369. private _updateMatrix2x2ForEffect;
  7370. private _updateMatrix2x2ForUniform;
  7371. private _updateFloatForEffect;
  7372. private _updateFloatForUniform;
  7373. private _updateFloat2ForEffect;
  7374. private _updateFloat2ForUniform;
  7375. private _updateFloat3ForEffect;
  7376. private _updateFloat3ForUniform;
  7377. private _updateFloat4ForEffect;
  7378. private _updateFloat4ForUniform;
  7379. private _updateMatrixForEffect;
  7380. private _updateMatrixForUniform;
  7381. private _updateVector3ForEffect;
  7382. private _updateVector3ForUniform;
  7383. private _updateVector4ForEffect;
  7384. private _updateVector4ForUniform;
  7385. private _updateColor3ForEffect;
  7386. private _updateColor3ForUniform;
  7387. private _updateColor4ForEffect;
  7388. private _updateColor4ForUniform;
  7389. /**
  7390. * Sets a sampler uniform on the effect.
  7391. * @param name Define the name of the sampler.
  7392. * @param texture Define the texture to set in the sampler
  7393. */
  7394. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7395. /**
  7396. * Directly updates the value of the uniform in the cache AND on the GPU.
  7397. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7398. * @param data Define the flattened data
  7399. */
  7400. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7401. /**
  7402. * Binds this uniform buffer to an effect.
  7403. * @param effect Define the effect to bind the buffer to
  7404. * @param name Name of the uniform block in the shader.
  7405. */
  7406. bindToEffect(effect: Effect, name: string): void;
  7407. /**
  7408. * Disposes the uniform buffer.
  7409. */
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Enum that determines the text-wrapping mode to use.
  7416. */
  7417. export enum InspectableType {
  7418. /**
  7419. * Checkbox for booleans
  7420. */
  7421. Checkbox = 0,
  7422. /**
  7423. * Sliders for numbers
  7424. */
  7425. Slider = 1,
  7426. /**
  7427. * Vector3
  7428. */
  7429. Vector3 = 2,
  7430. /**
  7431. * Quaternions
  7432. */
  7433. Quaternion = 3,
  7434. /**
  7435. * Color3
  7436. */
  7437. Color3 = 4,
  7438. /**
  7439. * String
  7440. */
  7441. String = 5
  7442. }
  7443. /**
  7444. * Interface used to define custom inspectable properties.
  7445. * This interface is used by the inspector to display custom property grids
  7446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7447. */
  7448. export interface IInspectable {
  7449. /**
  7450. * Gets the label to display
  7451. */
  7452. label: string;
  7453. /**
  7454. * Gets the name of the property to edit
  7455. */
  7456. propertyName: string;
  7457. /**
  7458. * Gets the type of the editor to use
  7459. */
  7460. type: InspectableType;
  7461. /**
  7462. * Gets the minimum value of the property when using in "slider" mode
  7463. */
  7464. min?: number;
  7465. /**
  7466. * Gets the maximum value of the property when using in "slider" mode
  7467. */
  7468. max?: number;
  7469. /**
  7470. * Gets the setp to use when using in "slider" mode
  7471. */
  7472. step?: number;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class used to provide helper for timing
  7478. */
  7479. export class TimingTools {
  7480. /**
  7481. * Polyfill for setImmediate
  7482. * @param action defines the action to execute after the current execution block
  7483. */
  7484. static SetImmediate(action: () => void): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Class used to enable instatition of objects by class name
  7490. */
  7491. export class InstantiationTools {
  7492. /**
  7493. * Use this object to register external classes like custom textures or material
  7494. * to allow the laoders to instantiate them
  7495. */
  7496. static RegisteredExternalClasses: {
  7497. [key: string]: Object;
  7498. };
  7499. /**
  7500. * Tries to instantiate a new object from a given class name
  7501. * @param className defines the class name to instantiate
  7502. * @returns the new object or null if the system was not able to do the instantiation
  7503. */
  7504. static Instantiate(className: string): any;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Define options used to create a depth texture
  7510. */
  7511. export class DepthTextureCreationOptions {
  7512. /** Specifies whether or not a stencil should be allocated in the texture */
  7513. generateStencil?: boolean;
  7514. /** Specifies whether or not bilinear filtering is enable on the texture */
  7515. bilinearFiltering?: boolean;
  7516. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7517. comparisonFunction?: number;
  7518. /** Specifies if the created texture is a cube texture */
  7519. isCube?: boolean;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. interface ThinEngine {
  7524. /**
  7525. * Creates a depth stencil cube texture.
  7526. * This is only available in WebGL 2.
  7527. * @param size The size of face edge in the cube texture.
  7528. * @param options The options defining the cube texture.
  7529. * @returns The cube texture
  7530. */
  7531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7532. /**
  7533. * Creates a cube texture
  7534. * @param rootUrl defines the url where the files to load is located
  7535. * @param scene defines the current scene
  7536. * @param files defines the list of files to load (1 per face)
  7537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7538. * @param onLoad defines an optional callback raised when the texture is loaded
  7539. * @param onError defines an optional callback raised if there is an issue to load the texture
  7540. * @param format defines the format of the data
  7541. * @param forcedExtension defines the extension to use to pick the right loader
  7542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7547. * @returns the cube texture as an InternalTexture
  7548. */
  7549. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7550. /**
  7551. * Creates a cube texture
  7552. * @param rootUrl defines the url where the files to load is located
  7553. * @param scene defines the current scene
  7554. * @param files defines the list of files to load (1 per face)
  7555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7556. * @param onLoad defines an optional callback raised when the texture is loaded
  7557. * @param onError defines an optional callback raised if there is an issue to load the texture
  7558. * @param format defines the format of the data
  7559. * @param forcedExtension defines the extension to use to pick the right loader
  7560. * @returns the cube texture as an InternalTexture
  7561. */
  7562. 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;
  7563. /**
  7564. * Creates a cube texture
  7565. * @param rootUrl defines the url where the files to load is located
  7566. * @param scene defines the current scene
  7567. * @param files defines the list of files to load (1 per face)
  7568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7569. * @param onLoad defines an optional callback raised when the texture is loaded
  7570. * @param onError defines an optional callback raised if there is an issue to load the texture
  7571. * @param format defines the format of the data
  7572. * @param forcedExtension defines the extension to use to pick the right loader
  7573. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7574. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7575. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. 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;
  7579. /** @hidden */
  7580. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7581. /** @hidden */
  7582. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /** @hidden */
  7584. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Class for creating a cube texture
  7592. */
  7593. export class CubeTexture extends BaseTexture {
  7594. private _delayedOnLoad;
  7595. /**
  7596. * The url of the texture
  7597. */
  7598. url: string;
  7599. /**
  7600. * Gets or sets the center of the bounding box associated with the cube texture.
  7601. * It must define where the camera used to render the texture was set
  7602. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7603. */
  7604. boundingBoxPosition: Vector3;
  7605. private _boundingBoxSize;
  7606. /**
  7607. * Gets or sets the size of the bounding box associated with the cube texture
  7608. * When defined, the cubemap will switch to local mode
  7609. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7610. * @example https://www.babylonjs-playground.com/#RNASML
  7611. */
  7612. /**
  7613. * Returns the bounding box size
  7614. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7615. */
  7616. boundingBoxSize: Vector3;
  7617. protected _rotationY: number;
  7618. /**
  7619. * Sets texture matrix rotation angle around Y axis in radians.
  7620. */
  7621. /**
  7622. * Gets texture matrix rotation angle around Y axis radians.
  7623. */
  7624. rotationY: number;
  7625. /**
  7626. * Are mip maps generated for this texture or not.
  7627. */
  7628. readonly noMipmap: boolean;
  7629. private _noMipmap;
  7630. private _files;
  7631. private _extensions;
  7632. private _textureMatrix;
  7633. private _format;
  7634. private _createPolynomials;
  7635. /** @hidden */
  7636. _prefiltered: boolean;
  7637. /**
  7638. * Creates a cube texture from an array of image urls
  7639. * @param files defines an array of image urls
  7640. * @param scene defines the hosting scene
  7641. * @param noMipmap specifies if mip maps are not used
  7642. * @returns a cube texture
  7643. */
  7644. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7645. /**
  7646. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7647. * @param url defines the url of the prefiltered texture
  7648. * @param scene defines the scene the texture is attached to
  7649. * @param forcedExtension defines the extension of the file if different from the url
  7650. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7651. * @return the prefiltered texture
  7652. */
  7653. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7654. /**
  7655. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7656. * as prefiltered data.
  7657. * @param rootUrl defines the url of the texture or the root name of the six images
  7658. * @param scene defines the scene the texture is attached to
  7659. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7660. * @param noMipmap defines if mipmaps should be created or not
  7661. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7662. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7663. * @param onError defines a callback triggered in case of error during load
  7664. * @param format defines the internal format to use for the texture once loaded
  7665. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7666. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7667. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7668. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7669. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7670. * @return the cube texture
  7671. */
  7672. constructor(rootUrl: string, scene: Scene, 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);
  7673. /**
  7674. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7675. */
  7676. readonly isPrefiltered: boolean;
  7677. /**
  7678. * Get the current class name of the texture useful for serialization or dynamic coding.
  7679. * @returns "CubeTexture"
  7680. */
  7681. getClassName(): string;
  7682. /**
  7683. * Update the url (and optional buffer) of this texture if url was null during construction.
  7684. * @param url the url of the texture
  7685. * @param forcedExtension defines the extension to use
  7686. * @param onLoad callback called when the texture is loaded (defaults to null)
  7687. */
  7688. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7689. /**
  7690. * Delays loading of the cube texture
  7691. * @param forcedExtension defines the extension to use
  7692. */
  7693. delayLoad(forcedExtension?: string): void;
  7694. /**
  7695. * Returns the reflection texture matrix
  7696. * @returns the reflection texture matrix
  7697. */
  7698. getReflectionTextureMatrix(): Matrix;
  7699. /**
  7700. * Sets the reflection texture matrix
  7701. * @param value Reflection texture matrix
  7702. */
  7703. setReflectionTextureMatrix(value: Matrix): void;
  7704. /**
  7705. * Parses text to create a cube texture
  7706. * @param parsedTexture define the serialized text to read from
  7707. * @param scene defines the hosting scene
  7708. * @param rootUrl defines the root url of the cube texture
  7709. * @returns a cube texture
  7710. */
  7711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7712. /**
  7713. * Makes a clone, or deep copy, of the cube texture
  7714. * @returns a new cube texture
  7715. */
  7716. clone(): CubeTexture;
  7717. }
  7718. }
  7719. declare module BABYLON {
  7720. /**
  7721. * Manages the defines for the Material
  7722. */
  7723. export class MaterialDefines {
  7724. /** @hidden */
  7725. protected _keys: string[];
  7726. private _isDirty;
  7727. /** @hidden */
  7728. _renderId: number;
  7729. /** @hidden */
  7730. _areLightsDirty: boolean;
  7731. /** @hidden */
  7732. _areLightsDisposed: boolean;
  7733. /** @hidden */
  7734. _areAttributesDirty: boolean;
  7735. /** @hidden */
  7736. _areTexturesDirty: boolean;
  7737. /** @hidden */
  7738. _areFresnelDirty: boolean;
  7739. /** @hidden */
  7740. _areMiscDirty: boolean;
  7741. /** @hidden */
  7742. _areImageProcessingDirty: boolean;
  7743. /** @hidden */
  7744. _normals: boolean;
  7745. /** @hidden */
  7746. _uvs: boolean;
  7747. /** @hidden */
  7748. _needNormals: boolean;
  7749. /** @hidden */
  7750. _needUVs: boolean;
  7751. [id: string]: any;
  7752. /**
  7753. * Specifies if the material needs to be re-calculated
  7754. */
  7755. readonly isDirty: boolean;
  7756. /**
  7757. * Marks the material to indicate that it has been re-calculated
  7758. */
  7759. markAsProcessed(): void;
  7760. /**
  7761. * Marks the material to indicate that it needs to be re-calculated
  7762. */
  7763. markAsUnprocessed(): void;
  7764. /**
  7765. * Marks the material to indicate all of its defines need to be re-calculated
  7766. */
  7767. markAllAsDirty(): void;
  7768. /**
  7769. * Marks the material to indicate that image processing needs to be re-calculated
  7770. */
  7771. markAsImageProcessingDirty(): void;
  7772. /**
  7773. * Marks the material to indicate the lights need to be re-calculated
  7774. * @param disposed Defines whether the light is dirty due to dispose or not
  7775. */
  7776. markAsLightDirty(disposed?: boolean): void;
  7777. /**
  7778. * Marks the attribute state as changed
  7779. */
  7780. markAsAttributesDirty(): void;
  7781. /**
  7782. * Marks the texture state as changed
  7783. */
  7784. markAsTexturesDirty(): void;
  7785. /**
  7786. * Marks the fresnel state as changed
  7787. */
  7788. markAsFresnelDirty(): void;
  7789. /**
  7790. * Marks the misc state as changed
  7791. */
  7792. markAsMiscDirty(): void;
  7793. /**
  7794. * Rebuilds the material defines
  7795. */
  7796. rebuild(): void;
  7797. /**
  7798. * Specifies if two material defines are equal
  7799. * @param other - A material define instance to compare to
  7800. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7801. */
  7802. isEqual(other: MaterialDefines): boolean;
  7803. /**
  7804. * Clones this instance's defines to another instance
  7805. * @param other - material defines to clone values to
  7806. */
  7807. cloneTo(other: MaterialDefines): void;
  7808. /**
  7809. * Resets the material define values
  7810. */
  7811. reset(): void;
  7812. /**
  7813. * Converts the material define values to a string
  7814. * @returns - String of material define information
  7815. */
  7816. toString(): string;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7823. * 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;
  7824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7825. */
  7826. export class ColorCurves {
  7827. private _dirty;
  7828. private _tempColor;
  7829. private _globalCurve;
  7830. private _highlightsCurve;
  7831. private _midtonesCurve;
  7832. private _shadowsCurve;
  7833. private _positiveCurve;
  7834. private _negativeCurve;
  7835. private _globalHue;
  7836. private _globalDensity;
  7837. private _globalSaturation;
  7838. private _globalExposure;
  7839. /**
  7840. * Gets the global Hue value.
  7841. * 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).
  7842. */
  7843. /**
  7844. * Sets the global Hue value.
  7845. * 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).
  7846. */
  7847. globalHue: number;
  7848. /**
  7849. * Gets the global Density value.
  7850. * 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.
  7851. * Values less than zero provide a filter of opposite hue.
  7852. */
  7853. /**
  7854. * Sets the global Density value.
  7855. * 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.
  7856. * Values less than zero provide a filter of opposite hue.
  7857. */
  7858. globalDensity: number;
  7859. /**
  7860. * Gets the global Saturation value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the global Saturation value.
  7865. * 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.
  7866. */
  7867. globalSaturation: number;
  7868. /**
  7869. * Gets the global Exposure value.
  7870. * 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.
  7871. */
  7872. /**
  7873. * Sets the global Exposure value.
  7874. * 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.
  7875. */
  7876. globalExposure: number;
  7877. private _highlightsHue;
  7878. private _highlightsDensity;
  7879. private _highlightsSaturation;
  7880. private _highlightsExposure;
  7881. /**
  7882. * Gets the highlights Hue value.
  7883. * 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).
  7884. */
  7885. /**
  7886. * Sets the highlights Hue value.
  7887. * 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).
  7888. */
  7889. highlightsHue: number;
  7890. /**
  7891. * Gets the highlights Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. /**
  7896. * Sets the highlights Density value.
  7897. * 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.
  7898. * Values less than zero provide a filter of opposite hue.
  7899. */
  7900. highlightsDensity: number;
  7901. /**
  7902. * Gets the highlights Saturation value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the highlights Saturation value.
  7907. * 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.
  7908. */
  7909. highlightsSaturation: number;
  7910. /**
  7911. * Gets the highlights Exposure value.
  7912. * 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.
  7913. */
  7914. /**
  7915. * Sets the highlights Exposure value.
  7916. * 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.
  7917. */
  7918. highlightsExposure: number;
  7919. private _midtonesHue;
  7920. private _midtonesDensity;
  7921. private _midtonesSaturation;
  7922. private _midtonesExposure;
  7923. /**
  7924. * Gets the midtones Hue value.
  7925. * 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).
  7926. */
  7927. /**
  7928. * Sets the midtones Hue value.
  7929. * 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).
  7930. */
  7931. midtonesHue: number;
  7932. /**
  7933. * Gets the midtones Density value.
  7934. * 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.
  7935. * Values less than zero provide a filter of opposite hue.
  7936. */
  7937. /**
  7938. * Sets the midtones Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. midtonesDensity: number;
  7943. /**
  7944. * Gets the midtones Saturation value.
  7945. * 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.
  7946. */
  7947. /**
  7948. * Sets the midtones Saturation value.
  7949. * 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.
  7950. */
  7951. midtonesSaturation: number;
  7952. /**
  7953. * Gets the midtones Exposure value.
  7954. * 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.
  7955. */
  7956. /**
  7957. * Sets the midtones Exposure value.
  7958. * 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.
  7959. */
  7960. midtonesExposure: number;
  7961. private _shadowsHue;
  7962. private _shadowsDensity;
  7963. private _shadowsSaturation;
  7964. private _shadowsExposure;
  7965. /**
  7966. * Gets the shadows Hue value.
  7967. * 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).
  7968. */
  7969. /**
  7970. * Sets the shadows Hue value.
  7971. * 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).
  7972. */
  7973. shadowsHue: number;
  7974. /**
  7975. * Gets the shadows Density value.
  7976. * 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.
  7977. * Values less than zero provide a filter of opposite hue.
  7978. */
  7979. /**
  7980. * Sets the shadows Density value.
  7981. * 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.
  7982. * Values less than zero provide a filter of opposite hue.
  7983. */
  7984. shadowsDensity: number;
  7985. /**
  7986. * Gets the shadows Saturation value.
  7987. * 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.
  7988. */
  7989. /**
  7990. * Sets the shadows Saturation value.
  7991. * 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.
  7992. */
  7993. shadowsSaturation: number;
  7994. /**
  7995. * Gets the shadows Exposure value.
  7996. * 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.
  7997. */
  7998. /**
  7999. * Sets the shadows Exposure value.
  8000. * 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.
  8001. */
  8002. shadowsExposure: number;
  8003. /**
  8004. * Returns the class name
  8005. * @returns The class name
  8006. */
  8007. getClassName(): string;
  8008. /**
  8009. * Binds the color curves to the shader.
  8010. * @param colorCurves The color curve to bind
  8011. * @param effect The effect to bind to
  8012. * @param positiveUniform The positive uniform shader parameter
  8013. * @param neutralUniform The neutral uniform shader parameter
  8014. * @param negativeUniform The negative uniform shader parameter
  8015. */
  8016. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8017. /**
  8018. * Prepare the list of uniforms associated with the ColorCurves effects.
  8019. * @param uniformsList The list of uniforms used in the effect
  8020. */
  8021. static PrepareUniforms(uniformsList: string[]): void;
  8022. /**
  8023. * Returns color grading data based on a hue, density, saturation and exposure value.
  8024. * @param filterHue The hue of the color filter.
  8025. * @param filterDensity The density of the color filter.
  8026. * @param saturation The saturation.
  8027. * @param exposure The exposure.
  8028. * @param result The result data container.
  8029. */
  8030. private getColorGradingDataToRef;
  8031. /**
  8032. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8033. * @param value The input slider value in range [-100,100].
  8034. * @returns Adjusted value.
  8035. */
  8036. private static applyColorGradingSliderNonlinear;
  8037. /**
  8038. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8039. * @param hue The hue (H) input.
  8040. * @param saturation The saturation (S) input.
  8041. * @param brightness The brightness (B) input.
  8042. * @result An RGBA color represented as Vector4.
  8043. */
  8044. private static fromHSBToRef;
  8045. /**
  8046. * Returns a value clamped between min and max
  8047. * @param value The value to clamp
  8048. * @param min The minimum of value
  8049. * @param max The maximum of value
  8050. * @returns The clamped value.
  8051. */
  8052. private static clamp;
  8053. /**
  8054. * Clones the current color curve instance.
  8055. * @return The cloned curves
  8056. */
  8057. clone(): ColorCurves;
  8058. /**
  8059. * Serializes the current color curve instance to a json representation.
  8060. * @return a JSON representation
  8061. */
  8062. serialize(): any;
  8063. /**
  8064. * Parses the color curve from a json representation.
  8065. * @param source the JSON source to parse
  8066. * @return The parsed curves
  8067. */
  8068. static Parse(source: any): ColorCurves;
  8069. }
  8070. }
  8071. declare module BABYLON {
  8072. /**
  8073. * Interface to follow in your material defines to integrate easily the
  8074. * Image proccessing functions.
  8075. * @hidden
  8076. */
  8077. export interface IImageProcessingConfigurationDefines {
  8078. IMAGEPROCESSING: boolean;
  8079. VIGNETTE: boolean;
  8080. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8081. VIGNETTEBLENDMODEOPAQUE: boolean;
  8082. TONEMAPPING: boolean;
  8083. TONEMAPPING_ACES: boolean;
  8084. CONTRAST: boolean;
  8085. EXPOSURE: boolean;
  8086. COLORCURVES: boolean;
  8087. COLORGRADING: boolean;
  8088. COLORGRADING3D: boolean;
  8089. SAMPLER3DGREENDEPTH: boolean;
  8090. SAMPLER3DBGRMAP: boolean;
  8091. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8092. }
  8093. /**
  8094. * @hidden
  8095. */
  8096. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8097. IMAGEPROCESSING: boolean;
  8098. VIGNETTE: boolean;
  8099. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8100. VIGNETTEBLENDMODEOPAQUE: boolean;
  8101. TONEMAPPING: boolean;
  8102. TONEMAPPING_ACES: boolean;
  8103. CONTRAST: boolean;
  8104. COLORCURVES: boolean;
  8105. COLORGRADING: boolean;
  8106. COLORGRADING3D: boolean;
  8107. SAMPLER3DGREENDEPTH: boolean;
  8108. SAMPLER3DBGRMAP: boolean;
  8109. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8110. EXPOSURE: boolean;
  8111. constructor();
  8112. }
  8113. /**
  8114. * This groups together the common properties used for image processing either in direct forward pass
  8115. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8116. * or not.
  8117. */
  8118. export class ImageProcessingConfiguration {
  8119. /**
  8120. * Default tone mapping applied in BabylonJS.
  8121. */
  8122. static readonly TONEMAPPING_STANDARD: number;
  8123. /**
  8124. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8125. * to other engines rendering to increase portability.
  8126. */
  8127. static readonly TONEMAPPING_ACES: number;
  8128. /**
  8129. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8130. */
  8131. colorCurves: Nullable<ColorCurves>;
  8132. private _colorCurvesEnabled;
  8133. /**
  8134. * Gets wether the color curves effect is enabled.
  8135. */
  8136. /**
  8137. * Sets wether the color curves effect is enabled.
  8138. */
  8139. colorCurvesEnabled: boolean;
  8140. private _colorGradingTexture;
  8141. /**
  8142. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8143. */
  8144. /**
  8145. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8146. */
  8147. colorGradingTexture: Nullable<BaseTexture>;
  8148. private _colorGradingEnabled;
  8149. /**
  8150. * Gets wether the color grading effect is enabled.
  8151. */
  8152. /**
  8153. * Sets wether the color grading effect is enabled.
  8154. */
  8155. colorGradingEnabled: boolean;
  8156. private _colorGradingWithGreenDepth;
  8157. /**
  8158. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8159. */
  8160. /**
  8161. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8162. */
  8163. colorGradingWithGreenDepth: boolean;
  8164. private _colorGradingBGR;
  8165. /**
  8166. * Gets wether the color grading texture contains BGR values.
  8167. */
  8168. /**
  8169. * Sets wether the color grading texture contains BGR values.
  8170. */
  8171. colorGradingBGR: boolean;
  8172. /** @hidden */
  8173. _exposure: number;
  8174. /**
  8175. * Gets the Exposure used in the effect.
  8176. */
  8177. /**
  8178. * Sets the Exposure used in the effect.
  8179. */
  8180. exposure: number;
  8181. private _toneMappingEnabled;
  8182. /**
  8183. * Gets wether the tone mapping effect is enabled.
  8184. */
  8185. /**
  8186. * Sets wether the tone mapping effect is enabled.
  8187. */
  8188. toneMappingEnabled: boolean;
  8189. private _toneMappingType;
  8190. /**
  8191. * Gets the type of tone mapping effect.
  8192. */
  8193. /**
  8194. * Sets the type of tone mapping effect used in BabylonJS.
  8195. */
  8196. toneMappingType: number;
  8197. protected _contrast: number;
  8198. /**
  8199. * Gets the contrast used in the effect.
  8200. */
  8201. /**
  8202. * Sets the contrast used in the effect.
  8203. */
  8204. contrast: number;
  8205. /**
  8206. * Vignette stretch size.
  8207. */
  8208. vignetteStretch: number;
  8209. /**
  8210. * Vignette centre X Offset.
  8211. */
  8212. vignetteCentreX: number;
  8213. /**
  8214. * Vignette centre Y Offset.
  8215. */
  8216. vignetteCentreY: number;
  8217. /**
  8218. * Vignette weight or intensity of the vignette effect.
  8219. */
  8220. vignetteWeight: number;
  8221. /**
  8222. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8223. * if vignetteEnabled is set to true.
  8224. */
  8225. vignetteColor: Color4;
  8226. /**
  8227. * Camera field of view used by the Vignette effect.
  8228. */
  8229. vignetteCameraFov: number;
  8230. private _vignetteBlendMode;
  8231. /**
  8232. * Gets the vignette blend mode allowing different kind of effect.
  8233. */
  8234. /**
  8235. * Sets the vignette blend mode allowing different kind of effect.
  8236. */
  8237. vignetteBlendMode: number;
  8238. private _vignetteEnabled;
  8239. /**
  8240. * Gets wether the vignette effect is enabled.
  8241. */
  8242. /**
  8243. * Sets wether the vignette effect is enabled.
  8244. */
  8245. vignetteEnabled: boolean;
  8246. private _applyByPostProcess;
  8247. /**
  8248. * Gets wether the image processing is applied through a post process or not.
  8249. */
  8250. /**
  8251. * Sets wether the image processing is applied through a post process or not.
  8252. */
  8253. applyByPostProcess: boolean;
  8254. private _isEnabled;
  8255. /**
  8256. * Gets wether the image processing is enabled or not.
  8257. */
  8258. /**
  8259. * Sets wether the image processing is enabled or not.
  8260. */
  8261. isEnabled: boolean;
  8262. /**
  8263. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8264. */
  8265. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8266. /**
  8267. * Method called each time the image processing information changes requires to recompile the effect.
  8268. */
  8269. protected _updateParameters(): void;
  8270. /**
  8271. * Gets the current class name.
  8272. * @return "ImageProcessingConfiguration"
  8273. */
  8274. getClassName(): string;
  8275. /**
  8276. * Prepare the list of uniforms associated with the Image Processing effects.
  8277. * @param uniforms The list of uniforms used in the effect
  8278. * @param defines the list of defines currently in use
  8279. */
  8280. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8281. /**
  8282. * Prepare the list of samplers associated with the Image Processing effects.
  8283. * @param samplersList The list of uniforms used in the effect
  8284. * @param defines the list of defines currently in use
  8285. */
  8286. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8287. /**
  8288. * Prepare the list of defines associated to the shader.
  8289. * @param defines the list of defines to complete
  8290. * @param forPostProcess Define if we are currently in post process mode or not
  8291. */
  8292. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8293. /**
  8294. * Returns true if all the image processing information are ready.
  8295. * @returns True if ready, otherwise, false
  8296. */
  8297. isReady(): boolean;
  8298. /**
  8299. * Binds the image processing to the shader.
  8300. * @param effect The effect to bind to
  8301. * @param aspectRatio Define the current aspect ratio of the effect
  8302. */
  8303. bind(effect: Effect, aspectRatio?: number): void;
  8304. /**
  8305. * Clones the current image processing instance.
  8306. * @return The cloned image processing
  8307. */
  8308. clone(): ImageProcessingConfiguration;
  8309. /**
  8310. * Serializes the current image processing instance to a json representation.
  8311. * @return a JSON representation
  8312. */
  8313. serialize(): any;
  8314. /**
  8315. * Parses the image processing from a json representation.
  8316. * @param source the JSON source to parse
  8317. * @return The parsed image processing
  8318. */
  8319. static Parse(source: any): ImageProcessingConfiguration;
  8320. private static _VIGNETTEMODE_MULTIPLY;
  8321. private static _VIGNETTEMODE_OPAQUE;
  8322. /**
  8323. * Used to apply the vignette as a mix with the pixel color.
  8324. */
  8325. static readonly VIGNETTEMODE_MULTIPLY: number;
  8326. /**
  8327. * Used to apply the vignette as a replacement of the pixel color.
  8328. */
  8329. static readonly VIGNETTEMODE_OPAQUE: number;
  8330. }
  8331. }
  8332. declare module BABYLON {
  8333. /** @hidden */
  8334. export var postprocessVertexShader: {
  8335. name: string;
  8336. shader: string;
  8337. };
  8338. }
  8339. declare module BABYLON {
  8340. /** Defines supported spaces */
  8341. export enum Space {
  8342. /** Local (object) space */
  8343. LOCAL = 0,
  8344. /** World space */
  8345. WORLD = 1,
  8346. /** Bone space */
  8347. BONE = 2
  8348. }
  8349. /** Defines the 3 main axes */
  8350. export class Axis {
  8351. /** X axis */
  8352. static X: Vector3;
  8353. /** Y axis */
  8354. static Y: Vector3;
  8355. /** Z axis */
  8356. static Z: Vector3;
  8357. }
  8358. }
  8359. declare module BABYLON {
  8360. /**
  8361. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8362. * This is the base of the follow, arc rotate cameras and Free camera
  8363. * @see http://doc.babylonjs.com/features/cameras
  8364. */
  8365. export class TargetCamera extends Camera {
  8366. private static _RigCamTransformMatrix;
  8367. private static _TargetTransformMatrix;
  8368. private static _TargetFocalPoint;
  8369. /**
  8370. * Define the current direction the camera is moving to
  8371. */
  8372. cameraDirection: Vector3;
  8373. /**
  8374. * Define the current rotation the camera is rotating to
  8375. */
  8376. cameraRotation: Vector2;
  8377. /**
  8378. * When set, the up vector of the camera will be updated by the rotation of the camera
  8379. */
  8380. updateUpVectorFromRotation: boolean;
  8381. private _tmpQuaternion;
  8382. /**
  8383. * Define the current rotation of the camera
  8384. */
  8385. rotation: Vector3;
  8386. /**
  8387. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8388. */
  8389. rotationQuaternion: Quaternion;
  8390. /**
  8391. * Define the current speed of the camera
  8392. */
  8393. speed: number;
  8394. /**
  8395. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8396. * around all axis.
  8397. */
  8398. noRotationConstraint: boolean;
  8399. /**
  8400. * Define the current target of the camera as an object or a position.
  8401. */
  8402. lockedTarget: any;
  8403. /** @hidden */
  8404. _currentTarget: Vector3;
  8405. /** @hidden */
  8406. _initialFocalDistance: number;
  8407. /** @hidden */
  8408. _viewMatrix: Matrix;
  8409. /** @hidden */
  8410. _camMatrix: Matrix;
  8411. /** @hidden */
  8412. _cameraTransformMatrix: Matrix;
  8413. /** @hidden */
  8414. _cameraRotationMatrix: Matrix;
  8415. /** @hidden */
  8416. _referencePoint: Vector3;
  8417. /** @hidden */
  8418. _transformedReferencePoint: Vector3;
  8419. protected _globalCurrentTarget: Vector3;
  8420. protected _globalCurrentUpVector: Vector3;
  8421. /** @hidden */
  8422. _reset: () => void;
  8423. private _defaultUp;
  8424. /**
  8425. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8426. * This is the base of the follow, arc rotate cameras and Free camera
  8427. * @see http://doc.babylonjs.com/features/cameras
  8428. * @param name Defines the name of the camera in the scene
  8429. * @param position Defines the start position of the camera in the scene
  8430. * @param scene Defines the scene the camera belongs to
  8431. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8432. */
  8433. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8434. /**
  8435. * Gets the position in front of the camera at a given distance.
  8436. * @param distance The distance from the camera we want the position to be
  8437. * @returns the position
  8438. */
  8439. getFrontPosition(distance: number): Vector3;
  8440. /** @hidden */
  8441. _getLockedTargetPosition(): Nullable<Vector3>;
  8442. private _storedPosition;
  8443. private _storedRotation;
  8444. private _storedRotationQuaternion;
  8445. /**
  8446. * Store current camera state of the camera (fov, position, rotation, etc..)
  8447. * @returns the camera
  8448. */
  8449. storeState(): Camera;
  8450. /**
  8451. * Restored camera state. You must call storeState() first
  8452. * @returns whether it was successful or not
  8453. * @hidden
  8454. */
  8455. _restoreStateValues(): boolean;
  8456. /** @hidden */
  8457. _initCache(): void;
  8458. /** @hidden */
  8459. _updateCache(ignoreParentClass?: boolean): void;
  8460. /** @hidden */
  8461. _isSynchronizedViewMatrix(): boolean;
  8462. /** @hidden */
  8463. _computeLocalCameraSpeed(): number;
  8464. /**
  8465. * Defines the target the camera should look at.
  8466. * @param target Defines the new target as a Vector or a mesh
  8467. */
  8468. setTarget(target: Vector3): void;
  8469. /**
  8470. * Return the current target position of the camera. This value is expressed in local space.
  8471. * @returns the target position
  8472. */
  8473. getTarget(): Vector3;
  8474. /** @hidden */
  8475. _decideIfNeedsToMove(): boolean;
  8476. /** @hidden */
  8477. _updatePosition(): void;
  8478. /** @hidden */
  8479. _checkInputs(): void;
  8480. protected _updateCameraRotationMatrix(): void;
  8481. /**
  8482. * 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)
  8483. * @returns the current camera
  8484. */
  8485. private _rotateUpVectorWithCameraRotationMatrix;
  8486. private _cachedRotationZ;
  8487. private _cachedQuaternionRotationZ;
  8488. /** @hidden */
  8489. _getViewMatrix(): Matrix;
  8490. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8491. /**
  8492. * @hidden
  8493. */
  8494. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8495. /**
  8496. * @hidden
  8497. */
  8498. _updateRigCameras(): void;
  8499. private _getRigCamPositionAndTarget;
  8500. /**
  8501. * Gets the current object class name.
  8502. * @return the class name
  8503. */
  8504. getClassName(): string;
  8505. }
  8506. }
  8507. declare module BABYLON {
  8508. /**
  8509. * Gather the list of keyboard event types as constants.
  8510. */
  8511. export class KeyboardEventTypes {
  8512. /**
  8513. * The keydown event is fired when a key becomes active (pressed).
  8514. */
  8515. static readonly KEYDOWN: number;
  8516. /**
  8517. * The keyup event is fired when a key has been released.
  8518. */
  8519. static readonly KEYUP: number;
  8520. }
  8521. /**
  8522. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8523. */
  8524. export class KeyboardInfo {
  8525. /**
  8526. * Defines the type of event (KeyboardEventTypes)
  8527. */
  8528. type: number;
  8529. /**
  8530. * Defines the related dom event
  8531. */
  8532. event: KeyboardEvent;
  8533. /**
  8534. * Instantiates a new keyboard info.
  8535. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8536. * @param type Defines the type of event (KeyboardEventTypes)
  8537. * @param event Defines the related dom event
  8538. */
  8539. constructor(
  8540. /**
  8541. * Defines the type of event (KeyboardEventTypes)
  8542. */
  8543. type: number,
  8544. /**
  8545. * Defines the related dom event
  8546. */
  8547. event: KeyboardEvent);
  8548. }
  8549. /**
  8550. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8551. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8552. */
  8553. export class KeyboardInfoPre extends KeyboardInfo {
  8554. /**
  8555. * Defines the type of event (KeyboardEventTypes)
  8556. */
  8557. type: number;
  8558. /**
  8559. * Defines the related dom event
  8560. */
  8561. event: KeyboardEvent;
  8562. /**
  8563. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8564. */
  8565. skipOnPointerObservable: boolean;
  8566. /**
  8567. * Instantiates a new keyboard pre info.
  8568. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8569. * @param type Defines the type of event (KeyboardEventTypes)
  8570. * @param event Defines the related dom event
  8571. */
  8572. constructor(
  8573. /**
  8574. * Defines the type of event (KeyboardEventTypes)
  8575. */
  8576. type: number,
  8577. /**
  8578. * Defines the related dom event
  8579. */
  8580. event: KeyboardEvent);
  8581. }
  8582. }
  8583. declare module BABYLON {
  8584. /**
  8585. * Manage the keyboard inputs to control the movement of a free camera.
  8586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8587. */
  8588. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8589. /**
  8590. * Defines the camera the input is attached to.
  8591. */
  8592. camera: FreeCamera;
  8593. /**
  8594. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8595. */
  8596. keysUp: number[];
  8597. /**
  8598. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8599. */
  8600. keysDown: number[];
  8601. /**
  8602. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8603. */
  8604. keysLeft: number[];
  8605. /**
  8606. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8607. */
  8608. keysRight: number[];
  8609. private _keys;
  8610. private _onCanvasBlurObserver;
  8611. private _onKeyboardObserver;
  8612. private _engine;
  8613. private _scene;
  8614. /**
  8615. * Attach the input controls to a specific dom element to get the input from.
  8616. * @param element Defines the element the controls should be listened from
  8617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8618. */
  8619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8620. /**
  8621. * Detach the current controls from the specified dom element.
  8622. * @param element Defines the element to stop listening the inputs from
  8623. */
  8624. detachControl(element: Nullable<HTMLElement>): void;
  8625. /**
  8626. * Update the current camera state depending on the inputs that have been used this frame.
  8627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8628. */
  8629. checkInputs(): void;
  8630. /**
  8631. * Gets the class name of the current intput.
  8632. * @returns the class name
  8633. */
  8634. getClassName(): string;
  8635. /** @hidden */
  8636. _onLostFocus(): void;
  8637. /**
  8638. * Get the friendly name associated with the input class.
  8639. * @returns the input friendly name
  8640. */
  8641. getSimpleName(): string;
  8642. }
  8643. }
  8644. declare module BABYLON {
  8645. /**
  8646. * Interface describing all the common properties and methods a shadow light needs to implement.
  8647. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8648. * as well as binding the different shadow properties to the effects.
  8649. */
  8650. export interface IShadowLight extends Light {
  8651. /**
  8652. * The light id in the scene (used in scene.findLighById for instance)
  8653. */
  8654. id: string;
  8655. /**
  8656. * The position the shdow will be casted from.
  8657. */
  8658. position: Vector3;
  8659. /**
  8660. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8661. */
  8662. direction: Vector3;
  8663. /**
  8664. * The transformed position. Position of the light in world space taking parenting in account.
  8665. */
  8666. transformedPosition: Vector3;
  8667. /**
  8668. * The transformed direction. Direction of the light in world space taking parenting in account.
  8669. */
  8670. transformedDirection: Vector3;
  8671. /**
  8672. * The friendly name of the light in the scene.
  8673. */
  8674. name: string;
  8675. /**
  8676. * Defines the shadow projection clipping minimum z value.
  8677. */
  8678. shadowMinZ: number;
  8679. /**
  8680. * Defines the shadow projection clipping maximum z value.
  8681. */
  8682. shadowMaxZ: number;
  8683. /**
  8684. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8685. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8686. */
  8687. computeTransformedInformation(): boolean;
  8688. /**
  8689. * Gets the scene the light belongs to.
  8690. * @returns The scene
  8691. */
  8692. getScene(): Scene;
  8693. /**
  8694. * Callback defining a custom Projection Matrix Builder.
  8695. * This can be used to override the default projection matrix computation.
  8696. */
  8697. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8698. /**
  8699. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8700. * @param matrix The materix to updated with the projection information
  8701. * @param viewMatrix The transform matrix of the light
  8702. * @param renderList The list of mesh to render in the map
  8703. * @returns The current light
  8704. */
  8705. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8706. /**
  8707. * Gets the current depth scale used in ESM.
  8708. * @returns The scale
  8709. */
  8710. getDepthScale(): number;
  8711. /**
  8712. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8713. * @returns true if a cube texture needs to be use
  8714. */
  8715. needCube(): boolean;
  8716. /**
  8717. * Detects if the projection matrix requires to be recomputed this frame.
  8718. * @returns true if it requires to be recomputed otherwise, false.
  8719. */
  8720. needProjectionMatrixCompute(): boolean;
  8721. /**
  8722. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8723. */
  8724. forceProjectionMatrixCompute(): void;
  8725. /**
  8726. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8727. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8728. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8729. */
  8730. getShadowDirection(faceIndex?: number): Vector3;
  8731. /**
  8732. * Gets the minZ used for shadow according to both the scene and the light.
  8733. * @param activeCamera The camera we are returning the min for
  8734. * @returns the depth min z
  8735. */
  8736. getDepthMinZ(activeCamera: Camera): number;
  8737. /**
  8738. * Gets the maxZ used for shadow according to both the scene and the light.
  8739. * @param activeCamera The camera we are returning the max for
  8740. * @returns the depth max z
  8741. */
  8742. getDepthMaxZ(activeCamera: Camera): number;
  8743. }
  8744. /**
  8745. * Base implementation IShadowLight
  8746. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8747. */
  8748. export abstract class ShadowLight extends Light implements IShadowLight {
  8749. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8750. protected _position: Vector3;
  8751. protected _setPosition(value: Vector3): void;
  8752. /**
  8753. * Sets the position the shadow will be casted from. Also use as the light position for both
  8754. * point and spot lights.
  8755. */
  8756. /**
  8757. * Sets the position the shadow will be casted from. Also use as the light position for both
  8758. * point and spot lights.
  8759. */
  8760. position: Vector3;
  8761. protected _direction: Vector3;
  8762. protected _setDirection(value: Vector3): void;
  8763. /**
  8764. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8765. * Also use as the light direction on spot and directional lights.
  8766. */
  8767. /**
  8768. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8769. * Also use as the light direction on spot and directional lights.
  8770. */
  8771. direction: Vector3;
  8772. private _shadowMinZ;
  8773. /**
  8774. * Gets the shadow projection clipping minimum z value.
  8775. */
  8776. /**
  8777. * Sets the shadow projection clipping minimum z value.
  8778. */
  8779. shadowMinZ: number;
  8780. private _shadowMaxZ;
  8781. /**
  8782. * Sets the shadow projection clipping maximum z value.
  8783. */
  8784. /**
  8785. * Gets the shadow projection clipping maximum z value.
  8786. */
  8787. shadowMaxZ: number;
  8788. /**
  8789. * Callback defining a custom Projection Matrix Builder.
  8790. * This can be used to override the default projection matrix computation.
  8791. */
  8792. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8793. /**
  8794. * The transformed position. Position of the light in world space taking parenting in account.
  8795. */
  8796. transformedPosition: Vector3;
  8797. /**
  8798. * The transformed direction. Direction of the light in world space taking parenting in account.
  8799. */
  8800. transformedDirection: Vector3;
  8801. private _needProjectionMatrixCompute;
  8802. /**
  8803. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8804. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8805. */
  8806. computeTransformedInformation(): boolean;
  8807. /**
  8808. * Return the depth scale used for the shadow map.
  8809. * @returns the depth scale.
  8810. */
  8811. getDepthScale(): number;
  8812. /**
  8813. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8814. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8815. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8816. */
  8817. getShadowDirection(faceIndex?: number): Vector3;
  8818. /**
  8819. * Returns the ShadowLight absolute position in the World.
  8820. * @returns the position vector in world space
  8821. */
  8822. getAbsolutePosition(): Vector3;
  8823. /**
  8824. * Sets the ShadowLight direction toward the passed target.
  8825. * @param target The point to target in local space
  8826. * @returns the updated ShadowLight direction
  8827. */
  8828. setDirectionToTarget(target: Vector3): Vector3;
  8829. /**
  8830. * Returns the light rotation in euler definition.
  8831. * @returns the x y z rotation in local space.
  8832. */
  8833. getRotation(): Vector3;
  8834. /**
  8835. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8836. * @returns true if a cube texture needs to be use
  8837. */
  8838. needCube(): boolean;
  8839. /**
  8840. * Detects if the projection matrix requires to be recomputed this frame.
  8841. * @returns true if it requires to be recomputed otherwise, false.
  8842. */
  8843. needProjectionMatrixCompute(): boolean;
  8844. /**
  8845. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8846. */
  8847. forceProjectionMatrixCompute(): void;
  8848. /** @hidden */
  8849. _initCache(): void;
  8850. /** @hidden */
  8851. _isSynchronized(): boolean;
  8852. /**
  8853. * Computes the world matrix of the node
  8854. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8855. * @returns the world matrix
  8856. */
  8857. computeWorldMatrix(force?: boolean): Matrix;
  8858. /**
  8859. * Gets the minZ used for shadow according to both the scene and the light.
  8860. * @param activeCamera The camera we are returning the min for
  8861. * @returns the depth min z
  8862. */
  8863. getDepthMinZ(activeCamera: Camera): number;
  8864. /**
  8865. * Gets the maxZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the max for
  8867. * @returns the depth max z
  8868. */
  8869. getDepthMaxZ(activeCamera: Camera): number;
  8870. /**
  8871. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8872. * @param matrix The materix to updated with the projection information
  8873. * @param viewMatrix The transform matrix of the light
  8874. * @param renderList The list of mesh to render in the map
  8875. * @returns The current light
  8876. */
  8877. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8878. }
  8879. }
  8880. declare module BABYLON {
  8881. /**
  8882. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8883. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8884. */
  8885. export class EffectFallbacks implements IEffectFallbacks {
  8886. private _defines;
  8887. private _currentRank;
  8888. private _maxRank;
  8889. private _mesh;
  8890. /**
  8891. * Removes the fallback from the bound mesh.
  8892. */
  8893. unBindMesh(): void;
  8894. /**
  8895. * Adds a fallback on the specified property.
  8896. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8897. * @param define The name of the define in the shader
  8898. */
  8899. addFallback(rank: number, define: string): void;
  8900. /**
  8901. * Sets the mesh to use CPU skinning when needing to fallback.
  8902. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8903. * @param mesh The mesh to use the fallbacks.
  8904. */
  8905. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8906. /**
  8907. * Checks to see if more fallbacks are still availible.
  8908. */
  8909. readonly hasMoreFallbacks: boolean;
  8910. /**
  8911. * Removes the defines that should be removed when falling back.
  8912. * @param currentDefines defines the current define statements for the shader.
  8913. * @param effect defines the current effect we try to compile
  8914. * @returns The resulting defines with defines of the current rank removed.
  8915. */
  8916. reduce(currentDefines: string, effect: Effect): string;
  8917. }
  8918. }
  8919. declare module BABYLON {
  8920. /**
  8921. * "Static Class" containing the most commonly used helper while dealing with material for
  8922. * rendering purpose.
  8923. *
  8924. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8925. *
  8926. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8927. */
  8928. export class MaterialHelper {
  8929. /**
  8930. * Bind the current view position to an effect.
  8931. * @param effect The effect to be bound
  8932. * @param scene The scene the eyes position is used from
  8933. */
  8934. static BindEyePosition(effect: Effect, scene: Scene): void;
  8935. /**
  8936. * Helps preparing the defines values about the UVs in used in the effect.
  8937. * UVs are shared as much as we can accross channels in the shaders.
  8938. * @param texture The texture we are preparing the UVs for
  8939. * @param defines The defines to update
  8940. * @param key The channel key "diffuse", "specular"... used in the shader
  8941. */
  8942. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8943. /**
  8944. * Binds a texture matrix value to its corrsponding uniform
  8945. * @param texture The texture to bind the matrix for
  8946. * @param uniformBuffer The uniform buffer receivin the data
  8947. * @param key The channel key "diffuse", "specular"... used in the shader
  8948. */
  8949. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8950. /**
  8951. * Gets the current status of the fog (should it be enabled?)
  8952. * @param mesh defines the mesh to evaluate for fog support
  8953. * @param scene defines the hosting scene
  8954. * @returns true if fog must be enabled
  8955. */
  8956. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8957. /**
  8958. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8959. * @param mesh defines the current mesh
  8960. * @param scene defines the current scene
  8961. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8962. * @param pointsCloud defines if point cloud rendering has to be turned on
  8963. * @param fogEnabled defines if fog has to be turned on
  8964. * @param alphaTest defines if alpha testing has to be turned on
  8965. * @param defines defines the current list of defines
  8966. */
  8967. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8968. /**
  8969. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8970. * @param scene defines the current scene
  8971. * @param engine defines the current engine
  8972. * @param defines specifies the list of active defines
  8973. * @param useInstances defines if instances have to be turned on
  8974. * @param useClipPlane defines if clip plane have to be turned on
  8975. */
  8976. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8977. /**
  8978. * Prepares the defines for bones
  8979. * @param mesh The mesh containing the geometry data we will draw
  8980. * @param defines The defines to update
  8981. */
  8982. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8983. /**
  8984. * Prepares the defines for morph targets
  8985. * @param mesh The mesh containing the geometry data we will draw
  8986. * @param defines The defines to update
  8987. */
  8988. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8989. /**
  8990. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8991. * @param mesh The mesh containing the geometry data we will draw
  8992. * @param defines The defines to update
  8993. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8994. * @param useBones Precise whether bones should be used or not (override mesh info)
  8995. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8996. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8997. * @returns false if defines are considered not dirty and have not been checked
  8998. */
  8999. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9000. /**
  9001. * Prepares the defines related to multiview
  9002. * @param scene The scene we are intending to draw
  9003. * @param defines The defines to update
  9004. */
  9005. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9006. /**
  9007. * Prepares the defines related to the light information passed in parameter
  9008. * @param scene The scene we are intending to draw
  9009. * @param mesh The mesh the effect is compiling for
  9010. * @param light The light the effect is compiling for
  9011. * @param lightIndex The index of the light
  9012. * @param defines The defines to update
  9013. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9014. * @param state Defines the current state regarding what is needed (normals, etc...)
  9015. */
  9016. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9017. needNormals: boolean;
  9018. needRebuild: boolean;
  9019. shadowEnabled: boolean;
  9020. specularEnabled: boolean;
  9021. lightmapMode: boolean;
  9022. }): void;
  9023. /**
  9024. * Prepares the defines related to the light information passed in parameter
  9025. * @param scene The scene we are intending to draw
  9026. * @param mesh The mesh the effect is compiling for
  9027. * @param defines The defines to update
  9028. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9029. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9030. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9031. * @returns true if normals will be required for the rest of the effect
  9032. */
  9033. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9034. /**
  9035. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9036. * @param lightIndex defines the light index
  9037. * @param uniformsList The uniform list
  9038. * @param samplersList The sampler list
  9039. * @param projectedLightTexture defines if projected texture must be used
  9040. * @param uniformBuffersList defines an optional list of uniform buffers
  9041. */
  9042. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9043. /**
  9044. * Prepares the uniforms and samplers list to be used in the effect
  9045. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9046. * @param samplersList The sampler list
  9047. * @param defines The defines helping in the list generation
  9048. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9049. */
  9050. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9051. /**
  9052. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9053. * @param defines The defines to update while falling back
  9054. * @param fallbacks The authorized effect fallbacks
  9055. * @param maxSimultaneousLights The maximum number of lights allowed
  9056. * @param rank the current rank of the Effect
  9057. * @returns The newly affected rank
  9058. */
  9059. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9060. private static _TmpMorphInfluencers;
  9061. /**
  9062. * Prepares the list of attributes required for morph targets according to the effect defines.
  9063. * @param attribs The current list of supported attribs
  9064. * @param mesh The mesh to prepare the morph targets attributes for
  9065. * @param influencers The number of influencers
  9066. */
  9067. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9068. /**
  9069. * Prepares the list of attributes required for morph targets according to the effect defines.
  9070. * @param attribs The current list of supported attribs
  9071. * @param mesh The mesh to prepare the morph targets attributes for
  9072. * @param defines The current Defines of the effect
  9073. */
  9074. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9075. /**
  9076. * Prepares the list of attributes required for bones according to the effect defines.
  9077. * @param attribs The current list of supported attribs
  9078. * @param mesh The mesh to prepare the bones attributes for
  9079. * @param defines The current Defines of the effect
  9080. * @param fallbacks The current efffect fallback strategy
  9081. */
  9082. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9083. /**
  9084. * Check and prepare the list of attributes required for instances according to the effect defines.
  9085. * @param attribs The current list of supported attribs
  9086. * @param defines The current MaterialDefines of the effect
  9087. */
  9088. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9089. /**
  9090. * Add the list of attributes required for instances to the attribs array.
  9091. * @param attribs The current list of supported attribs
  9092. */
  9093. static PushAttributesForInstances(attribs: string[]): void;
  9094. /**
  9095. * Binds the light shadow information to the effect for the given mesh.
  9096. * @param light The light containing the generator
  9097. * @param scene The scene the lights belongs to
  9098. * @param mesh The mesh we are binding the information to render
  9099. * @param lightIndex The light index in the effect used to render the mesh
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9103. /**
  9104. * Binds the light information to the effect.
  9105. * @param light The light containing the generator
  9106. * @param effect The effect we are binding the data to
  9107. * @param lightIndex The light index in the effect used to render
  9108. */
  9109. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9110. /**
  9111. * Binds the lights information from the scene to the effect for the given mesh.
  9112. * @param light Light to bind
  9113. * @param lightIndex Light index
  9114. * @param scene The scene where the light belongs to
  9115. * @param mesh The mesh we are binding the information to render
  9116. * @param effect The effect we are binding the data to
  9117. * @param useSpecular Defines if specular is supported
  9118. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9119. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9120. */
  9121. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9122. /**
  9123. * Binds the lights information from the scene to the effect for the given mesh.
  9124. * @param scene The scene the lights belongs to
  9125. * @param mesh The mesh we are binding the information to render
  9126. * @param effect The effect we are binding the data to
  9127. * @param defines The generated defines for the effect
  9128. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9129. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9130. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9131. */
  9132. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9133. private static _tempFogColor;
  9134. /**
  9135. * Binds the fog information from the scene to the effect for the given mesh.
  9136. * @param scene The scene the lights belongs to
  9137. * @param mesh The mesh we are binding the information to render
  9138. * @param effect The effect we are binding the data to
  9139. * @param linearSpace Defines if the fog effect is applied in linear space
  9140. */
  9141. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9142. /**
  9143. * Binds the bones information from the mesh to the effect.
  9144. * @param mesh The mesh we are binding the information to render
  9145. * @param effect The effect we are binding the data to
  9146. */
  9147. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9148. /**
  9149. * Binds the morph targets information from the mesh to the effect.
  9150. * @param abstractMesh The mesh we are binding the information to render
  9151. * @param effect The effect we are binding the data to
  9152. */
  9153. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9154. /**
  9155. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9156. * @param defines The generated defines used in the effect
  9157. * @param effect The effect we are binding the data to
  9158. * @param scene The scene we are willing to render with logarithmic scale for
  9159. */
  9160. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9161. /**
  9162. * Binds the clip plane information from the scene to the effect.
  9163. * @param scene The scene the clip plane information are extracted from
  9164. * @param effect The effect we are binding the data to
  9165. */
  9166. static BindClipPlane(effect: Effect, scene: Scene): void;
  9167. }
  9168. }
  9169. declare module BABYLON {
  9170. /** @hidden */
  9171. export var packingFunctions: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module BABYLON {
  9177. /** @hidden */
  9178. export var shadowMapPixelShader: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module BABYLON {
  9184. /** @hidden */
  9185. export var bonesDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module BABYLON {
  9191. /** @hidden */
  9192. export var morphTargetsVertexGlobalDeclaration: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module BABYLON {
  9198. /** @hidden */
  9199. export var morphTargetsVertexDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module BABYLON {
  9205. /** @hidden */
  9206. export var instancesDeclaration: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module BABYLON {
  9212. /** @hidden */
  9213. export var helperFunctions: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module BABYLON {
  9219. /** @hidden */
  9220. export var morphTargetsVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module BABYLON {
  9226. /** @hidden */
  9227. export var instancesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module BABYLON {
  9233. /** @hidden */
  9234. export var bonesVertex: {
  9235. name: string;
  9236. shader: string;
  9237. };
  9238. }
  9239. declare module BABYLON {
  9240. /** @hidden */
  9241. export var shadowMapVertexShader: {
  9242. name: string;
  9243. shader: string;
  9244. };
  9245. }
  9246. declare module BABYLON {
  9247. /** @hidden */
  9248. export var depthBoxBlurPixelShader: {
  9249. name: string;
  9250. shader: string;
  9251. };
  9252. }
  9253. declare module BABYLON {
  9254. /**
  9255. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9256. */
  9257. export interface ICustomShaderOptions {
  9258. /**
  9259. * Gets or sets the custom shader name to use
  9260. */
  9261. shaderName: string;
  9262. /**
  9263. * The list of attribute names used in the shader
  9264. */
  9265. attributes?: string[];
  9266. /**
  9267. * The list of unifrom names used in the shader
  9268. */
  9269. uniforms?: string[];
  9270. /**
  9271. * The list of sampler names used in the shader
  9272. */
  9273. samplers?: string[];
  9274. /**
  9275. * The list of defines used in the shader
  9276. */
  9277. defines?: string[];
  9278. }
  9279. /**
  9280. * Interface to implement to create a shadow generator compatible with BJS.
  9281. */
  9282. export interface IShadowGenerator {
  9283. /**
  9284. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9285. * @returns The render target texture if present otherwise, null
  9286. */
  9287. getShadowMap(): Nullable<RenderTargetTexture>;
  9288. /**
  9289. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9290. * @returns The render target texture if the shadow map is present otherwise, null
  9291. */
  9292. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9293. /**
  9294. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9295. * @param subMesh The submesh we want to render in the shadow map
  9296. * @param useInstances Defines wether will draw in the map using instances
  9297. * @returns true if ready otherwise, false
  9298. */
  9299. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9300. /**
  9301. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9302. * @param defines Defines of the material we want to update
  9303. * @param lightIndex Index of the light in the enabled light list of the material
  9304. */
  9305. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9306. /**
  9307. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9308. * defined in the generator but impacting the effect).
  9309. * It implies the unifroms available on the materials are the standard BJS ones.
  9310. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9311. * @param effect The effect we are binfing the information for
  9312. */
  9313. bindShadowLight(lightIndex: string, effect: Effect): void;
  9314. /**
  9315. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9316. * (eq to shadow prjection matrix * light transform matrix)
  9317. * @returns The transform matrix used to create the shadow map
  9318. */
  9319. getTransformMatrix(): Matrix;
  9320. /**
  9321. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9322. * Cube and 2D textures for instance.
  9323. */
  9324. recreateShadowMap(): void;
  9325. /**
  9326. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9327. * @param onCompiled Callback triggered at the and of the effects compilation
  9328. * @param options Sets of optional options forcing the compilation with different modes
  9329. */
  9330. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9331. useInstances: boolean;
  9332. }>): void;
  9333. /**
  9334. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9335. * @param options Sets of optional options forcing the compilation with different modes
  9336. * @returns A promise that resolves when the compilation completes
  9337. */
  9338. forceCompilationAsync(options?: Partial<{
  9339. useInstances: boolean;
  9340. }>): Promise<void>;
  9341. /**
  9342. * Serializes the shadow generator setup to a json object.
  9343. * @returns The serialized JSON object
  9344. */
  9345. serialize(): any;
  9346. /**
  9347. * Disposes the Shadow map and related Textures and effects.
  9348. */
  9349. dispose(): void;
  9350. }
  9351. /**
  9352. * Default implementation IShadowGenerator.
  9353. * This is the main object responsible of generating shadows in the framework.
  9354. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9355. */
  9356. export class ShadowGenerator implements IShadowGenerator {
  9357. /**
  9358. * Shadow generator mode None: no filtering applied.
  9359. */
  9360. static readonly FILTER_NONE: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9364. */
  9365. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9366. /**
  9367. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9368. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9369. */
  9370. static readonly FILTER_POISSONSAMPLING: number;
  9371. /**
  9372. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9374. */
  9375. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9376. /**
  9377. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9378. * edge artifacts on steep falloff.
  9379. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9380. */
  9381. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9382. /**
  9383. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9384. * edge artifacts on steep falloff.
  9385. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9386. */
  9387. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9388. /**
  9389. * Shadow generator mode PCF: Percentage Closer Filtering
  9390. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9391. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9392. */
  9393. static readonly FILTER_PCF: number;
  9394. /**
  9395. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9396. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9397. * Contact Hardening
  9398. */
  9399. static readonly FILTER_PCSS: number;
  9400. /**
  9401. * Reserved for PCF and PCSS
  9402. * Highest Quality.
  9403. *
  9404. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9405. *
  9406. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9407. */
  9408. static readonly QUALITY_HIGH: number;
  9409. /**
  9410. * Reserved for PCF and PCSS
  9411. * Good tradeoff for quality/perf cross devices
  9412. *
  9413. * Execute PCF on a 3*3 kernel.
  9414. *
  9415. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9416. */
  9417. static readonly QUALITY_MEDIUM: number;
  9418. /**
  9419. * Reserved for PCF and PCSS
  9420. * The lowest quality but the fastest.
  9421. *
  9422. * Execute PCF on a 1*1 kernel.
  9423. *
  9424. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9425. */
  9426. static readonly QUALITY_LOW: number;
  9427. /** Gets or sets the custom shader name to use */
  9428. customShaderOptions: ICustomShaderOptions;
  9429. /**
  9430. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9431. */
  9432. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9433. /**
  9434. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9435. */
  9436. onAfterShadowMapRenderObservable: Observable<Effect>;
  9437. /**
  9438. * Observable triggered before a mesh is rendered in the shadow map.
  9439. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9440. */
  9441. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9442. /**
  9443. * Observable triggered after a mesh is rendered in the shadow map.
  9444. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9445. */
  9446. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9447. private _bias;
  9448. /**
  9449. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9450. */
  9451. /**
  9452. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9453. */
  9454. bias: number;
  9455. private _normalBias;
  9456. /**
  9457. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9458. */
  9459. /**
  9460. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9461. */
  9462. normalBias: number;
  9463. private _blurBoxOffset;
  9464. /**
  9465. * Gets the blur box offset: offset applied during the blur pass.
  9466. * Only useful if useKernelBlur = false
  9467. */
  9468. /**
  9469. * Sets the blur box offset: offset applied during the blur pass.
  9470. * Only useful if useKernelBlur = false
  9471. */
  9472. blurBoxOffset: number;
  9473. private _blurScale;
  9474. /**
  9475. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9476. * 2 means half of the size.
  9477. */
  9478. /**
  9479. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9480. * 2 means half of the size.
  9481. */
  9482. blurScale: number;
  9483. private _blurKernel;
  9484. /**
  9485. * Gets the blur kernel: kernel size of the blur pass.
  9486. * Only useful if useKernelBlur = true
  9487. */
  9488. /**
  9489. * Sets the blur kernel: kernel size of the blur pass.
  9490. * Only useful if useKernelBlur = true
  9491. */
  9492. blurKernel: number;
  9493. private _useKernelBlur;
  9494. /**
  9495. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9496. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9497. */
  9498. /**
  9499. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9500. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9501. */
  9502. useKernelBlur: boolean;
  9503. private _depthScale;
  9504. /**
  9505. * Gets the depth scale used in ESM mode.
  9506. */
  9507. /**
  9508. * Sets the depth scale used in ESM mode.
  9509. * This can override the scale stored on the light.
  9510. */
  9511. depthScale: number;
  9512. private _filter;
  9513. /**
  9514. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9515. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9516. */
  9517. /**
  9518. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9519. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9520. */
  9521. filter: number;
  9522. /**
  9523. * Gets if the current filter is set to Poisson Sampling.
  9524. */
  9525. /**
  9526. * Sets the current filter to Poisson Sampling.
  9527. */
  9528. usePoissonSampling: boolean;
  9529. /**
  9530. * Gets if the current filter is set to ESM.
  9531. */
  9532. /**
  9533. * Sets the current filter is to ESM.
  9534. */
  9535. useExponentialShadowMap: boolean;
  9536. /**
  9537. * Gets if the current filter is set to filtered ESM.
  9538. */
  9539. /**
  9540. * Gets if the current filter is set to filtered ESM.
  9541. */
  9542. useBlurExponentialShadowMap: boolean;
  9543. /**
  9544. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9545. * exponential to prevent steep falloff artifacts).
  9546. */
  9547. /**
  9548. * Sets the current filter to "close ESM" (using the inverse of the
  9549. * exponential to prevent steep falloff artifacts).
  9550. */
  9551. useCloseExponentialShadowMap: boolean;
  9552. /**
  9553. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9554. * exponential to prevent steep falloff artifacts).
  9555. */
  9556. /**
  9557. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9558. * exponential to prevent steep falloff artifacts).
  9559. */
  9560. useBlurCloseExponentialShadowMap: boolean;
  9561. /**
  9562. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9563. */
  9564. /**
  9565. * Sets the current filter to "PCF" (percentage closer filtering).
  9566. */
  9567. usePercentageCloserFiltering: boolean;
  9568. private _filteringQuality;
  9569. /**
  9570. * Gets the PCF or PCSS Quality.
  9571. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9572. */
  9573. /**
  9574. * Sets the PCF or PCSS Quality.
  9575. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9576. */
  9577. filteringQuality: number;
  9578. /**
  9579. * Gets if the current filter is set to "PCSS" (contact hardening).
  9580. */
  9581. /**
  9582. * Sets the current filter to "PCSS" (contact hardening).
  9583. */
  9584. useContactHardeningShadow: boolean;
  9585. private _contactHardeningLightSizeUVRatio;
  9586. /**
  9587. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9588. * Using a ratio helps keeping shape stability independently of the map size.
  9589. *
  9590. * It does not account for the light projection as it was having too much
  9591. * instability during the light setup or during light position changes.
  9592. *
  9593. * Only valid if useContactHardeningShadow is true.
  9594. */
  9595. /**
  9596. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9597. * Using a ratio helps keeping shape stability independently of the map size.
  9598. *
  9599. * It does not account for the light projection as it was having too much
  9600. * instability during the light setup or during light position changes.
  9601. *
  9602. * Only valid if useContactHardeningShadow is true.
  9603. */
  9604. contactHardeningLightSizeUVRatio: number;
  9605. private _darkness;
  9606. /** Gets or sets the actual darkness of a shadow */
  9607. darkness: number;
  9608. /**
  9609. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9610. * 0 means strongest and 1 would means no shadow.
  9611. * @returns the darkness.
  9612. */
  9613. getDarkness(): number;
  9614. /**
  9615. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9616. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9617. * @returns the shadow generator allowing fluent coding.
  9618. */
  9619. setDarkness(darkness: number): ShadowGenerator;
  9620. private _transparencyShadow;
  9621. /** Gets or sets the ability to have transparent shadow */
  9622. transparencyShadow: boolean;
  9623. /**
  9624. * Sets the ability to have transparent shadow (boolean).
  9625. * @param transparent True if transparent else False
  9626. * @returns the shadow generator allowing fluent coding
  9627. */
  9628. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9629. private _shadowMap;
  9630. private _shadowMap2;
  9631. /**
  9632. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9633. * @returns The render target texture if present otherwise, null
  9634. */
  9635. getShadowMap(): Nullable<RenderTargetTexture>;
  9636. /**
  9637. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9638. * @returns The render target texture if the shadow map is present otherwise, null
  9639. */
  9640. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9641. /**
  9642. * Gets the class name of that object
  9643. * @returns "ShadowGenerator"
  9644. */
  9645. getClassName(): string;
  9646. /**
  9647. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9648. * @param mesh Mesh to add
  9649. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9650. * @returns the Shadow Generator itself
  9651. */
  9652. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9653. /**
  9654. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9655. * @param mesh Mesh to remove
  9656. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9657. * @returns the Shadow Generator itself
  9658. */
  9659. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9660. /**
  9661. * Controls the extent to which the shadows fade out at the edge of the frustum
  9662. * Used only by directionals and spots
  9663. */
  9664. frustumEdgeFalloff: number;
  9665. private _light;
  9666. /**
  9667. * Returns the associated light object.
  9668. * @returns the light generating the shadow
  9669. */
  9670. getLight(): IShadowLight;
  9671. /**
  9672. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9673. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9674. * It might on the other hand introduce peter panning.
  9675. */
  9676. forceBackFacesOnly: boolean;
  9677. private _scene;
  9678. private _lightDirection;
  9679. private _effect;
  9680. private _viewMatrix;
  9681. private _projectionMatrix;
  9682. private _transformMatrix;
  9683. private _cachedPosition;
  9684. private _cachedDirection;
  9685. private _cachedDefines;
  9686. private _currentRenderID;
  9687. private _boxBlurPostprocess;
  9688. private _kernelBlurXPostprocess;
  9689. private _kernelBlurYPostprocess;
  9690. private _blurPostProcesses;
  9691. private _mapSize;
  9692. private _currentFaceIndex;
  9693. private _currentFaceIndexCache;
  9694. private _textureType;
  9695. private _defaultTextureMatrix;
  9696. /** @hidden */
  9697. static _SceneComponentInitialization: (scene: Scene) => void;
  9698. /**
  9699. * Creates a ShadowGenerator object.
  9700. * A ShadowGenerator is the required tool to use the shadows.
  9701. * Each light casting shadows needs to use its own ShadowGenerator.
  9702. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9703. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9704. * @param light The light object generating the shadows.
  9705. * @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.
  9706. */
  9707. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9708. private _initializeGenerator;
  9709. private _initializeShadowMap;
  9710. private _initializeBlurRTTAndPostProcesses;
  9711. private _renderForShadowMap;
  9712. private _renderSubMeshForShadowMap;
  9713. private _applyFilterValues;
  9714. /**
  9715. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9716. * @param onCompiled Callback triggered at the and of the effects compilation
  9717. * @param options Sets of optional options forcing the compilation with different modes
  9718. */
  9719. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9720. useInstances: boolean;
  9721. }>): void;
  9722. /**
  9723. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9724. * @param options Sets of optional options forcing the compilation with different modes
  9725. * @returns A promise that resolves when the compilation completes
  9726. */
  9727. forceCompilationAsync(options?: Partial<{
  9728. useInstances: boolean;
  9729. }>): Promise<void>;
  9730. /**
  9731. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9732. * @param subMesh The submesh we want to render in the shadow map
  9733. * @param useInstances Defines wether will draw in the map using instances
  9734. * @returns true if ready otherwise, false
  9735. */
  9736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9737. /**
  9738. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9739. * @param defines Defines of the material we want to update
  9740. * @param lightIndex Index of the light in the enabled light list of the material
  9741. */
  9742. prepareDefines(defines: any, lightIndex: number): void;
  9743. /**
  9744. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9745. * defined in the generator but impacting the effect).
  9746. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9747. * @param effect The effect we are binfing the information for
  9748. */
  9749. bindShadowLight(lightIndex: string, effect: Effect): void;
  9750. /**
  9751. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9752. * (eq to shadow prjection matrix * light transform matrix)
  9753. * @returns The transform matrix used to create the shadow map
  9754. */
  9755. getTransformMatrix(): Matrix;
  9756. /**
  9757. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9758. * Cube and 2D textures for instance.
  9759. */
  9760. recreateShadowMap(): void;
  9761. private _disposeBlurPostProcesses;
  9762. private _disposeRTTandPostProcesses;
  9763. /**
  9764. * Disposes the ShadowGenerator.
  9765. * Returns nothing.
  9766. */
  9767. dispose(): void;
  9768. /**
  9769. * Serializes the shadow generator setup to a json object.
  9770. * @returns The serialized JSON object
  9771. */
  9772. serialize(): any;
  9773. /**
  9774. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9775. * @param parsedShadowGenerator The JSON object to parse
  9776. * @param scene The scene to create the shadow map for
  9777. * @returns The parsed shadow generator
  9778. */
  9779. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9780. }
  9781. }
  9782. declare module BABYLON {
  9783. /**
  9784. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9785. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9786. * 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.
  9787. */
  9788. export abstract class Light extends Node {
  9789. /**
  9790. * Falloff Default: light is falling off following the material specification:
  9791. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9792. */
  9793. static readonly FALLOFF_DEFAULT: number;
  9794. /**
  9795. * Falloff Physical: light is falling off following the inverse squared distance law.
  9796. */
  9797. static readonly FALLOFF_PHYSICAL: number;
  9798. /**
  9799. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9800. * to enhance interoperability with other engines.
  9801. */
  9802. static readonly FALLOFF_GLTF: number;
  9803. /**
  9804. * Falloff Standard: light is falling off like in the standard material
  9805. * to enhance interoperability with other materials.
  9806. */
  9807. static readonly FALLOFF_STANDARD: number;
  9808. /**
  9809. * If every light affecting the material is in this lightmapMode,
  9810. * material.lightmapTexture adds or multiplies
  9811. * (depends on material.useLightmapAsShadowmap)
  9812. * after every other light calculations.
  9813. */
  9814. static readonly LIGHTMAP_DEFAULT: number;
  9815. /**
  9816. * material.lightmapTexture as only diffuse lighting from this light
  9817. * adds only specular lighting from this light
  9818. * adds dynamic shadows
  9819. */
  9820. static readonly LIGHTMAP_SPECULAR: number;
  9821. /**
  9822. * material.lightmapTexture as only lighting
  9823. * no light calculation from this light
  9824. * only adds dynamic shadows from this light
  9825. */
  9826. static readonly LIGHTMAP_SHADOWSONLY: number;
  9827. /**
  9828. * Each light type uses the default quantity according to its type:
  9829. * point/spot lights use luminous intensity
  9830. * directional lights use illuminance
  9831. */
  9832. static readonly INTENSITYMODE_AUTOMATIC: number;
  9833. /**
  9834. * lumen (lm)
  9835. */
  9836. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9837. /**
  9838. * candela (lm/sr)
  9839. */
  9840. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9841. /**
  9842. * lux (lm/m^2)
  9843. */
  9844. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9845. /**
  9846. * nit (cd/m^2)
  9847. */
  9848. static readonly INTENSITYMODE_LUMINANCE: number;
  9849. /**
  9850. * Light type const id of the point light.
  9851. */
  9852. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9853. /**
  9854. * Light type const id of the directional light.
  9855. */
  9856. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9857. /**
  9858. * Light type const id of the spot light.
  9859. */
  9860. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9861. /**
  9862. * Light type const id of the hemispheric light.
  9863. */
  9864. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9865. /**
  9866. * Diffuse gives the basic color to an object.
  9867. */
  9868. diffuse: Color3;
  9869. /**
  9870. * Specular produces a highlight color on an object.
  9871. * Note: This is note affecting PBR materials.
  9872. */
  9873. specular: Color3;
  9874. /**
  9875. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9876. * falling off base on range or angle.
  9877. * This can be set to any values in Light.FALLOFF_x.
  9878. *
  9879. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9880. * other types of materials.
  9881. */
  9882. falloffType: number;
  9883. /**
  9884. * Strength of the light.
  9885. * Note: By default it is define in the framework own unit.
  9886. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9887. */
  9888. intensity: number;
  9889. private _range;
  9890. protected _inverseSquaredRange: number;
  9891. /**
  9892. * Defines how far from the source the light is impacting in scene units.
  9893. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9894. */
  9895. /**
  9896. * Defines how far from the source the light is impacting in scene units.
  9897. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9898. */
  9899. range: number;
  9900. /**
  9901. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9902. * of light.
  9903. */
  9904. private _photometricScale;
  9905. private _intensityMode;
  9906. /**
  9907. * Gets the photometric scale used to interpret the intensity.
  9908. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9909. */
  9910. /**
  9911. * Sets the photometric scale used to interpret the intensity.
  9912. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9913. */
  9914. intensityMode: number;
  9915. private _radius;
  9916. /**
  9917. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9918. */
  9919. /**
  9920. * sets the light radius used by PBR Materials to simulate soft area lights.
  9921. */
  9922. radius: number;
  9923. private _renderPriority;
  9924. /**
  9925. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9926. * exceeding the number allowed of the materials.
  9927. */
  9928. renderPriority: number;
  9929. private _shadowEnabled;
  9930. /**
  9931. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9932. * the current shadow generator.
  9933. */
  9934. /**
  9935. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9936. * the current shadow generator.
  9937. */
  9938. shadowEnabled: boolean;
  9939. private _includedOnlyMeshes;
  9940. /**
  9941. * Gets the only meshes impacted by this light.
  9942. */
  9943. /**
  9944. * Sets the only meshes impacted by this light.
  9945. */
  9946. includedOnlyMeshes: AbstractMesh[];
  9947. private _excludedMeshes;
  9948. /**
  9949. * Gets the meshes not impacted by this light.
  9950. */
  9951. /**
  9952. * Sets the meshes not impacted by this light.
  9953. */
  9954. excludedMeshes: AbstractMesh[];
  9955. private _excludeWithLayerMask;
  9956. /**
  9957. * Gets the layer id use to find what meshes are not impacted by the light.
  9958. * Inactive if 0
  9959. */
  9960. /**
  9961. * Sets the layer id use to find what meshes are not impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. excludeWithLayerMask: number;
  9965. private _includeOnlyWithLayerMask;
  9966. /**
  9967. * Gets the layer id use to find what meshes are impacted by the light.
  9968. * Inactive if 0
  9969. */
  9970. /**
  9971. * Sets the layer id use to find what meshes are impacted by the light.
  9972. * Inactive if 0
  9973. */
  9974. includeOnlyWithLayerMask: number;
  9975. private _lightmapMode;
  9976. /**
  9977. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9978. */
  9979. /**
  9980. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9981. */
  9982. lightmapMode: number;
  9983. /**
  9984. * Shadow generator associted to the light.
  9985. * @hidden Internal use only.
  9986. */
  9987. _shadowGenerator: Nullable<IShadowGenerator>;
  9988. /**
  9989. * @hidden Internal use only.
  9990. */
  9991. _excludedMeshesIds: string[];
  9992. /**
  9993. * @hidden Internal use only.
  9994. */
  9995. _includedOnlyMeshesIds: string[];
  9996. /**
  9997. * The current light unifom buffer.
  9998. * @hidden Internal use only.
  9999. */
  10000. _uniformBuffer: UniformBuffer;
  10001. /**
  10002. * Creates a Light object in the scene.
  10003. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10004. * @param name The firendly name of the light
  10005. * @param scene The scene the light belongs too
  10006. */
  10007. constructor(name: string, scene: Scene);
  10008. protected abstract _buildUniformLayout(): void;
  10009. /**
  10010. * Sets the passed Effect "effect" with the Light information.
  10011. * @param effect The effect to update
  10012. * @param lightIndex The index of the light in the effect to update
  10013. * @returns The light
  10014. */
  10015. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10016. /**
  10017. * Sets the passed Effect "effect" with the Light information.
  10018. * @param effect The effect to update
  10019. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10020. * @returns The light
  10021. */
  10022. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10023. /**
  10024. * Returns the string "Light".
  10025. * @returns the class name
  10026. */
  10027. getClassName(): string;
  10028. /** @hidden */
  10029. readonly _isLight: boolean;
  10030. /**
  10031. * Converts the light information to a readable string for debug purpose.
  10032. * @param fullDetails Supports for multiple levels of logging within scene loading
  10033. * @returns the human readable light info
  10034. */
  10035. toString(fullDetails?: boolean): string;
  10036. /** @hidden */
  10037. protected _syncParentEnabledState(): void;
  10038. /**
  10039. * Set the enabled state of this node.
  10040. * @param value - the new enabled state
  10041. */
  10042. setEnabled(value: boolean): void;
  10043. /**
  10044. * Returns the Light associated shadow generator if any.
  10045. * @return the associated shadow generator.
  10046. */
  10047. getShadowGenerator(): Nullable<IShadowGenerator>;
  10048. /**
  10049. * Returns a Vector3, the absolute light position in the World.
  10050. * @returns the world space position of the light
  10051. */
  10052. getAbsolutePosition(): Vector3;
  10053. /**
  10054. * Specifies if the light will affect the passed mesh.
  10055. * @param mesh The mesh to test against the light
  10056. * @return true the mesh is affected otherwise, false.
  10057. */
  10058. canAffectMesh(mesh: AbstractMesh): boolean;
  10059. /**
  10060. * Sort function to order lights for rendering.
  10061. * @param a First Light object to compare to second.
  10062. * @param b Second Light object to compare first.
  10063. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10064. */
  10065. static CompareLightsPriority(a: Light, b: Light): number;
  10066. /**
  10067. * Releases resources associated with this node.
  10068. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10069. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10070. */
  10071. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10072. /**
  10073. * Returns the light type ID (integer).
  10074. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10075. */
  10076. getTypeID(): number;
  10077. /**
  10078. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10079. * @returns the scaled intensity in intensity mode unit
  10080. */
  10081. getScaledIntensity(): number;
  10082. /**
  10083. * Returns a new Light object, named "name", from the current one.
  10084. * @param name The name of the cloned light
  10085. * @returns the new created light
  10086. */
  10087. clone(name: string): Nullable<Light>;
  10088. /**
  10089. * Serializes the current light into a Serialization object.
  10090. * @returns the serialized object.
  10091. */
  10092. serialize(): any;
  10093. /**
  10094. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10095. * This new light is named "name" and added to the passed scene.
  10096. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10097. * @param name The friendly name of the light
  10098. * @param scene The scene the new light will belong to
  10099. * @returns the constructor function
  10100. */
  10101. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10102. /**
  10103. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10104. * @param parsedLight The JSON representation of the light
  10105. * @param scene The scene to create the parsed light in
  10106. * @returns the created light after parsing
  10107. */
  10108. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10109. private _hookArrayForExcluded;
  10110. private _hookArrayForIncludedOnly;
  10111. private _resyncMeshes;
  10112. /**
  10113. * Forces the meshes to update their light related information in their rendering used effects
  10114. * @hidden Internal Use Only
  10115. */
  10116. _markMeshesAsLightDirty(): void;
  10117. /**
  10118. * Recomputes the cached photometric scale if needed.
  10119. */
  10120. private _computePhotometricScale;
  10121. /**
  10122. * Returns the Photometric Scale according to the light type and intensity mode.
  10123. */
  10124. private _getPhotometricScale;
  10125. /**
  10126. * Reorder the light in the scene according to their defined priority.
  10127. * @hidden Internal Use Only
  10128. */
  10129. _reorderLightsInScene(): void;
  10130. /**
  10131. * Prepares the list of defines specific to the light type.
  10132. * @param defines the list of defines
  10133. * @param lightIndex defines the index of the light for the effect
  10134. */
  10135. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10136. }
  10137. }
  10138. declare module BABYLON {
  10139. /**
  10140. * Interface used to define Action
  10141. */
  10142. export interface IAction {
  10143. /**
  10144. * Trigger for the action
  10145. */
  10146. trigger: number;
  10147. /** Options of the trigger */
  10148. triggerOptions: any;
  10149. /**
  10150. * Gets the trigger parameters
  10151. * @returns the trigger parameters
  10152. */
  10153. getTriggerParameter(): any;
  10154. /**
  10155. * Internal only - executes current action event
  10156. * @hidden
  10157. */
  10158. _executeCurrent(evt?: ActionEvent): void;
  10159. /**
  10160. * Serialize placeholder for child classes
  10161. * @param parent of child
  10162. * @returns the serialized object
  10163. */
  10164. serialize(parent: any): any;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _prepare(): void;
  10170. /**
  10171. * Internal only - manager for action
  10172. * @hidden
  10173. */
  10174. _actionManager: AbstractActionManager;
  10175. /**
  10176. * Adds action to chain of actions, may be a DoNothingAction
  10177. * @param action defines the next action to execute
  10178. * @returns The action passed in
  10179. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10180. */
  10181. then(action: IAction): IAction;
  10182. }
  10183. /**
  10184. * The action to be carried out following a trigger
  10185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10186. */
  10187. export class Action implements IAction {
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any;
  10190. /**
  10191. * Trigger for the action
  10192. */
  10193. trigger: number;
  10194. /**
  10195. * Internal only - manager for action
  10196. * @hidden
  10197. */
  10198. _actionManager: ActionManager;
  10199. private _nextActiveAction;
  10200. private _child;
  10201. private _condition?;
  10202. private _triggerParameter;
  10203. /**
  10204. * An event triggered prior to action being executed.
  10205. */
  10206. onBeforeExecuteObservable: Observable<Action>;
  10207. /**
  10208. * Creates a new Action
  10209. * @param triggerOptions the trigger, with or without parameters, for the action
  10210. * @param condition an optional determinant of action
  10211. */
  10212. constructor(
  10213. /** the trigger, with or without parameters, for the action */
  10214. triggerOptions: any, condition?: Condition);
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. _prepare(): void;
  10220. /**
  10221. * Gets the trigger parameters
  10222. * @returns the trigger parameters
  10223. */
  10224. getTriggerParameter(): any;
  10225. /**
  10226. * Internal only - executes current action event
  10227. * @hidden
  10228. */
  10229. _executeCurrent(evt?: ActionEvent): void;
  10230. /**
  10231. * Execute placeholder for child classes
  10232. * @param evt optional action event
  10233. */
  10234. execute(evt?: ActionEvent): void;
  10235. /**
  10236. * Skips to next active action
  10237. */
  10238. skipToNextActiveAction(): void;
  10239. /**
  10240. * Adds action to chain of actions, may be a DoNothingAction
  10241. * @param action defines the next action to execute
  10242. * @returns The action passed in
  10243. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10244. */
  10245. then(action: Action): Action;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. _getProperty(propertyPath: string): string;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. _getEffectiveTarget(target: any, propertyPath: string): any;
  10256. /**
  10257. * Serialize placeholder for child classes
  10258. * @param parent of child
  10259. * @returns the serialized object
  10260. */
  10261. serialize(parent: any): any;
  10262. /**
  10263. * Internal only called by serialize
  10264. * @hidden
  10265. */
  10266. protected _serialize(serializedAction: any, parent?: any): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. static _SerializeValueAsString: (value: any) => string;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. static _GetTargetProperty: (target: Node | Scene) => {
  10277. name: string;
  10278. targetType: string;
  10279. value: string;
  10280. };
  10281. }
  10282. }
  10283. declare module BABYLON {
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module BABYLON {
  10494. /**
  10495. * This defines an action responsible to toggle a boolean once triggered.
  10496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10497. */
  10498. export class SwitchBooleanAction extends Action {
  10499. /**
  10500. * The path to the boolean property in the target object
  10501. */
  10502. propertyPath: string;
  10503. private _target;
  10504. private _effectiveTarget;
  10505. private _property;
  10506. /**
  10507. * Instantiate the action
  10508. * @param triggerOptions defines the trigger options
  10509. * @param target defines the object containing the boolean
  10510. * @param propertyPath defines the path to the boolean property in the target object
  10511. * @param condition defines the trigger related conditions
  10512. */
  10513. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10514. /** @hidden */
  10515. _prepare(): void;
  10516. /**
  10517. * Execute the action toggle the boolean value.
  10518. */
  10519. execute(): void;
  10520. /**
  10521. * Serializes the actions and its related information.
  10522. * @param parent defines the object to serialize in
  10523. * @returns the serialized object
  10524. */
  10525. serialize(parent: any): any;
  10526. }
  10527. /**
  10528. * This defines an action responsible to set a the state field of the target
  10529. * to a desired value once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class SetStateAction extends Action {
  10533. /**
  10534. * The value to store in the state field.
  10535. */
  10536. value: string;
  10537. private _target;
  10538. /**
  10539. * Instantiate the action
  10540. * @param triggerOptions defines the trigger options
  10541. * @param target defines the object containing the state property
  10542. * @param value defines the value to store in the state field
  10543. * @param condition defines the trigger related conditions
  10544. */
  10545. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10546. /**
  10547. * Execute the action and store the value on the target state property.
  10548. */
  10549. execute(): void;
  10550. /**
  10551. * Serializes the actions and its related information.
  10552. * @param parent defines the object to serialize in
  10553. * @returns the serialized object
  10554. */
  10555. serialize(parent: any): any;
  10556. }
  10557. /**
  10558. * This defines an action responsible to set a property of the target
  10559. * to a desired value once triggered.
  10560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10561. */
  10562. export class SetValueAction extends Action {
  10563. /**
  10564. * The path of the property to set in the target.
  10565. */
  10566. propertyPath: string;
  10567. /**
  10568. * The value to set in the property
  10569. */
  10570. value: any;
  10571. private _target;
  10572. private _effectiveTarget;
  10573. private _property;
  10574. /**
  10575. * Instantiate the action
  10576. * @param triggerOptions defines the trigger options
  10577. * @param target defines the object containing the property
  10578. * @param propertyPath defines the path of the property to set in the target
  10579. * @param value defines the value to set in the property
  10580. * @param condition defines the trigger related conditions
  10581. */
  10582. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10583. /** @hidden */
  10584. _prepare(): void;
  10585. /**
  10586. * Execute the action and set the targetted property to the desired value.
  10587. */
  10588. execute(): void;
  10589. /**
  10590. * Serializes the actions and its related information.
  10591. * @param parent defines the object to serialize in
  10592. * @returns the serialized object
  10593. */
  10594. serialize(parent: any): any;
  10595. }
  10596. /**
  10597. * This defines an action responsible to increment the target value
  10598. * to a desired value once triggered.
  10599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10600. */
  10601. export class IncrementValueAction extends Action {
  10602. /**
  10603. * The path of the property to increment in the target.
  10604. */
  10605. propertyPath: string;
  10606. /**
  10607. * The value we should increment the property by.
  10608. */
  10609. value: any;
  10610. private _target;
  10611. private _effectiveTarget;
  10612. private _property;
  10613. /**
  10614. * Instantiate the action
  10615. * @param triggerOptions defines the trigger options
  10616. * @param target defines the object containing the property
  10617. * @param propertyPath defines the path of the property to increment in the target
  10618. * @param value defines the value value we should increment the property by
  10619. * @param condition defines the trigger related conditions
  10620. */
  10621. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10622. /** @hidden */
  10623. _prepare(): void;
  10624. /**
  10625. * Execute the action and increment the target of the value amount.
  10626. */
  10627. execute(): void;
  10628. /**
  10629. * Serializes the actions and its related information.
  10630. * @param parent defines the object to serialize in
  10631. * @returns the serialized object
  10632. */
  10633. serialize(parent: any): any;
  10634. }
  10635. /**
  10636. * This defines an action responsible to start an animation once triggered.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class PlayAnimationAction extends Action {
  10640. /**
  10641. * Where the animation should start (animation frame)
  10642. */
  10643. from: number;
  10644. /**
  10645. * Where the animation should stop (animation frame)
  10646. */
  10647. to: number;
  10648. /**
  10649. * Define if the animation should loop or stop after the first play.
  10650. */
  10651. loop?: boolean;
  10652. private _target;
  10653. /**
  10654. * Instantiate the action
  10655. * @param triggerOptions defines the trigger options
  10656. * @param target defines the target animation or animation name
  10657. * @param from defines from where the animation should start (animation frame)
  10658. * @param end defines where the animation should stop (animation frame)
  10659. * @param loop defines if the animation should loop or stop after the first play
  10660. * @param condition defines the trigger related conditions
  10661. */
  10662. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10663. /** @hidden */
  10664. _prepare(): void;
  10665. /**
  10666. * Execute the action and play the animation.
  10667. */
  10668. execute(): void;
  10669. /**
  10670. * Serializes the actions and its related information.
  10671. * @param parent defines the object to serialize in
  10672. * @returns the serialized object
  10673. */
  10674. serialize(parent: any): any;
  10675. }
  10676. /**
  10677. * This defines an action responsible to stop an animation once triggered.
  10678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10679. */
  10680. export class StopAnimationAction extends Action {
  10681. private _target;
  10682. /**
  10683. * Instantiate the action
  10684. * @param triggerOptions defines the trigger options
  10685. * @param target defines the target animation or animation name
  10686. * @param condition defines the trigger related conditions
  10687. */
  10688. constructor(triggerOptions: any, target: any, condition?: Condition);
  10689. /** @hidden */
  10690. _prepare(): void;
  10691. /**
  10692. * Execute the action and stop the animation.
  10693. */
  10694. execute(): void;
  10695. /**
  10696. * Serializes the actions and its related information.
  10697. * @param parent defines the object to serialize in
  10698. * @returns the serialized object
  10699. */
  10700. serialize(parent: any): any;
  10701. }
  10702. /**
  10703. * This defines an action responsible that does nothing once triggered.
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10705. */
  10706. export class DoNothingAction extends Action {
  10707. /**
  10708. * Instantiate the action
  10709. * @param triggerOptions defines the trigger options
  10710. * @param condition defines the trigger related conditions
  10711. */
  10712. constructor(triggerOptions?: any, condition?: Condition);
  10713. /**
  10714. * Execute the action and do nothing.
  10715. */
  10716. execute(): void;
  10717. /**
  10718. * Serializes the actions and its related information.
  10719. * @param parent defines the object to serialize in
  10720. * @returns the serialized object
  10721. */
  10722. serialize(parent: any): any;
  10723. }
  10724. /**
  10725. * This defines an action responsible to trigger several actions once triggered.
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10727. */
  10728. export class CombineAction extends Action {
  10729. /**
  10730. * The list of aggregated animations to run.
  10731. */
  10732. children: Action[];
  10733. /**
  10734. * Instantiate the action
  10735. * @param triggerOptions defines the trigger options
  10736. * @param children defines the list of aggregated animations to run
  10737. * @param condition defines the trigger related conditions
  10738. */
  10739. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10740. /** @hidden */
  10741. _prepare(): void;
  10742. /**
  10743. * Execute the action and executes all the aggregated actions.
  10744. */
  10745. execute(evt: ActionEvent): void;
  10746. /**
  10747. * Serializes the actions and its related information.
  10748. * @param parent defines the object to serialize in
  10749. * @returns the serialized object
  10750. */
  10751. serialize(parent: any): any;
  10752. }
  10753. /**
  10754. * This defines an action responsible to run code (external event) once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class ExecuteCodeAction extends Action {
  10758. /**
  10759. * The callback function to run.
  10760. */
  10761. func: (evt: ActionEvent) => void;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param func defines the callback function to run
  10766. * @param condition defines the trigger related conditions
  10767. */
  10768. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10769. /**
  10770. * Execute the action and run the attached code.
  10771. */
  10772. execute(evt: ActionEvent): void;
  10773. }
  10774. /**
  10775. * This defines an action responsible to set the parent property of the target once triggered.
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10777. */
  10778. export class SetParentAction extends Action {
  10779. private _parent;
  10780. private _target;
  10781. /**
  10782. * Instantiate the action
  10783. * @param triggerOptions defines the trigger options
  10784. * @param target defines the target containing the parent property
  10785. * @param parent defines from where the animation should start (animation frame)
  10786. * @param condition defines the trigger related conditions
  10787. */
  10788. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10789. /** @hidden */
  10790. _prepare(): void;
  10791. /**
  10792. * Execute the action and set the parent property.
  10793. */
  10794. execute(): void;
  10795. /**
  10796. * Serializes the actions and its related information.
  10797. * @param parent defines the object to serialize in
  10798. * @returns the serialized object
  10799. */
  10800. serialize(parent: any): any;
  10801. }
  10802. }
  10803. declare module BABYLON {
  10804. /**
  10805. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10806. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10808. */
  10809. export class ActionManager extends AbstractActionManager {
  10810. /**
  10811. * Nothing
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly NothingTrigger: number;
  10815. /**
  10816. * On pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnPickTrigger: number;
  10820. /**
  10821. * On left pick
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnLeftPickTrigger: number;
  10825. /**
  10826. * On right pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnRightPickTrigger: number;
  10830. /**
  10831. * On center pick
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnCenterPickTrigger: number;
  10835. /**
  10836. * On pick down
  10837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10838. */
  10839. static readonly OnPickDownTrigger: number;
  10840. /**
  10841. * On double pick
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10843. */
  10844. static readonly OnDoublePickTrigger: number;
  10845. /**
  10846. * On pick up
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10848. */
  10849. static readonly OnPickUpTrigger: number;
  10850. /**
  10851. * On pick out.
  10852. * This trigger will only be raised if you also declared a OnPickDown
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPickOutTrigger: number;
  10856. /**
  10857. * On long press
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnLongPressTrigger: number;
  10861. /**
  10862. * On pointer over
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnPointerOverTrigger: number;
  10866. /**
  10867. * On pointer out
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnPointerOutTrigger: number;
  10871. /**
  10872. * On every frame
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnEveryFrameTrigger: number;
  10876. /**
  10877. * On intersection enter
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnIntersectionEnterTrigger: number;
  10881. /**
  10882. * On intersection exit
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnIntersectionExitTrigger: number;
  10886. /**
  10887. * On key down
  10888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10889. */
  10890. static readonly OnKeyDownTrigger: number;
  10891. /**
  10892. * On key up
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnKeyUpTrigger: number;
  10896. private _scene;
  10897. /**
  10898. * Creates a new action manager
  10899. * @param scene defines the hosting scene
  10900. */
  10901. constructor(scene: Scene);
  10902. /**
  10903. * Releases all associated resources
  10904. */
  10905. dispose(): void;
  10906. /**
  10907. * Gets hosting scene
  10908. * @returns the hosting scene
  10909. */
  10910. getScene(): Scene;
  10911. /**
  10912. * Does this action manager handles actions of any of the given triggers
  10913. * @param triggers defines the triggers to be tested
  10914. * @return a boolean indicating whether one (or more) of the triggers is handled
  10915. */
  10916. hasSpecificTriggers(triggers: number[]): boolean;
  10917. /**
  10918. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10919. * speed.
  10920. * @param triggerA defines the trigger to be tested
  10921. * @param triggerB defines the trigger to be tested
  10922. * @return a boolean indicating whether one (or more) of the triggers is handled
  10923. */
  10924. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10925. /**
  10926. * Does this action manager handles actions of a given trigger
  10927. * @param trigger defines the trigger to be tested
  10928. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10929. * @return whether the trigger is handled
  10930. */
  10931. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10932. /**
  10933. * Does this action manager has pointer triggers
  10934. */
  10935. readonly hasPointerTriggers: boolean;
  10936. /**
  10937. * Does this action manager has pick triggers
  10938. */
  10939. readonly hasPickTriggers: boolean;
  10940. /**
  10941. * Registers an action to this action manager
  10942. * @param action defines the action to be registered
  10943. * @return the action amended (prepared) after registration
  10944. */
  10945. registerAction(action: IAction): Nullable<IAction>;
  10946. /**
  10947. * Unregisters an action to this action manager
  10948. * @param action defines the action to be unregistered
  10949. * @return a boolean indicating whether the action has been unregistered
  10950. */
  10951. unregisterAction(action: IAction): Boolean;
  10952. /**
  10953. * Process a specific trigger
  10954. * @param trigger defines the trigger to process
  10955. * @param evt defines the event details to be processed
  10956. */
  10957. processTrigger(trigger: number, evt?: IActionEvent): void;
  10958. /** @hidden */
  10959. _getEffectiveTarget(target: any, propertyPath: string): any;
  10960. /** @hidden */
  10961. _getProperty(propertyPath: string): string;
  10962. /**
  10963. * Serialize this manager to a JSON object
  10964. * @param name defines the property name to store this manager
  10965. * @returns a JSON representation of this manager
  10966. */
  10967. serialize(name: string): any;
  10968. /**
  10969. * Creates a new ActionManager from a JSON data
  10970. * @param parsedActions defines the JSON data to read from
  10971. * @param object defines the hosting mesh
  10972. * @param scene defines the hosting scene
  10973. */
  10974. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10975. /**
  10976. * Get a trigger name by index
  10977. * @param trigger defines the trigger index
  10978. * @returns a trigger name
  10979. */
  10980. static GetTriggerName(trigger: number): string;
  10981. }
  10982. }
  10983. declare module BABYLON {
  10984. /**
  10985. * Class representing a ray with position and direction
  10986. */
  10987. export class Ray {
  10988. /** origin point */
  10989. origin: Vector3;
  10990. /** direction */
  10991. direction: Vector3;
  10992. /** length of the ray */
  10993. length: number;
  10994. private static readonly TmpVector3;
  10995. private _tmpRay;
  10996. /**
  10997. * Creates a new ray
  10998. * @param origin origin point
  10999. * @param direction direction
  11000. * @param length length of the ray
  11001. */
  11002. constructor(
  11003. /** origin point */
  11004. origin: Vector3,
  11005. /** direction */
  11006. direction: Vector3,
  11007. /** length of the ray */
  11008. length?: number);
  11009. /**
  11010. * Checks if the ray intersects a box
  11011. * @param minimum bound of the box
  11012. * @param maximum bound of the box
  11013. * @param intersectionTreshold extra extend to be added to the box in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * Checks if the ray intersects a box
  11019. * @param box the bounding box to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11021. * @returns if the box was hit
  11022. */
  11023. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a sphere
  11026. * @param sphere the bounding sphere to check
  11027. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11028. * @returns true if it hits the sphere
  11029. */
  11030. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11031. /**
  11032. * If the ray hits a triange
  11033. * @param vertex0 triangle vertex
  11034. * @param vertex1 triangle vertex
  11035. * @param vertex2 triangle vertex
  11036. * @returns intersection information if hit
  11037. */
  11038. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11039. /**
  11040. * Checks if ray intersects a plane
  11041. * @param plane the plane to check
  11042. * @returns the distance away it was hit
  11043. */
  11044. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11045. /**
  11046. * Calculate the intercept of a ray on a given axis
  11047. * @param axis to check 'x' | 'y' | 'z'
  11048. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11049. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11050. */
  11051. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param mesh the mesh to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @returns picking info of the intersecton
  11057. */
  11058. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11059. /**
  11060. * Checks if ray intersects a mesh
  11061. * @param meshes the meshes to check
  11062. * @param fastCheck if only the bounding box should checked
  11063. * @param results array to store result in
  11064. * @returns Array of picking infos
  11065. */
  11066. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11067. private _comparePickingInfo;
  11068. private static smallnum;
  11069. private static rayl;
  11070. /**
  11071. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11072. * @param sega the first point of the segment to test the intersection against
  11073. * @param segb the second point of the segment to test the intersection against
  11074. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11075. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11076. */
  11077. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11078. /**
  11079. * Update the ray from viewport position
  11080. * @param x position
  11081. * @param y y position
  11082. * @param viewportWidth viewport width
  11083. * @param viewportHeight viewport height
  11084. * @param world world matrix
  11085. * @param view view matrix
  11086. * @param projection projection matrix
  11087. * @returns this ray updated
  11088. */
  11089. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11090. /**
  11091. * Creates a ray with origin and direction of 0,0,0
  11092. * @returns the new ray
  11093. */
  11094. static Zero(): Ray;
  11095. /**
  11096. * Creates a new ray from screen space and viewport
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns new ray
  11105. */
  11106. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * 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
  11109. * transformed to the given world matrix.
  11110. * @param origin The origin point
  11111. * @param end The end point
  11112. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11113. * @returns the new ray
  11114. */
  11115. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @returns the resulting new ray
  11121. */
  11122. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11123. /**
  11124. * Transforms a ray by a matrix
  11125. * @param ray ray to transform
  11126. * @param matrix matrix to apply
  11127. * @param result ray to store result in
  11128. */
  11129. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11130. /**
  11131. * Unproject a ray from screen space to object space
  11132. * @param sourceX defines the screen space x coordinate to use
  11133. * @param sourceY defines the screen space y coordinate to use
  11134. * @param viewportWidth defines the current width of the viewport
  11135. * @param viewportHeight defines the current height of the viewport
  11136. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11137. * @param view defines the view matrix to use
  11138. * @param projection defines the projection matrix to use
  11139. */
  11140. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11141. }
  11142. /**
  11143. * Type used to define predicate used to select faces when a mesh intersection is detected
  11144. */
  11145. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11146. interface Scene {
  11147. /** @hidden */
  11148. _tempPickingRay: Nullable<Ray>;
  11149. /** @hidden */
  11150. _cachedRayForTransform: Ray;
  11151. /** @hidden */
  11152. _pickWithRayInverseMatrix: Matrix;
  11153. /** @hidden */
  11154. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11155. /** @hidden */
  11156. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11157. }
  11158. }
  11159. declare module BABYLON {
  11160. /**
  11161. * Groups all the scene component constants in one place to ease maintenance.
  11162. * @hidden
  11163. */
  11164. export class SceneComponentConstants {
  11165. static readonly NAME_EFFECTLAYER: string;
  11166. static readonly NAME_LAYER: string;
  11167. static readonly NAME_LENSFLARESYSTEM: string;
  11168. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11169. static readonly NAME_PARTICLESYSTEM: string;
  11170. static readonly NAME_GAMEPAD: string;
  11171. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11172. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11173. static readonly NAME_DEPTHRENDERER: string;
  11174. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11175. static readonly NAME_SPRITE: string;
  11176. static readonly NAME_OUTLINERENDERER: string;
  11177. static readonly NAME_PROCEDURALTEXTURE: string;
  11178. static readonly NAME_SHADOWGENERATOR: string;
  11179. static readonly NAME_OCTREE: string;
  11180. static readonly NAME_PHYSICSENGINE: string;
  11181. static readonly NAME_AUDIO: string;
  11182. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11183. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11184. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11185. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11186. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11187. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11188. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11189. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11190. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11191. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11192. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11193. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11194. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11195. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11196. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11197. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11198. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11199. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11200. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11201. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11202. static readonly STEP_AFTERRENDER_AUDIO: number;
  11203. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11204. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11205. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11206. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11207. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11208. static readonly STEP_POINTERMOVE_SPRITE: number;
  11209. static readonly STEP_POINTERDOWN_SPRITE: number;
  11210. static readonly STEP_POINTERUP_SPRITE: number;
  11211. }
  11212. /**
  11213. * This represents a scene component.
  11214. *
  11215. * This is used to decouple the dependency the scene is having on the different workloads like
  11216. * layers, post processes...
  11217. */
  11218. export interface ISceneComponent {
  11219. /**
  11220. * The name of the component. Each component must have a unique name.
  11221. */
  11222. name: string;
  11223. /**
  11224. * The scene the component belongs to.
  11225. */
  11226. scene: Scene;
  11227. /**
  11228. * Register the component to one instance of a scene.
  11229. */
  11230. register(): void;
  11231. /**
  11232. * Rebuilds the elements related to this component in case of
  11233. * context lost for instance.
  11234. */
  11235. rebuild(): void;
  11236. /**
  11237. * Disposes the component and the associated ressources.
  11238. */
  11239. dispose(): void;
  11240. }
  11241. /**
  11242. * This represents a SERIALIZABLE scene component.
  11243. *
  11244. * This extends Scene Component to add Serialization methods on top.
  11245. */
  11246. export interface ISceneSerializableComponent extends ISceneComponent {
  11247. /**
  11248. * Adds all the elements from the container to the scene
  11249. * @param container the container holding the elements
  11250. */
  11251. addFromContainer(container: AbstractScene): void;
  11252. /**
  11253. * Removes all the elements in the container from the scene
  11254. * @param container contains the elements to remove
  11255. * @param dispose if the removed element should be disposed (default: false)
  11256. */
  11257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11258. /**
  11259. * Serializes the component data to the specified json object
  11260. * @param serializationObject The object to serialize to
  11261. */
  11262. serialize(serializationObject: any): void;
  11263. }
  11264. /**
  11265. * Strong typing of a Mesh related stage step action
  11266. */
  11267. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11268. /**
  11269. * Strong typing of a Evaluate Sub Mesh related stage step action
  11270. */
  11271. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11272. /**
  11273. * Strong typing of a Active Mesh related stage step action
  11274. */
  11275. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11276. /**
  11277. * Strong typing of a Camera related stage step action
  11278. */
  11279. export type CameraStageAction = (camera: Camera) => void;
  11280. /**
  11281. * Strong typing of a Camera Frame buffer related stage step action
  11282. */
  11283. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11284. /**
  11285. * Strong typing of a Render Target related stage step action
  11286. */
  11287. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11288. /**
  11289. * Strong typing of a RenderingGroup related stage step action
  11290. */
  11291. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11292. /**
  11293. * Strong typing of a Mesh Render related stage step action
  11294. */
  11295. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11296. /**
  11297. * Strong typing of a simple stage step action
  11298. */
  11299. export type SimpleStageAction = () => void;
  11300. /**
  11301. * Strong typing of a render target action.
  11302. */
  11303. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11304. /**
  11305. * Strong typing of a pointer move action.
  11306. */
  11307. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11308. /**
  11309. * Strong typing of a pointer up/down action.
  11310. */
  11311. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11312. /**
  11313. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11314. * @hidden
  11315. */
  11316. export class Stage<T extends Function> extends Array<{
  11317. index: number;
  11318. component: ISceneComponent;
  11319. action: T;
  11320. }> {
  11321. /**
  11322. * Hide ctor from the rest of the world.
  11323. * @param items The items to add.
  11324. */
  11325. private constructor();
  11326. /**
  11327. * Creates a new Stage.
  11328. * @returns A new instance of a Stage
  11329. */
  11330. static Create<T extends Function>(): Stage<T>;
  11331. /**
  11332. * Registers a step in an ordered way in the targeted stage.
  11333. * @param index Defines the position to register the step in
  11334. * @param component Defines the component attached to the step
  11335. * @param action Defines the action to launch during the step
  11336. */
  11337. registerStep(index: number, component: ISceneComponent, action: T): void;
  11338. /**
  11339. * Clears all the steps from the stage.
  11340. */
  11341. clear(): void;
  11342. }
  11343. }
  11344. declare module BABYLON {
  11345. interface Scene {
  11346. /** @hidden */
  11347. _pointerOverSprite: Nullable<Sprite>;
  11348. /** @hidden */
  11349. _pickedDownSprite: Nullable<Sprite>;
  11350. /** @hidden */
  11351. _tempSpritePickingRay: Nullable<Ray>;
  11352. /**
  11353. * All of the sprite managers added to this scene
  11354. * @see http://doc.babylonjs.com/babylon101/sprites
  11355. */
  11356. spriteManagers: Array<ISpriteManager>;
  11357. /**
  11358. * An event triggered when sprites rendering is about to start
  11359. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11360. */
  11361. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11362. /**
  11363. * An event triggered when sprites rendering is done
  11364. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11365. */
  11366. onAfterSpritesRenderingObservable: Observable<Scene>;
  11367. /** @hidden */
  11368. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11369. /** Launch a ray to try to pick a sprite in the scene
  11370. * @param x position on screen
  11371. * @param y position on screen
  11372. * @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
  11373. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11374. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11375. * @returns a PickingInfo
  11376. */
  11377. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11378. /** Use the given ray to pick a sprite in the scene
  11379. * @param ray The ray (in world space) to use to pick meshes
  11380. * @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
  11381. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11382. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11383. * @returns a PickingInfo
  11384. */
  11385. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11386. /** @hidden */
  11387. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11388. /** Launch a ray to try to pick sprites in the scene
  11389. * @param x position on screen
  11390. * @param y position on screen
  11391. * @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
  11392. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11393. * @returns a PickingInfo array
  11394. */
  11395. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11396. /** Use the given ray to pick sprites in the scene
  11397. * @param ray The ray (in world space) to use to pick meshes
  11398. * @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
  11399. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11400. * @returns a PickingInfo array
  11401. */
  11402. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11403. /**
  11404. * Force the sprite under the pointer
  11405. * @param sprite defines the sprite to use
  11406. */
  11407. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11408. /**
  11409. * Gets the sprite under the pointer
  11410. * @returns a Sprite or null if no sprite is under the pointer
  11411. */
  11412. getPointerOverSprite(): Nullable<Sprite>;
  11413. }
  11414. /**
  11415. * Defines the sprite scene component responsible to manage sprites
  11416. * in a given scene.
  11417. */
  11418. export class SpriteSceneComponent implements ISceneComponent {
  11419. /**
  11420. * The component name helpfull to identify the component in the list of scene components.
  11421. */
  11422. readonly name: string;
  11423. /**
  11424. * The scene the component belongs to.
  11425. */
  11426. scene: Scene;
  11427. /** @hidden */
  11428. private _spritePredicate;
  11429. /**
  11430. * Creates a new instance of the component for the given scene
  11431. * @param scene Defines the scene to register the component in
  11432. */
  11433. constructor(scene: Scene);
  11434. /**
  11435. * Registers the component in a given scene
  11436. */
  11437. register(): void;
  11438. /**
  11439. * Rebuilds the elements related to this component in case of
  11440. * context lost for instance.
  11441. */
  11442. rebuild(): void;
  11443. /**
  11444. * Disposes the component and the associated ressources.
  11445. */
  11446. dispose(): void;
  11447. private _pickSpriteButKeepRay;
  11448. private _pointerMove;
  11449. private _pointerDown;
  11450. private _pointerUp;
  11451. }
  11452. }
  11453. declare module BABYLON {
  11454. /** @hidden */
  11455. export var fogFragmentDeclaration: {
  11456. name: string;
  11457. shader: string;
  11458. };
  11459. }
  11460. declare module BABYLON {
  11461. /** @hidden */
  11462. export var fogFragment: {
  11463. name: string;
  11464. shader: string;
  11465. };
  11466. }
  11467. declare module BABYLON {
  11468. /** @hidden */
  11469. export var spritesPixelShader: {
  11470. name: string;
  11471. shader: string;
  11472. };
  11473. }
  11474. declare module BABYLON {
  11475. /** @hidden */
  11476. export var fogVertexDeclaration: {
  11477. name: string;
  11478. shader: string;
  11479. };
  11480. }
  11481. declare module BABYLON {
  11482. /** @hidden */
  11483. export var spritesVertexShader: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11491. */
  11492. export interface ISpriteManager extends IDisposable {
  11493. /**
  11494. * Restricts the camera to viewing objects with the same layerMask.
  11495. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11496. */
  11497. layerMask: number;
  11498. /**
  11499. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11500. */
  11501. isPickable: boolean;
  11502. /**
  11503. * Specifies the rendering group id for this mesh (0 by default)
  11504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11505. */
  11506. renderingGroupId: number;
  11507. /**
  11508. * Defines the list of sprites managed by the manager.
  11509. */
  11510. sprites: Array<Sprite>;
  11511. /**
  11512. * Tests the intersection of a sprite with a specific ray.
  11513. * @param ray The ray we are sending to test the collision
  11514. * @param camera The camera space we are sending rays in
  11515. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11516. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11517. * @returns picking info or null.
  11518. */
  11519. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11520. /**
  11521. * Intersects the sprites with a ray
  11522. * @param ray defines the ray to intersect with
  11523. * @param camera defines the current active camera
  11524. * @param predicate defines a predicate used to select candidate sprites
  11525. * @returns null if no hit or a PickingInfo array
  11526. */
  11527. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11528. /**
  11529. * Renders the list of sprites on screen.
  11530. */
  11531. render(): void;
  11532. }
  11533. /**
  11534. * Class used to manage multiple sprites on the same spritesheet
  11535. * @see http://doc.babylonjs.com/babylon101/sprites
  11536. */
  11537. export class SpriteManager implements ISpriteManager {
  11538. /** defines the manager's name */
  11539. name: string;
  11540. /** Gets the list of sprites */
  11541. sprites: Sprite[];
  11542. /** Gets or sets the rendering group id (0 by default) */
  11543. renderingGroupId: number;
  11544. /** Gets or sets camera layer mask */
  11545. layerMask: number;
  11546. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11547. fogEnabled: boolean;
  11548. /** Gets or sets a boolean indicating if the sprites are pickable */
  11549. isPickable: boolean;
  11550. /** Defines the default width of a cell in the spritesheet */
  11551. cellWidth: number;
  11552. /** Defines the default height of a cell in the spritesheet */
  11553. cellHeight: number;
  11554. /** Associative array from JSON sprite data file */
  11555. private _cellData;
  11556. /** Array of sprite names from JSON sprite data file */
  11557. private _spriteMap;
  11558. /** True when packed cell data from JSON file is ready*/
  11559. private _packedAndReady;
  11560. /**
  11561. * An event triggered when the manager is disposed.
  11562. */
  11563. onDisposeObservable: Observable<SpriteManager>;
  11564. private _onDisposeObserver;
  11565. /**
  11566. * Callback called when the manager is disposed
  11567. */
  11568. onDispose: () => void;
  11569. private _capacity;
  11570. private _fromPacked;
  11571. private _spriteTexture;
  11572. private _epsilon;
  11573. private _scene;
  11574. private _vertexData;
  11575. private _buffer;
  11576. private _vertexBuffers;
  11577. private _indexBuffer;
  11578. private _effectBase;
  11579. private _effectFog;
  11580. /**
  11581. * Gets or sets the spritesheet texture
  11582. */
  11583. texture: Texture;
  11584. /**
  11585. * Creates a new sprite manager
  11586. * @param name defines the manager's name
  11587. * @param imgUrl defines the sprite sheet url
  11588. * @param capacity defines the maximum allowed number of sprites
  11589. * @param cellSize defines the size of a sprite cell
  11590. * @param scene defines the hosting scene
  11591. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11592. * @param samplingMode defines the smapling mode to use with spritesheet
  11593. * @param fromPacked set to false; do not alter
  11594. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11595. */
  11596. constructor(
  11597. /** defines the manager's name */
  11598. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11599. private _makePacked;
  11600. private _appendSpriteVertex;
  11601. /**
  11602. * Intersects the sprites with a ray
  11603. * @param ray defines the ray to intersect with
  11604. * @param camera defines the current active camera
  11605. * @param predicate defines a predicate used to select candidate sprites
  11606. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11607. * @returns null if no hit or a PickingInfo
  11608. */
  11609. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11610. /**
  11611. * Intersects the sprites with a ray
  11612. * @param ray defines the ray to intersect with
  11613. * @param camera defines the current active camera
  11614. * @param predicate defines a predicate used to select candidate sprites
  11615. * @returns null if no hit or a PickingInfo array
  11616. */
  11617. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11618. /**
  11619. * Render all child sprites
  11620. */
  11621. render(): void;
  11622. /**
  11623. * Release associated resources
  11624. */
  11625. dispose(): void;
  11626. }
  11627. }
  11628. declare module BABYLON {
  11629. /**
  11630. * Class used to represent a sprite
  11631. * @see http://doc.babylonjs.com/babylon101/sprites
  11632. */
  11633. export class Sprite {
  11634. /** defines the name */
  11635. name: string;
  11636. /** Gets or sets the current world position */
  11637. position: Vector3;
  11638. /** Gets or sets the main color */
  11639. color: Color4;
  11640. /** Gets or sets the width */
  11641. width: number;
  11642. /** Gets or sets the height */
  11643. height: number;
  11644. /** Gets or sets rotation angle */
  11645. angle: number;
  11646. /** Gets or sets the cell index in the sprite sheet */
  11647. cellIndex: number;
  11648. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11649. cellRef: string;
  11650. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11651. invertU: number;
  11652. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11653. invertV: number;
  11654. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11655. disposeWhenFinishedAnimating: boolean;
  11656. /** Gets the list of attached animations */
  11657. animations: Animation[];
  11658. /** Gets or sets a boolean indicating if the sprite can be picked */
  11659. isPickable: boolean;
  11660. /**
  11661. * Gets or sets the associated action manager
  11662. */
  11663. actionManager: Nullable<ActionManager>;
  11664. private _animationStarted;
  11665. private _loopAnimation;
  11666. private _fromIndex;
  11667. private _toIndex;
  11668. private _delay;
  11669. private _direction;
  11670. private _manager;
  11671. private _time;
  11672. private _onAnimationEnd;
  11673. /**
  11674. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11675. */
  11676. isVisible: boolean;
  11677. /**
  11678. * Gets or sets the sprite size
  11679. */
  11680. size: number;
  11681. /**
  11682. * Creates a new Sprite
  11683. * @param name defines the name
  11684. * @param manager defines the manager
  11685. */
  11686. constructor(
  11687. /** defines the name */
  11688. name: string, manager: ISpriteManager);
  11689. /**
  11690. * Starts an animation
  11691. * @param from defines the initial key
  11692. * @param to defines the end key
  11693. * @param loop defines if the animation must loop
  11694. * @param delay defines the start delay (in ms)
  11695. * @param onAnimationEnd defines a callback to call when animation ends
  11696. */
  11697. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11698. /** Stops current animation (if any) */
  11699. stopAnimation(): void;
  11700. /** @hidden */
  11701. _animate(deltaTime: number): void;
  11702. /** Release associated resources */
  11703. dispose(): void;
  11704. }
  11705. }
  11706. declare module BABYLON {
  11707. /**
  11708. * Information about the result of picking within a scene
  11709. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11710. */
  11711. export class PickingInfo {
  11712. /** @hidden */
  11713. _pickingUnavailable: boolean;
  11714. /**
  11715. * If the pick collided with an object
  11716. */
  11717. hit: boolean;
  11718. /**
  11719. * Distance away where the pick collided
  11720. */
  11721. distance: number;
  11722. /**
  11723. * The location of pick collision
  11724. */
  11725. pickedPoint: Nullable<Vector3>;
  11726. /**
  11727. * The mesh corresponding the the pick collision
  11728. */
  11729. pickedMesh: Nullable<AbstractMesh>;
  11730. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11731. bu: number;
  11732. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11733. bv: number;
  11734. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11735. faceId: number;
  11736. /** Id of the the submesh that was picked */
  11737. subMeshId: number;
  11738. /** If a sprite was picked, this will be the sprite the pick collided with */
  11739. pickedSprite: Nullable<Sprite>;
  11740. /**
  11741. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11742. */
  11743. originMesh: Nullable<AbstractMesh>;
  11744. /**
  11745. * The ray that was used to perform the picking.
  11746. */
  11747. ray: Nullable<Ray>;
  11748. /**
  11749. * Gets the normal correspodning to the face the pick collided with
  11750. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11751. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11752. * @returns The normal correspodning to the face the pick collided with
  11753. */
  11754. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11755. /**
  11756. * Gets the texture coordinates of where the pick occured
  11757. * @returns the vector containing the coordnates of the texture
  11758. */
  11759. getTextureCoordinates(): Nullable<Vector2>;
  11760. }
  11761. }
  11762. declare module BABYLON {
  11763. /**
  11764. * Gather the list of pointer event types as constants.
  11765. */
  11766. export class PointerEventTypes {
  11767. /**
  11768. * 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.
  11769. */
  11770. static readonly POINTERDOWN: number;
  11771. /**
  11772. * The pointerup event is fired when a pointer is no longer active.
  11773. */
  11774. static readonly POINTERUP: number;
  11775. /**
  11776. * The pointermove event is fired when a pointer changes coordinates.
  11777. */
  11778. static readonly POINTERMOVE: number;
  11779. /**
  11780. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11781. */
  11782. static readonly POINTERWHEEL: number;
  11783. /**
  11784. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11785. */
  11786. static readonly POINTERPICK: number;
  11787. /**
  11788. * The pointertap event is fired when a the object has been touched and released without drag.
  11789. */
  11790. static readonly POINTERTAP: number;
  11791. /**
  11792. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11793. */
  11794. static readonly POINTERDOUBLETAP: number;
  11795. }
  11796. /**
  11797. * Base class of pointer info types.
  11798. */
  11799. export class PointerInfoBase {
  11800. /**
  11801. * Defines the type of event (PointerEventTypes)
  11802. */
  11803. type: number;
  11804. /**
  11805. * Defines the related dom event
  11806. */
  11807. event: PointerEvent | MouseWheelEvent;
  11808. /**
  11809. * Instantiates the base class of pointers info.
  11810. * @param type Defines the type of event (PointerEventTypes)
  11811. * @param event Defines the related dom event
  11812. */
  11813. constructor(
  11814. /**
  11815. * Defines the type of event (PointerEventTypes)
  11816. */
  11817. type: number,
  11818. /**
  11819. * Defines the related dom event
  11820. */
  11821. event: PointerEvent | MouseWheelEvent);
  11822. }
  11823. /**
  11824. * This class is used to store pointer related info for the onPrePointerObservable event.
  11825. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11826. */
  11827. export class PointerInfoPre extends PointerInfoBase {
  11828. /**
  11829. * Ray from a pointer if availible (eg. 6dof controller)
  11830. */
  11831. ray: Nullable<Ray>;
  11832. /**
  11833. * Defines the local position of the pointer on the canvas.
  11834. */
  11835. localPosition: Vector2;
  11836. /**
  11837. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11838. */
  11839. skipOnPointerObservable: boolean;
  11840. /**
  11841. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11842. * @param type Defines the type of event (PointerEventTypes)
  11843. * @param event Defines the related dom event
  11844. * @param localX Defines the local x coordinates of the pointer when the event occured
  11845. * @param localY Defines the local y coordinates of the pointer when the event occured
  11846. */
  11847. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11848. }
  11849. /**
  11850. * This type contains all the data related to a pointer event in Babylon.js.
  11851. * 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.
  11852. */
  11853. export class PointerInfo extends PointerInfoBase {
  11854. /**
  11855. * Defines the picking info associated to the info (if any)\
  11856. */
  11857. pickInfo: Nullable<PickingInfo>;
  11858. /**
  11859. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11860. * @param type Defines the type of event (PointerEventTypes)
  11861. * @param event Defines the related dom event
  11862. * @param pickInfo Defines the picking info associated to the info (if any)\
  11863. */
  11864. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11865. /**
  11866. * Defines the picking info associated to the info (if any)\
  11867. */
  11868. pickInfo: Nullable<PickingInfo>);
  11869. }
  11870. /**
  11871. * Data relating to a touch event on the screen.
  11872. */
  11873. export interface PointerTouch {
  11874. /**
  11875. * X coordinate of touch.
  11876. */
  11877. x: number;
  11878. /**
  11879. * Y coordinate of touch.
  11880. */
  11881. y: number;
  11882. /**
  11883. * Id of touch. Unique for each finger.
  11884. */
  11885. pointerId: number;
  11886. /**
  11887. * Event type passed from DOM.
  11888. */
  11889. type: any;
  11890. }
  11891. }
  11892. declare module BABYLON {
  11893. /**
  11894. * Manage the mouse inputs to control the movement of a free camera.
  11895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11896. */
  11897. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11898. /**
  11899. * Define if touch is enabled in the mouse input
  11900. */
  11901. touchEnabled: boolean;
  11902. /**
  11903. * Defines the camera the input is attached to.
  11904. */
  11905. camera: FreeCamera;
  11906. /**
  11907. * Defines the buttons associated with the input to handle camera move.
  11908. */
  11909. buttons: number[];
  11910. /**
  11911. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11912. */
  11913. angularSensibility: number;
  11914. private _pointerInput;
  11915. private _onMouseMove;
  11916. private _observer;
  11917. private previousPosition;
  11918. /**
  11919. * Observable for when a pointer move event occurs containing the move offset
  11920. */
  11921. onPointerMovedObservable: Observable<{
  11922. offsetX: number;
  11923. offsetY: number;
  11924. }>;
  11925. /**
  11926. * @hidden
  11927. * If the camera should be rotated automatically based on pointer movement
  11928. */
  11929. _allowCameraRotation: boolean;
  11930. /**
  11931. * Manage the mouse inputs to control the movement of a free camera.
  11932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11933. * @param touchEnabled Defines if touch is enabled or not
  11934. */
  11935. constructor(
  11936. /**
  11937. * Define if touch is enabled in the mouse input
  11938. */
  11939. touchEnabled?: boolean);
  11940. /**
  11941. * Attach the input controls to a specific dom element to get the input from.
  11942. * @param element Defines the element the controls should be listened from
  11943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11944. */
  11945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11946. /**
  11947. * Called on JS contextmenu event.
  11948. * Override this method to provide functionality.
  11949. */
  11950. protected onContextMenu(evt: PointerEvent): void;
  11951. /**
  11952. * Detach the current controls from the specified dom element.
  11953. * @param element Defines the element to stop listening the inputs from
  11954. */
  11955. detachControl(element: Nullable<HTMLElement>): void;
  11956. /**
  11957. * Gets the class name of the current intput.
  11958. * @returns the class name
  11959. */
  11960. getClassName(): string;
  11961. /**
  11962. * Get the friendly name associated with the input class.
  11963. * @returns the input friendly name
  11964. */
  11965. getSimpleName(): string;
  11966. }
  11967. }
  11968. declare module BABYLON {
  11969. /**
  11970. * Manage the touch inputs to control the movement of a free camera.
  11971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11972. */
  11973. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11974. /**
  11975. * Defines the camera the input is attached to.
  11976. */
  11977. camera: FreeCamera;
  11978. /**
  11979. * Defines the touch sensibility for rotation.
  11980. * The higher the faster.
  11981. */
  11982. touchAngularSensibility: number;
  11983. /**
  11984. * Defines the touch sensibility for move.
  11985. * The higher the faster.
  11986. */
  11987. touchMoveSensibility: number;
  11988. private _offsetX;
  11989. private _offsetY;
  11990. private _pointerPressed;
  11991. private _pointerInput;
  11992. private _observer;
  11993. private _onLostFocus;
  11994. /**
  11995. * Attach the input controls to a specific dom element to get the input from.
  11996. * @param element Defines the element the controls should be listened from
  11997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11998. */
  11999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12000. /**
  12001. * Detach the current controls from the specified dom element.
  12002. * @param element Defines the element to stop listening the inputs from
  12003. */
  12004. detachControl(element: Nullable<HTMLElement>): void;
  12005. /**
  12006. * Update the current camera state depending on the inputs that have been used this frame.
  12007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12008. */
  12009. checkInputs(): void;
  12010. /**
  12011. * Gets the class name of the current intput.
  12012. * @returns the class name
  12013. */
  12014. getClassName(): string;
  12015. /**
  12016. * Get the friendly name associated with the input class.
  12017. * @returns the input friendly name
  12018. */
  12019. getSimpleName(): string;
  12020. }
  12021. }
  12022. declare module BABYLON {
  12023. /**
  12024. * Default Inputs manager for the FreeCamera.
  12025. * It groups all the default supported inputs for ease of use.
  12026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12027. */
  12028. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12029. /**
  12030. * @hidden
  12031. */
  12032. _mouseInput: Nullable<FreeCameraMouseInput>;
  12033. /**
  12034. * Instantiates a new FreeCameraInputsManager.
  12035. * @param camera Defines the camera the inputs belong to
  12036. */
  12037. constructor(camera: FreeCamera);
  12038. /**
  12039. * Add keyboard input support to the input manager.
  12040. * @returns the current input manager
  12041. */
  12042. addKeyboard(): FreeCameraInputsManager;
  12043. /**
  12044. * Add mouse input support to the input manager.
  12045. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12046. * @returns the current input manager
  12047. */
  12048. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12049. /**
  12050. * Removes the mouse input support from the manager
  12051. * @returns the current input manager
  12052. */
  12053. removeMouse(): FreeCameraInputsManager;
  12054. /**
  12055. * Add touch input support to the input manager.
  12056. * @returns the current input manager
  12057. */
  12058. addTouch(): FreeCameraInputsManager;
  12059. /**
  12060. * Remove all attached input methods from a camera
  12061. */
  12062. clear(): void;
  12063. }
  12064. }
  12065. declare module BABYLON {
  12066. /**
  12067. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12068. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12069. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12070. */
  12071. export class FreeCamera extends TargetCamera {
  12072. /**
  12073. * Define the collision ellipsoid of the camera.
  12074. * This is helpful to simulate a camera body like the player body around the camera
  12075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12076. */
  12077. ellipsoid: Vector3;
  12078. /**
  12079. * Define an offset for the position of the ellipsoid around the camera.
  12080. * This can be helpful to determine the center of the body near the gravity center of the body
  12081. * instead of its head.
  12082. */
  12083. ellipsoidOffset: Vector3;
  12084. /**
  12085. * Enable or disable collisions of the camera with the rest of the scene objects.
  12086. */
  12087. checkCollisions: boolean;
  12088. /**
  12089. * Enable or disable gravity on the camera.
  12090. */
  12091. applyGravity: boolean;
  12092. /**
  12093. * Define the input manager associated to the camera.
  12094. */
  12095. inputs: FreeCameraInputsManager;
  12096. /**
  12097. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12098. * Higher values reduce sensitivity.
  12099. */
  12100. /**
  12101. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12102. * Higher values reduce sensitivity.
  12103. */
  12104. angularSensibility: number;
  12105. /**
  12106. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12107. */
  12108. keysUp: number[];
  12109. /**
  12110. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12111. */
  12112. keysDown: number[];
  12113. /**
  12114. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12115. */
  12116. keysLeft: number[];
  12117. /**
  12118. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12119. */
  12120. keysRight: number[];
  12121. /**
  12122. * Event raised when the camera collide with a mesh in the scene.
  12123. */
  12124. onCollide: (collidedMesh: AbstractMesh) => void;
  12125. private _collider;
  12126. private _needMoveForGravity;
  12127. private _oldPosition;
  12128. private _diffPosition;
  12129. private _newPosition;
  12130. /** @hidden */
  12131. _localDirection: Vector3;
  12132. /** @hidden */
  12133. _transformedDirection: Vector3;
  12134. /**
  12135. * Instantiates a Free Camera.
  12136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12137. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12139. * @param name Define the name of the camera in the scene
  12140. * @param position Define the start position of the camera in the scene
  12141. * @param scene Define the scene the camera belongs to
  12142. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12143. */
  12144. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12145. /**
  12146. * Attached controls to the current camera.
  12147. * @param element Defines the element the controls should be listened from
  12148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12149. */
  12150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12151. /**
  12152. * Detach the current controls from the camera.
  12153. * The camera will stop reacting to inputs.
  12154. * @param element Defines the element to stop listening the inputs from
  12155. */
  12156. detachControl(element: HTMLElement): void;
  12157. private _collisionMask;
  12158. /**
  12159. * Define a collision mask to limit the list of object the camera can collide with
  12160. */
  12161. collisionMask: number;
  12162. /** @hidden */
  12163. _collideWithWorld(displacement: Vector3): void;
  12164. private _onCollisionPositionChange;
  12165. /** @hidden */
  12166. _checkInputs(): void;
  12167. /** @hidden */
  12168. _decideIfNeedsToMove(): boolean;
  12169. /** @hidden */
  12170. _updatePosition(): void;
  12171. /**
  12172. * Destroy the camera and release the current resources hold by it.
  12173. */
  12174. dispose(): void;
  12175. /**
  12176. * Gets the current object class name.
  12177. * @return the class name
  12178. */
  12179. getClassName(): string;
  12180. }
  12181. }
  12182. declare module BABYLON {
  12183. /**
  12184. * Represents a gamepad control stick position
  12185. */
  12186. export class StickValues {
  12187. /**
  12188. * The x component of the control stick
  12189. */
  12190. x: number;
  12191. /**
  12192. * The y component of the control stick
  12193. */
  12194. y: number;
  12195. /**
  12196. * Initializes the gamepad x and y control stick values
  12197. * @param x The x component of the gamepad control stick value
  12198. * @param y The y component of the gamepad control stick value
  12199. */
  12200. constructor(
  12201. /**
  12202. * The x component of the control stick
  12203. */
  12204. x: number,
  12205. /**
  12206. * The y component of the control stick
  12207. */
  12208. y: number);
  12209. }
  12210. /**
  12211. * An interface which manages callbacks for gamepad button changes
  12212. */
  12213. export interface GamepadButtonChanges {
  12214. /**
  12215. * Called when a gamepad has been changed
  12216. */
  12217. changed: boolean;
  12218. /**
  12219. * Called when a gamepad press event has been triggered
  12220. */
  12221. pressChanged: boolean;
  12222. /**
  12223. * Called when a touch event has been triggered
  12224. */
  12225. touchChanged: boolean;
  12226. /**
  12227. * Called when a value has changed
  12228. */
  12229. valueChanged: boolean;
  12230. }
  12231. /**
  12232. * Represents a gamepad
  12233. */
  12234. export class Gamepad {
  12235. /**
  12236. * The id of the gamepad
  12237. */
  12238. id: string;
  12239. /**
  12240. * The index of the gamepad
  12241. */
  12242. index: number;
  12243. /**
  12244. * The browser gamepad
  12245. */
  12246. browserGamepad: any;
  12247. /**
  12248. * Specifies what type of gamepad this represents
  12249. */
  12250. type: number;
  12251. private _leftStick;
  12252. private _rightStick;
  12253. /** @hidden */
  12254. _isConnected: boolean;
  12255. private _leftStickAxisX;
  12256. private _leftStickAxisY;
  12257. private _rightStickAxisX;
  12258. private _rightStickAxisY;
  12259. /**
  12260. * Triggered when the left control stick has been changed
  12261. */
  12262. private _onleftstickchanged;
  12263. /**
  12264. * Triggered when the right control stick has been changed
  12265. */
  12266. private _onrightstickchanged;
  12267. /**
  12268. * Represents a gamepad controller
  12269. */
  12270. static GAMEPAD: number;
  12271. /**
  12272. * Represents a generic controller
  12273. */
  12274. static GENERIC: number;
  12275. /**
  12276. * Represents an XBox controller
  12277. */
  12278. static XBOX: number;
  12279. /**
  12280. * Represents a pose-enabled controller
  12281. */
  12282. static POSE_ENABLED: number;
  12283. /**
  12284. * Represents an Dual Shock controller
  12285. */
  12286. static DUALSHOCK: number;
  12287. /**
  12288. * Specifies whether the left control stick should be Y-inverted
  12289. */
  12290. protected _invertLeftStickY: boolean;
  12291. /**
  12292. * Specifies if the gamepad has been connected
  12293. */
  12294. readonly isConnected: boolean;
  12295. /**
  12296. * Initializes the gamepad
  12297. * @param id The id of the gamepad
  12298. * @param index The index of the gamepad
  12299. * @param browserGamepad The browser gamepad
  12300. * @param leftStickX The x component of the left joystick
  12301. * @param leftStickY The y component of the left joystick
  12302. * @param rightStickX The x component of the right joystick
  12303. * @param rightStickY The y component of the right joystick
  12304. */
  12305. constructor(
  12306. /**
  12307. * The id of the gamepad
  12308. */
  12309. id: string,
  12310. /**
  12311. * The index of the gamepad
  12312. */
  12313. index: number,
  12314. /**
  12315. * The browser gamepad
  12316. */
  12317. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12318. /**
  12319. * Callback triggered when the left joystick has changed
  12320. * @param callback
  12321. */
  12322. onleftstickchanged(callback: (values: StickValues) => void): void;
  12323. /**
  12324. * Callback triggered when the right joystick has changed
  12325. * @param callback
  12326. */
  12327. onrightstickchanged(callback: (values: StickValues) => void): void;
  12328. /**
  12329. * Gets the left joystick
  12330. */
  12331. /**
  12332. * Sets the left joystick values
  12333. */
  12334. leftStick: StickValues;
  12335. /**
  12336. * Gets the right joystick
  12337. */
  12338. /**
  12339. * Sets the right joystick value
  12340. */
  12341. rightStick: StickValues;
  12342. /**
  12343. * Updates the gamepad joystick positions
  12344. */
  12345. update(): void;
  12346. /**
  12347. * Disposes the gamepad
  12348. */
  12349. dispose(): void;
  12350. }
  12351. /**
  12352. * Represents a generic gamepad
  12353. */
  12354. export class GenericPad extends Gamepad {
  12355. private _buttons;
  12356. private _onbuttondown;
  12357. private _onbuttonup;
  12358. /**
  12359. * Observable triggered when a button has been pressed
  12360. */
  12361. onButtonDownObservable: Observable<number>;
  12362. /**
  12363. * Observable triggered when a button has been released
  12364. */
  12365. onButtonUpObservable: Observable<number>;
  12366. /**
  12367. * Callback triggered when a button has been pressed
  12368. * @param callback Called when a button has been pressed
  12369. */
  12370. onbuttondown(callback: (buttonPressed: number) => void): void;
  12371. /**
  12372. * Callback triggered when a button has been released
  12373. * @param callback Called when a button has been released
  12374. */
  12375. onbuttonup(callback: (buttonReleased: number) => void): void;
  12376. /**
  12377. * Initializes the generic gamepad
  12378. * @param id The id of the generic gamepad
  12379. * @param index The index of the generic gamepad
  12380. * @param browserGamepad The browser gamepad
  12381. */
  12382. constructor(id: string, index: number, browserGamepad: any);
  12383. private _setButtonValue;
  12384. /**
  12385. * Updates the generic gamepad
  12386. */
  12387. update(): void;
  12388. /**
  12389. * Disposes the generic gamepad
  12390. */
  12391. dispose(): void;
  12392. }
  12393. }
  12394. declare module BABYLON {
  12395. interface Engine {
  12396. /**
  12397. * Creates a raw texture
  12398. * @param data defines the data to store in the texture
  12399. * @param width defines the width of the texture
  12400. * @param height defines the height of the texture
  12401. * @param format defines the format of the data
  12402. * @param generateMipMaps defines if the engine should generate the mip levels
  12403. * @param invertY defines if data must be stored with Y axis inverted
  12404. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12405. * @param compression defines the compression used (null by default)
  12406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12407. * @returns the raw texture inside an InternalTexture
  12408. */
  12409. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12410. /**
  12411. * Update a raw texture
  12412. * @param texture defines the texture to update
  12413. * @param data defines the data to store in the texture
  12414. * @param format defines the format of the data
  12415. * @param invertY defines if data must be stored with Y axis inverted
  12416. */
  12417. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12418. /**
  12419. * Update a raw texture
  12420. * @param texture defines the texture to update
  12421. * @param data defines the data to store in the texture
  12422. * @param format defines the format of the data
  12423. * @param invertY defines if data must be stored with Y axis inverted
  12424. * @param compression defines the compression used (null by default)
  12425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12426. */
  12427. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12428. /**
  12429. * Creates a new raw cube texture
  12430. * @param data defines the array of data to use to create each face
  12431. * @param size defines the size of the textures
  12432. * @param format defines the format of the data
  12433. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12434. * @param generateMipMaps defines if the engine should generate the mip levels
  12435. * @param invertY defines if data must be stored with Y axis inverted
  12436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12437. * @param compression defines the compression used (null by default)
  12438. * @returns the cube texture as an InternalTexture
  12439. */
  12440. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12441. /**
  12442. * Update a raw cube texture
  12443. * @param texture defines the texture to udpdate
  12444. * @param data defines the data to store
  12445. * @param format defines the data format
  12446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12447. * @param invertY defines if data must be stored with Y axis inverted
  12448. */
  12449. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12450. /**
  12451. * Update a raw cube texture
  12452. * @param texture defines the texture to udpdate
  12453. * @param data defines the data to store
  12454. * @param format defines the data format
  12455. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12456. * @param invertY defines if data must be stored with Y axis inverted
  12457. * @param compression defines the compression used (null by default)
  12458. */
  12459. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12460. /**
  12461. * Update a raw cube texture
  12462. * @param texture defines the texture to udpdate
  12463. * @param data defines the data to store
  12464. * @param format defines the data format
  12465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. * @param compression defines the compression used (null by default)
  12468. * @param level defines which level of the texture to update
  12469. */
  12470. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12471. /**
  12472. * Creates a new raw cube texture from a specified url
  12473. * @param url defines the url where the data is located
  12474. * @param scene defines the current scene
  12475. * @param size defines the size of the textures
  12476. * @param format defines the format of the data
  12477. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12478. * @param noMipmap defines if the engine should avoid generating the mip levels
  12479. * @param callback defines a callback used to extract texture data from loaded data
  12480. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12481. * @param onLoad defines a callback called when texture is loaded
  12482. * @param onError defines a callback called if there is an error
  12483. * @returns the cube texture as an InternalTexture
  12484. */
  12485. createRawCubeTextureFromUrl(url: string, scene: 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;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12499. * @param invertY defines if data must be stored with Y axis inverted
  12500. * @returns the cube texture as an InternalTexture
  12501. */
  12502. createRawCubeTextureFromUrl(url: string, scene: 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;
  12503. /**
  12504. * Creates a new raw 3D texture
  12505. * @param data defines the data used to create the texture
  12506. * @param width defines the width of the texture
  12507. * @param height defines the height of the texture
  12508. * @param depth defines the depth of the texture
  12509. * @param format defines the format of the texture
  12510. * @param generateMipMaps defines if the engine must generate mip levels
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12513. * @param compression defines the compressed used (can be null)
  12514. * @param textureType defines the compressed used (can be null)
  12515. * @returns a new raw 3D texture (stored in an InternalTexture)
  12516. */
  12517. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12518. /**
  12519. * Update a raw 3D texture
  12520. * @param texture defines the texture to update
  12521. * @param data defines the data to store
  12522. * @param format defines the data format
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. */
  12525. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12526. /**
  12527. * Update a raw 3D texture
  12528. * @param texture defines the texture to update
  12529. * @param data defines the data to store
  12530. * @param format defines the data format
  12531. * @param invertY defines if data must be stored with Y axis inverted
  12532. * @param compression defines the used compression (can be null)
  12533. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12534. */
  12535. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * Raw texture can help creating a texture directly from an array of data.
  12541. * This can be super useful if you either get the data from an uncompressed source or
  12542. * if you wish to create your texture pixel by pixel.
  12543. */
  12544. export class RawTexture extends Texture {
  12545. /**
  12546. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12547. */
  12548. format: number;
  12549. private _engine;
  12550. /**
  12551. * Instantiates a new RawTexture.
  12552. * Raw texture can help creating a texture directly from an array of data.
  12553. * This can be super useful if you either get the data from an uncompressed source or
  12554. * if you wish to create your texture pixel by pixel.
  12555. * @param data define the array of data to use to create the texture
  12556. * @param width define the width of the texture
  12557. * @param height define the height of the texture
  12558. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12559. * @param scene define the scene the texture belongs to
  12560. * @param generateMipMaps define whether mip maps should be generated or not
  12561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12564. */
  12565. constructor(data: ArrayBufferView, width: number, height: number,
  12566. /**
  12567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12568. */
  12569. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12570. /**
  12571. * Updates the texture underlying data.
  12572. * @param data Define the new data of the texture
  12573. */
  12574. update(data: ArrayBufferView): void;
  12575. /**
  12576. * Creates a luminance texture from some data.
  12577. * @param data Define the texture data
  12578. * @param width Define the width of the texture
  12579. * @param height Define the height of the texture
  12580. * @param scene Define the scene the texture belongs to
  12581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12584. * @returns the luminance texture
  12585. */
  12586. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12587. /**
  12588. * Creates a luminance alpha texture from some data.
  12589. * @param data Define the texture data
  12590. * @param width Define the width of the texture
  12591. * @param height Define the height of the texture
  12592. * @param scene Define the scene the texture belongs to
  12593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12596. * @returns the luminance alpha texture
  12597. */
  12598. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12599. /**
  12600. * Creates an alpha texture from some data.
  12601. * @param data Define the texture data
  12602. * @param width Define the width of the texture
  12603. * @param height Define the height of the texture
  12604. * @param scene Define the scene the texture belongs to
  12605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12608. * @returns the alpha texture
  12609. */
  12610. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12611. /**
  12612. * Creates a RGB texture from some data.
  12613. * @param data Define the texture data
  12614. * @param width Define the width of the texture
  12615. * @param height Define the height of the texture
  12616. * @param scene Define the scene the texture belongs to
  12617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12620. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12621. * @returns the RGB alpha texture
  12622. */
  12623. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12624. /**
  12625. * Creates a RGBA texture from some data.
  12626. * @param data Define the texture data
  12627. * @param width Define the width of the texture
  12628. * @param height Define the height of the texture
  12629. * @param scene Define the scene the texture belongs to
  12630. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12631. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12632. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12633. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12634. * @returns the RGBA texture
  12635. */
  12636. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12637. /**
  12638. * Creates a R texture from some data.
  12639. * @param data Define the texture data
  12640. * @param width Define the width of the texture
  12641. * @param height Define the height of the texture
  12642. * @param scene Define the scene the texture belongs to
  12643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12647. * @returns the R texture
  12648. */
  12649. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12650. }
  12651. }
  12652. declare module BABYLON {
  12653. /**
  12654. * Interface for the size containing width and height
  12655. */
  12656. export interface ISize {
  12657. /**
  12658. * Width
  12659. */
  12660. width: number;
  12661. /**
  12662. * Heighht
  12663. */
  12664. height: number;
  12665. }
  12666. /**
  12667. * Size containing widht and height
  12668. */
  12669. export class Size implements ISize {
  12670. /**
  12671. * Width
  12672. */
  12673. width: number;
  12674. /**
  12675. * Height
  12676. */
  12677. height: number;
  12678. /**
  12679. * Creates a Size object from the given width and height (floats).
  12680. * @param width width of the new size
  12681. * @param height height of the new size
  12682. */
  12683. constructor(width: number, height: number);
  12684. /**
  12685. * Returns a string with the Size width and height
  12686. * @returns a string with the Size width and height
  12687. */
  12688. toString(): string;
  12689. /**
  12690. * "Size"
  12691. * @returns the string "Size"
  12692. */
  12693. getClassName(): string;
  12694. /**
  12695. * Returns the Size hash code.
  12696. * @returns a hash code for a unique width and height
  12697. */
  12698. getHashCode(): number;
  12699. /**
  12700. * Updates the current size from the given one.
  12701. * @param src the given size
  12702. */
  12703. copyFrom(src: Size): void;
  12704. /**
  12705. * Updates in place the current Size from the given floats.
  12706. * @param width width of the new size
  12707. * @param height height of the new size
  12708. * @returns the updated Size.
  12709. */
  12710. copyFromFloats(width: number, height: number): Size;
  12711. /**
  12712. * Updates in place the current Size from the given floats.
  12713. * @param width width to set
  12714. * @param height height to set
  12715. * @returns the updated Size.
  12716. */
  12717. set(width: number, height: number): Size;
  12718. /**
  12719. * Multiplies the width and height by numbers
  12720. * @param w factor to multiple the width by
  12721. * @param h factor to multiple the height by
  12722. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12723. */
  12724. multiplyByFloats(w: number, h: number): Size;
  12725. /**
  12726. * Clones the size
  12727. * @returns a new Size copied from the given one.
  12728. */
  12729. clone(): Size;
  12730. /**
  12731. * True if the current Size and the given one width and height are strictly equal.
  12732. * @param other the other size to compare against
  12733. * @returns True if the current Size and the given one width and height are strictly equal.
  12734. */
  12735. equals(other: Size): boolean;
  12736. /**
  12737. * The surface of the Size : width * height (float).
  12738. */
  12739. readonly surface: number;
  12740. /**
  12741. * Create a new size of zero
  12742. * @returns a new Size set to (0.0, 0.0)
  12743. */
  12744. static Zero(): Size;
  12745. /**
  12746. * Sums the width and height of two sizes
  12747. * @param otherSize size to add to this size
  12748. * @returns a new Size set as the addition result of the current Size and the given one.
  12749. */
  12750. add(otherSize: Size): Size;
  12751. /**
  12752. * Subtracts the width and height of two
  12753. * @param otherSize size to subtract to this size
  12754. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12755. */
  12756. subtract(otherSize: Size): Size;
  12757. /**
  12758. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12759. * @param start starting size to lerp between
  12760. * @param end end size to lerp between
  12761. * @param amount amount to lerp between the start and end values
  12762. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12763. */
  12764. static Lerp(start: Size, end: Size, amount: number): Size;
  12765. }
  12766. }
  12767. declare module BABYLON {
  12768. /**
  12769. * Defines a runtime animation
  12770. */
  12771. export class RuntimeAnimation {
  12772. private _events;
  12773. /**
  12774. * The current frame of the runtime animation
  12775. */
  12776. private _currentFrame;
  12777. /**
  12778. * The animation used by the runtime animation
  12779. */
  12780. private _animation;
  12781. /**
  12782. * The target of the runtime animation
  12783. */
  12784. private _target;
  12785. /**
  12786. * The initiating animatable
  12787. */
  12788. private _host;
  12789. /**
  12790. * The original value of the runtime animation
  12791. */
  12792. private _originalValue;
  12793. /**
  12794. * The original blend value of the runtime animation
  12795. */
  12796. private _originalBlendValue;
  12797. /**
  12798. * The offsets cache of the runtime animation
  12799. */
  12800. private _offsetsCache;
  12801. /**
  12802. * The high limits cache of the runtime animation
  12803. */
  12804. private _highLimitsCache;
  12805. /**
  12806. * Specifies if the runtime animation has been stopped
  12807. */
  12808. private _stopped;
  12809. /**
  12810. * The blending factor of the runtime animation
  12811. */
  12812. private _blendingFactor;
  12813. /**
  12814. * The BabylonJS scene
  12815. */
  12816. private _scene;
  12817. /**
  12818. * The current value of the runtime animation
  12819. */
  12820. private _currentValue;
  12821. /** @hidden */
  12822. _animationState: _IAnimationState;
  12823. /**
  12824. * The active target of the runtime animation
  12825. */
  12826. private _activeTargets;
  12827. private _currentActiveTarget;
  12828. private _directTarget;
  12829. /**
  12830. * The target path of the runtime animation
  12831. */
  12832. private _targetPath;
  12833. /**
  12834. * The weight of the runtime animation
  12835. */
  12836. private _weight;
  12837. /**
  12838. * The ratio offset of the runtime animation
  12839. */
  12840. private _ratioOffset;
  12841. /**
  12842. * The previous delay of the runtime animation
  12843. */
  12844. private _previousDelay;
  12845. /**
  12846. * The previous ratio of the runtime animation
  12847. */
  12848. private _previousRatio;
  12849. private _enableBlending;
  12850. private _keys;
  12851. private _minFrame;
  12852. private _maxFrame;
  12853. private _minValue;
  12854. private _maxValue;
  12855. private _targetIsArray;
  12856. /**
  12857. * Gets the current frame of the runtime animation
  12858. */
  12859. readonly currentFrame: number;
  12860. /**
  12861. * Gets the weight of the runtime animation
  12862. */
  12863. readonly weight: number;
  12864. /**
  12865. * Gets the current value of the runtime animation
  12866. */
  12867. readonly currentValue: any;
  12868. /**
  12869. * Gets the target path of the runtime animation
  12870. */
  12871. readonly targetPath: string;
  12872. /**
  12873. * Gets the actual target of the runtime animation
  12874. */
  12875. readonly target: any;
  12876. /** @hidden */
  12877. _onLoop: () => void;
  12878. /**
  12879. * Create a new RuntimeAnimation object
  12880. * @param target defines the target of the animation
  12881. * @param animation defines the source animation object
  12882. * @param scene defines the hosting scene
  12883. * @param host defines the initiating Animatable
  12884. */
  12885. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12886. private _preparePath;
  12887. /**
  12888. * Gets the animation from the runtime animation
  12889. */
  12890. readonly animation: Animation;
  12891. /**
  12892. * Resets the runtime animation to the beginning
  12893. * @param restoreOriginal defines whether to restore the target property to the original value
  12894. */
  12895. reset(restoreOriginal?: boolean): void;
  12896. /**
  12897. * Specifies if the runtime animation is stopped
  12898. * @returns Boolean specifying if the runtime animation is stopped
  12899. */
  12900. isStopped(): boolean;
  12901. /**
  12902. * Disposes of the runtime animation
  12903. */
  12904. dispose(): void;
  12905. /**
  12906. * Apply the interpolated value to the target
  12907. * @param currentValue defines the value computed by the animation
  12908. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12909. */
  12910. setValue(currentValue: any, weight: number): void;
  12911. private _getOriginalValues;
  12912. private _setValue;
  12913. /**
  12914. * Gets the loop pmode of the runtime animation
  12915. * @returns Loop Mode
  12916. */
  12917. private _getCorrectLoopMode;
  12918. /**
  12919. * Move the current animation to a given frame
  12920. * @param frame defines the frame to move to
  12921. */
  12922. goToFrame(frame: number): void;
  12923. /**
  12924. * @hidden Internal use only
  12925. */
  12926. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12927. /**
  12928. * Execute the current animation
  12929. * @param delay defines the delay to add to the current frame
  12930. * @param from defines the lower bound of the animation range
  12931. * @param to defines the upper bound of the animation range
  12932. * @param loop defines if the current animation must loop
  12933. * @param speedRatio defines the current speed ratio
  12934. * @param weight defines the weight of the animation (default is -1 so no weight)
  12935. * @param onLoop optional callback called when animation loops
  12936. * @returns a boolean indicating if the animation is running
  12937. */
  12938. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12939. }
  12940. }
  12941. declare module BABYLON {
  12942. /**
  12943. * Class used to store an actual running animation
  12944. */
  12945. export class Animatable {
  12946. /** defines the target object */
  12947. target: any;
  12948. /** defines the starting frame number (default is 0) */
  12949. fromFrame: number;
  12950. /** defines the ending frame number (default is 100) */
  12951. toFrame: number;
  12952. /** defines if the animation must loop (default is false) */
  12953. loopAnimation: boolean;
  12954. /** defines a callback to call when animation ends if it is not looping */
  12955. onAnimationEnd?: (() => void) | null | undefined;
  12956. /** defines a callback to call when animation loops */
  12957. onAnimationLoop?: (() => void) | null | undefined;
  12958. private _localDelayOffset;
  12959. private _pausedDelay;
  12960. private _runtimeAnimations;
  12961. private _paused;
  12962. private _scene;
  12963. private _speedRatio;
  12964. private _weight;
  12965. private _syncRoot;
  12966. /**
  12967. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12968. * This will only apply for non looping animation (default is true)
  12969. */
  12970. disposeOnEnd: boolean;
  12971. /**
  12972. * Gets a boolean indicating if the animation has started
  12973. */
  12974. animationStarted: boolean;
  12975. /**
  12976. * Observer raised when the animation ends
  12977. */
  12978. onAnimationEndObservable: Observable<Animatable>;
  12979. /**
  12980. * Observer raised when the animation loops
  12981. */
  12982. onAnimationLoopObservable: Observable<Animatable>;
  12983. /**
  12984. * Gets the root Animatable used to synchronize and normalize animations
  12985. */
  12986. readonly syncRoot: Nullable<Animatable>;
  12987. /**
  12988. * Gets the current frame of the first RuntimeAnimation
  12989. * Used to synchronize Animatables
  12990. */
  12991. readonly masterFrame: number;
  12992. /**
  12993. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12994. */
  12995. weight: number;
  12996. /**
  12997. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12998. */
  12999. speedRatio: number;
  13000. /**
  13001. * Creates a new Animatable
  13002. * @param scene defines the hosting scene
  13003. * @param target defines the target object
  13004. * @param fromFrame defines the starting frame number (default is 0)
  13005. * @param toFrame defines the ending frame number (default is 100)
  13006. * @param loopAnimation defines if the animation must loop (default is false)
  13007. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13008. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13009. * @param animations defines a group of animation to add to the new Animatable
  13010. * @param onAnimationLoop defines a callback to call when animation loops
  13011. */
  13012. constructor(scene: Scene,
  13013. /** defines the target object */
  13014. target: any,
  13015. /** defines the starting frame number (default is 0) */
  13016. fromFrame?: number,
  13017. /** defines the ending frame number (default is 100) */
  13018. toFrame?: number,
  13019. /** defines if the animation must loop (default is false) */
  13020. loopAnimation?: boolean, speedRatio?: number,
  13021. /** defines a callback to call when animation ends if it is not looping */
  13022. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13023. /** defines a callback to call when animation loops */
  13024. onAnimationLoop?: (() => void) | null | undefined);
  13025. /**
  13026. * Synchronize and normalize current Animatable with a source Animatable
  13027. * This is useful when using animation weights and when animations are not of the same length
  13028. * @param root defines the root Animatable to synchronize with
  13029. * @returns the current Animatable
  13030. */
  13031. syncWith(root: Animatable): Animatable;
  13032. /**
  13033. * Gets the list of runtime animations
  13034. * @returns an array of RuntimeAnimation
  13035. */
  13036. getAnimations(): RuntimeAnimation[];
  13037. /**
  13038. * Adds more animations to the current animatable
  13039. * @param target defines the target of the animations
  13040. * @param animations defines the new animations to add
  13041. */
  13042. appendAnimations(target: any, animations: Animation[]): void;
  13043. /**
  13044. * Gets the source animation for a specific property
  13045. * @param property defines the propertyu to look for
  13046. * @returns null or the source animation for the given property
  13047. */
  13048. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13049. /**
  13050. * Gets the runtime animation for a specific property
  13051. * @param property defines the propertyu to look for
  13052. * @returns null or the runtime animation for the given property
  13053. */
  13054. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13055. /**
  13056. * Resets the animatable to its original state
  13057. */
  13058. reset(): void;
  13059. /**
  13060. * Allows the animatable to blend with current running animations
  13061. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13062. * @param blendingSpeed defines the blending speed to use
  13063. */
  13064. enableBlending(blendingSpeed: number): void;
  13065. /**
  13066. * Disable animation blending
  13067. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13068. */
  13069. disableBlending(): void;
  13070. /**
  13071. * Jump directly to a given frame
  13072. * @param frame defines the frame to jump to
  13073. */
  13074. goToFrame(frame: number): void;
  13075. /**
  13076. * Pause the animation
  13077. */
  13078. pause(): void;
  13079. /**
  13080. * Restart the animation
  13081. */
  13082. restart(): void;
  13083. private _raiseOnAnimationEnd;
  13084. /**
  13085. * Stop and delete the current animation
  13086. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13087. * @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)
  13088. */
  13089. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13090. /**
  13091. * Wait asynchronously for the animation to end
  13092. * @returns a promise which will be fullfilled when the animation ends
  13093. */
  13094. waitAsync(): Promise<Animatable>;
  13095. /** @hidden */
  13096. _animate(delay: number): boolean;
  13097. }
  13098. interface Scene {
  13099. /** @hidden */
  13100. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13101. /** @hidden */
  13102. _processLateAnimationBindingsForMatrices(holder: {
  13103. totalWeight: number;
  13104. animations: RuntimeAnimation[];
  13105. originalValue: Matrix;
  13106. }): any;
  13107. /** @hidden */
  13108. _processLateAnimationBindingsForQuaternions(holder: {
  13109. totalWeight: number;
  13110. animations: RuntimeAnimation[];
  13111. originalValue: Quaternion;
  13112. }, refQuaternion: Quaternion): Quaternion;
  13113. /** @hidden */
  13114. _processLateAnimationBindings(): void;
  13115. /**
  13116. * Will start the animation sequence of a given target
  13117. * @param target defines the target
  13118. * @param from defines from which frame should animation start
  13119. * @param to defines until which frame should animation run.
  13120. * @param weight defines the weight to apply to the animation (1.0 by default)
  13121. * @param loop defines if the animation loops
  13122. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13123. * @param onAnimationEnd defines the function to be executed when the animation ends
  13124. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13125. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13126. * @param onAnimationLoop defines the callback to call when an animation loops
  13127. * @returns the animatable object created for this animation
  13128. */
  13129. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13130. /**
  13131. * Will start the animation sequence of a given target
  13132. * @param target defines the target
  13133. * @param from defines from which frame should animation start
  13134. * @param to defines until which frame should animation run.
  13135. * @param loop defines if the animation loops
  13136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13137. * @param onAnimationEnd defines the function to be executed when the animation ends
  13138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13139. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13140. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13141. * @param onAnimationLoop defines the callback to call when an animation loops
  13142. * @returns the animatable object created for this animation
  13143. */
  13144. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13145. /**
  13146. * Will start the animation sequence of a given target and its hierarchy
  13147. * @param target defines the target
  13148. * @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.
  13149. * @param from defines from which frame should animation start
  13150. * @param to defines until which frame should animation run.
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13156. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13157. * @param onAnimationLoop defines the callback to call when an animation loops
  13158. * @returns the list of created animatables
  13159. */
  13160. 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): Animatable[];
  13161. /**
  13162. * Begin a new animation on a given node
  13163. * @param target defines the target where the animation will take place
  13164. * @param animations defines the list of animations to start
  13165. * @param from defines the initial value
  13166. * @param to defines the final value
  13167. * @param loop defines if you want animation to loop (off by default)
  13168. * @param speedRatio defines the speed ratio to apply to all animations
  13169. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13170. * @param onAnimationLoop defines the callback to call when an animation loops
  13171. * @returns the list of created animatables
  13172. */
  13173. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13174. /**
  13175. * Begin a new animation on a given node and its hierarchy
  13176. * @param target defines the root node where the animation will take place
  13177. * @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.
  13178. * @param animations defines the list of animations to start
  13179. * @param from defines the initial value
  13180. * @param to defines the final value
  13181. * @param loop defines if you want animation to loop (off by default)
  13182. * @param speedRatio defines the speed ratio to apply to all animations
  13183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13184. * @param onAnimationLoop defines the callback to call when an animation loops
  13185. * @returns the list of animatables created for all nodes
  13186. */
  13187. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13188. /**
  13189. * Gets the animatable associated with a specific target
  13190. * @param target defines the target of the animatable
  13191. * @returns the required animatable if found
  13192. */
  13193. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13194. /**
  13195. * Gets all animatables associated with a given target
  13196. * @param target defines the target to look animatables for
  13197. * @returns an array of Animatables
  13198. */
  13199. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13200. /**
  13201. * Stops and removes all animations that have been applied to the scene
  13202. */
  13203. stopAllAnimations(): void;
  13204. }
  13205. interface Bone {
  13206. /**
  13207. * Copy an animation range from another bone
  13208. * @param source defines the source bone
  13209. * @param rangeName defines the range name to copy
  13210. * @param frameOffset defines the frame offset
  13211. * @param rescaleAsRequired defines if rescaling must be applied if required
  13212. * @param skelDimensionsRatio defines the scaling ratio
  13213. * @returns true if operation was successful
  13214. */
  13215. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13216. }
  13217. }
  13218. declare module BABYLON {
  13219. /**
  13220. * Class used to override all child animations of a given target
  13221. */
  13222. export class AnimationPropertiesOverride {
  13223. /**
  13224. * Gets or sets a value indicating if animation blending must be used
  13225. */
  13226. enableBlending: boolean;
  13227. /**
  13228. * Gets or sets the blending speed to use when enableBlending is true
  13229. */
  13230. blendingSpeed: number;
  13231. /**
  13232. * Gets or sets the default loop mode to use
  13233. */
  13234. loopMode: number;
  13235. }
  13236. }
  13237. declare module BABYLON {
  13238. /**
  13239. * Class used to handle skinning animations
  13240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13241. */
  13242. export class Skeleton implements IAnimatable {
  13243. /** defines the skeleton name */
  13244. name: string;
  13245. /** defines the skeleton Id */
  13246. id: string;
  13247. /**
  13248. * Defines the list of child bones
  13249. */
  13250. bones: Bone[];
  13251. /**
  13252. * Defines an estimate of the dimension of the skeleton at rest
  13253. */
  13254. dimensionsAtRest: Vector3;
  13255. /**
  13256. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13257. */
  13258. needInitialSkinMatrix: boolean;
  13259. /**
  13260. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13261. */
  13262. overrideMesh: Nullable<AbstractMesh>;
  13263. /**
  13264. * Gets the list of animations attached to this skeleton
  13265. */
  13266. animations: Array<Animation>;
  13267. private _scene;
  13268. private _isDirty;
  13269. private _transformMatrices;
  13270. private _transformMatrixTexture;
  13271. private _meshesWithPoseMatrix;
  13272. private _animatables;
  13273. private _identity;
  13274. private _synchronizedWithMesh;
  13275. private _ranges;
  13276. private _lastAbsoluteTransformsUpdateId;
  13277. private _canUseTextureForBones;
  13278. private _uniqueId;
  13279. /** @hidden */
  13280. _numBonesWithLinkedTransformNode: number;
  13281. /** @hidden */
  13282. _hasWaitingData: Nullable<boolean>;
  13283. /**
  13284. * Specifies if the skeleton should be serialized
  13285. */
  13286. doNotSerialize: boolean;
  13287. private _useTextureToStoreBoneMatrices;
  13288. /**
  13289. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13290. * Please note that this option is not available if the hardware does not support it
  13291. */
  13292. useTextureToStoreBoneMatrices: boolean;
  13293. private _animationPropertiesOverride;
  13294. /**
  13295. * Gets or sets the animation properties override
  13296. */
  13297. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13298. /**
  13299. * List of inspectable custom properties (used by the Inspector)
  13300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13301. */
  13302. inspectableCustomProperties: IInspectable[];
  13303. /**
  13304. * An observable triggered before computing the skeleton's matrices
  13305. */
  13306. onBeforeComputeObservable: Observable<Skeleton>;
  13307. /**
  13308. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13309. */
  13310. readonly isUsingTextureForMatrices: boolean;
  13311. /**
  13312. * Gets the unique ID of this skeleton
  13313. */
  13314. readonly uniqueId: number;
  13315. /**
  13316. * Creates a new skeleton
  13317. * @param name defines the skeleton name
  13318. * @param id defines the skeleton Id
  13319. * @param scene defines the hosting scene
  13320. */
  13321. constructor(
  13322. /** defines the skeleton name */
  13323. name: string,
  13324. /** defines the skeleton Id */
  13325. id: string, scene: Scene);
  13326. /**
  13327. * Gets the current object class name.
  13328. * @return the class name
  13329. */
  13330. getClassName(): string;
  13331. /**
  13332. * Returns an array containing the root bones
  13333. * @returns an array containing the root bones
  13334. */
  13335. getChildren(): Array<Bone>;
  13336. /**
  13337. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13338. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13339. * @returns a Float32Array containing matrices data
  13340. */
  13341. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13342. /**
  13343. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13344. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13345. * @returns a raw texture containing the data
  13346. */
  13347. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13348. /**
  13349. * Gets the current hosting scene
  13350. * @returns a scene object
  13351. */
  13352. getScene(): Scene;
  13353. /**
  13354. * Gets a string representing the current skeleton data
  13355. * @param fullDetails defines a boolean indicating if we want a verbose version
  13356. * @returns a string representing the current skeleton data
  13357. */
  13358. toString(fullDetails?: boolean): string;
  13359. /**
  13360. * Get bone's index searching by name
  13361. * @param name defines bone's name to search for
  13362. * @return the indice of the bone. Returns -1 if not found
  13363. */
  13364. getBoneIndexByName(name: string): number;
  13365. /**
  13366. * Creater a new animation range
  13367. * @param name defines the name of the range
  13368. * @param from defines the start key
  13369. * @param to defines the end key
  13370. */
  13371. createAnimationRange(name: string, from: number, to: number): void;
  13372. /**
  13373. * Delete a specific animation range
  13374. * @param name defines the name of the range
  13375. * @param deleteFrames defines if frames must be removed as well
  13376. */
  13377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13378. /**
  13379. * Gets a specific animation range
  13380. * @param name defines the name of the range to look for
  13381. * @returns the requested animation range or null if not found
  13382. */
  13383. getAnimationRange(name: string): Nullable<AnimationRange>;
  13384. /**
  13385. * Gets the list of all animation ranges defined on this skeleton
  13386. * @returns an array
  13387. */
  13388. getAnimationRanges(): Nullable<AnimationRange>[];
  13389. /**
  13390. * Copy animation range from a source skeleton.
  13391. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13392. * @param source defines the source skeleton
  13393. * @param name defines the name of the range to copy
  13394. * @param rescaleAsRequired defines if rescaling must be applied if required
  13395. * @returns true if operation was successful
  13396. */
  13397. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13398. /**
  13399. * Forces the skeleton to go to rest pose
  13400. */
  13401. returnToRest(): void;
  13402. private _getHighestAnimationFrame;
  13403. /**
  13404. * Begin a specific animation range
  13405. * @param name defines the name of the range to start
  13406. * @param loop defines if looping must be turned on (false by default)
  13407. * @param speedRatio defines the speed ratio to apply (1 by default)
  13408. * @param onAnimationEnd defines a callback which will be called when animation will end
  13409. * @returns a new animatable
  13410. */
  13411. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13412. /** @hidden */
  13413. _markAsDirty(): void;
  13414. /** @hidden */
  13415. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13416. /** @hidden */
  13417. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13418. private _computeTransformMatrices;
  13419. /**
  13420. * Build all resources required to render a skeleton
  13421. */
  13422. prepare(): void;
  13423. /**
  13424. * Gets the list of animatables currently running for this skeleton
  13425. * @returns an array of animatables
  13426. */
  13427. getAnimatables(): IAnimatable[];
  13428. /**
  13429. * Clone the current skeleton
  13430. * @param name defines the name of the new skeleton
  13431. * @param id defines the id of the new skeleton
  13432. * @returns the new skeleton
  13433. */
  13434. clone(name: string, id: string): Skeleton;
  13435. /**
  13436. * Enable animation blending for this skeleton
  13437. * @param blendingSpeed defines the blending speed to apply
  13438. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13439. */
  13440. enableBlending(blendingSpeed?: number): void;
  13441. /**
  13442. * Releases all resources associated with the current skeleton
  13443. */
  13444. dispose(): void;
  13445. /**
  13446. * Serialize the skeleton in a JSON object
  13447. * @returns a JSON object
  13448. */
  13449. serialize(): any;
  13450. /**
  13451. * Creates a new skeleton from serialized data
  13452. * @param parsedSkeleton defines the serialized data
  13453. * @param scene defines the hosting scene
  13454. * @returns a new skeleton
  13455. */
  13456. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13457. /**
  13458. * Compute all node absolute transforms
  13459. * @param forceUpdate defines if computation must be done even if cache is up to date
  13460. */
  13461. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13462. /**
  13463. * Gets the root pose matrix
  13464. * @returns a matrix
  13465. */
  13466. getPoseMatrix(): Nullable<Matrix>;
  13467. /**
  13468. * Sorts bones per internal index
  13469. */
  13470. sortBones(): void;
  13471. private _sortBones;
  13472. }
  13473. }
  13474. declare module BABYLON {
  13475. /**
  13476. * Class used to store bone information
  13477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13478. */
  13479. export class Bone extends Node {
  13480. /**
  13481. * defines the bone name
  13482. */
  13483. name: string;
  13484. private static _tmpVecs;
  13485. private static _tmpQuat;
  13486. private static _tmpMats;
  13487. /**
  13488. * Gets the list of child bones
  13489. */
  13490. children: Bone[];
  13491. /** Gets the animations associated with this bone */
  13492. animations: Animation[];
  13493. /**
  13494. * Gets or sets bone length
  13495. */
  13496. length: number;
  13497. /**
  13498. * @hidden Internal only
  13499. * Set this value to map this bone to a different index in the transform matrices
  13500. * Set this value to -1 to exclude the bone from the transform matrices
  13501. */
  13502. _index: Nullable<number>;
  13503. private _skeleton;
  13504. private _localMatrix;
  13505. private _restPose;
  13506. private _baseMatrix;
  13507. private _absoluteTransform;
  13508. private _invertedAbsoluteTransform;
  13509. private _parent;
  13510. private _scalingDeterminant;
  13511. private _worldTransform;
  13512. private _localScaling;
  13513. private _localRotation;
  13514. private _localPosition;
  13515. private _needToDecompose;
  13516. private _needToCompose;
  13517. /** @hidden */
  13518. _linkedTransformNode: Nullable<TransformNode>;
  13519. /** @hidden */
  13520. _waitingTransformNodeId: Nullable<string>;
  13521. /** @hidden */
  13522. /** @hidden */
  13523. _matrix: Matrix;
  13524. /**
  13525. * Create a new bone
  13526. * @param name defines the bone name
  13527. * @param skeleton defines the parent skeleton
  13528. * @param parentBone defines the parent (can be null if the bone is the root)
  13529. * @param localMatrix defines the local matrix
  13530. * @param restPose defines the rest pose matrix
  13531. * @param baseMatrix defines the base matrix
  13532. * @param index defines index of the bone in the hiearchy
  13533. */
  13534. constructor(
  13535. /**
  13536. * defines the bone name
  13537. */
  13538. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13539. /**
  13540. * Gets the current object class name.
  13541. * @return the class name
  13542. */
  13543. getClassName(): string;
  13544. /**
  13545. * Gets the parent skeleton
  13546. * @returns a skeleton
  13547. */
  13548. getSkeleton(): Skeleton;
  13549. /**
  13550. * Gets parent bone
  13551. * @returns a bone or null if the bone is the root of the bone hierarchy
  13552. */
  13553. getParent(): Nullable<Bone>;
  13554. /**
  13555. * Returns an array containing the root bones
  13556. * @returns an array containing the root bones
  13557. */
  13558. getChildren(): Array<Bone>;
  13559. /**
  13560. * Sets the parent bone
  13561. * @param parent defines the parent (can be null if the bone is the root)
  13562. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13563. */
  13564. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13565. /**
  13566. * Gets the local matrix
  13567. * @returns a matrix
  13568. */
  13569. getLocalMatrix(): Matrix;
  13570. /**
  13571. * Gets the base matrix (initial matrix which remains unchanged)
  13572. * @returns a matrix
  13573. */
  13574. getBaseMatrix(): Matrix;
  13575. /**
  13576. * Gets the rest pose matrix
  13577. * @returns a matrix
  13578. */
  13579. getRestPose(): Matrix;
  13580. /**
  13581. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13582. */
  13583. getWorldMatrix(): Matrix;
  13584. /**
  13585. * Sets the local matrix to rest pose matrix
  13586. */
  13587. returnToRest(): void;
  13588. /**
  13589. * Gets the inverse of the absolute transform matrix.
  13590. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13591. * @returns a matrix
  13592. */
  13593. getInvertedAbsoluteTransform(): Matrix;
  13594. /**
  13595. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13596. * @returns a matrix
  13597. */
  13598. getAbsoluteTransform(): Matrix;
  13599. /**
  13600. * Links with the given transform node.
  13601. * The local matrix of this bone is copied from the transform node every frame.
  13602. * @param transformNode defines the transform node to link to
  13603. */
  13604. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13605. /**
  13606. * Gets the node used to drive the bone's transformation
  13607. * @returns a transform node or null
  13608. */
  13609. getTransformNode(): Nullable<TransformNode>;
  13610. /** Gets or sets current position (in local space) */
  13611. position: Vector3;
  13612. /** Gets or sets current rotation (in local space) */
  13613. rotation: Vector3;
  13614. /** Gets or sets current rotation quaternion (in local space) */
  13615. rotationQuaternion: Quaternion;
  13616. /** Gets or sets current scaling (in local space) */
  13617. scaling: Vector3;
  13618. /**
  13619. * Gets the animation properties override
  13620. */
  13621. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13622. private _decompose;
  13623. private _compose;
  13624. /**
  13625. * Update the base and local matrices
  13626. * @param matrix defines the new base or local matrix
  13627. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13628. * @param updateLocalMatrix defines if the local matrix should be updated
  13629. */
  13630. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13631. /** @hidden */
  13632. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13633. /**
  13634. * Flag the bone as dirty (Forcing it to update everything)
  13635. */
  13636. markAsDirty(): void;
  13637. /** @hidden */
  13638. _markAsDirtyAndCompose(): void;
  13639. private _markAsDirtyAndDecompose;
  13640. /**
  13641. * Translate the bone in local or world space
  13642. * @param vec The amount to translate the bone
  13643. * @param space The space that the translation is in
  13644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13645. */
  13646. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13647. /**
  13648. * Set the postion of the bone in local or world space
  13649. * @param position The position to set the bone
  13650. * @param space The space that the position is in
  13651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13652. */
  13653. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13654. /**
  13655. * Set the absolute position of the bone (world space)
  13656. * @param position The position to set the bone
  13657. * @param mesh The mesh that this bone is attached to
  13658. */
  13659. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13660. /**
  13661. * Scale the bone on the x, y and z axes (in local space)
  13662. * @param x The amount to scale the bone on the x axis
  13663. * @param y The amount to scale the bone on the y axis
  13664. * @param z The amount to scale the bone on the z axis
  13665. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13666. */
  13667. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13668. /**
  13669. * Set the bone scaling in local space
  13670. * @param scale defines the scaling vector
  13671. */
  13672. setScale(scale: Vector3): void;
  13673. /**
  13674. * Gets the current scaling in local space
  13675. * @returns the current scaling vector
  13676. */
  13677. getScale(): Vector3;
  13678. /**
  13679. * Gets the current scaling in local space and stores it in a target vector
  13680. * @param result defines the target vector
  13681. */
  13682. getScaleToRef(result: Vector3): void;
  13683. /**
  13684. * Set the yaw, pitch, and roll of the bone in local or world space
  13685. * @param yaw The rotation of the bone on the y axis
  13686. * @param pitch The rotation of the bone on the x axis
  13687. * @param roll The rotation of the bone on the z axis
  13688. * @param space The space that the axes of rotation are in
  13689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13690. */
  13691. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13692. /**
  13693. * Add a rotation to the bone on an axis in local or world space
  13694. * @param axis The axis to rotate the bone on
  13695. * @param amount The amount to rotate the bone
  13696. * @param space The space that the axis is in
  13697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13698. */
  13699. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13700. /**
  13701. * Set the rotation of the bone to a particular axis angle in local or world space
  13702. * @param axis The axis to rotate the bone on
  13703. * @param angle The angle that the bone should be rotated to
  13704. * @param space The space that the axis is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the euler rotation of the bone in local of world space
  13710. * @param rotation The euler rotation that the bone should be set to
  13711. * @param space The space that the rotation is in
  13712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13713. */
  13714. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13715. /**
  13716. * Set the quaternion rotation of the bone in local of world space
  13717. * @param quat The quaternion rotation that the bone should be set to
  13718. * @param space The space that the rotation is in
  13719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13720. */
  13721. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13722. /**
  13723. * Set the rotation matrix of the bone in local of world space
  13724. * @param rotMat The rotation matrix that the bone should be set to
  13725. * @param space The space that the rotation is in
  13726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13727. */
  13728. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13729. private _rotateWithMatrix;
  13730. private _getNegativeRotationToRef;
  13731. /**
  13732. * Get the position of the bone in local or world space
  13733. * @param space The space that the returned position is in
  13734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13735. * @returns The position of the bone
  13736. */
  13737. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13738. /**
  13739. * Copy the position of the bone to a vector3 in local or world space
  13740. * @param space The space that the returned position is in
  13741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13742. * @param result The vector3 to copy the position to
  13743. */
  13744. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13745. /**
  13746. * Get the absolute position of the bone (world space)
  13747. * @param mesh The mesh that this bone is attached to
  13748. * @returns The absolute position of the bone
  13749. */
  13750. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13751. /**
  13752. * Copy the absolute position of the bone (world space) to the result param
  13753. * @param mesh The mesh that this bone is attached to
  13754. * @param result The vector3 to copy the absolute position to
  13755. */
  13756. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13757. /**
  13758. * Compute the absolute transforms of this bone and its children
  13759. */
  13760. computeAbsoluteTransforms(): void;
  13761. /**
  13762. * Get the world direction from an axis that is in the local space of the bone
  13763. * @param localAxis The local direction that is used to compute the world direction
  13764. * @param mesh The mesh that this bone is attached to
  13765. * @returns The world direction
  13766. */
  13767. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13768. /**
  13769. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13770. * @param localAxis The local direction that is used to compute the world direction
  13771. * @param mesh The mesh that this bone is attached to
  13772. * @param result The vector3 that the world direction will be copied to
  13773. */
  13774. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13775. /**
  13776. * Get the euler rotation of the bone in local or world space
  13777. * @param space The space that the rotation should be in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. * @returns The euler rotation
  13780. */
  13781. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13782. /**
  13783. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13784. * @param space The space that the rotation should be in
  13785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13786. * @param result The vector3 that the rotation should be copied to
  13787. */
  13788. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13789. /**
  13790. * Get the quaternion rotation of the bone in either local or world space
  13791. * @param space The space that the rotation should be in
  13792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13793. * @returns The quaternion rotation
  13794. */
  13795. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13796. /**
  13797. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13798. * @param space The space that the rotation should be in
  13799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13800. * @param result The quaternion that the rotation should be copied to
  13801. */
  13802. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13803. /**
  13804. * Get the rotation matrix of the bone in local or world space
  13805. * @param space The space that the rotation should be in
  13806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13807. * @returns The rotation matrix
  13808. */
  13809. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13810. /**
  13811. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13812. * @param space The space that the rotation should be in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. * @param result The quaternion that the rotation should be copied to
  13815. */
  13816. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13817. /**
  13818. * Get the world position of a point that is in the local space of the bone
  13819. * @param position The local position
  13820. * @param mesh The mesh that this bone is attached to
  13821. * @returns The world position
  13822. */
  13823. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13824. /**
  13825. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13826. * @param position The local position
  13827. * @param mesh The mesh that this bone is attached to
  13828. * @param result The vector3 that the world position should be copied to
  13829. */
  13830. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13831. /**
  13832. * Get the local position of a point that is in world space
  13833. * @param position The world position
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The local position
  13836. */
  13837. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Get the local position of a point that is in world space and copy it to the result param
  13840. * @param position The world position
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the local position should be copied to
  13843. */
  13844. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. }
  13846. }
  13847. declare module BABYLON {
  13848. /**
  13849. * 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.
  13850. * @see https://doc.babylonjs.com/how_to/transformnode
  13851. */
  13852. export class TransformNode extends Node {
  13853. /**
  13854. * Object will not rotate to face the camera
  13855. */
  13856. static BILLBOARDMODE_NONE: number;
  13857. /**
  13858. * Object will rotate to face the camera but only on the x axis
  13859. */
  13860. static BILLBOARDMODE_X: number;
  13861. /**
  13862. * Object will rotate to face the camera but only on the y axis
  13863. */
  13864. static BILLBOARDMODE_Y: number;
  13865. /**
  13866. * Object will rotate to face the camera but only on the z axis
  13867. */
  13868. static BILLBOARDMODE_Z: number;
  13869. /**
  13870. * Object will rotate to face the camera
  13871. */
  13872. static BILLBOARDMODE_ALL: number;
  13873. /**
  13874. * Object will rotate to face the camera's position instead of orientation
  13875. */
  13876. static BILLBOARDMODE_USE_POSITION: number;
  13877. private _forward;
  13878. private _forwardInverted;
  13879. private _up;
  13880. private _right;
  13881. private _rightInverted;
  13882. private _position;
  13883. private _rotation;
  13884. private _rotationQuaternion;
  13885. protected _scaling: Vector3;
  13886. protected _isDirty: boolean;
  13887. private _transformToBoneReferal;
  13888. private _isAbsoluteSynced;
  13889. private _billboardMode;
  13890. /**
  13891. * Gets or sets the billboard mode. Default is 0.
  13892. *
  13893. * | Value | Type | Description |
  13894. * | --- | --- | --- |
  13895. * | 0 | BILLBOARDMODE_NONE | |
  13896. * | 1 | BILLBOARDMODE_X | |
  13897. * | 2 | BILLBOARDMODE_Y | |
  13898. * | 4 | BILLBOARDMODE_Z | |
  13899. * | 7 | BILLBOARDMODE_ALL | |
  13900. *
  13901. */
  13902. billboardMode: number;
  13903. private _preserveParentRotationForBillboard;
  13904. /**
  13905. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13906. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13907. */
  13908. preserveParentRotationForBillboard: boolean;
  13909. /**
  13910. * 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
  13911. */
  13912. scalingDeterminant: number;
  13913. private _infiniteDistance;
  13914. /**
  13915. * Gets or sets the distance of the object to max, often used by skybox
  13916. */
  13917. infiniteDistance: boolean;
  13918. /**
  13919. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13920. * By default the system will update normals to compensate
  13921. */
  13922. ignoreNonUniformScaling: boolean;
  13923. /**
  13924. * 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
  13925. */
  13926. reIntegrateRotationIntoRotationQuaternion: boolean;
  13927. /** @hidden */
  13928. _poseMatrix: Nullable<Matrix>;
  13929. /** @hidden */
  13930. _localMatrix: Matrix;
  13931. private _usePivotMatrix;
  13932. private _absolutePosition;
  13933. private _absoluteScaling;
  13934. private _absoluteRotationQuaternion;
  13935. private _pivotMatrix;
  13936. private _pivotMatrixInverse;
  13937. protected _postMultiplyPivotMatrix: boolean;
  13938. protected _isWorldMatrixFrozen: boolean;
  13939. /** @hidden */
  13940. _indexInSceneTransformNodesArray: number;
  13941. /**
  13942. * An event triggered after the world matrix is updated
  13943. */
  13944. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13945. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13946. /**
  13947. * Gets a string identifying the name of the class
  13948. * @returns "TransformNode" string
  13949. */
  13950. getClassName(): string;
  13951. /**
  13952. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13953. */
  13954. position: Vector3;
  13955. /**
  13956. * 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)).
  13957. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13958. */
  13959. rotation: Vector3;
  13960. /**
  13961. * 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)).
  13962. */
  13963. scaling: Vector3;
  13964. /**
  13965. * 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).
  13966. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13967. */
  13968. rotationQuaternion: Nullable<Quaternion>;
  13969. /**
  13970. * The forward direction of that transform in world space.
  13971. */
  13972. readonly forward: Vector3;
  13973. /**
  13974. * The up direction of that transform in world space.
  13975. */
  13976. readonly up: Vector3;
  13977. /**
  13978. * The right direction of that transform in world space.
  13979. */
  13980. readonly right: Vector3;
  13981. /**
  13982. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13983. * @param matrix the matrix to copy the pose from
  13984. * @returns this TransformNode.
  13985. */
  13986. updatePoseMatrix(matrix: Matrix): TransformNode;
  13987. /**
  13988. * Returns the mesh Pose matrix.
  13989. * @returns the pose matrix
  13990. */
  13991. getPoseMatrix(): Matrix;
  13992. /** @hidden */
  13993. _isSynchronized(): boolean;
  13994. /** @hidden */
  13995. _initCache(): void;
  13996. /**
  13997. * Flag the transform node as dirty (Forcing it to update everything)
  13998. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13999. * @returns this transform node
  14000. */
  14001. markAsDirty(property: string): TransformNode;
  14002. /**
  14003. * Returns the current mesh absolute position.
  14004. * Returns a Vector3.
  14005. */
  14006. readonly absolutePosition: Vector3;
  14007. /**
  14008. * Returns the current mesh absolute scaling.
  14009. * Returns a Vector3.
  14010. */
  14011. readonly absoluteScaling: Vector3;
  14012. /**
  14013. * Returns the current mesh absolute rotation.
  14014. * Returns a Quaternion.
  14015. */
  14016. readonly absoluteRotationQuaternion: Quaternion;
  14017. /**
  14018. * Sets a new matrix to apply before all other transformation
  14019. * @param matrix defines the transform matrix
  14020. * @returns the current TransformNode
  14021. */
  14022. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14023. /**
  14024. * Sets a new pivot matrix to the current node
  14025. * @param matrix defines the new pivot matrix to use
  14026. * @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
  14027. * @returns the current TransformNode
  14028. */
  14029. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14030. /**
  14031. * Returns the mesh pivot matrix.
  14032. * Default : Identity.
  14033. * @returns the matrix
  14034. */
  14035. getPivotMatrix(): Matrix;
  14036. /**
  14037. * Instantiate (when possible) or clone that node with its hierarchy
  14038. * @param newParent defines the new parent to use for the instance (or clone)
  14039. * @returns an instance (or a clone) of the current node with its hiearchy
  14040. */
  14041. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14042. /**
  14043. * Prevents the World matrix to be computed any longer
  14044. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14045. * @returns the TransformNode.
  14046. */
  14047. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14048. /**
  14049. * Allows back the World matrix computation.
  14050. * @returns the TransformNode.
  14051. */
  14052. unfreezeWorldMatrix(): this;
  14053. /**
  14054. * True if the World matrix has been frozen.
  14055. */
  14056. readonly isWorldMatrixFrozen: boolean;
  14057. /**
  14058. * Retuns the mesh absolute position in the World.
  14059. * @returns a Vector3.
  14060. */
  14061. getAbsolutePosition(): Vector3;
  14062. /**
  14063. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14064. * @param absolutePosition the absolute position to set
  14065. * @returns the TransformNode.
  14066. */
  14067. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14068. /**
  14069. * Sets the mesh position in its local space.
  14070. * @param vector3 the position to set in localspace
  14071. * @returns the TransformNode.
  14072. */
  14073. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14074. /**
  14075. * Returns the mesh position in the local space from the current World matrix values.
  14076. * @returns a new Vector3.
  14077. */
  14078. getPositionExpressedInLocalSpace(): Vector3;
  14079. /**
  14080. * Translates the mesh along the passed Vector3 in its local space.
  14081. * @param vector3 the distance to translate in localspace
  14082. * @returns the TransformNode.
  14083. */
  14084. locallyTranslate(vector3: Vector3): TransformNode;
  14085. private static _lookAtVectorCache;
  14086. /**
  14087. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14088. * @param targetPoint the position (must be in same space as current mesh) to look at
  14089. * @param yawCor optional yaw (y-axis) correction in radians
  14090. * @param pitchCor optional pitch (x-axis) correction in radians
  14091. * @param rollCor optional roll (z-axis) correction in radians
  14092. * @param space the choosen space of the target
  14093. * @returns the TransformNode.
  14094. */
  14095. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14096. /**
  14097. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14098. * This Vector3 is expressed in the World space.
  14099. * @param localAxis axis to rotate
  14100. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14101. */
  14102. getDirection(localAxis: Vector3): Vector3;
  14103. /**
  14104. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14105. * localAxis is expressed in the mesh local space.
  14106. * result is computed in the Wordl space from the mesh World matrix.
  14107. * @param localAxis axis to rotate
  14108. * @param result the resulting transformnode
  14109. * @returns this TransformNode.
  14110. */
  14111. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14112. /**
  14113. * Sets this transform node rotation to the given local axis.
  14114. * @param localAxis the axis in local space
  14115. * @param yawCor optional yaw (y-axis) correction in radians
  14116. * @param pitchCor optional pitch (x-axis) correction in radians
  14117. * @param rollCor optional roll (z-axis) correction in radians
  14118. * @returns this TransformNode
  14119. */
  14120. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14121. /**
  14122. * Sets a new pivot point to the current node
  14123. * @param point defines the new pivot point to use
  14124. * @param space defines if the point is in world or local space (local by default)
  14125. * @returns the current TransformNode
  14126. */
  14127. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14128. /**
  14129. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14130. * @returns the pivot point
  14131. */
  14132. getPivotPoint(): Vector3;
  14133. /**
  14134. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14135. * @param result the vector3 to store the result
  14136. * @returns this TransformNode.
  14137. */
  14138. getPivotPointToRef(result: Vector3): TransformNode;
  14139. /**
  14140. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14141. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14142. */
  14143. getAbsolutePivotPoint(): Vector3;
  14144. /**
  14145. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14146. * @param result vector3 to store the result
  14147. * @returns this TransformNode.
  14148. */
  14149. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14150. /**
  14151. * Defines the passed node as the parent of the current node.
  14152. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14153. * @see https://doc.babylonjs.com/how_to/parenting
  14154. * @param node the node ot set as the parent
  14155. * @returns this TransformNode.
  14156. */
  14157. setParent(node: Nullable<Node>): TransformNode;
  14158. private _nonUniformScaling;
  14159. /**
  14160. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14161. */
  14162. readonly nonUniformScaling: boolean;
  14163. /** @hidden */
  14164. _updateNonUniformScalingState(value: boolean): boolean;
  14165. /**
  14166. * Attach the current TransformNode to another TransformNode associated with a bone
  14167. * @param bone Bone affecting the TransformNode
  14168. * @param affectedTransformNode TransformNode associated with the bone
  14169. * @returns this object
  14170. */
  14171. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14172. /**
  14173. * Detach the transform node if its associated with a bone
  14174. * @returns this object
  14175. */
  14176. detachFromBone(): TransformNode;
  14177. private static _rotationAxisCache;
  14178. /**
  14179. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14180. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14181. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14182. * The passed axis is also normalized.
  14183. * @param axis the axis to rotate around
  14184. * @param amount the amount to rotate in radians
  14185. * @param space Space to rotate in (Default: local)
  14186. * @returns the TransformNode.
  14187. */
  14188. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14189. /**
  14190. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14191. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14192. * The passed axis is also normalized. .
  14193. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14194. * @param point the point to rotate around
  14195. * @param axis the axis to rotate around
  14196. * @param amount the amount to rotate in radians
  14197. * @returns the TransformNode
  14198. */
  14199. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14200. /**
  14201. * Translates the mesh along the axis vector for the passed distance in the given space.
  14202. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14203. * @param axis the axis to translate in
  14204. * @param distance the distance to translate
  14205. * @param space Space to rotate in (Default: local)
  14206. * @returns the TransformNode.
  14207. */
  14208. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14209. /**
  14210. * Adds a rotation step to the mesh current rotation.
  14211. * x, y, z are Euler angles expressed in radians.
  14212. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14213. * This means this rotation is made in the mesh local space only.
  14214. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14215. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14216. * ```javascript
  14217. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14218. * ```
  14219. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14220. * 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.
  14221. * @param x Rotation to add
  14222. * @param y Rotation to add
  14223. * @param z Rotation to add
  14224. * @returns the TransformNode.
  14225. */
  14226. addRotation(x: number, y: number, z: number): TransformNode;
  14227. /**
  14228. * @hidden
  14229. */
  14230. protected _getEffectiveParent(): Nullable<Node>;
  14231. /**
  14232. * Computes the world matrix of the node
  14233. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14234. * @returns the world matrix
  14235. */
  14236. computeWorldMatrix(force?: boolean): Matrix;
  14237. protected _afterComputeWorldMatrix(): void;
  14238. /**
  14239. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14240. * @param func callback function to add
  14241. *
  14242. * @returns the TransformNode.
  14243. */
  14244. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14245. /**
  14246. * Removes a registered callback function.
  14247. * @param func callback function to remove
  14248. * @returns the TransformNode.
  14249. */
  14250. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Gets the position of the current mesh in camera space
  14253. * @param camera defines the camera to use
  14254. * @returns a position
  14255. */
  14256. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14257. /**
  14258. * Returns the distance from the mesh to the active camera
  14259. * @param camera defines the camera to use
  14260. * @returns the distance
  14261. */
  14262. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14263. /**
  14264. * Clone the current transform node
  14265. * @param name Name of the new clone
  14266. * @param newParent New parent for the clone
  14267. * @param doNotCloneChildren Do not clone children hierarchy
  14268. * @returns the new transform node
  14269. */
  14270. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14271. /**
  14272. * Serializes the objects information.
  14273. * @param currentSerializationObject defines the object to serialize in
  14274. * @returns the serialized object
  14275. */
  14276. serialize(currentSerializationObject?: any): any;
  14277. /**
  14278. * Returns a new TransformNode object parsed from the source provided.
  14279. * @param parsedTransformNode is the source.
  14280. * @param scene the scne the object belongs to
  14281. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14282. * @returns a new TransformNode object parsed from the source provided.
  14283. */
  14284. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14285. /**
  14286. * Get all child-transformNodes of this node
  14287. * @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
  14288. * @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
  14289. * @returns an array of TransformNode
  14290. */
  14291. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14292. /**
  14293. * Releases resources associated with this transform node.
  14294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14296. */
  14297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14298. /**
  14299. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14300. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14301. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14302. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14303. * @returns the current mesh
  14304. */
  14305. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14306. private _syncAbsoluteScalingAndRotation;
  14307. }
  14308. }
  14309. declare module BABYLON {
  14310. /**
  14311. * Defines the types of pose enabled controllers that are supported
  14312. */
  14313. export enum PoseEnabledControllerType {
  14314. /**
  14315. * HTC Vive
  14316. */
  14317. VIVE = 0,
  14318. /**
  14319. * Oculus Rift
  14320. */
  14321. OCULUS = 1,
  14322. /**
  14323. * Windows mixed reality
  14324. */
  14325. WINDOWS = 2,
  14326. /**
  14327. * Samsung gear VR
  14328. */
  14329. GEAR_VR = 3,
  14330. /**
  14331. * Google Daydream
  14332. */
  14333. DAYDREAM = 4,
  14334. /**
  14335. * Generic
  14336. */
  14337. GENERIC = 5
  14338. }
  14339. /**
  14340. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14341. */
  14342. export interface MutableGamepadButton {
  14343. /**
  14344. * Value of the button/trigger
  14345. */
  14346. value: number;
  14347. /**
  14348. * If the button/trigger is currently touched
  14349. */
  14350. touched: boolean;
  14351. /**
  14352. * If the button/trigger is currently pressed
  14353. */
  14354. pressed: boolean;
  14355. }
  14356. /**
  14357. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14358. * @hidden
  14359. */
  14360. export interface ExtendedGamepadButton extends GamepadButton {
  14361. /**
  14362. * If the button/trigger is currently pressed
  14363. */
  14364. readonly pressed: boolean;
  14365. /**
  14366. * If the button/trigger is currently touched
  14367. */
  14368. readonly touched: boolean;
  14369. /**
  14370. * Value of the button/trigger
  14371. */
  14372. readonly value: number;
  14373. }
  14374. /** @hidden */
  14375. export interface _GamePadFactory {
  14376. /**
  14377. * Returns wether or not the current gamepad can be created for this type of controller.
  14378. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14379. * @returns true if it can be created, otherwise false
  14380. */
  14381. canCreate(gamepadInfo: any): boolean;
  14382. /**
  14383. * Creates a new instance of the Gamepad.
  14384. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14385. * @returns the new gamepad instance
  14386. */
  14387. create(gamepadInfo: any): Gamepad;
  14388. }
  14389. /**
  14390. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14391. */
  14392. export class PoseEnabledControllerHelper {
  14393. /** @hidden */
  14394. static _ControllerFactories: _GamePadFactory[];
  14395. /** @hidden */
  14396. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14397. /**
  14398. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14399. * @param vrGamepad the gamepad to initialized
  14400. * @returns a vr controller of the type the gamepad identified as
  14401. */
  14402. static InitiateController(vrGamepad: any): Gamepad;
  14403. }
  14404. /**
  14405. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14406. */
  14407. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14408. /**
  14409. * If the controller is used in a webXR session
  14410. */
  14411. isXR: boolean;
  14412. private _deviceRoomPosition;
  14413. private _deviceRoomRotationQuaternion;
  14414. /**
  14415. * The device position in babylon space
  14416. */
  14417. devicePosition: Vector3;
  14418. /**
  14419. * The device rotation in babylon space
  14420. */
  14421. deviceRotationQuaternion: Quaternion;
  14422. /**
  14423. * The scale factor of the device in babylon space
  14424. */
  14425. deviceScaleFactor: number;
  14426. /**
  14427. * (Likely devicePosition should be used instead) The device position in its room space
  14428. */
  14429. position: Vector3;
  14430. /**
  14431. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14432. */
  14433. rotationQuaternion: Quaternion;
  14434. /**
  14435. * The type of controller (Eg. Windows mixed reality)
  14436. */
  14437. controllerType: PoseEnabledControllerType;
  14438. protected _calculatedPosition: Vector3;
  14439. private _calculatedRotation;
  14440. /**
  14441. * The raw pose from the device
  14442. */
  14443. rawPose: DevicePose;
  14444. private _trackPosition;
  14445. private _maxRotationDistFromHeadset;
  14446. private _draggedRoomRotation;
  14447. /**
  14448. * @hidden
  14449. */
  14450. _disableTrackPosition(fixedPosition: Vector3): void;
  14451. /**
  14452. * Internal, the mesh attached to the controller
  14453. * @hidden
  14454. */
  14455. _mesh: Nullable<AbstractMesh>;
  14456. private _poseControlledCamera;
  14457. private _leftHandSystemQuaternion;
  14458. /**
  14459. * Internal, matrix used to convert room space to babylon space
  14460. * @hidden
  14461. */
  14462. _deviceToWorld: Matrix;
  14463. /**
  14464. * Node to be used when casting a ray from the controller
  14465. * @hidden
  14466. */
  14467. _pointingPoseNode: Nullable<TransformNode>;
  14468. /**
  14469. * Name of the child mesh that can be used to cast a ray from the controller
  14470. */
  14471. static readonly POINTING_POSE: string;
  14472. /**
  14473. * Creates a new PoseEnabledController from a gamepad
  14474. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14475. */
  14476. constructor(browserGamepad: any);
  14477. private _workingMatrix;
  14478. /**
  14479. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14480. */
  14481. update(): void;
  14482. /**
  14483. * Updates only the pose device and mesh without doing any button event checking
  14484. */
  14485. protected _updatePoseAndMesh(): void;
  14486. /**
  14487. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14488. * @param poseData raw pose fromthe device
  14489. */
  14490. updateFromDevice(poseData: DevicePose): void;
  14491. /**
  14492. * @hidden
  14493. */
  14494. _meshAttachedObservable: Observable<AbstractMesh>;
  14495. /**
  14496. * Attaches a mesh to the controller
  14497. * @param mesh the mesh to be attached
  14498. */
  14499. attachToMesh(mesh: AbstractMesh): void;
  14500. /**
  14501. * Attaches the controllers mesh to a camera
  14502. * @param camera the camera the mesh should be attached to
  14503. */
  14504. attachToPoseControlledCamera(camera: TargetCamera): void;
  14505. /**
  14506. * Disposes of the controller
  14507. */
  14508. dispose(): void;
  14509. /**
  14510. * The mesh that is attached to the controller
  14511. */
  14512. readonly mesh: Nullable<AbstractMesh>;
  14513. /**
  14514. * Gets the ray of the controller in the direction the controller is pointing
  14515. * @param length the length the resulting ray should be
  14516. * @returns a ray in the direction the controller is pointing
  14517. */
  14518. getForwardRay(length?: number): Ray;
  14519. }
  14520. }
  14521. declare module BABYLON {
  14522. /**
  14523. * Defines the WebVRController object that represents controllers tracked in 3D space
  14524. */
  14525. export abstract class WebVRController extends PoseEnabledController {
  14526. /**
  14527. * Internal, the default controller model for the controller
  14528. */
  14529. protected _defaultModel: Nullable<AbstractMesh>;
  14530. /**
  14531. * Fired when the trigger state has changed
  14532. */
  14533. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14534. /**
  14535. * Fired when the main button state has changed
  14536. */
  14537. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14538. /**
  14539. * Fired when the secondary button state has changed
  14540. */
  14541. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14542. /**
  14543. * Fired when the pad state has changed
  14544. */
  14545. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14546. /**
  14547. * Fired when controllers stick values have changed
  14548. */
  14549. onPadValuesChangedObservable: Observable<StickValues>;
  14550. /**
  14551. * Array of button availible on the controller
  14552. */
  14553. protected _buttons: Array<MutableGamepadButton>;
  14554. private _onButtonStateChange;
  14555. /**
  14556. * Fired when a controller button's state has changed
  14557. * @param callback the callback containing the button that was modified
  14558. */
  14559. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14560. /**
  14561. * X and Y axis corresponding to the controllers joystick
  14562. */
  14563. pad: StickValues;
  14564. /**
  14565. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14566. */
  14567. hand: string;
  14568. /**
  14569. * The default controller model for the controller
  14570. */
  14571. readonly defaultModel: Nullable<AbstractMesh>;
  14572. /**
  14573. * Creates a new WebVRController from a gamepad
  14574. * @param vrGamepad the gamepad that the WebVRController should be created from
  14575. */
  14576. constructor(vrGamepad: any);
  14577. /**
  14578. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14579. */
  14580. update(): void;
  14581. /**
  14582. * Function to be called when a button is modified
  14583. */
  14584. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14585. /**
  14586. * Loads a mesh and attaches it to the controller
  14587. * @param scene the scene the mesh should be added to
  14588. * @param meshLoaded callback for when the mesh has been loaded
  14589. */
  14590. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14591. private _setButtonValue;
  14592. private _changes;
  14593. private _checkChanges;
  14594. /**
  14595. * Disposes of th webVRCOntroller
  14596. */
  14597. dispose(): void;
  14598. }
  14599. }
  14600. declare module BABYLON {
  14601. /**
  14602. * The HemisphericLight simulates the ambient environment light,
  14603. * so the passed direction is the light reflection direction, not the incoming direction.
  14604. */
  14605. export class HemisphericLight extends Light {
  14606. /**
  14607. * The groundColor is the light in the opposite direction to the one specified during creation.
  14608. * 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.
  14609. */
  14610. groundColor: Color3;
  14611. /**
  14612. * The light reflection direction, not the incoming direction.
  14613. */
  14614. direction: Vector3;
  14615. /**
  14616. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14617. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14618. * The HemisphericLight can't cast shadows.
  14619. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14620. * @param name The friendly name of the light
  14621. * @param direction The direction of the light reflection
  14622. * @param scene The scene the light belongs to
  14623. */
  14624. constructor(name: string, direction: Vector3, scene: Scene);
  14625. protected _buildUniformLayout(): void;
  14626. /**
  14627. * Returns the string "HemisphericLight".
  14628. * @return The class name
  14629. */
  14630. getClassName(): string;
  14631. /**
  14632. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14633. * Returns the updated direction.
  14634. * @param target The target the direction should point to
  14635. * @return The computed direction
  14636. */
  14637. setDirectionToTarget(target: Vector3): Vector3;
  14638. /**
  14639. * Returns the shadow generator associated to the light.
  14640. * @returns Always null for hemispheric lights because it does not support shadows.
  14641. */
  14642. getShadowGenerator(): Nullable<IShadowGenerator>;
  14643. /**
  14644. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14645. * @param effect The effect to update
  14646. * @param lightIndex The index of the light in the effect to update
  14647. * @returns The hemispheric light
  14648. */
  14649. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14650. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14651. /**
  14652. * Computes the world matrix of the node
  14653. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14654. * @param useWasUpdatedFlag defines a reserved property
  14655. * @returns the world matrix
  14656. */
  14657. computeWorldMatrix(): Matrix;
  14658. /**
  14659. * Returns the integer 3.
  14660. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14661. */
  14662. getTypeID(): number;
  14663. /**
  14664. * Prepares the list of defines specific to the light type.
  14665. * @param defines the list of defines
  14666. * @param lightIndex defines the index of the light for the effect
  14667. */
  14668. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. /** @hidden */
  14673. export var vrMultiviewToSingleviewPixelShader: {
  14674. name: string;
  14675. shader: string;
  14676. };
  14677. }
  14678. declare module BABYLON {
  14679. /**
  14680. * Renders to multiple views with a single draw call
  14681. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14682. */
  14683. export class MultiviewRenderTarget extends RenderTargetTexture {
  14684. /**
  14685. * Creates a multiview render target
  14686. * @param scene scene used with the render target
  14687. * @param size the size of the render target (used for each view)
  14688. */
  14689. constructor(scene: Scene, size?: number | {
  14690. width: number;
  14691. height: number;
  14692. } | {
  14693. ratio: number;
  14694. });
  14695. /**
  14696. * @hidden
  14697. * @param faceIndex the face index, if its a cube texture
  14698. */
  14699. _bindFrameBuffer(faceIndex?: number): void;
  14700. /**
  14701. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14702. * @returns the view count
  14703. */
  14704. getViewCount(): number;
  14705. }
  14706. }
  14707. declare module BABYLON {
  14708. /**
  14709. * Represents a camera frustum
  14710. */
  14711. export class Frustum {
  14712. /**
  14713. * Gets the planes representing the frustum
  14714. * @param transform matrix to be applied to the returned planes
  14715. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14716. */
  14717. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14718. /**
  14719. * Gets the near frustum plane transformed by the transform matrix
  14720. * @param transform transformation matrix to be applied to the resulting frustum plane
  14721. * @param frustumPlane the resuling frustum plane
  14722. */
  14723. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14724. /**
  14725. * Gets the far frustum plane transformed by the transform matrix
  14726. * @param transform transformation matrix to be applied to the resulting frustum plane
  14727. * @param frustumPlane the resuling frustum plane
  14728. */
  14729. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14730. /**
  14731. * Gets the left frustum plane transformed by the transform matrix
  14732. * @param transform transformation matrix to be applied to the resulting frustum plane
  14733. * @param frustumPlane the resuling frustum plane
  14734. */
  14735. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14736. /**
  14737. * Gets the right frustum plane transformed by the transform matrix
  14738. * @param transform transformation matrix to be applied to the resulting frustum plane
  14739. * @param frustumPlane the resuling frustum plane
  14740. */
  14741. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14742. /**
  14743. * Gets the top frustum plane transformed by the transform matrix
  14744. * @param transform transformation matrix to be applied to the resulting frustum plane
  14745. * @param frustumPlane the resuling frustum plane
  14746. */
  14747. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14748. /**
  14749. * Gets the bottom frustum plane transformed by the transform matrix
  14750. * @param transform transformation matrix to be applied to the resulting frustum plane
  14751. * @param frustumPlane the resuling frustum plane
  14752. */
  14753. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14754. /**
  14755. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14756. * @param transform transformation matrix to be applied to the resulting frustum planes
  14757. * @param frustumPlanes the resuling frustum planes
  14758. */
  14759. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14760. }
  14761. }
  14762. declare module BABYLON {
  14763. interface Engine {
  14764. /**
  14765. * Creates a new multiview render target
  14766. * @param width defines the width of the texture
  14767. * @param height defines the height of the texture
  14768. * @returns the created multiview texture
  14769. */
  14770. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14771. /**
  14772. * Binds a multiview framebuffer to be drawn to
  14773. * @param multiviewTexture texture to bind
  14774. */
  14775. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14776. }
  14777. interface Camera {
  14778. /**
  14779. * @hidden
  14780. * 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)
  14781. */
  14782. _useMultiviewToSingleView: boolean;
  14783. /**
  14784. * @hidden
  14785. * 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)
  14786. */
  14787. _multiviewTexture: Nullable<RenderTargetTexture>;
  14788. /**
  14789. * @hidden
  14790. * ensures the multiview texture of the camera exists and has the specified width/height
  14791. * @param width height to set on the multiview texture
  14792. * @param height width to set on the multiview texture
  14793. */
  14794. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14795. }
  14796. interface Scene {
  14797. /** @hidden */
  14798. _transformMatrixR: Matrix;
  14799. /** @hidden */
  14800. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14801. /** @hidden */
  14802. _createMultiviewUbo(): void;
  14803. /** @hidden */
  14804. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14805. /** @hidden */
  14806. _renderMultiviewToSingleView(camera: Camera): void;
  14807. }
  14808. }
  14809. declare module BABYLON {
  14810. /**
  14811. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14812. * This will not be used for webXR as it supports displaying texture arrays directly
  14813. */
  14814. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14815. /**
  14816. * Initializes a VRMultiviewToSingleview
  14817. * @param name name of the post process
  14818. * @param camera camera to be applied to
  14819. * @param scaleFactor scaling factor to the size of the output texture
  14820. */
  14821. constructor(name: string, camera: Camera, scaleFactor: number);
  14822. }
  14823. }
  14824. declare module BABYLON {
  14825. interface Engine {
  14826. /** @hidden */
  14827. _vrDisplay: any;
  14828. /** @hidden */
  14829. _vrSupported: boolean;
  14830. /** @hidden */
  14831. _oldSize: Size;
  14832. /** @hidden */
  14833. _oldHardwareScaleFactor: number;
  14834. /** @hidden */
  14835. _vrExclusivePointerMode: boolean;
  14836. /** @hidden */
  14837. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14838. /** @hidden */
  14839. _onVRDisplayPointerRestricted: () => void;
  14840. /** @hidden */
  14841. _onVRDisplayPointerUnrestricted: () => void;
  14842. /** @hidden */
  14843. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14844. /** @hidden */
  14845. _onVrDisplayDisconnect: Nullable<() => void>;
  14846. /** @hidden */
  14847. _onVrDisplayPresentChange: Nullable<() => void>;
  14848. /**
  14849. * Observable signaled when VR display mode changes
  14850. */
  14851. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14852. /**
  14853. * Observable signaled when VR request present is complete
  14854. */
  14855. onVRRequestPresentComplete: Observable<boolean>;
  14856. /**
  14857. * Observable signaled when VR request present starts
  14858. */
  14859. onVRRequestPresentStart: Observable<Engine>;
  14860. /**
  14861. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14862. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14863. */
  14864. isInVRExclusivePointerMode: boolean;
  14865. /**
  14866. * Gets a boolean indicating if a webVR device was detected
  14867. * @returns true if a webVR device was detected
  14868. */
  14869. isVRDevicePresent(): boolean;
  14870. /**
  14871. * Gets the current webVR device
  14872. * @returns the current webVR device (or null)
  14873. */
  14874. getVRDevice(): any;
  14875. /**
  14876. * Initializes a webVR display and starts listening to display change events
  14877. * The onVRDisplayChangedObservable will be notified upon these changes
  14878. * @returns A promise containing a VRDisplay and if vr is supported
  14879. */
  14880. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14881. /** @hidden */
  14882. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14883. /**
  14884. * Call this function to switch to webVR mode
  14885. * Will do nothing if webVR is not supported or if there is no webVR device
  14886. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14887. */
  14888. enableVR(): void;
  14889. /** @hidden */
  14890. _onVRFullScreenTriggered(): void;
  14891. }
  14892. }
  14893. declare module BABYLON {
  14894. /**
  14895. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14896. * IMPORTANT!! The data is right-hand data.
  14897. * @export
  14898. * @interface DevicePose
  14899. */
  14900. export interface DevicePose {
  14901. /**
  14902. * The position of the device, values in array are [x,y,z].
  14903. */
  14904. readonly position: Nullable<Float32Array>;
  14905. /**
  14906. * The linearVelocity of the device, values in array are [x,y,z].
  14907. */
  14908. readonly linearVelocity: Nullable<Float32Array>;
  14909. /**
  14910. * The linearAcceleration of the device, values in array are [x,y,z].
  14911. */
  14912. readonly linearAcceleration: Nullable<Float32Array>;
  14913. /**
  14914. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14915. */
  14916. readonly orientation: Nullable<Float32Array>;
  14917. /**
  14918. * The angularVelocity of the device, values in array are [x,y,z].
  14919. */
  14920. readonly angularVelocity: Nullable<Float32Array>;
  14921. /**
  14922. * The angularAcceleration of the device, values in array are [x,y,z].
  14923. */
  14924. readonly angularAcceleration: Nullable<Float32Array>;
  14925. }
  14926. /**
  14927. * Interface representing a pose controlled object in Babylon.
  14928. * A pose controlled object has both regular pose values as well as pose values
  14929. * from an external device such as a VR head mounted display
  14930. */
  14931. export interface PoseControlled {
  14932. /**
  14933. * The position of the object in babylon space.
  14934. */
  14935. position: Vector3;
  14936. /**
  14937. * The rotation quaternion of the object in babylon space.
  14938. */
  14939. rotationQuaternion: Quaternion;
  14940. /**
  14941. * The position of the device in babylon space.
  14942. */
  14943. devicePosition?: Vector3;
  14944. /**
  14945. * The rotation quaternion of the device in babylon space.
  14946. */
  14947. deviceRotationQuaternion: Quaternion;
  14948. /**
  14949. * The raw pose coming from the device.
  14950. */
  14951. rawPose: Nullable<DevicePose>;
  14952. /**
  14953. * The scale of the device to be used when translating from device space to babylon space.
  14954. */
  14955. deviceScaleFactor: number;
  14956. /**
  14957. * Updates the poseControlled values based on the input device pose.
  14958. * @param poseData the pose data to update the object with
  14959. */
  14960. updateFromDevice(poseData: DevicePose): void;
  14961. }
  14962. /**
  14963. * Set of options to customize the webVRCamera
  14964. */
  14965. export interface WebVROptions {
  14966. /**
  14967. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14968. */
  14969. trackPosition?: boolean;
  14970. /**
  14971. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14972. */
  14973. positionScale?: number;
  14974. /**
  14975. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14976. */
  14977. displayName?: string;
  14978. /**
  14979. * Should the native controller meshes be initialized. (default: true)
  14980. */
  14981. controllerMeshes?: boolean;
  14982. /**
  14983. * Creating a default HemiLight only on controllers. (default: true)
  14984. */
  14985. defaultLightingOnControllers?: boolean;
  14986. /**
  14987. * If you don't want to use the default VR button of the helper. (default: false)
  14988. */
  14989. useCustomVRButton?: boolean;
  14990. /**
  14991. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14992. */
  14993. customVRButton?: HTMLButtonElement;
  14994. /**
  14995. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14996. */
  14997. rayLength?: number;
  14998. /**
  14999. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15000. */
  15001. defaultHeight?: number;
  15002. /**
  15003. * If multiview should be used if availible (default: false)
  15004. */
  15005. useMultiview?: boolean;
  15006. }
  15007. /**
  15008. * This represents a WebVR camera.
  15009. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15010. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15011. */
  15012. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15013. private webVROptions;
  15014. /**
  15015. * @hidden
  15016. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15017. */
  15018. _vrDevice: any;
  15019. /**
  15020. * The rawPose of the vrDevice.
  15021. */
  15022. rawPose: Nullable<DevicePose>;
  15023. private _onVREnabled;
  15024. private _specsVersion;
  15025. private _attached;
  15026. private _frameData;
  15027. protected _descendants: Array<Node>;
  15028. private _deviceRoomPosition;
  15029. /** @hidden */
  15030. _deviceRoomRotationQuaternion: Quaternion;
  15031. private _standingMatrix;
  15032. /**
  15033. * Represents device position in babylon space.
  15034. */
  15035. devicePosition: Vector3;
  15036. /**
  15037. * Represents device rotation in babylon space.
  15038. */
  15039. deviceRotationQuaternion: Quaternion;
  15040. /**
  15041. * The scale of the device to be used when translating from device space to babylon space.
  15042. */
  15043. deviceScaleFactor: number;
  15044. private _deviceToWorld;
  15045. private _worldToDevice;
  15046. /**
  15047. * References to the webVR controllers for the vrDevice.
  15048. */
  15049. controllers: Array<WebVRController>;
  15050. /**
  15051. * Emits an event when a controller is attached.
  15052. */
  15053. onControllersAttachedObservable: Observable<WebVRController[]>;
  15054. /**
  15055. * Emits an event when a controller's mesh has been loaded;
  15056. */
  15057. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15058. /**
  15059. * Emits an event when the HMD's pose has been updated.
  15060. */
  15061. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15062. private _poseSet;
  15063. /**
  15064. * If the rig cameras be used as parent instead of this camera.
  15065. */
  15066. rigParenting: boolean;
  15067. private _lightOnControllers;
  15068. private _defaultHeight?;
  15069. /**
  15070. * Instantiates a WebVRFreeCamera.
  15071. * @param name The name of the WebVRFreeCamera
  15072. * @param position The starting anchor position for the camera
  15073. * @param scene The scene the camera belongs to
  15074. * @param webVROptions a set of customizable options for the webVRCamera
  15075. */
  15076. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15077. /**
  15078. * Gets the device distance from the ground in meters.
  15079. * @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.
  15080. */
  15081. deviceDistanceToRoomGround(): number;
  15082. /**
  15083. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15084. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15085. */
  15086. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15087. /**
  15088. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15089. * @returns A promise with a boolean set to if the standing matrix is supported.
  15090. */
  15091. useStandingMatrixAsync(): Promise<boolean>;
  15092. /**
  15093. * Disposes the camera
  15094. */
  15095. dispose(): void;
  15096. /**
  15097. * Gets a vrController by name.
  15098. * @param name The name of the controller to retreive
  15099. * @returns the controller matching the name specified or null if not found
  15100. */
  15101. getControllerByName(name: string): Nullable<WebVRController>;
  15102. private _leftController;
  15103. /**
  15104. * The controller corresponding to the users left hand.
  15105. */
  15106. readonly leftController: Nullable<WebVRController>;
  15107. private _rightController;
  15108. /**
  15109. * The controller corresponding to the users right hand.
  15110. */
  15111. readonly rightController: Nullable<WebVRController>;
  15112. /**
  15113. * Casts a ray forward from the vrCamera's gaze.
  15114. * @param length Length of the ray (default: 100)
  15115. * @returns the ray corresponding to the gaze
  15116. */
  15117. getForwardRay(length?: number): Ray;
  15118. /**
  15119. * @hidden
  15120. * Updates the camera based on device's frame data
  15121. */
  15122. _checkInputs(): void;
  15123. /**
  15124. * Updates the poseControlled values based on the input device pose.
  15125. * @param poseData Pose coming from the device
  15126. */
  15127. updateFromDevice(poseData: DevicePose): void;
  15128. private _htmlElementAttached;
  15129. private _detachIfAttached;
  15130. /**
  15131. * WebVR's attach control will start broadcasting frames to the device.
  15132. * Note that in certain browsers (chrome for example) this function must be called
  15133. * within a user-interaction callback. Example:
  15134. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15135. *
  15136. * @param element html element to attach the vrDevice to
  15137. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15138. */
  15139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15140. /**
  15141. * Detaches the camera from the html element and disables VR
  15142. *
  15143. * @param element html element to detach from
  15144. */
  15145. detachControl(element: HTMLElement): void;
  15146. /**
  15147. * @returns the name of this class
  15148. */
  15149. getClassName(): string;
  15150. /**
  15151. * Calls resetPose on the vrDisplay
  15152. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15153. */
  15154. resetToCurrentRotation(): void;
  15155. /**
  15156. * @hidden
  15157. * Updates the rig cameras (left and right eye)
  15158. */
  15159. _updateRigCameras(): void;
  15160. private _workingVector;
  15161. private _oneVector;
  15162. private _workingMatrix;
  15163. private updateCacheCalled;
  15164. private _correctPositionIfNotTrackPosition;
  15165. /**
  15166. * @hidden
  15167. * Updates the cached values of the camera
  15168. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15169. */
  15170. _updateCache(ignoreParentClass?: boolean): void;
  15171. /**
  15172. * @hidden
  15173. * Get current device position in babylon world
  15174. */
  15175. _computeDevicePosition(): void;
  15176. /**
  15177. * Updates the current device position and rotation in the babylon world
  15178. */
  15179. update(): void;
  15180. /**
  15181. * @hidden
  15182. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15183. * @returns an identity matrix
  15184. */
  15185. _getViewMatrix(): Matrix;
  15186. private _tmpMatrix;
  15187. /**
  15188. * This function is called by the two RIG cameras.
  15189. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15190. * @hidden
  15191. */
  15192. _getWebVRViewMatrix(): Matrix;
  15193. /** @hidden */
  15194. _getWebVRProjectionMatrix(): Matrix;
  15195. private _onGamepadConnectedObserver;
  15196. private _onGamepadDisconnectedObserver;
  15197. private _updateCacheWhenTrackingDisabledObserver;
  15198. /**
  15199. * Initializes the controllers and their meshes
  15200. */
  15201. initControllers(): void;
  15202. }
  15203. }
  15204. declare module BABYLON {
  15205. /**
  15206. * Size options for a post process
  15207. */
  15208. export type PostProcessOptions = {
  15209. width: number;
  15210. height: number;
  15211. };
  15212. /**
  15213. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15214. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15215. */
  15216. export class PostProcess {
  15217. /** Name of the PostProcess. */
  15218. name: string;
  15219. /**
  15220. * Gets or sets the unique id of the post process
  15221. */
  15222. uniqueId: number;
  15223. /**
  15224. * Width of the texture to apply the post process on
  15225. */
  15226. width: number;
  15227. /**
  15228. * Height of the texture to apply the post process on
  15229. */
  15230. height: number;
  15231. /**
  15232. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15233. * @hidden
  15234. */
  15235. _outputTexture: Nullable<InternalTexture>;
  15236. /**
  15237. * Sampling mode used by the shader
  15238. * See https://doc.babylonjs.com/classes/3.1/texture
  15239. */
  15240. renderTargetSamplingMode: number;
  15241. /**
  15242. * Clear color to use when screen clearing
  15243. */
  15244. clearColor: Color4;
  15245. /**
  15246. * If the buffer needs to be cleared before applying the post process. (default: true)
  15247. * Should be set to false if shader will overwrite all previous pixels.
  15248. */
  15249. autoClear: boolean;
  15250. /**
  15251. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15252. */
  15253. alphaMode: number;
  15254. /**
  15255. * Sets the setAlphaBlendConstants of the babylon engine
  15256. */
  15257. alphaConstants: Color4;
  15258. /**
  15259. * Animations to be used for the post processing
  15260. */
  15261. animations: Animation[];
  15262. /**
  15263. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15264. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15265. */
  15266. enablePixelPerfectMode: boolean;
  15267. /**
  15268. * Force the postprocess to be applied without taking in account viewport
  15269. */
  15270. forceFullscreenViewport: boolean;
  15271. /**
  15272. * List of inspectable custom properties (used by the Inspector)
  15273. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15274. */
  15275. inspectableCustomProperties: IInspectable[];
  15276. /**
  15277. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15278. *
  15279. * | Value | Type | Description |
  15280. * | ----- | ----------------------------------- | ----------- |
  15281. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15282. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15283. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15284. *
  15285. */
  15286. scaleMode: number;
  15287. /**
  15288. * Force textures to be a power of two (default: false)
  15289. */
  15290. alwaysForcePOT: boolean;
  15291. private _samples;
  15292. /**
  15293. * Number of sample textures (default: 1)
  15294. */
  15295. samples: number;
  15296. /**
  15297. * Modify the scale of the post process to be the same as the viewport (default: false)
  15298. */
  15299. adaptScaleToCurrentViewport: boolean;
  15300. private _camera;
  15301. private _scene;
  15302. private _engine;
  15303. private _options;
  15304. private _reusable;
  15305. private _textureType;
  15306. /**
  15307. * Smart array of input and output textures for the post process.
  15308. * @hidden
  15309. */
  15310. _textures: SmartArray<InternalTexture>;
  15311. /**
  15312. * The index in _textures that corresponds to the output texture.
  15313. * @hidden
  15314. */
  15315. _currentRenderTextureInd: number;
  15316. private _effect;
  15317. private _samplers;
  15318. private _fragmentUrl;
  15319. private _vertexUrl;
  15320. private _parameters;
  15321. private _scaleRatio;
  15322. protected _indexParameters: any;
  15323. private _shareOutputWithPostProcess;
  15324. private _texelSize;
  15325. private _forcedOutputTexture;
  15326. /**
  15327. * Returns the fragment url or shader name used in the post process.
  15328. * @returns the fragment url or name in the shader store.
  15329. */
  15330. getEffectName(): string;
  15331. /**
  15332. * An event triggered when the postprocess is activated.
  15333. */
  15334. onActivateObservable: Observable<Camera>;
  15335. private _onActivateObserver;
  15336. /**
  15337. * A function that is added to the onActivateObservable
  15338. */
  15339. onActivate: Nullable<(camera: Camera) => void>;
  15340. /**
  15341. * An event triggered when the postprocess changes its size.
  15342. */
  15343. onSizeChangedObservable: Observable<PostProcess>;
  15344. private _onSizeChangedObserver;
  15345. /**
  15346. * A function that is added to the onSizeChangedObservable
  15347. */
  15348. onSizeChanged: (postProcess: PostProcess) => void;
  15349. /**
  15350. * An event triggered when the postprocess applies its effect.
  15351. */
  15352. onApplyObservable: Observable<Effect>;
  15353. private _onApplyObserver;
  15354. /**
  15355. * A function that is added to the onApplyObservable
  15356. */
  15357. onApply: (effect: Effect) => void;
  15358. /**
  15359. * An event triggered before rendering the postprocess
  15360. */
  15361. onBeforeRenderObservable: Observable<Effect>;
  15362. private _onBeforeRenderObserver;
  15363. /**
  15364. * A function that is added to the onBeforeRenderObservable
  15365. */
  15366. onBeforeRender: (effect: Effect) => void;
  15367. /**
  15368. * An event triggered after rendering the postprocess
  15369. */
  15370. onAfterRenderObservable: Observable<Effect>;
  15371. private _onAfterRenderObserver;
  15372. /**
  15373. * A function that is added to the onAfterRenderObservable
  15374. */
  15375. onAfterRender: (efect: Effect) => void;
  15376. /**
  15377. * 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
  15378. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15379. */
  15380. inputTexture: InternalTexture;
  15381. /**
  15382. * Gets the camera which post process is applied to.
  15383. * @returns The camera the post process is applied to.
  15384. */
  15385. getCamera(): Camera;
  15386. /**
  15387. * Gets the texel size of the postprocess.
  15388. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15389. */
  15390. readonly texelSize: Vector2;
  15391. /**
  15392. * Creates a new instance PostProcess
  15393. * @param name The name of the PostProcess.
  15394. * @param fragmentUrl The url of the fragment shader to be used.
  15395. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15396. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15398. * @param camera The camera to apply the render pass to.
  15399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15400. * @param engine The engine which the post process will be applied. (default: current engine)
  15401. * @param reusable If the post process can be reused on the same frame. (default: false)
  15402. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15403. * @param textureType Type of textures used when performing the post process. (default: 0)
  15404. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15405. * @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
  15406. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15407. */
  15408. constructor(
  15409. /** Name of the PostProcess. */
  15410. 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);
  15411. /**
  15412. * Gets a string idenfifying the name of the class
  15413. * @returns "PostProcess" string
  15414. */
  15415. getClassName(): string;
  15416. /**
  15417. * Gets the engine which this post process belongs to.
  15418. * @returns The engine the post process was enabled with.
  15419. */
  15420. getEngine(): Engine;
  15421. /**
  15422. * The effect that is created when initializing the post process.
  15423. * @returns The created effect corresponding the the postprocess.
  15424. */
  15425. getEffect(): Effect;
  15426. /**
  15427. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15428. * @param postProcess The post process to share the output with.
  15429. * @returns This post process.
  15430. */
  15431. shareOutputWith(postProcess: PostProcess): PostProcess;
  15432. /**
  15433. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15434. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15435. */
  15436. useOwnOutput(): void;
  15437. /**
  15438. * Updates the effect with the current post process compile time values and recompiles the shader.
  15439. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15440. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15441. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15442. * @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
  15443. * @param onCompiled Called when the shader has been compiled.
  15444. * @param onError Called if there is an error when compiling a shader.
  15445. */
  15446. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15447. /**
  15448. * The post process is reusable if it can be used multiple times within one frame.
  15449. * @returns If the post process is reusable
  15450. */
  15451. isReusable(): boolean;
  15452. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15453. markTextureDirty(): void;
  15454. /**
  15455. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15456. * 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.
  15457. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15458. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15459. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15460. * @returns The target texture that was bound to be written to.
  15461. */
  15462. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15463. /**
  15464. * If the post process is supported.
  15465. */
  15466. readonly isSupported: boolean;
  15467. /**
  15468. * The aspect ratio of the output texture.
  15469. */
  15470. readonly aspectRatio: number;
  15471. /**
  15472. * Get a value indicating if the post-process is ready to be used
  15473. * @returns true if the post-process is ready (shader is compiled)
  15474. */
  15475. isReady(): boolean;
  15476. /**
  15477. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15478. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15479. */
  15480. apply(): Nullable<Effect>;
  15481. private _disposeTextures;
  15482. /**
  15483. * Disposes the post process.
  15484. * @param camera The camera to dispose the post process on.
  15485. */
  15486. dispose(camera?: Camera): void;
  15487. }
  15488. }
  15489. declare module BABYLON {
  15490. /** @hidden */
  15491. export var kernelBlurVaryingDeclaration: {
  15492. name: string;
  15493. shader: string;
  15494. };
  15495. }
  15496. declare module BABYLON {
  15497. /** @hidden */
  15498. export var kernelBlurFragment: {
  15499. name: string;
  15500. shader: string;
  15501. };
  15502. }
  15503. declare module BABYLON {
  15504. /** @hidden */
  15505. export var kernelBlurFragment2: {
  15506. name: string;
  15507. shader: string;
  15508. };
  15509. }
  15510. declare module BABYLON {
  15511. /** @hidden */
  15512. export var kernelBlurPixelShader: {
  15513. name: string;
  15514. shader: string;
  15515. };
  15516. }
  15517. declare module BABYLON {
  15518. /** @hidden */
  15519. export var kernelBlurVertex: {
  15520. name: string;
  15521. shader: string;
  15522. };
  15523. }
  15524. declare module BABYLON {
  15525. /** @hidden */
  15526. export var kernelBlurVertexShader: {
  15527. name: string;
  15528. shader: string;
  15529. };
  15530. }
  15531. declare module BABYLON {
  15532. /**
  15533. * The Blur Post Process which blurs an image based on a kernel and direction.
  15534. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15535. */
  15536. export class BlurPostProcess extends PostProcess {
  15537. /** The direction in which to blur the image. */
  15538. direction: Vector2;
  15539. private blockCompilation;
  15540. protected _kernel: number;
  15541. protected _idealKernel: number;
  15542. protected _packedFloat: boolean;
  15543. private _staticDefines;
  15544. /**
  15545. * Sets the length in pixels of the blur sample region
  15546. */
  15547. /**
  15548. * Gets the length in pixels of the blur sample region
  15549. */
  15550. kernel: number;
  15551. /**
  15552. * Sets wether or not the blur needs to unpack/repack floats
  15553. */
  15554. /**
  15555. * Gets wether or not the blur is unpacking/repacking floats
  15556. */
  15557. packedFloat: boolean;
  15558. /**
  15559. * Creates a new instance BlurPostProcess
  15560. * @param name The name of the effect.
  15561. * @param direction The direction in which to blur the image.
  15562. * @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.
  15563. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15564. * @param camera The camera to apply the render pass to.
  15565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15566. * @param engine The engine which the post process will be applied. (default: current engine)
  15567. * @param reusable If the post process can be reused on the same frame. (default: false)
  15568. * @param textureType Type of textures used when performing the post process. (default: 0)
  15569. * @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)
  15570. */
  15571. constructor(name: string,
  15572. /** The direction in which to blur the image. */
  15573. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15574. /**
  15575. * Updates the effect with the current post process compile time values and recompiles the shader.
  15576. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15577. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15578. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15579. * @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
  15580. * @param onCompiled Called when the shader has been compiled.
  15581. * @param onError Called if there is an error when compiling a shader.
  15582. */
  15583. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15584. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15585. /**
  15586. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15587. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15588. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15589. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15590. * The gaps between physical kernels are compensated for in the weighting of the samples
  15591. * @param idealKernel Ideal blur kernel.
  15592. * @return Nearest best kernel.
  15593. */
  15594. protected _nearestBestKernel(idealKernel: number): number;
  15595. /**
  15596. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15597. * @param x The point on the Gaussian distribution to sample.
  15598. * @return the value of the Gaussian function at x.
  15599. */
  15600. protected _gaussianWeight(x: number): number;
  15601. /**
  15602. * Generates a string that can be used as a floating point number in GLSL.
  15603. * @param x Value to print.
  15604. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15605. * @return GLSL float string.
  15606. */
  15607. protected _glslFloat(x: number, decimalFigures?: number): string;
  15608. }
  15609. }
  15610. declare module BABYLON {
  15611. /**
  15612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15614. * You can then easily use it as a reflectionTexture on a flat surface.
  15615. * In case the surface is not a plane, please consider relying on reflection probes.
  15616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15617. */
  15618. export class MirrorTexture extends RenderTargetTexture {
  15619. private scene;
  15620. /**
  15621. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15622. * 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.
  15623. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15624. */
  15625. mirrorPlane: Plane;
  15626. /**
  15627. * Define the blur ratio used to blur the reflection if needed.
  15628. */
  15629. blurRatio: number;
  15630. /**
  15631. * Define the adaptive blur kernel used to blur the reflection if needed.
  15632. * This will autocompute the closest best match for the `blurKernel`
  15633. */
  15634. adaptiveBlurKernel: number;
  15635. /**
  15636. * Define the blur kernel used to blur the reflection if needed.
  15637. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15638. */
  15639. blurKernel: number;
  15640. /**
  15641. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15642. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15643. */
  15644. blurKernelX: number;
  15645. /**
  15646. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15647. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15648. */
  15649. blurKernelY: number;
  15650. private _autoComputeBlurKernel;
  15651. protected _onRatioRescale(): void;
  15652. private _updateGammaSpace;
  15653. private _imageProcessingConfigChangeObserver;
  15654. private _transformMatrix;
  15655. private _mirrorMatrix;
  15656. private _savedViewMatrix;
  15657. private _blurX;
  15658. private _blurY;
  15659. private _adaptiveBlurKernel;
  15660. private _blurKernelX;
  15661. private _blurKernelY;
  15662. private _blurRatio;
  15663. /**
  15664. * Instantiates a Mirror Texture.
  15665. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15666. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15667. * You can then easily use it as a reflectionTexture on a flat surface.
  15668. * In case the surface is not a plane, please consider relying on reflection probes.
  15669. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15670. * @param name
  15671. * @param size
  15672. * @param scene
  15673. * @param generateMipMaps
  15674. * @param type
  15675. * @param samplingMode
  15676. * @param generateDepthBuffer
  15677. */
  15678. constructor(name: string, size: number | {
  15679. width: number;
  15680. height: number;
  15681. } | {
  15682. ratio: number;
  15683. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15684. private _preparePostProcesses;
  15685. /**
  15686. * Clone the mirror texture.
  15687. * @returns the cloned texture
  15688. */
  15689. clone(): MirrorTexture;
  15690. /**
  15691. * Serialize the texture to a JSON representation you could use in Parse later on
  15692. * @returns the serialized JSON representation
  15693. */
  15694. serialize(): any;
  15695. /**
  15696. * Dispose the texture and release its associated resources.
  15697. */
  15698. dispose(): void;
  15699. }
  15700. }
  15701. declare module BABYLON {
  15702. /**
  15703. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15704. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15705. */
  15706. export class Texture extends BaseTexture {
  15707. /**
  15708. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15709. */
  15710. static SerializeBuffers: boolean;
  15711. /** @hidden */
  15712. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15713. /** @hidden */
  15714. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15715. /** @hidden */
  15716. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15717. /** nearest is mag = nearest and min = nearest and mip = linear */
  15718. static readonly NEAREST_SAMPLINGMODE: number;
  15719. /** nearest is mag = nearest and min = nearest and mip = linear */
  15720. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15722. static readonly BILINEAR_SAMPLINGMODE: number;
  15723. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15724. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15725. /** Trilinear is mag = linear and min = linear and mip = linear */
  15726. static readonly TRILINEAR_SAMPLINGMODE: number;
  15727. /** Trilinear is mag = linear and min = linear and mip = linear */
  15728. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15729. /** mag = nearest and min = nearest and mip = nearest */
  15730. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15731. /** mag = nearest and min = linear and mip = nearest */
  15732. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15733. /** mag = nearest and min = linear and mip = linear */
  15734. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15735. /** mag = nearest and min = linear and mip = none */
  15736. static readonly NEAREST_LINEAR: number;
  15737. /** mag = nearest and min = nearest and mip = none */
  15738. static readonly NEAREST_NEAREST: number;
  15739. /** mag = linear and min = nearest and mip = nearest */
  15740. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15741. /** mag = linear and min = nearest and mip = linear */
  15742. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15743. /** mag = linear and min = linear and mip = none */
  15744. static readonly LINEAR_LINEAR: number;
  15745. /** mag = linear and min = nearest and mip = none */
  15746. static readonly LINEAR_NEAREST: number;
  15747. /** Explicit coordinates mode */
  15748. static readonly EXPLICIT_MODE: number;
  15749. /** Spherical coordinates mode */
  15750. static readonly SPHERICAL_MODE: number;
  15751. /** Planar coordinates mode */
  15752. static readonly PLANAR_MODE: number;
  15753. /** Cubic coordinates mode */
  15754. static readonly CUBIC_MODE: number;
  15755. /** Projection coordinates mode */
  15756. static readonly PROJECTION_MODE: number;
  15757. /** Inverse Cubic coordinates mode */
  15758. static readonly SKYBOX_MODE: number;
  15759. /** Inverse Cubic coordinates mode */
  15760. static readonly INVCUBIC_MODE: number;
  15761. /** Equirectangular coordinates mode */
  15762. static readonly EQUIRECTANGULAR_MODE: number;
  15763. /** Equirectangular Fixed coordinates mode */
  15764. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15765. /** Equirectangular Fixed Mirrored coordinates mode */
  15766. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15767. /** Texture is not repeating outside of 0..1 UVs */
  15768. static readonly CLAMP_ADDRESSMODE: number;
  15769. /** Texture is repeating outside of 0..1 UVs */
  15770. static readonly WRAP_ADDRESSMODE: number;
  15771. /** Texture is repeating and mirrored */
  15772. static readonly MIRROR_ADDRESSMODE: number;
  15773. /**
  15774. * 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
  15775. */
  15776. static UseSerializedUrlIfAny: boolean;
  15777. /**
  15778. * Define the url of the texture.
  15779. */
  15780. url: Nullable<string>;
  15781. /**
  15782. * Define an offset on the texture to offset the u coordinates of the UVs
  15783. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15784. */
  15785. uOffset: number;
  15786. /**
  15787. * Define an offset on the texture to offset the v coordinates of the UVs
  15788. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15789. */
  15790. vOffset: number;
  15791. /**
  15792. * Define an offset on the texture to scale the u coordinates of the UVs
  15793. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15794. */
  15795. uScale: number;
  15796. /**
  15797. * Define an offset on the texture to scale the v coordinates of the UVs
  15798. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15799. */
  15800. vScale: number;
  15801. /**
  15802. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15803. * @see http://doc.babylonjs.com/how_to/more_materials
  15804. */
  15805. uAng: number;
  15806. /**
  15807. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15808. * @see http://doc.babylonjs.com/how_to/more_materials
  15809. */
  15810. vAng: number;
  15811. /**
  15812. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15813. * @see http://doc.babylonjs.com/how_to/more_materials
  15814. */
  15815. wAng: number;
  15816. /**
  15817. * Defines the center of rotation (U)
  15818. */
  15819. uRotationCenter: number;
  15820. /**
  15821. * Defines the center of rotation (V)
  15822. */
  15823. vRotationCenter: number;
  15824. /**
  15825. * Defines the center of rotation (W)
  15826. */
  15827. wRotationCenter: number;
  15828. /**
  15829. * Are mip maps generated for this texture or not.
  15830. */
  15831. readonly noMipmap: boolean;
  15832. /**
  15833. * List of inspectable custom properties (used by the Inspector)
  15834. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15835. */
  15836. inspectableCustomProperties: Nullable<IInspectable[]>;
  15837. private _noMipmap;
  15838. /** @hidden */
  15839. _invertY: boolean;
  15840. private _rowGenerationMatrix;
  15841. private _cachedTextureMatrix;
  15842. private _projectionModeMatrix;
  15843. private _t0;
  15844. private _t1;
  15845. private _t2;
  15846. private _cachedUOffset;
  15847. private _cachedVOffset;
  15848. private _cachedUScale;
  15849. private _cachedVScale;
  15850. private _cachedUAng;
  15851. private _cachedVAng;
  15852. private _cachedWAng;
  15853. private _cachedProjectionMatrixId;
  15854. private _cachedCoordinatesMode;
  15855. /** @hidden */
  15856. protected _initialSamplingMode: number;
  15857. /** @hidden */
  15858. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15859. private _deleteBuffer;
  15860. protected _format: Nullable<number>;
  15861. private _delayedOnLoad;
  15862. private _delayedOnError;
  15863. /**
  15864. * Observable triggered once the texture has been loaded.
  15865. */
  15866. onLoadObservable: Observable<Texture>;
  15867. protected _isBlocking: boolean;
  15868. /**
  15869. * Is the texture preventing material to render while loading.
  15870. * If false, a default texture will be used instead of the loading one during the preparation step.
  15871. */
  15872. isBlocking: boolean;
  15873. /**
  15874. * Get the current sampling mode associated with the texture.
  15875. */
  15876. readonly samplingMode: number;
  15877. /**
  15878. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15879. */
  15880. readonly invertY: boolean;
  15881. /**
  15882. * Instantiates a new texture.
  15883. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15884. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15885. * @param url define the url of the picture to load as a texture
  15886. * @param scene define the scene or engine the texture will belong to
  15887. * @param noMipmap define if the texture will require mip maps or not
  15888. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15889. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15890. * @param onLoad define a callback triggered when the texture has been loaded
  15891. * @param onError define a callback triggered when an error occurred during the loading session
  15892. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15893. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15894. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15895. */
  15896. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15897. /**
  15898. * Update the url (and optional buffer) of this texture if url was null during construction.
  15899. * @param url the url of the texture
  15900. * @param buffer the buffer of the texture (defaults to null)
  15901. * @param onLoad callback called when the texture is loaded (defaults to null)
  15902. */
  15903. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15904. /**
  15905. * Finish the loading sequence of a texture flagged as delayed load.
  15906. * @hidden
  15907. */
  15908. delayLoad(): void;
  15909. private _prepareRowForTextureGeneration;
  15910. /**
  15911. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15912. * @returns the transform matrix of the texture.
  15913. */
  15914. getTextureMatrix(): Matrix;
  15915. /**
  15916. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15917. * @returns The reflection texture transform
  15918. */
  15919. getReflectionTextureMatrix(): Matrix;
  15920. /**
  15921. * Clones the texture.
  15922. * @returns the cloned texture
  15923. */
  15924. clone(): Texture;
  15925. /**
  15926. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15927. * @returns The JSON representation of the texture
  15928. */
  15929. serialize(): any;
  15930. /**
  15931. * Get the current class name of the texture useful for serialization or dynamic coding.
  15932. * @returns "Texture"
  15933. */
  15934. getClassName(): string;
  15935. /**
  15936. * Dispose the texture and release its associated resources.
  15937. */
  15938. dispose(): void;
  15939. /**
  15940. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15941. * @param parsedTexture Define the JSON representation of the texture
  15942. * @param scene Define the scene the parsed texture should be instantiated in
  15943. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15944. * @returns The parsed texture if successful
  15945. */
  15946. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15947. /**
  15948. * Creates a texture from its base 64 representation.
  15949. * @param data Define the base64 payload without the data: prefix
  15950. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15951. * @param scene Define the scene the texture should belong to
  15952. * @param noMipmap Forces the texture to not create mip map information if true
  15953. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15954. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15955. * @param onLoad define a callback triggered when the texture has been loaded
  15956. * @param onError define a callback triggered when an error occurred during the loading session
  15957. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15958. * @returns the created texture
  15959. */
  15960. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15961. /**
  15962. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15963. * @param data Define the base64 payload without the data: prefix
  15964. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15965. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15966. * @param scene Define the scene the texture should belong to
  15967. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15968. * @param noMipmap Forces the texture to not create mip map information if true
  15969. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15970. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15971. * @param onLoad define a callback triggered when the texture has been loaded
  15972. * @param onError define a callback triggered when an error occurred during the loading session
  15973. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15974. * @returns the created texture
  15975. */
  15976. 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;
  15977. }
  15978. }
  15979. declare module BABYLON {
  15980. /**
  15981. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15982. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15983. */
  15984. export class PostProcessManager {
  15985. private _scene;
  15986. private _indexBuffer;
  15987. private _vertexBuffers;
  15988. /**
  15989. * Creates a new instance PostProcess
  15990. * @param scene The scene that the post process is associated with.
  15991. */
  15992. constructor(scene: Scene);
  15993. private _prepareBuffers;
  15994. private _buildIndexBuffer;
  15995. /**
  15996. * Rebuilds the vertex buffers of the manager.
  15997. * @hidden
  15998. */
  15999. _rebuild(): void;
  16000. /**
  16001. * Prepares a frame to be run through a post process.
  16002. * @param sourceTexture The input texture to the post procesess. (default: null)
  16003. * @param postProcesses An array of post processes to be run. (default: null)
  16004. * @returns True if the post processes were able to be run.
  16005. * @hidden
  16006. */
  16007. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16008. /**
  16009. * Manually render a set of post processes to a texture.
  16010. * @param postProcesses An array of post processes to be run.
  16011. * @param targetTexture The target texture to render to.
  16012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16013. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16014. * @param lodLevel defines which lod of the texture to render to
  16015. */
  16016. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16017. /**
  16018. * Finalize the result of the output of the postprocesses.
  16019. * @param doNotPresent If true the result will not be displayed to the screen.
  16020. * @param targetTexture The target texture to render to.
  16021. * @param faceIndex The index of the face to bind the target texture to.
  16022. * @param postProcesses The array of post processes to render.
  16023. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16024. * @hidden
  16025. */
  16026. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16027. /**
  16028. * Disposes of the post process manager.
  16029. */
  16030. dispose(): void;
  16031. }
  16032. }
  16033. declare module BABYLON {
  16034. /** Interface used by value gradients (color, factor, ...) */
  16035. export interface IValueGradient {
  16036. /**
  16037. * Gets or sets the gradient value (between 0 and 1)
  16038. */
  16039. gradient: number;
  16040. }
  16041. /** Class used to store color4 gradient */
  16042. export class ColorGradient implements IValueGradient {
  16043. /**
  16044. * Gets or sets the gradient value (between 0 and 1)
  16045. */
  16046. gradient: number;
  16047. /**
  16048. * Gets or sets first associated color
  16049. */
  16050. color1: Color4;
  16051. /**
  16052. * Gets or sets second associated color
  16053. */
  16054. color2?: Color4;
  16055. /**
  16056. * Will get a color picked randomly between color1 and color2.
  16057. * If color2 is undefined then color1 will be used
  16058. * @param result defines the target Color4 to store the result in
  16059. */
  16060. getColorToRef(result: Color4): void;
  16061. }
  16062. /** Class used to store color 3 gradient */
  16063. export class Color3Gradient implements IValueGradient {
  16064. /**
  16065. * Gets or sets the gradient value (between 0 and 1)
  16066. */
  16067. gradient: number;
  16068. /**
  16069. * Gets or sets the associated color
  16070. */
  16071. color: Color3;
  16072. }
  16073. /** Class used to store factor gradient */
  16074. export class FactorGradient implements IValueGradient {
  16075. /**
  16076. * Gets or sets the gradient value (between 0 and 1)
  16077. */
  16078. gradient: number;
  16079. /**
  16080. * Gets or sets first associated factor
  16081. */
  16082. factor1: number;
  16083. /**
  16084. * Gets or sets second associated factor
  16085. */
  16086. factor2?: number;
  16087. /**
  16088. * Will get a number picked randomly between factor1 and factor2.
  16089. * If factor2 is undefined then factor1 will be used
  16090. * @returns the picked number
  16091. */
  16092. getFactor(): number;
  16093. }
  16094. /**
  16095. * Helper used to simplify some generic gradient tasks
  16096. */
  16097. export class GradientHelper {
  16098. /**
  16099. * Gets the current gradient from an array of IValueGradient
  16100. * @param ratio defines the current ratio to get
  16101. * @param gradients defines the array of IValueGradient
  16102. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16103. */
  16104. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16105. }
  16106. }
  16107. declare module BABYLON {
  16108. interface ThinEngine {
  16109. /**
  16110. * Creates a dynamic texture
  16111. * @param width defines the width of the texture
  16112. * @param height defines the height of the texture
  16113. * @param generateMipMaps defines if the engine should generate the mip levels
  16114. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16115. * @returns the dynamic texture inside an InternalTexture
  16116. */
  16117. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16118. /**
  16119. * Update the content of a dynamic texture
  16120. * @param texture defines the texture to update
  16121. * @param canvas defines the canvas containing the source
  16122. * @param invertY defines if data must be stored with Y axis inverted
  16123. * @param premulAlpha defines if alpha is stored as premultiplied
  16124. * @param format defines the format of the data
  16125. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16126. */
  16127. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16128. }
  16129. }
  16130. declare module BABYLON {
  16131. /**
  16132. * A class extending Texture allowing drawing on a texture
  16133. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16134. */
  16135. export class DynamicTexture extends Texture {
  16136. private _generateMipMaps;
  16137. private _canvas;
  16138. private _context;
  16139. private _engine;
  16140. /**
  16141. * Creates a DynamicTexture
  16142. * @param name defines the name of the texture
  16143. * @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
  16144. * @param scene defines the scene where you want the texture
  16145. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16146. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16147. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16148. */
  16149. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16150. /**
  16151. * Get the current class name of the texture useful for serialization or dynamic coding.
  16152. * @returns "DynamicTexture"
  16153. */
  16154. getClassName(): string;
  16155. /**
  16156. * Gets the current state of canRescale
  16157. */
  16158. readonly canRescale: boolean;
  16159. private _recreate;
  16160. /**
  16161. * Scales the texture
  16162. * @param ratio the scale factor to apply to both width and height
  16163. */
  16164. scale(ratio: number): void;
  16165. /**
  16166. * Resizes the texture
  16167. * @param width the new width
  16168. * @param height the new height
  16169. */
  16170. scaleTo(width: number, height: number): void;
  16171. /**
  16172. * Gets the context of the canvas used by the texture
  16173. * @returns the canvas context of the dynamic texture
  16174. */
  16175. getContext(): CanvasRenderingContext2D;
  16176. /**
  16177. * Clears the texture
  16178. */
  16179. clear(): void;
  16180. /**
  16181. * Updates the texture
  16182. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16183. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16184. */
  16185. update(invertY?: boolean, premulAlpha?: boolean): void;
  16186. /**
  16187. * Draws text onto the texture
  16188. * @param text defines the text to be drawn
  16189. * @param x defines the placement of the text from the left
  16190. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16191. * @param font defines the font to be used with font-style, font-size, font-name
  16192. * @param color defines the color used for the text
  16193. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16194. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16195. * @param update defines whether texture is immediately update (default is true)
  16196. */
  16197. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16198. /**
  16199. * Clones the texture
  16200. * @returns the clone of the texture.
  16201. */
  16202. clone(): DynamicTexture;
  16203. /**
  16204. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16205. * @returns a serialized dynamic texture object
  16206. */
  16207. serialize(): any;
  16208. /** @hidden */
  16209. _rebuild(): void;
  16210. }
  16211. }
  16212. declare module BABYLON {
  16213. interface AbstractScene {
  16214. /**
  16215. * The list of procedural textures added to the scene
  16216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16217. */
  16218. proceduralTextures: Array<ProceduralTexture>;
  16219. }
  16220. /**
  16221. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16222. * in a given scene.
  16223. */
  16224. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16225. /**
  16226. * The component name helpfull to identify the component in the list of scene components.
  16227. */
  16228. readonly name: string;
  16229. /**
  16230. * The scene the component belongs to.
  16231. */
  16232. scene: Scene;
  16233. /**
  16234. * Creates a new instance of the component for the given scene
  16235. * @param scene Defines the scene to register the component in
  16236. */
  16237. constructor(scene: Scene);
  16238. /**
  16239. * Registers the component in a given scene
  16240. */
  16241. register(): void;
  16242. /**
  16243. * Rebuilds the elements related to this component in case of
  16244. * context lost for instance.
  16245. */
  16246. rebuild(): void;
  16247. /**
  16248. * Disposes the component and the associated ressources.
  16249. */
  16250. dispose(): void;
  16251. private _beforeClear;
  16252. }
  16253. }
  16254. declare module BABYLON {
  16255. interface ThinEngine {
  16256. /**
  16257. * Creates a new render target cube texture
  16258. * @param size defines the size of the texture
  16259. * @param options defines the options used to create the texture
  16260. * @returns a new render target cube texture stored in an InternalTexture
  16261. */
  16262. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16263. }
  16264. }
  16265. declare module BABYLON {
  16266. /** @hidden */
  16267. export var proceduralVertexShader: {
  16268. name: string;
  16269. shader: string;
  16270. };
  16271. }
  16272. declare module BABYLON {
  16273. /**
  16274. * 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.
  16275. * This is the base class of any Procedural texture and contains most of the shareable code.
  16276. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16277. */
  16278. export class ProceduralTexture extends Texture {
  16279. isCube: boolean;
  16280. /**
  16281. * Define if the texture is enabled or not (disabled texture will not render)
  16282. */
  16283. isEnabled: boolean;
  16284. /**
  16285. * Define if the texture must be cleared before rendering (default is true)
  16286. */
  16287. autoClear: boolean;
  16288. /**
  16289. * Callback called when the texture is generated
  16290. */
  16291. onGenerated: () => void;
  16292. /**
  16293. * Event raised when the texture is generated
  16294. */
  16295. onGeneratedObservable: Observable<ProceduralTexture>;
  16296. /** @hidden */
  16297. _generateMipMaps: boolean;
  16298. /** @hidden **/
  16299. _effect: Effect;
  16300. /** @hidden */
  16301. _textures: {
  16302. [key: string]: Texture;
  16303. };
  16304. private _size;
  16305. private _currentRefreshId;
  16306. private _refreshRate;
  16307. private _vertexBuffers;
  16308. private _indexBuffer;
  16309. private _uniforms;
  16310. private _samplers;
  16311. private _fragment;
  16312. private _floats;
  16313. private _ints;
  16314. private _floatsArrays;
  16315. private _colors3;
  16316. private _colors4;
  16317. private _vectors2;
  16318. private _vectors3;
  16319. private _matrices;
  16320. private _fallbackTexture;
  16321. private _fallbackTextureUsed;
  16322. private _engine;
  16323. private _cachedDefines;
  16324. private _contentUpdateId;
  16325. private _contentData;
  16326. /**
  16327. * Instantiates a new procedural texture.
  16328. * 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.
  16329. * This is the base class of any Procedural texture and contains most of the shareable code.
  16330. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16331. * @param name Define the name of the texture
  16332. * @param size Define the size of the texture to create
  16333. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16334. * @param scene Define the scene the texture belongs to
  16335. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16336. * @param generateMipMaps Define if the texture should creates mip maps or not
  16337. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16338. */
  16339. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16340. /**
  16341. * The effect that is created when initializing the post process.
  16342. * @returns The created effect corresponding the the postprocess.
  16343. */
  16344. getEffect(): Effect;
  16345. /**
  16346. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16347. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16348. */
  16349. getContent(): Nullable<ArrayBufferView>;
  16350. private _createIndexBuffer;
  16351. /** @hidden */
  16352. _rebuild(): void;
  16353. /**
  16354. * Resets the texture in order to recreate its associated resources.
  16355. * This can be called in case of context loss
  16356. */
  16357. reset(): void;
  16358. protected _getDefines(): string;
  16359. /**
  16360. * Is the texture ready to be used ? (rendered at least once)
  16361. * @returns true if ready, otherwise, false.
  16362. */
  16363. isReady(): boolean;
  16364. /**
  16365. * Resets the refresh counter of the texture and start bak from scratch.
  16366. * Could be useful to regenerate the texture if it is setup to render only once.
  16367. */
  16368. resetRefreshCounter(): void;
  16369. /**
  16370. * Set the fragment shader to use in order to render the texture.
  16371. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16372. */
  16373. setFragment(fragment: any): void;
  16374. /**
  16375. * Define the refresh rate of the texture or the rendering frequency.
  16376. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16377. */
  16378. refreshRate: number;
  16379. /** @hidden */
  16380. _shouldRender(): boolean;
  16381. /**
  16382. * Get the size the texture is rendering at.
  16383. * @returns the size (texture is always squared)
  16384. */
  16385. getRenderSize(): number;
  16386. /**
  16387. * Resize the texture to new value.
  16388. * @param size Define the new size the texture should have
  16389. * @param generateMipMaps Define whether the new texture should create mip maps
  16390. */
  16391. resize(size: number, generateMipMaps: boolean): void;
  16392. private _checkUniform;
  16393. /**
  16394. * Set a texture in the shader program used to render.
  16395. * @param name Define the name of the uniform samplers as defined in the shader
  16396. * @param texture Define the texture to bind to this sampler
  16397. * @return the texture itself allowing "fluent" like uniform updates
  16398. */
  16399. setTexture(name: string, texture: Texture): ProceduralTexture;
  16400. /**
  16401. * Set a float in the shader.
  16402. * @param name Define the name of the uniform as defined in the shader
  16403. * @param value Define the value to give to the uniform
  16404. * @return the texture itself allowing "fluent" like uniform updates
  16405. */
  16406. setFloat(name: string, value: number): ProceduralTexture;
  16407. /**
  16408. * Set a int in the shader.
  16409. * @param name Define the name of the uniform as defined in the shader
  16410. * @param value Define the value to give to the uniform
  16411. * @return the texture itself allowing "fluent" like uniform updates
  16412. */
  16413. setInt(name: string, value: number): ProceduralTexture;
  16414. /**
  16415. * Set an array of floats in the shader.
  16416. * @param name Define the name of the uniform as defined in the shader
  16417. * @param value Define the value to give to the uniform
  16418. * @return the texture itself allowing "fluent" like uniform updates
  16419. */
  16420. setFloats(name: string, value: number[]): ProceduralTexture;
  16421. /**
  16422. * Set a vec3 in the shader from a Color3.
  16423. * @param name Define the name of the uniform as defined in the shader
  16424. * @param value Define the value to give to the uniform
  16425. * @return the texture itself allowing "fluent" like uniform updates
  16426. */
  16427. setColor3(name: string, value: Color3): ProceduralTexture;
  16428. /**
  16429. * Set a vec4 in the shader from a Color4.
  16430. * @param name Define the name of the uniform as defined in the shader
  16431. * @param value Define the value to give to the uniform
  16432. * @return the texture itself allowing "fluent" like uniform updates
  16433. */
  16434. setColor4(name: string, value: Color4): ProceduralTexture;
  16435. /**
  16436. * Set a vec2 in the shader from a Vector2.
  16437. * @param name Define the name of the uniform as defined in the shader
  16438. * @param value Define the value to give to the uniform
  16439. * @return the texture itself allowing "fluent" like uniform updates
  16440. */
  16441. setVector2(name: string, value: Vector2): ProceduralTexture;
  16442. /**
  16443. * Set a vec3 in the shader from a Vector3.
  16444. * @param name Define the name of the uniform as defined in the shader
  16445. * @param value Define the value to give to the uniform
  16446. * @return the texture itself allowing "fluent" like uniform updates
  16447. */
  16448. setVector3(name: string, value: Vector3): ProceduralTexture;
  16449. /**
  16450. * Set a mat4 in the shader from a MAtrix.
  16451. * @param name Define the name of the uniform as defined in the shader
  16452. * @param value Define the value to give to the uniform
  16453. * @return the texture itself allowing "fluent" like uniform updates
  16454. */
  16455. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16456. /**
  16457. * Render the texture to its associated render target.
  16458. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16459. */
  16460. render(useCameraPostProcess?: boolean): void;
  16461. /**
  16462. * Clone the texture.
  16463. * @returns the cloned texture
  16464. */
  16465. clone(): ProceduralTexture;
  16466. /**
  16467. * Dispose the texture and release its asoociated resources.
  16468. */
  16469. dispose(): void;
  16470. }
  16471. }
  16472. declare module BABYLON {
  16473. /**
  16474. * This represents the base class for particle system in Babylon.
  16475. * 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.
  16476. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16477. * @example https://doc.babylonjs.com/babylon101/particles
  16478. */
  16479. export class BaseParticleSystem {
  16480. /**
  16481. * Source color is added to the destination color without alpha affecting the result
  16482. */
  16483. static BLENDMODE_ONEONE: number;
  16484. /**
  16485. * Blend current color and particle color using particle’s alpha
  16486. */
  16487. static BLENDMODE_STANDARD: number;
  16488. /**
  16489. * Add current color and particle color multiplied by particle’s alpha
  16490. */
  16491. static BLENDMODE_ADD: number;
  16492. /**
  16493. * Multiply current color with particle color
  16494. */
  16495. static BLENDMODE_MULTIPLY: number;
  16496. /**
  16497. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16498. */
  16499. static BLENDMODE_MULTIPLYADD: number;
  16500. /**
  16501. * List of animations used by the particle system.
  16502. */
  16503. animations: Animation[];
  16504. /**
  16505. * The id of the Particle system.
  16506. */
  16507. id: string;
  16508. /**
  16509. * The friendly name of the Particle system.
  16510. */
  16511. name: string;
  16512. /**
  16513. * The rendering group used by the Particle system to chose when to render.
  16514. */
  16515. renderingGroupId: number;
  16516. /**
  16517. * The emitter represents the Mesh or position we are attaching the particle system to.
  16518. */
  16519. emitter: Nullable<AbstractMesh | Vector3>;
  16520. /**
  16521. * The maximum number of particles to emit per frame
  16522. */
  16523. emitRate: number;
  16524. /**
  16525. * If you want to launch only a few particles at once, that can be done, as well.
  16526. */
  16527. manualEmitCount: number;
  16528. /**
  16529. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16530. */
  16531. updateSpeed: number;
  16532. /**
  16533. * The amount of time the particle system is running (depends of the overall update speed).
  16534. */
  16535. targetStopDuration: number;
  16536. /**
  16537. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16538. */
  16539. disposeOnStop: boolean;
  16540. /**
  16541. * Minimum power of emitting particles.
  16542. */
  16543. minEmitPower: number;
  16544. /**
  16545. * Maximum power of emitting particles.
  16546. */
  16547. maxEmitPower: number;
  16548. /**
  16549. * Minimum life time of emitting particles.
  16550. */
  16551. minLifeTime: number;
  16552. /**
  16553. * Maximum life time of emitting particles.
  16554. */
  16555. maxLifeTime: number;
  16556. /**
  16557. * Minimum Size of emitting particles.
  16558. */
  16559. minSize: number;
  16560. /**
  16561. * Maximum Size of emitting particles.
  16562. */
  16563. maxSize: number;
  16564. /**
  16565. * Minimum scale of emitting particles on X axis.
  16566. */
  16567. minScaleX: number;
  16568. /**
  16569. * Maximum scale of emitting particles on X axis.
  16570. */
  16571. maxScaleX: number;
  16572. /**
  16573. * Minimum scale of emitting particles on Y axis.
  16574. */
  16575. minScaleY: number;
  16576. /**
  16577. * Maximum scale of emitting particles on Y axis.
  16578. */
  16579. maxScaleY: number;
  16580. /**
  16581. * Gets or sets the minimal initial rotation in radians.
  16582. */
  16583. minInitialRotation: number;
  16584. /**
  16585. * Gets or sets the maximal initial rotation in radians.
  16586. */
  16587. maxInitialRotation: number;
  16588. /**
  16589. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16590. */
  16591. minAngularSpeed: number;
  16592. /**
  16593. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16594. */
  16595. maxAngularSpeed: number;
  16596. /**
  16597. * The texture used to render each particle. (this can be a spritesheet)
  16598. */
  16599. particleTexture: Nullable<Texture>;
  16600. /**
  16601. * The layer mask we are rendering the particles through.
  16602. */
  16603. layerMask: number;
  16604. /**
  16605. * This can help using your own shader to render the particle system.
  16606. * The according effect will be created
  16607. */
  16608. customShader: any;
  16609. /**
  16610. * By default particle system starts as soon as they are created. This prevents the
  16611. * automatic start to happen and let you decide when to start emitting particles.
  16612. */
  16613. preventAutoStart: boolean;
  16614. private _noiseTexture;
  16615. /**
  16616. * Gets or sets a texture used to add random noise to particle positions
  16617. */
  16618. noiseTexture: Nullable<ProceduralTexture>;
  16619. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16620. noiseStrength: Vector3;
  16621. /**
  16622. * Callback triggered when the particle animation is ending.
  16623. */
  16624. onAnimationEnd: Nullable<() => void>;
  16625. /**
  16626. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16627. */
  16628. blendMode: number;
  16629. /**
  16630. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16631. * to override the particles.
  16632. */
  16633. forceDepthWrite: boolean;
  16634. /** 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 */
  16635. preWarmCycles: number;
  16636. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16637. preWarmStepOffset: number;
  16638. /**
  16639. * 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)
  16640. */
  16641. spriteCellChangeSpeed: number;
  16642. /**
  16643. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16644. */
  16645. startSpriteCellID: number;
  16646. /**
  16647. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16648. */
  16649. endSpriteCellID: number;
  16650. /**
  16651. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16652. */
  16653. spriteCellWidth: number;
  16654. /**
  16655. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16656. */
  16657. spriteCellHeight: number;
  16658. /**
  16659. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16660. */
  16661. spriteRandomStartCell: boolean;
  16662. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16663. translationPivot: Vector2;
  16664. /** @hidden */
  16665. protected _isAnimationSheetEnabled: boolean;
  16666. /**
  16667. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16668. */
  16669. beginAnimationOnStart: boolean;
  16670. /**
  16671. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16672. */
  16673. beginAnimationFrom: number;
  16674. /**
  16675. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16676. */
  16677. beginAnimationTo: number;
  16678. /**
  16679. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16680. */
  16681. beginAnimationLoop: boolean;
  16682. /**
  16683. * Gets or sets a world offset applied to all particles
  16684. */
  16685. worldOffset: Vector3;
  16686. /**
  16687. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16688. */
  16689. isAnimationSheetEnabled: boolean;
  16690. /**
  16691. * Get hosting scene
  16692. * @returns the scene
  16693. */
  16694. getScene(): Scene;
  16695. /**
  16696. * You can use gravity if you want to give an orientation to your particles.
  16697. */
  16698. gravity: Vector3;
  16699. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16700. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16701. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16702. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16703. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16704. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16705. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16706. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16707. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16708. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16709. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16710. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16711. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16712. /**
  16713. * Defines the delay in milliseconds before starting the system (0 by default)
  16714. */
  16715. startDelay: number;
  16716. /**
  16717. * Gets the current list of drag gradients.
  16718. * You must use addDragGradient and removeDragGradient to udpate this list
  16719. * @returns the list of drag gradients
  16720. */
  16721. getDragGradients(): Nullable<Array<FactorGradient>>;
  16722. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16723. limitVelocityDamping: number;
  16724. /**
  16725. * Gets the current list of limit velocity gradients.
  16726. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16727. * @returns the list of limit velocity gradients
  16728. */
  16729. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16730. /**
  16731. * Gets the current list of color gradients.
  16732. * You must use addColorGradient and removeColorGradient to udpate this list
  16733. * @returns the list of color gradients
  16734. */
  16735. getColorGradients(): Nullable<Array<ColorGradient>>;
  16736. /**
  16737. * Gets the current list of size gradients.
  16738. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16739. * @returns the list of size gradients
  16740. */
  16741. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16742. /**
  16743. * Gets the current list of color remap gradients.
  16744. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16745. * @returns the list of color remap gradients
  16746. */
  16747. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16748. /**
  16749. * Gets the current list of alpha remap gradients.
  16750. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16751. * @returns the list of alpha remap gradients
  16752. */
  16753. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16754. /**
  16755. * Gets the current list of life time gradients.
  16756. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16757. * @returns the list of life time gradients
  16758. */
  16759. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16760. /**
  16761. * Gets the current list of angular speed gradients.
  16762. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16763. * @returns the list of angular speed gradients
  16764. */
  16765. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16766. /**
  16767. * Gets the current list of velocity gradients.
  16768. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16769. * @returns the list of velocity gradients
  16770. */
  16771. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16772. /**
  16773. * Gets the current list of start size gradients.
  16774. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16775. * @returns the list of start size gradients
  16776. */
  16777. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16778. /**
  16779. * Gets the current list of emit rate gradients.
  16780. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16781. * @returns the list of emit rate gradients
  16782. */
  16783. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16784. /**
  16785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16786. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16787. */
  16788. direction1: Vector3;
  16789. /**
  16790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16791. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16792. */
  16793. direction2: Vector3;
  16794. /**
  16795. * 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.
  16796. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16797. */
  16798. minEmitBox: Vector3;
  16799. /**
  16800. * 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.
  16801. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16802. */
  16803. maxEmitBox: Vector3;
  16804. /**
  16805. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16806. */
  16807. color1: Color4;
  16808. /**
  16809. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16810. */
  16811. color2: Color4;
  16812. /**
  16813. * Color the particle will have at the end of its lifetime
  16814. */
  16815. colorDead: Color4;
  16816. /**
  16817. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16818. */
  16819. textureMask: Color4;
  16820. /**
  16821. * The particle emitter type defines the emitter used by the particle system.
  16822. * It can be for example box, sphere, or cone...
  16823. */
  16824. particleEmitterType: IParticleEmitterType;
  16825. /** @hidden */
  16826. _isSubEmitter: boolean;
  16827. /**
  16828. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16829. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16830. */
  16831. billboardMode: number;
  16832. protected _isBillboardBased: boolean;
  16833. /**
  16834. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16835. */
  16836. isBillboardBased: boolean;
  16837. /**
  16838. * The scene the particle system belongs to.
  16839. */
  16840. protected _scene: Scene;
  16841. /**
  16842. * Local cache of defines for image processing.
  16843. */
  16844. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16845. /**
  16846. * Default configuration related to image processing available in the standard Material.
  16847. */
  16848. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16849. /**
  16850. * Gets the image processing configuration used either in this material.
  16851. */
  16852. /**
  16853. * Sets the Default image processing configuration used either in the this material.
  16854. *
  16855. * If sets to null, the scene one is in use.
  16856. */
  16857. imageProcessingConfiguration: ImageProcessingConfiguration;
  16858. /**
  16859. * Attaches a new image processing configuration to the Standard Material.
  16860. * @param configuration
  16861. */
  16862. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16863. /** @hidden */
  16864. protected _reset(): void;
  16865. /** @hidden */
  16866. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16867. /**
  16868. * Instantiates a particle system.
  16869. * 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.
  16870. * @param name The name of the particle system
  16871. */
  16872. constructor(name: string);
  16873. /**
  16874. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16877. * @returns the emitter
  16878. */
  16879. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16880. /**
  16881. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16882. * @param radius The radius of the hemisphere to emit from
  16883. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16884. * @returns the emitter
  16885. */
  16886. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16887. /**
  16888. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16889. * @param radius The radius of the sphere to emit from
  16890. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16891. * @returns the emitter
  16892. */
  16893. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16894. /**
  16895. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16896. * @param radius The radius of the sphere to emit from
  16897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16899. * @returns the emitter
  16900. */
  16901. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16902. /**
  16903. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16904. * @param radius The radius of the emission cylinder
  16905. * @param height The height of the emission cylinder
  16906. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16907. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16908. * @returns the emitter
  16909. */
  16910. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16911. /**
  16912. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16913. * @param radius The radius of the cylinder to emit from
  16914. * @param height The height of the emission cylinder
  16915. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16916. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16917. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16918. * @returns the emitter
  16919. */
  16920. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16921. /**
  16922. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16923. * @param radius The radius of the cone to emit from
  16924. * @param angle The base angle of the cone
  16925. * @returns the emitter
  16926. */
  16927. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16928. /**
  16929. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16930. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16931. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16932. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16933. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16934. * @returns the emitter
  16935. */
  16936. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16937. }
  16938. }
  16939. declare module BABYLON {
  16940. /**
  16941. * Type of sub emitter
  16942. */
  16943. export enum SubEmitterType {
  16944. /**
  16945. * Attached to the particle over it's lifetime
  16946. */
  16947. ATTACHED = 0,
  16948. /**
  16949. * Created when the particle dies
  16950. */
  16951. END = 1
  16952. }
  16953. /**
  16954. * Sub emitter class used to emit particles from an existing particle
  16955. */
  16956. export class SubEmitter {
  16957. /**
  16958. * the particle system to be used by the sub emitter
  16959. */
  16960. particleSystem: ParticleSystem;
  16961. /**
  16962. * Type of the submitter (Default: END)
  16963. */
  16964. type: SubEmitterType;
  16965. /**
  16966. * 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)
  16967. * Note: This only is supported when using an emitter of type Mesh
  16968. */
  16969. inheritDirection: boolean;
  16970. /**
  16971. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16972. */
  16973. inheritedVelocityAmount: number;
  16974. /**
  16975. * Creates a sub emitter
  16976. * @param particleSystem the particle system to be used by the sub emitter
  16977. */
  16978. constructor(
  16979. /**
  16980. * the particle system to be used by the sub emitter
  16981. */
  16982. particleSystem: ParticleSystem);
  16983. /**
  16984. * Clones the sub emitter
  16985. * @returns the cloned sub emitter
  16986. */
  16987. clone(): SubEmitter;
  16988. /**
  16989. * Serialize current object to a JSON object
  16990. * @returns the serialized object
  16991. */
  16992. serialize(): any;
  16993. /** @hidden */
  16994. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16995. /**
  16996. * Creates a new SubEmitter from a serialized JSON version
  16997. * @param serializationObject defines the JSON object to read from
  16998. * @param scene defines the hosting scene
  16999. * @param rootUrl defines the rootUrl for data loading
  17000. * @returns a new SubEmitter
  17001. */
  17002. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17003. /** Release associated resources */
  17004. dispose(): void;
  17005. }
  17006. }
  17007. declare module BABYLON {
  17008. /** @hidden */
  17009. export var clipPlaneFragmentDeclaration: {
  17010. name: string;
  17011. shader: string;
  17012. };
  17013. }
  17014. declare module BABYLON {
  17015. /** @hidden */
  17016. export var imageProcessingDeclaration: {
  17017. name: string;
  17018. shader: string;
  17019. };
  17020. }
  17021. declare module BABYLON {
  17022. /** @hidden */
  17023. export var imageProcessingFunctions: {
  17024. name: string;
  17025. shader: string;
  17026. };
  17027. }
  17028. declare module BABYLON {
  17029. /** @hidden */
  17030. export var clipPlaneFragment: {
  17031. name: string;
  17032. shader: string;
  17033. };
  17034. }
  17035. declare module BABYLON {
  17036. /** @hidden */
  17037. export var particlesPixelShader: {
  17038. name: string;
  17039. shader: string;
  17040. };
  17041. }
  17042. declare module BABYLON {
  17043. /** @hidden */
  17044. export var clipPlaneVertexDeclaration: {
  17045. name: string;
  17046. shader: string;
  17047. };
  17048. }
  17049. declare module BABYLON {
  17050. /** @hidden */
  17051. export var clipPlaneVertex: {
  17052. name: string;
  17053. shader: string;
  17054. };
  17055. }
  17056. declare module BABYLON {
  17057. /** @hidden */
  17058. export var particlesVertexShader: {
  17059. name: string;
  17060. shader: string;
  17061. };
  17062. }
  17063. declare module BABYLON {
  17064. /**
  17065. * This represents a particle system in Babylon.
  17066. * 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.
  17067. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17068. * @example https://doc.babylonjs.com/babylon101/particles
  17069. */
  17070. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17071. /**
  17072. * Billboard mode will only apply to Y axis
  17073. */
  17074. static readonly BILLBOARDMODE_Y: number;
  17075. /**
  17076. * Billboard mode will apply to all axes
  17077. */
  17078. static readonly BILLBOARDMODE_ALL: number;
  17079. /**
  17080. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17081. */
  17082. static readonly BILLBOARDMODE_STRETCHED: number;
  17083. /**
  17084. * This function can be defined to provide custom update for active particles.
  17085. * This function will be called instead of regular update (age, position, color, etc.).
  17086. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17087. */
  17088. updateFunction: (particles: Particle[]) => void;
  17089. private _emitterWorldMatrix;
  17090. /**
  17091. * This function can be defined to specify initial direction for every new particle.
  17092. * It by default use the emitterType defined function
  17093. */
  17094. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17095. /**
  17096. * This function can be defined to specify initial position for every new particle.
  17097. * It by default use the emitterType defined function
  17098. */
  17099. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17100. /**
  17101. * @hidden
  17102. */
  17103. _inheritedVelocityOffset: Vector3;
  17104. /**
  17105. * An event triggered when the system is disposed
  17106. */
  17107. onDisposeObservable: Observable<ParticleSystem>;
  17108. private _onDisposeObserver;
  17109. /**
  17110. * Sets a callback that will be triggered when the system is disposed
  17111. */
  17112. onDispose: () => void;
  17113. private _particles;
  17114. private _epsilon;
  17115. private _capacity;
  17116. private _stockParticles;
  17117. private _newPartsExcess;
  17118. private _vertexData;
  17119. private _vertexBuffer;
  17120. private _vertexBuffers;
  17121. private _spriteBuffer;
  17122. private _indexBuffer;
  17123. private _effect;
  17124. private _customEffect;
  17125. private _cachedDefines;
  17126. private _scaledColorStep;
  17127. private _colorDiff;
  17128. private _scaledDirection;
  17129. private _scaledGravity;
  17130. private _currentRenderId;
  17131. private _alive;
  17132. private _useInstancing;
  17133. private _started;
  17134. private _stopped;
  17135. private _actualFrame;
  17136. private _scaledUpdateSpeed;
  17137. private _vertexBufferSize;
  17138. /** @hidden */
  17139. _currentEmitRateGradient: Nullable<FactorGradient>;
  17140. /** @hidden */
  17141. _currentEmitRate1: number;
  17142. /** @hidden */
  17143. _currentEmitRate2: number;
  17144. /** @hidden */
  17145. _currentStartSizeGradient: Nullable<FactorGradient>;
  17146. /** @hidden */
  17147. _currentStartSize1: number;
  17148. /** @hidden */
  17149. _currentStartSize2: number;
  17150. private readonly _rawTextureWidth;
  17151. private _rampGradientsTexture;
  17152. private _useRampGradients;
  17153. /** Gets or sets a boolean indicating that ramp gradients must be used
  17154. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17155. */
  17156. useRampGradients: boolean;
  17157. /**
  17158. * 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.
  17159. * 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: [])
  17160. */
  17161. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17162. private _subEmitters;
  17163. /**
  17164. * @hidden
  17165. * If the particle systems emitter should be disposed when the particle system is disposed
  17166. */
  17167. _disposeEmitterOnDispose: boolean;
  17168. /**
  17169. * The current active Sub-systems, this property is used by the root particle system only.
  17170. */
  17171. activeSubSystems: Array<ParticleSystem>;
  17172. private _rootParticleSystem;
  17173. /**
  17174. * Gets the current list of active particles
  17175. */
  17176. readonly particles: Particle[];
  17177. /**
  17178. * Returns the string "ParticleSystem"
  17179. * @returns a string containing the class name
  17180. */
  17181. getClassName(): string;
  17182. /**
  17183. * Instantiates a particle system.
  17184. * 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.
  17185. * @param name The name of the particle system
  17186. * @param capacity The max number of particles alive at the same time
  17187. * @param scene The scene the particle system belongs to
  17188. * @param customEffect a custom effect used to change the way particles are rendered by default
  17189. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17190. * @param epsilon Offset used to render the particles
  17191. */
  17192. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17193. private _addFactorGradient;
  17194. private _removeFactorGradient;
  17195. /**
  17196. * Adds a new life time gradient
  17197. * @param gradient defines the gradient to use (between 0 and 1)
  17198. * @param factor defines the life time factor to affect to the specified gradient
  17199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17200. * @returns the current particle system
  17201. */
  17202. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17203. /**
  17204. * Remove a specific life time gradient
  17205. * @param gradient defines the gradient to remove
  17206. * @returns the current particle system
  17207. */
  17208. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17209. /**
  17210. * Adds a new size gradient
  17211. * @param gradient defines the gradient to use (between 0 and 1)
  17212. * @param factor defines the size factor to affect to the specified gradient
  17213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17214. * @returns the current particle system
  17215. */
  17216. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17217. /**
  17218. * Remove a specific size gradient
  17219. * @param gradient defines the gradient to remove
  17220. * @returns the current particle system
  17221. */
  17222. removeSizeGradient(gradient: number): IParticleSystem;
  17223. /**
  17224. * Adds a new color remap gradient
  17225. * @param gradient defines the gradient to use (between 0 and 1)
  17226. * @param min defines the color remap minimal range
  17227. * @param max defines the color remap maximal range
  17228. * @returns the current particle system
  17229. */
  17230. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17231. /**
  17232. * Remove a specific color remap gradient
  17233. * @param gradient defines the gradient to remove
  17234. * @returns the current particle system
  17235. */
  17236. removeColorRemapGradient(gradient: number): IParticleSystem;
  17237. /**
  17238. * Adds a new alpha remap gradient
  17239. * @param gradient defines the gradient to use (between 0 and 1)
  17240. * @param min defines the alpha remap minimal range
  17241. * @param max defines the alpha remap maximal range
  17242. * @returns the current particle system
  17243. */
  17244. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17245. /**
  17246. * Remove a specific alpha remap gradient
  17247. * @param gradient defines the gradient to remove
  17248. * @returns the current particle system
  17249. */
  17250. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17251. /**
  17252. * Adds a new angular speed gradient
  17253. * @param gradient defines the gradient to use (between 0 and 1)
  17254. * @param factor defines the angular speed to affect to the specified gradient
  17255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17256. * @returns the current particle system
  17257. */
  17258. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17259. /**
  17260. * Remove a specific angular speed gradient
  17261. * @param gradient defines the gradient to remove
  17262. * @returns the current particle system
  17263. */
  17264. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17265. /**
  17266. * Adds a new velocity gradient
  17267. * @param gradient defines the gradient to use (between 0 and 1)
  17268. * @param factor defines the velocity to affect to the specified gradient
  17269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17270. * @returns the current particle system
  17271. */
  17272. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17273. /**
  17274. * Remove a specific velocity gradient
  17275. * @param gradient defines the gradient to remove
  17276. * @returns the current particle system
  17277. */
  17278. removeVelocityGradient(gradient: number): IParticleSystem;
  17279. /**
  17280. * Adds a new limit velocity gradient
  17281. * @param gradient defines the gradient to use (between 0 and 1)
  17282. * @param factor defines the limit velocity value to affect to the specified gradient
  17283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17284. * @returns the current particle system
  17285. */
  17286. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17287. /**
  17288. * Remove a specific limit velocity gradient
  17289. * @param gradient defines the gradient to remove
  17290. * @returns the current particle system
  17291. */
  17292. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17293. /**
  17294. * Adds a new drag gradient
  17295. * @param gradient defines the gradient to use (between 0 and 1)
  17296. * @param factor defines the drag value to affect to the specified gradient
  17297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17298. * @returns the current particle system
  17299. */
  17300. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17301. /**
  17302. * Remove a specific drag gradient
  17303. * @param gradient defines the gradient to remove
  17304. * @returns the current particle system
  17305. */
  17306. removeDragGradient(gradient: number): IParticleSystem;
  17307. /**
  17308. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17309. * @param gradient defines the gradient to use (between 0 and 1)
  17310. * @param factor defines the emit rate value to affect to the specified gradient
  17311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17312. * @returns the current particle system
  17313. */
  17314. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17315. /**
  17316. * Remove a specific emit rate gradient
  17317. * @param gradient defines the gradient to remove
  17318. * @returns the current particle system
  17319. */
  17320. removeEmitRateGradient(gradient: number): IParticleSystem;
  17321. /**
  17322. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17323. * @param gradient defines the gradient to use (between 0 and 1)
  17324. * @param factor defines the start size value to affect to the specified gradient
  17325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17326. * @returns the current particle system
  17327. */
  17328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17329. /**
  17330. * Remove a specific start size gradient
  17331. * @param gradient defines the gradient to remove
  17332. * @returns the current particle system
  17333. */
  17334. removeStartSizeGradient(gradient: number): IParticleSystem;
  17335. private _createRampGradientTexture;
  17336. /**
  17337. * Gets the current list of ramp gradients.
  17338. * You must use addRampGradient and removeRampGradient to udpate this list
  17339. * @returns the list of ramp gradients
  17340. */
  17341. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17342. /**
  17343. * Adds a new ramp gradient used to remap particle colors
  17344. * @param gradient defines the gradient to use (between 0 and 1)
  17345. * @param color defines the color to affect to the specified gradient
  17346. * @returns the current particle system
  17347. */
  17348. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17349. /**
  17350. * Remove a specific ramp gradient
  17351. * @param gradient defines the gradient to remove
  17352. * @returns the current particle system
  17353. */
  17354. removeRampGradient(gradient: number): ParticleSystem;
  17355. /**
  17356. * Adds a new color gradient
  17357. * @param gradient defines the gradient to use (between 0 and 1)
  17358. * @param color1 defines the color to affect to the specified gradient
  17359. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17360. * @returns this particle system
  17361. */
  17362. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17363. /**
  17364. * Remove a specific color gradient
  17365. * @param gradient defines the gradient to remove
  17366. * @returns this particle system
  17367. */
  17368. removeColorGradient(gradient: number): IParticleSystem;
  17369. private _fetchR;
  17370. protected _reset(): void;
  17371. private _resetEffect;
  17372. private _createVertexBuffers;
  17373. private _createIndexBuffer;
  17374. /**
  17375. * Gets the maximum number of particles active at the same time.
  17376. * @returns The max number of active particles.
  17377. */
  17378. getCapacity(): number;
  17379. /**
  17380. * Gets whether there are still active particles in the system.
  17381. * @returns True if it is alive, otherwise false.
  17382. */
  17383. isAlive(): boolean;
  17384. /**
  17385. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17386. * @returns True if it has been started, otherwise false.
  17387. */
  17388. isStarted(): boolean;
  17389. private _prepareSubEmitterInternalArray;
  17390. /**
  17391. * Starts the particle system and begins to emit
  17392. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17393. */
  17394. start(delay?: number): void;
  17395. /**
  17396. * Stops the particle system.
  17397. * @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.
  17398. */
  17399. stop(stopSubEmitters?: boolean): void;
  17400. /**
  17401. * Remove all active particles
  17402. */
  17403. reset(): void;
  17404. /**
  17405. * @hidden (for internal use only)
  17406. */
  17407. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17408. /**
  17409. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17410. * Its lifetime will start back at 0.
  17411. */
  17412. recycleParticle: (particle: Particle) => void;
  17413. private _stopSubEmitters;
  17414. private _createParticle;
  17415. private _removeFromRoot;
  17416. private _emitFromParticle;
  17417. private _update;
  17418. /** @hidden */
  17419. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17420. /** @hidden */
  17421. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17422. /** @hidden */
  17423. private _getEffect;
  17424. /**
  17425. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17426. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17427. */
  17428. animate(preWarmOnly?: boolean): void;
  17429. private _appendParticleVertices;
  17430. /**
  17431. * Rebuilds the particle system.
  17432. */
  17433. rebuild(): void;
  17434. /**
  17435. * Is this system ready to be used/rendered
  17436. * @return true if the system is ready
  17437. */
  17438. isReady(): boolean;
  17439. private _render;
  17440. /**
  17441. * Renders the particle system in its current state.
  17442. * @returns the current number of particles
  17443. */
  17444. render(): number;
  17445. /**
  17446. * Disposes the particle system and free the associated resources
  17447. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17448. */
  17449. dispose(disposeTexture?: boolean): void;
  17450. /**
  17451. * Clones the particle system.
  17452. * @param name The name of the cloned object
  17453. * @param newEmitter The new emitter to use
  17454. * @returns the cloned particle system
  17455. */
  17456. clone(name: string, newEmitter: any): ParticleSystem;
  17457. /**
  17458. * Serializes the particle system to a JSON object.
  17459. * @returns the JSON object
  17460. */
  17461. serialize(): any;
  17462. /** @hidden */
  17463. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17464. /** @hidden */
  17465. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17466. /**
  17467. * Parses a JSON object to create a particle system.
  17468. * @param parsedParticleSystem The JSON object to parse
  17469. * @param scene The scene to create the particle system in
  17470. * @param rootUrl The root url to use to load external dependencies like texture
  17471. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17472. * @returns the Parsed particle system
  17473. */
  17474. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17475. }
  17476. }
  17477. declare module BABYLON {
  17478. /**
  17479. * A particle represents one of the element emitted by a particle system.
  17480. * This is mainly define by its coordinates, direction, velocity and age.
  17481. */
  17482. export class Particle {
  17483. /**
  17484. * The particle system the particle belongs to.
  17485. */
  17486. particleSystem: ParticleSystem;
  17487. private static _Count;
  17488. /**
  17489. * Unique ID of the particle
  17490. */
  17491. id: number;
  17492. /**
  17493. * The world position of the particle in the scene.
  17494. */
  17495. position: Vector3;
  17496. /**
  17497. * The world direction of the particle in the scene.
  17498. */
  17499. direction: Vector3;
  17500. /**
  17501. * The color of the particle.
  17502. */
  17503. color: Color4;
  17504. /**
  17505. * The color change of the particle per step.
  17506. */
  17507. colorStep: Color4;
  17508. /**
  17509. * Defines how long will the life of the particle be.
  17510. */
  17511. lifeTime: number;
  17512. /**
  17513. * The current age of the particle.
  17514. */
  17515. age: number;
  17516. /**
  17517. * The current size of the particle.
  17518. */
  17519. size: number;
  17520. /**
  17521. * The current scale of the particle.
  17522. */
  17523. scale: Vector2;
  17524. /**
  17525. * The current angle of the particle.
  17526. */
  17527. angle: number;
  17528. /**
  17529. * Defines how fast is the angle changing.
  17530. */
  17531. angularSpeed: number;
  17532. /**
  17533. * Defines the cell index used by the particle to be rendered from a sprite.
  17534. */
  17535. cellIndex: number;
  17536. /**
  17537. * The information required to support color remapping
  17538. */
  17539. remapData: Vector4;
  17540. /** @hidden */
  17541. _randomCellOffset?: number;
  17542. /** @hidden */
  17543. _initialDirection: Nullable<Vector3>;
  17544. /** @hidden */
  17545. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17546. /** @hidden */
  17547. _initialStartSpriteCellID: number;
  17548. /** @hidden */
  17549. _initialEndSpriteCellID: number;
  17550. /** @hidden */
  17551. _currentColorGradient: Nullable<ColorGradient>;
  17552. /** @hidden */
  17553. _currentColor1: Color4;
  17554. /** @hidden */
  17555. _currentColor2: Color4;
  17556. /** @hidden */
  17557. _currentSizeGradient: Nullable<FactorGradient>;
  17558. /** @hidden */
  17559. _currentSize1: number;
  17560. /** @hidden */
  17561. _currentSize2: number;
  17562. /** @hidden */
  17563. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17564. /** @hidden */
  17565. _currentAngularSpeed1: number;
  17566. /** @hidden */
  17567. _currentAngularSpeed2: number;
  17568. /** @hidden */
  17569. _currentVelocityGradient: Nullable<FactorGradient>;
  17570. /** @hidden */
  17571. _currentVelocity1: number;
  17572. /** @hidden */
  17573. _currentVelocity2: number;
  17574. /** @hidden */
  17575. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17576. /** @hidden */
  17577. _currentLimitVelocity1: number;
  17578. /** @hidden */
  17579. _currentLimitVelocity2: number;
  17580. /** @hidden */
  17581. _currentDragGradient: Nullable<FactorGradient>;
  17582. /** @hidden */
  17583. _currentDrag1: number;
  17584. /** @hidden */
  17585. _currentDrag2: number;
  17586. /** @hidden */
  17587. _randomNoiseCoordinates1: Vector3;
  17588. /** @hidden */
  17589. _randomNoiseCoordinates2: Vector3;
  17590. /**
  17591. * Creates a new instance Particle
  17592. * @param particleSystem the particle system the particle belongs to
  17593. */
  17594. constructor(
  17595. /**
  17596. * The particle system the particle belongs to.
  17597. */
  17598. particleSystem: ParticleSystem);
  17599. private updateCellInfoFromSystem;
  17600. /**
  17601. * Defines how the sprite cell index is updated for the particle
  17602. */
  17603. updateCellIndex(): void;
  17604. /** @hidden */
  17605. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17606. /** @hidden */
  17607. _inheritParticleInfoToSubEmitters(): void;
  17608. /** @hidden */
  17609. _reset(): void;
  17610. /**
  17611. * Copy the properties of particle to another one.
  17612. * @param other the particle to copy the information to.
  17613. */
  17614. copyTo(other: Particle): void;
  17615. }
  17616. }
  17617. declare module BABYLON {
  17618. /**
  17619. * Particle emitter represents a volume emitting particles.
  17620. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17621. */
  17622. export interface IParticleEmitterType {
  17623. /**
  17624. * Called by the particle System when the direction is computed for the created particle.
  17625. * @param worldMatrix is the world matrix of the particle system
  17626. * @param directionToUpdate is the direction vector to update with the result
  17627. * @param particle is the particle we are computed the direction for
  17628. */
  17629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17630. /**
  17631. * Called by the particle System when the position is computed for the created particle.
  17632. * @param worldMatrix is the world matrix of the particle system
  17633. * @param positionToUpdate is the position vector to update with the result
  17634. * @param particle is the particle we are computed the position for
  17635. */
  17636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17637. /**
  17638. * Clones the current emitter and returns a copy of it
  17639. * @returns the new emitter
  17640. */
  17641. clone(): IParticleEmitterType;
  17642. /**
  17643. * Called by the GPUParticleSystem to setup the update shader
  17644. * @param effect defines the update shader
  17645. */
  17646. applyToShader(effect: Effect): void;
  17647. /**
  17648. * Returns a string to use to update the GPU particles update shader
  17649. * @returns the effect defines string
  17650. */
  17651. getEffectDefines(): string;
  17652. /**
  17653. * Returns a string representing the class name
  17654. * @returns a string containing the class name
  17655. */
  17656. getClassName(): string;
  17657. /**
  17658. * Serializes the particle system to a JSON object.
  17659. * @returns the JSON object
  17660. */
  17661. serialize(): any;
  17662. /**
  17663. * Parse properties from a JSON object
  17664. * @param serializationObject defines the JSON object
  17665. */
  17666. parse(serializationObject: any): void;
  17667. }
  17668. }
  17669. declare module BABYLON {
  17670. /**
  17671. * Particle emitter emitting particles from the inside of a box.
  17672. * It emits the particles randomly between 2 given directions.
  17673. */
  17674. export class BoxParticleEmitter implements IParticleEmitterType {
  17675. /**
  17676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17677. */
  17678. direction1: Vector3;
  17679. /**
  17680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17681. */
  17682. direction2: Vector3;
  17683. /**
  17684. * 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.
  17685. */
  17686. minEmitBox: Vector3;
  17687. /**
  17688. * 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.
  17689. */
  17690. maxEmitBox: Vector3;
  17691. /**
  17692. * Creates a new instance BoxParticleEmitter
  17693. */
  17694. constructor();
  17695. /**
  17696. * Called by the particle System when the direction is computed for the created particle.
  17697. * @param worldMatrix is the world matrix of the particle system
  17698. * @param directionToUpdate is the direction vector to update with the result
  17699. * @param particle is the particle we are computed the direction for
  17700. */
  17701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17702. /**
  17703. * Called by the particle System when the position is computed for the created particle.
  17704. * @param worldMatrix is the world matrix of the particle system
  17705. * @param positionToUpdate is the position vector to update with the result
  17706. * @param particle is the particle we are computed the position for
  17707. */
  17708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17709. /**
  17710. * Clones the current emitter and returns a copy of it
  17711. * @returns the new emitter
  17712. */
  17713. clone(): BoxParticleEmitter;
  17714. /**
  17715. * Called by the GPUParticleSystem to setup the update shader
  17716. * @param effect defines the update shader
  17717. */
  17718. applyToShader(effect: Effect): void;
  17719. /**
  17720. * Returns a string to use to update the GPU particles update shader
  17721. * @returns a string containng the defines string
  17722. */
  17723. getEffectDefines(): string;
  17724. /**
  17725. * Returns the string "BoxParticleEmitter"
  17726. * @returns a string containing the class name
  17727. */
  17728. getClassName(): string;
  17729. /**
  17730. * Serializes the particle system to a JSON object.
  17731. * @returns the JSON object
  17732. */
  17733. serialize(): any;
  17734. /**
  17735. * Parse properties from a JSON object
  17736. * @param serializationObject defines the JSON object
  17737. */
  17738. parse(serializationObject: any): void;
  17739. }
  17740. }
  17741. declare module BABYLON {
  17742. /**
  17743. * Particle emitter emitting particles from the inside of a cone.
  17744. * It emits the particles alongside the cone volume from the base to the particle.
  17745. * The emission direction might be randomized.
  17746. */
  17747. export class ConeParticleEmitter implements IParticleEmitterType {
  17748. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17749. directionRandomizer: number;
  17750. private _radius;
  17751. private _angle;
  17752. private _height;
  17753. /**
  17754. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17755. */
  17756. radiusRange: number;
  17757. /**
  17758. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17759. */
  17760. heightRange: number;
  17761. /**
  17762. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17763. */
  17764. emitFromSpawnPointOnly: boolean;
  17765. /**
  17766. * Gets or sets the radius of the emission cone
  17767. */
  17768. radius: number;
  17769. /**
  17770. * Gets or sets the angle of the emission cone
  17771. */
  17772. angle: number;
  17773. private _buildHeight;
  17774. /**
  17775. * Creates a new instance ConeParticleEmitter
  17776. * @param radius the radius of the emission cone (1 by default)
  17777. * @param angle the cone base angle (PI by default)
  17778. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17779. */
  17780. constructor(radius?: number, angle?: number,
  17781. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17782. directionRandomizer?: number);
  17783. /**
  17784. * Called by the particle System when the direction is computed for the created particle.
  17785. * @param worldMatrix is the world matrix of the particle system
  17786. * @param directionToUpdate is the direction vector to update with the result
  17787. * @param particle is the particle we are computed the direction for
  17788. */
  17789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17790. /**
  17791. * Called by the particle System when the position is computed for the created particle.
  17792. * @param worldMatrix is the world matrix of the particle system
  17793. * @param positionToUpdate is the position vector to update with the result
  17794. * @param particle is the particle we are computed the position for
  17795. */
  17796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17797. /**
  17798. * Clones the current emitter and returns a copy of it
  17799. * @returns the new emitter
  17800. */
  17801. clone(): ConeParticleEmitter;
  17802. /**
  17803. * Called by the GPUParticleSystem to setup the update shader
  17804. * @param effect defines the update shader
  17805. */
  17806. applyToShader(effect: Effect): void;
  17807. /**
  17808. * Returns a string to use to update the GPU particles update shader
  17809. * @returns a string containng the defines string
  17810. */
  17811. getEffectDefines(): string;
  17812. /**
  17813. * Returns the string "ConeParticleEmitter"
  17814. * @returns a string containing the class name
  17815. */
  17816. getClassName(): string;
  17817. /**
  17818. * Serializes the particle system to a JSON object.
  17819. * @returns the JSON object
  17820. */
  17821. serialize(): any;
  17822. /**
  17823. * Parse properties from a JSON object
  17824. * @param serializationObject defines the JSON object
  17825. */
  17826. parse(serializationObject: any): void;
  17827. }
  17828. }
  17829. declare module BABYLON {
  17830. /**
  17831. * Particle emitter emitting particles from the inside of a cylinder.
  17832. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17833. */
  17834. export class CylinderParticleEmitter implements IParticleEmitterType {
  17835. /**
  17836. * The radius of the emission cylinder.
  17837. */
  17838. radius: number;
  17839. /**
  17840. * The height of the emission cylinder.
  17841. */
  17842. height: number;
  17843. /**
  17844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17845. */
  17846. radiusRange: number;
  17847. /**
  17848. * How much to randomize the particle direction [0-1].
  17849. */
  17850. directionRandomizer: number;
  17851. /**
  17852. * Creates a new instance CylinderParticleEmitter
  17853. * @param radius the radius of the emission cylinder (1 by default)
  17854. * @param height the height of the emission cylinder (1 by default)
  17855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17856. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17857. */
  17858. constructor(
  17859. /**
  17860. * The radius of the emission cylinder.
  17861. */
  17862. radius?: number,
  17863. /**
  17864. * The height of the emission cylinder.
  17865. */
  17866. height?: number,
  17867. /**
  17868. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17869. */
  17870. radiusRange?: number,
  17871. /**
  17872. * How much to randomize the particle direction [0-1].
  17873. */
  17874. directionRandomizer?: number);
  17875. /**
  17876. * Called by the particle System when the direction is computed for the created particle.
  17877. * @param worldMatrix is the world matrix of the particle system
  17878. * @param directionToUpdate is the direction vector to update with the result
  17879. * @param particle is the particle we are computed the direction for
  17880. */
  17881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17882. /**
  17883. * Called by the particle System when the position is computed for the created particle.
  17884. * @param worldMatrix is the world matrix of the particle system
  17885. * @param positionToUpdate is the position vector to update with the result
  17886. * @param particle is the particle we are computed the position for
  17887. */
  17888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17889. /**
  17890. * Clones the current emitter and returns a copy of it
  17891. * @returns the new emitter
  17892. */
  17893. clone(): CylinderParticleEmitter;
  17894. /**
  17895. * Called by the GPUParticleSystem to setup the update shader
  17896. * @param effect defines the update shader
  17897. */
  17898. applyToShader(effect: Effect): void;
  17899. /**
  17900. * Returns a string to use to update the GPU particles update shader
  17901. * @returns a string containng the defines string
  17902. */
  17903. getEffectDefines(): string;
  17904. /**
  17905. * Returns the string "CylinderParticleEmitter"
  17906. * @returns a string containing the class name
  17907. */
  17908. getClassName(): string;
  17909. /**
  17910. * Serializes the particle system to a JSON object.
  17911. * @returns the JSON object
  17912. */
  17913. serialize(): any;
  17914. /**
  17915. * Parse properties from a JSON object
  17916. * @param serializationObject defines the JSON object
  17917. */
  17918. parse(serializationObject: any): void;
  17919. }
  17920. /**
  17921. * Particle emitter emitting particles from the inside of a cylinder.
  17922. * It emits the particles randomly between two vectors.
  17923. */
  17924. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17925. /**
  17926. * The min limit of the emission direction.
  17927. */
  17928. direction1: Vector3;
  17929. /**
  17930. * The max limit of the emission direction.
  17931. */
  17932. direction2: Vector3;
  17933. /**
  17934. * Creates a new instance CylinderDirectedParticleEmitter
  17935. * @param radius the radius of the emission cylinder (1 by default)
  17936. * @param height the height of the emission cylinder (1 by default)
  17937. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17938. * @param direction1 the min limit of the emission direction (up vector by default)
  17939. * @param direction2 the max limit of the emission direction (up vector by default)
  17940. */
  17941. constructor(radius?: number, height?: number, radiusRange?: number,
  17942. /**
  17943. * The min limit of the emission direction.
  17944. */
  17945. direction1?: Vector3,
  17946. /**
  17947. * The max limit of the emission direction.
  17948. */
  17949. direction2?: Vector3);
  17950. /**
  17951. * Called by the particle System when the direction is computed for the created particle.
  17952. * @param worldMatrix is the world matrix of the particle system
  17953. * @param directionToUpdate is the direction vector to update with the result
  17954. * @param particle is the particle we are computed the direction for
  17955. */
  17956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17957. /**
  17958. * Clones the current emitter and returns a copy of it
  17959. * @returns the new emitter
  17960. */
  17961. clone(): CylinderDirectedParticleEmitter;
  17962. /**
  17963. * Called by the GPUParticleSystem to setup the update shader
  17964. * @param effect defines the update shader
  17965. */
  17966. applyToShader(effect: Effect): void;
  17967. /**
  17968. * Returns a string to use to update the GPU particles update shader
  17969. * @returns a string containng the defines string
  17970. */
  17971. getEffectDefines(): string;
  17972. /**
  17973. * Returns the string "CylinderDirectedParticleEmitter"
  17974. * @returns a string containing the class name
  17975. */
  17976. getClassName(): string;
  17977. /**
  17978. * Serializes the particle system to a JSON object.
  17979. * @returns the JSON object
  17980. */
  17981. serialize(): any;
  17982. /**
  17983. * Parse properties from a JSON object
  17984. * @param serializationObject defines the JSON object
  17985. */
  17986. parse(serializationObject: any): void;
  17987. }
  17988. }
  17989. declare module BABYLON {
  17990. /**
  17991. * Particle emitter emitting particles from the inside of a hemisphere.
  17992. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17993. */
  17994. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17995. /**
  17996. * The radius of the emission hemisphere.
  17997. */
  17998. radius: number;
  17999. /**
  18000. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18001. */
  18002. radiusRange: number;
  18003. /**
  18004. * How much to randomize the particle direction [0-1].
  18005. */
  18006. directionRandomizer: number;
  18007. /**
  18008. * Creates a new instance HemisphericParticleEmitter
  18009. * @param radius the radius of the emission hemisphere (1 by default)
  18010. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18011. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18012. */
  18013. constructor(
  18014. /**
  18015. * The radius of the emission hemisphere.
  18016. */
  18017. radius?: number,
  18018. /**
  18019. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18020. */
  18021. radiusRange?: number,
  18022. /**
  18023. * How much to randomize the particle direction [0-1].
  18024. */
  18025. directionRandomizer?: number);
  18026. /**
  18027. * Called by the particle System when the direction is computed for the created particle.
  18028. * @param worldMatrix is the world matrix of the particle system
  18029. * @param directionToUpdate is the direction vector to update with the result
  18030. * @param particle is the particle we are computed the direction for
  18031. */
  18032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18033. /**
  18034. * Called by the particle System when the position is computed for the created particle.
  18035. * @param worldMatrix is the world matrix of the particle system
  18036. * @param positionToUpdate is the position vector to update with the result
  18037. * @param particle is the particle we are computed the position for
  18038. */
  18039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18040. /**
  18041. * Clones the current emitter and returns a copy of it
  18042. * @returns the new emitter
  18043. */
  18044. clone(): HemisphericParticleEmitter;
  18045. /**
  18046. * Called by the GPUParticleSystem to setup the update shader
  18047. * @param effect defines the update shader
  18048. */
  18049. applyToShader(effect: Effect): void;
  18050. /**
  18051. * Returns a string to use to update the GPU particles update shader
  18052. * @returns a string containng the defines string
  18053. */
  18054. getEffectDefines(): string;
  18055. /**
  18056. * Returns the string "HemisphericParticleEmitter"
  18057. * @returns a string containing the class name
  18058. */
  18059. getClassName(): string;
  18060. /**
  18061. * Serializes the particle system to a JSON object.
  18062. * @returns the JSON object
  18063. */
  18064. serialize(): any;
  18065. /**
  18066. * Parse properties from a JSON object
  18067. * @param serializationObject defines the JSON object
  18068. */
  18069. parse(serializationObject: any): void;
  18070. }
  18071. }
  18072. declare module BABYLON {
  18073. /**
  18074. * Particle emitter emitting particles from a point.
  18075. * It emits the particles randomly between 2 given directions.
  18076. */
  18077. export class PointParticleEmitter implements IParticleEmitterType {
  18078. /**
  18079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18080. */
  18081. direction1: Vector3;
  18082. /**
  18083. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18084. */
  18085. direction2: Vector3;
  18086. /**
  18087. * Creates a new instance PointParticleEmitter
  18088. */
  18089. constructor();
  18090. /**
  18091. * Called by the particle System when the direction is computed for the created particle.
  18092. * @param worldMatrix is the world matrix of the particle system
  18093. * @param directionToUpdate is the direction vector to update with the result
  18094. * @param particle is the particle we are computed the direction for
  18095. */
  18096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18097. /**
  18098. * Called by the particle System when the position is computed for the created particle.
  18099. * @param worldMatrix is the world matrix of the particle system
  18100. * @param positionToUpdate is the position vector to update with the result
  18101. * @param particle is the particle we are computed the position for
  18102. */
  18103. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18104. /**
  18105. * Clones the current emitter and returns a copy of it
  18106. * @returns the new emitter
  18107. */
  18108. clone(): PointParticleEmitter;
  18109. /**
  18110. * Called by the GPUParticleSystem to setup the update shader
  18111. * @param effect defines the update shader
  18112. */
  18113. applyToShader(effect: Effect): void;
  18114. /**
  18115. * Returns a string to use to update the GPU particles update shader
  18116. * @returns a string containng the defines string
  18117. */
  18118. getEffectDefines(): string;
  18119. /**
  18120. * Returns the string "PointParticleEmitter"
  18121. * @returns a string containing the class name
  18122. */
  18123. getClassName(): string;
  18124. /**
  18125. * Serializes the particle system to a JSON object.
  18126. * @returns the JSON object
  18127. */
  18128. serialize(): any;
  18129. /**
  18130. * Parse properties from a JSON object
  18131. * @param serializationObject defines the JSON object
  18132. */
  18133. parse(serializationObject: any): void;
  18134. }
  18135. }
  18136. declare module BABYLON {
  18137. /**
  18138. * Particle emitter emitting particles from the inside of a sphere.
  18139. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18140. */
  18141. export class SphereParticleEmitter implements IParticleEmitterType {
  18142. /**
  18143. * The radius of the emission sphere.
  18144. */
  18145. radius: number;
  18146. /**
  18147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18148. */
  18149. radiusRange: number;
  18150. /**
  18151. * How much to randomize the particle direction [0-1].
  18152. */
  18153. directionRandomizer: number;
  18154. /**
  18155. * Creates a new instance SphereParticleEmitter
  18156. * @param radius the radius of the emission sphere (1 by default)
  18157. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18158. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18159. */
  18160. constructor(
  18161. /**
  18162. * The radius of the emission sphere.
  18163. */
  18164. radius?: number,
  18165. /**
  18166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18167. */
  18168. radiusRange?: number,
  18169. /**
  18170. * How much to randomize the particle direction [0-1].
  18171. */
  18172. directionRandomizer?: number);
  18173. /**
  18174. * Called by the particle System when the direction is computed for the created particle.
  18175. * @param worldMatrix is the world matrix of the particle system
  18176. * @param directionToUpdate is the direction vector to update with the result
  18177. * @param particle is the particle we are computed the direction for
  18178. */
  18179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18180. /**
  18181. * Called by the particle System when the position is computed for the created particle.
  18182. * @param worldMatrix is the world matrix of the particle system
  18183. * @param positionToUpdate is the position vector to update with the result
  18184. * @param particle is the particle we are computed the position for
  18185. */
  18186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18187. /**
  18188. * Clones the current emitter and returns a copy of it
  18189. * @returns the new emitter
  18190. */
  18191. clone(): SphereParticleEmitter;
  18192. /**
  18193. * Called by the GPUParticleSystem to setup the update shader
  18194. * @param effect defines the update shader
  18195. */
  18196. applyToShader(effect: Effect): void;
  18197. /**
  18198. * Returns a string to use to update the GPU particles update shader
  18199. * @returns a string containng the defines string
  18200. */
  18201. getEffectDefines(): string;
  18202. /**
  18203. * Returns the string "SphereParticleEmitter"
  18204. * @returns a string containing the class name
  18205. */
  18206. getClassName(): string;
  18207. /**
  18208. * Serializes the particle system to a JSON object.
  18209. * @returns the JSON object
  18210. */
  18211. serialize(): any;
  18212. /**
  18213. * Parse properties from a JSON object
  18214. * @param serializationObject defines the JSON object
  18215. */
  18216. parse(serializationObject: any): void;
  18217. }
  18218. /**
  18219. * Particle emitter emitting particles from the inside of a sphere.
  18220. * It emits the particles randomly between two vectors.
  18221. */
  18222. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18223. /**
  18224. * The min limit of the emission direction.
  18225. */
  18226. direction1: Vector3;
  18227. /**
  18228. * The max limit of the emission direction.
  18229. */
  18230. direction2: Vector3;
  18231. /**
  18232. * Creates a new instance SphereDirectedParticleEmitter
  18233. * @param radius the radius of the emission sphere (1 by default)
  18234. * @param direction1 the min limit of the emission direction (up vector by default)
  18235. * @param direction2 the max limit of the emission direction (up vector by default)
  18236. */
  18237. constructor(radius?: number,
  18238. /**
  18239. * The min limit of the emission direction.
  18240. */
  18241. direction1?: Vector3,
  18242. /**
  18243. * The max limit of the emission direction.
  18244. */
  18245. direction2?: Vector3);
  18246. /**
  18247. * Called by the particle System when the direction is computed for the created particle.
  18248. * @param worldMatrix is the world matrix of the particle system
  18249. * @param directionToUpdate is the direction vector to update with the result
  18250. * @param particle is the particle we are computed the direction for
  18251. */
  18252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18253. /**
  18254. * Clones the current emitter and returns a copy of it
  18255. * @returns the new emitter
  18256. */
  18257. clone(): SphereDirectedParticleEmitter;
  18258. /**
  18259. * Called by the GPUParticleSystem to setup the update shader
  18260. * @param effect defines the update shader
  18261. */
  18262. applyToShader(effect: Effect): void;
  18263. /**
  18264. * Returns a string to use to update the GPU particles update shader
  18265. * @returns a string containng the defines string
  18266. */
  18267. getEffectDefines(): string;
  18268. /**
  18269. * Returns the string "SphereDirectedParticleEmitter"
  18270. * @returns a string containing the class name
  18271. */
  18272. getClassName(): string;
  18273. /**
  18274. * Serializes the particle system to a JSON object.
  18275. * @returns the JSON object
  18276. */
  18277. serialize(): any;
  18278. /**
  18279. * Parse properties from a JSON object
  18280. * @param serializationObject defines the JSON object
  18281. */
  18282. parse(serializationObject: any): void;
  18283. }
  18284. }
  18285. declare module BABYLON {
  18286. /**
  18287. * Interface representing a particle system in Babylon.js.
  18288. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18289. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18290. */
  18291. export interface IParticleSystem {
  18292. /**
  18293. * List of animations used by the particle system.
  18294. */
  18295. animations: Animation[];
  18296. /**
  18297. * The id of the Particle system.
  18298. */
  18299. id: string;
  18300. /**
  18301. * The name of the Particle system.
  18302. */
  18303. name: string;
  18304. /**
  18305. * The emitter represents the Mesh or position we are attaching the particle system to.
  18306. */
  18307. emitter: Nullable<AbstractMesh | Vector3>;
  18308. /**
  18309. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18310. */
  18311. isBillboardBased: boolean;
  18312. /**
  18313. * The rendering group used by the Particle system to chose when to render.
  18314. */
  18315. renderingGroupId: number;
  18316. /**
  18317. * The layer mask we are rendering the particles through.
  18318. */
  18319. layerMask: number;
  18320. /**
  18321. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18322. */
  18323. updateSpeed: number;
  18324. /**
  18325. * The amount of time the particle system is running (depends of the overall update speed).
  18326. */
  18327. targetStopDuration: number;
  18328. /**
  18329. * The texture used to render each particle. (this can be a spritesheet)
  18330. */
  18331. particleTexture: Nullable<Texture>;
  18332. /**
  18333. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18334. */
  18335. blendMode: number;
  18336. /**
  18337. * Minimum life time of emitting particles.
  18338. */
  18339. minLifeTime: number;
  18340. /**
  18341. * Maximum life time of emitting particles.
  18342. */
  18343. maxLifeTime: number;
  18344. /**
  18345. * Minimum Size of emitting particles.
  18346. */
  18347. minSize: number;
  18348. /**
  18349. * Maximum Size of emitting particles.
  18350. */
  18351. maxSize: number;
  18352. /**
  18353. * Minimum scale of emitting particles on X axis.
  18354. */
  18355. minScaleX: number;
  18356. /**
  18357. * Maximum scale of emitting particles on X axis.
  18358. */
  18359. maxScaleX: number;
  18360. /**
  18361. * Minimum scale of emitting particles on Y axis.
  18362. */
  18363. minScaleY: number;
  18364. /**
  18365. * Maximum scale of emitting particles on Y axis.
  18366. */
  18367. maxScaleY: number;
  18368. /**
  18369. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18370. */
  18371. color1: Color4;
  18372. /**
  18373. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18374. */
  18375. color2: Color4;
  18376. /**
  18377. * Color the particle will have at the end of its lifetime.
  18378. */
  18379. colorDead: Color4;
  18380. /**
  18381. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18382. */
  18383. emitRate: number;
  18384. /**
  18385. * You can use gravity if you want to give an orientation to your particles.
  18386. */
  18387. gravity: Vector3;
  18388. /**
  18389. * Minimum power of emitting particles.
  18390. */
  18391. minEmitPower: number;
  18392. /**
  18393. * Maximum power of emitting particles.
  18394. */
  18395. maxEmitPower: number;
  18396. /**
  18397. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18398. */
  18399. minAngularSpeed: number;
  18400. /**
  18401. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18402. */
  18403. maxAngularSpeed: number;
  18404. /**
  18405. * Gets or sets the minimal initial rotation in radians.
  18406. */
  18407. minInitialRotation: number;
  18408. /**
  18409. * Gets or sets the maximal initial rotation in radians.
  18410. */
  18411. maxInitialRotation: number;
  18412. /**
  18413. * The particle emitter type defines the emitter used by the particle system.
  18414. * It can be for example box, sphere, or cone...
  18415. */
  18416. particleEmitterType: Nullable<IParticleEmitterType>;
  18417. /**
  18418. * Defines the delay in milliseconds before starting the system (0 by default)
  18419. */
  18420. startDelay: number;
  18421. /**
  18422. * 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
  18423. */
  18424. preWarmCycles: number;
  18425. /**
  18426. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18427. */
  18428. preWarmStepOffset: number;
  18429. /**
  18430. * 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)
  18431. */
  18432. spriteCellChangeSpeed: number;
  18433. /**
  18434. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18435. */
  18436. startSpriteCellID: number;
  18437. /**
  18438. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18439. */
  18440. endSpriteCellID: number;
  18441. /**
  18442. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18443. */
  18444. spriteCellWidth: number;
  18445. /**
  18446. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18447. */
  18448. spriteCellHeight: number;
  18449. /**
  18450. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18451. */
  18452. spriteRandomStartCell: boolean;
  18453. /**
  18454. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18455. */
  18456. isAnimationSheetEnabled: boolean;
  18457. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18458. translationPivot: Vector2;
  18459. /**
  18460. * Gets or sets a texture used to add random noise to particle positions
  18461. */
  18462. noiseTexture: Nullable<BaseTexture>;
  18463. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18464. noiseStrength: Vector3;
  18465. /**
  18466. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18467. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18468. */
  18469. billboardMode: number;
  18470. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18471. limitVelocityDamping: number;
  18472. /**
  18473. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18474. */
  18475. beginAnimationOnStart: boolean;
  18476. /**
  18477. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18478. */
  18479. beginAnimationFrom: number;
  18480. /**
  18481. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18482. */
  18483. beginAnimationTo: number;
  18484. /**
  18485. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18486. */
  18487. beginAnimationLoop: boolean;
  18488. /**
  18489. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18490. */
  18491. disposeOnStop: boolean;
  18492. /**
  18493. * Gets the maximum number of particles active at the same time.
  18494. * @returns The max number of active particles.
  18495. */
  18496. getCapacity(): number;
  18497. /**
  18498. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18499. * @returns True if it has been started, otherwise false.
  18500. */
  18501. isStarted(): boolean;
  18502. /**
  18503. * Animates the particle system for this frame.
  18504. */
  18505. animate(): void;
  18506. /**
  18507. * Renders the particle system in its current state.
  18508. * @returns the current number of particles
  18509. */
  18510. render(): number;
  18511. /**
  18512. * Dispose the particle system and frees its associated resources.
  18513. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18514. */
  18515. dispose(disposeTexture?: boolean): void;
  18516. /**
  18517. * Clones the particle system.
  18518. * @param name The name of the cloned object
  18519. * @param newEmitter The new emitter to use
  18520. * @returns the cloned particle system
  18521. */
  18522. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18523. /**
  18524. * Serializes the particle system to a JSON object.
  18525. * @returns the JSON object
  18526. */
  18527. serialize(): any;
  18528. /**
  18529. * Rebuild the particle system
  18530. */
  18531. rebuild(): void;
  18532. /**
  18533. * Starts the particle system and begins to emit
  18534. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18535. */
  18536. start(delay?: number): void;
  18537. /**
  18538. * Stops the particle system.
  18539. */
  18540. stop(): void;
  18541. /**
  18542. * Remove all active particles
  18543. */
  18544. reset(): void;
  18545. /**
  18546. * Is this system ready to be used/rendered
  18547. * @return true if the system is ready
  18548. */
  18549. isReady(): boolean;
  18550. /**
  18551. * Adds a new color gradient
  18552. * @param gradient defines the gradient to use (between 0 and 1)
  18553. * @param color1 defines the color to affect to the specified gradient
  18554. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18555. * @returns the current particle system
  18556. */
  18557. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18558. /**
  18559. * Remove a specific color gradient
  18560. * @param gradient defines the gradient to remove
  18561. * @returns the current particle system
  18562. */
  18563. removeColorGradient(gradient: number): IParticleSystem;
  18564. /**
  18565. * Adds a new size gradient
  18566. * @param gradient defines the gradient to use (between 0 and 1)
  18567. * @param factor defines the size factor to affect to the specified gradient
  18568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18569. * @returns the current particle system
  18570. */
  18571. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18572. /**
  18573. * Remove a specific size gradient
  18574. * @param gradient defines the gradient to remove
  18575. * @returns the current particle system
  18576. */
  18577. removeSizeGradient(gradient: number): IParticleSystem;
  18578. /**
  18579. * Gets the current list of color gradients.
  18580. * You must use addColorGradient and removeColorGradient to udpate this list
  18581. * @returns the list of color gradients
  18582. */
  18583. getColorGradients(): Nullable<Array<ColorGradient>>;
  18584. /**
  18585. * Gets the current list of size gradients.
  18586. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18587. * @returns the list of size gradients
  18588. */
  18589. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18590. /**
  18591. * Gets the current list of angular speed gradients.
  18592. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18593. * @returns the list of angular speed gradients
  18594. */
  18595. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18596. /**
  18597. * Adds a new angular speed gradient
  18598. * @param gradient defines the gradient to use (between 0 and 1)
  18599. * @param factor defines the angular speed to affect to the specified gradient
  18600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18601. * @returns the current particle system
  18602. */
  18603. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18604. /**
  18605. * Remove a specific angular speed gradient
  18606. * @param gradient defines the gradient to remove
  18607. * @returns the current particle system
  18608. */
  18609. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18610. /**
  18611. * Gets the current list of velocity gradients.
  18612. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18613. * @returns the list of velocity gradients
  18614. */
  18615. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18616. /**
  18617. * Adds a new velocity gradient
  18618. * @param gradient defines the gradient to use (between 0 and 1)
  18619. * @param factor defines the velocity to affect to the specified gradient
  18620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18621. * @returns the current particle system
  18622. */
  18623. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18624. /**
  18625. * Remove a specific velocity gradient
  18626. * @param gradient defines the gradient to remove
  18627. * @returns the current particle system
  18628. */
  18629. removeVelocityGradient(gradient: number): IParticleSystem;
  18630. /**
  18631. * Gets the current list of limit velocity gradients.
  18632. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18633. * @returns the list of limit velocity gradients
  18634. */
  18635. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18636. /**
  18637. * Adds a new limit velocity gradient
  18638. * @param gradient defines the gradient to use (between 0 and 1)
  18639. * @param factor defines the limit velocity to affect to the specified gradient
  18640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18641. * @returns the current particle system
  18642. */
  18643. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18644. /**
  18645. * Remove a specific limit velocity gradient
  18646. * @param gradient defines the gradient to remove
  18647. * @returns the current particle system
  18648. */
  18649. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18650. /**
  18651. * Adds a new drag gradient
  18652. * @param gradient defines the gradient to use (between 0 and 1)
  18653. * @param factor defines the drag to affect to the specified gradient
  18654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18655. * @returns the current particle system
  18656. */
  18657. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18658. /**
  18659. * Remove a specific drag gradient
  18660. * @param gradient defines the gradient to remove
  18661. * @returns the current particle system
  18662. */
  18663. removeDragGradient(gradient: number): IParticleSystem;
  18664. /**
  18665. * Gets the current list of drag gradients.
  18666. * You must use addDragGradient and removeDragGradient to udpate this list
  18667. * @returns the list of drag gradients
  18668. */
  18669. getDragGradients(): Nullable<Array<FactorGradient>>;
  18670. /**
  18671. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18672. * @param gradient defines the gradient to use (between 0 and 1)
  18673. * @param factor defines the emit rate to affect to the specified gradient
  18674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18675. * @returns the current particle system
  18676. */
  18677. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18678. /**
  18679. * Remove a specific emit rate gradient
  18680. * @param gradient defines the gradient to remove
  18681. * @returns the current particle system
  18682. */
  18683. removeEmitRateGradient(gradient: number): IParticleSystem;
  18684. /**
  18685. * Gets the current list of emit rate gradients.
  18686. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18687. * @returns the list of emit rate gradients
  18688. */
  18689. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18690. /**
  18691. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18692. * @param gradient defines the gradient to use (between 0 and 1)
  18693. * @param factor defines the start size to affect to the specified gradient
  18694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18695. * @returns the current particle system
  18696. */
  18697. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18698. /**
  18699. * Remove a specific start size gradient
  18700. * @param gradient defines the gradient to remove
  18701. * @returns the current particle system
  18702. */
  18703. removeStartSizeGradient(gradient: number): IParticleSystem;
  18704. /**
  18705. * Gets the current list of start size gradients.
  18706. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18707. * @returns the list of start size gradients
  18708. */
  18709. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18710. /**
  18711. * Adds a new life time gradient
  18712. * @param gradient defines the gradient to use (between 0 and 1)
  18713. * @param factor defines the life time factor to affect to the specified gradient
  18714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18715. * @returns the current particle system
  18716. */
  18717. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18718. /**
  18719. * Remove a specific life time gradient
  18720. * @param gradient defines the gradient to remove
  18721. * @returns the current particle system
  18722. */
  18723. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18724. /**
  18725. * Gets the current list of life time gradients.
  18726. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18727. * @returns the list of life time gradients
  18728. */
  18729. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18730. /**
  18731. * Gets the current list of color gradients.
  18732. * You must use addColorGradient and removeColorGradient to udpate this list
  18733. * @returns the list of color gradients
  18734. */
  18735. getColorGradients(): Nullable<Array<ColorGradient>>;
  18736. /**
  18737. * Adds a new ramp gradient used to remap particle colors
  18738. * @param gradient defines the gradient to use (between 0 and 1)
  18739. * @param color defines the color to affect to the specified gradient
  18740. * @returns the current particle system
  18741. */
  18742. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18743. /**
  18744. * Gets the current list of ramp gradients.
  18745. * You must use addRampGradient and removeRampGradient to udpate this list
  18746. * @returns the list of ramp gradients
  18747. */
  18748. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18749. /** Gets or sets a boolean indicating that ramp gradients must be used
  18750. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18751. */
  18752. useRampGradients: boolean;
  18753. /**
  18754. * Adds a new color remap gradient
  18755. * @param gradient defines the gradient to use (between 0 and 1)
  18756. * @param min defines the color remap minimal range
  18757. * @param max defines the color remap maximal range
  18758. * @returns the current particle system
  18759. */
  18760. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18761. /**
  18762. * Gets the current list of color remap gradients.
  18763. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18764. * @returns the list of color remap gradients
  18765. */
  18766. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18767. /**
  18768. * Adds a new alpha remap gradient
  18769. * @param gradient defines the gradient to use (between 0 and 1)
  18770. * @param min defines the alpha remap minimal range
  18771. * @param max defines the alpha remap maximal range
  18772. * @returns the current particle system
  18773. */
  18774. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18775. /**
  18776. * Gets the current list of alpha remap gradients.
  18777. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18778. * @returns the list of alpha remap gradients
  18779. */
  18780. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18781. /**
  18782. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18783. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18784. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18785. * @returns the emitter
  18786. */
  18787. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18788. /**
  18789. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18790. * @param radius The radius of the hemisphere to emit from
  18791. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18792. * @returns the emitter
  18793. */
  18794. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18795. /**
  18796. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18797. * @param radius The radius of the sphere to emit from
  18798. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18799. * @returns the emitter
  18800. */
  18801. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18802. /**
  18803. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18804. * @param radius The radius of the sphere to emit from
  18805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18807. * @returns the emitter
  18808. */
  18809. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18810. /**
  18811. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18812. * @param radius The radius of the emission cylinder
  18813. * @param height The height of the emission cylinder
  18814. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18815. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18816. * @returns the emitter
  18817. */
  18818. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18819. /**
  18820. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18821. * @param radius The radius of the cylinder to emit from
  18822. * @param height The height of the emission cylinder
  18823. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18824. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18825. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18826. * @returns the emitter
  18827. */
  18828. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18829. /**
  18830. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18831. * @param radius The radius of the cone to emit from
  18832. * @param angle The base angle of the cone
  18833. * @returns the emitter
  18834. */
  18835. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18836. /**
  18837. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18838. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18839. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18840. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18841. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18842. * @returns the emitter
  18843. */
  18844. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18845. /**
  18846. * Get hosting scene
  18847. * @returns the scene
  18848. */
  18849. getScene(): Scene;
  18850. }
  18851. }
  18852. declare module BABYLON {
  18853. /**
  18854. * Creates an instance based on a source mesh.
  18855. */
  18856. export class InstancedMesh extends AbstractMesh {
  18857. private _sourceMesh;
  18858. private _currentLOD;
  18859. /** @hidden */
  18860. _indexInSourceMeshInstanceArray: number;
  18861. constructor(name: string, source: Mesh);
  18862. /**
  18863. * Returns the string "InstancedMesh".
  18864. */
  18865. getClassName(): string;
  18866. /** Gets the list of lights affecting that mesh */
  18867. readonly lightSources: Light[];
  18868. _resyncLightSources(): void;
  18869. _resyncLighSource(light: Light): void;
  18870. _removeLightSource(light: Light, dispose: boolean): void;
  18871. /**
  18872. * If the source mesh receives shadows
  18873. */
  18874. readonly receiveShadows: boolean;
  18875. /**
  18876. * The material of the source mesh
  18877. */
  18878. readonly material: Nullable<Material>;
  18879. /**
  18880. * Visibility of the source mesh
  18881. */
  18882. readonly visibility: number;
  18883. /**
  18884. * Skeleton of the source mesh
  18885. */
  18886. readonly skeleton: Nullable<Skeleton>;
  18887. /**
  18888. * Rendering ground id of the source mesh
  18889. */
  18890. renderingGroupId: number;
  18891. /**
  18892. * Returns the total number of vertices (integer).
  18893. */
  18894. getTotalVertices(): number;
  18895. /**
  18896. * Returns a positive integer : the total number of indices in this mesh geometry.
  18897. * @returns the numner of indices or zero if the mesh has no geometry.
  18898. */
  18899. getTotalIndices(): number;
  18900. /**
  18901. * The source mesh of the instance
  18902. */
  18903. readonly sourceMesh: Mesh;
  18904. /**
  18905. * Is this node ready to be used/rendered
  18906. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18907. * @return {boolean} is it ready
  18908. */
  18909. isReady(completeCheck?: boolean): boolean;
  18910. /**
  18911. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18912. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18913. * @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.
  18914. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18915. */
  18916. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18917. /**
  18918. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18919. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18920. * The `data` are either a numeric array either a Float32Array.
  18921. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18922. * 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).
  18923. * Note that a new underlying VertexBuffer object is created each call.
  18924. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18925. *
  18926. * Possible `kind` values :
  18927. * - VertexBuffer.PositionKind
  18928. * - VertexBuffer.UVKind
  18929. * - VertexBuffer.UV2Kind
  18930. * - VertexBuffer.UV3Kind
  18931. * - VertexBuffer.UV4Kind
  18932. * - VertexBuffer.UV5Kind
  18933. * - VertexBuffer.UV6Kind
  18934. * - VertexBuffer.ColorKind
  18935. * - VertexBuffer.MatricesIndicesKind
  18936. * - VertexBuffer.MatricesIndicesExtraKind
  18937. * - VertexBuffer.MatricesWeightsKind
  18938. * - VertexBuffer.MatricesWeightsExtraKind
  18939. *
  18940. * Returns the Mesh.
  18941. */
  18942. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18943. /**
  18944. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18945. * If the mesh has no geometry, it is simply returned as it is.
  18946. * The `data` are either a numeric array either a Float32Array.
  18947. * No new underlying VertexBuffer object is created.
  18948. * 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.
  18949. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18950. *
  18951. * Possible `kind` values :
  18952. * - VertexBuffer.PositionKind
  18953. * - VertexBuffer.UVKind
  18954. * - VertexBuffer.UV2Kind
  18955. * - VertexBuffer.UV3Kind
  18956. * - VertexBuffer.UV4Kind
  18957. * - VertexBuffer.UV5Kind
  18958. * - VertexBuffer.UV6Kind
  18959. * - VertexBuffer.ColorKind
  18960. * - VertexBuffer.MatricesIndicesKind
  18961. * - VertexBuffer.MatricesIndicesExtraKind
  18962. * - VertexBuffer.MatricesWeightsKind
  18963. * - VertexBuffer.MatricesWeightsExtraKind
  18964. *
  18965. * Returns the Mesh.
  18966. */
  18967. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18968. /**
  18969. * Sets the mesh indices.
  18970. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18971. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18972. * This method creates a new index buffer each call.
  18973. * Returns the Mesh.
  18974. */
  18975. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18976. /**
  18977. * Boolean : True if the mesh owns the requested kind of data.
  18978. */
  18979. isVerticesDataPresent(kind: string): boolean;
  18980. /**
  18981. * Returns an array of indices (IndicesArray).
  18982. */
  18983. getIndices(): Nullable<IndicesArray>;
  18984. readonly _positions: Nullable<Vector3[]>;
  18985. /**
  18986. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18987. * This means the mesh underlying bounding box and sphere are recomputed.
  18988. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18989. * @returns the current mesh
  18990. */
  18991. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18992. /** @hidden */
  18993. _preActivate(): InstancedMesh;
  18994. /** @hidden */
  18995. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18996. /** @hidden */
  18997. _postActivate(): void;
  18998. getWorldMatrix(): Matrix;
  18999. readonly isAnInstance: boolean;
  19000. /**
  19001. * Returns the current associated LOD AbstractMesh.
  19002. */
  19003. getLOD(camera: Camera): AbstractMesh;
  19004. /** @hidden */
  19005. _syncSubMeshes(): InstancedMesh;
  19006. /** @hidden */
  19007. _generatePointsArray(): boolean;
  19008. /**
  19009. * Creates a new InstancedMesh from the current mesh.
  19010. * - name (string) : the cloned mesh name
  19011. * - newParent (optional Node) : the optional Node to parent the clone to.
  19012. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19013. *
  19014. * Returns the clone.
  19015. */
  19016. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19017. /**
  19018. * Disposes the InstancedMesh.
  19019. * Returns nothing.
  19020. */
  19021. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19022. }
  19023. }
  19024. declare module BABYLON {
  19025. /**
  19026. * Defines the options associated with the creation of a shader material.
  19027. */
  19028. export interface IShaderMaterialOptions {
  19029. /**
  19030. * Does the material work in alpha blend mode
  19031. */
  19032. needAlphaBlending: boolean;
  19033. /**
  19034. * Does the material work in alpha test mode
  19035. */
  19036. needAlphaTesting: boolean;
  19037. /**
  19038. * The list of attribute names used in the shader
  19039. */
  19040. attributes: string[];
  19041. /**
  19042. * The list of unifrom names used in the shader
  19043. */
  19044. uniforms: string[];
  19045. /**
  19046. * The list of UBO names used in the shader
  19047. */
  19048. uniformBuffers: string[];
  19049. /**
  19050. * The list of sampler names used in the shader
  19051. */
  19052. samplers: string[];
  19053. /**
  19054. * The list of defines used in the shader
  19055. */
  19056. defines: string[];
  19057. }
  19058. /**
  19059. * 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.
  19060. *
  19061. * This returned material effects how the mesh will look based on the code in the shaders.
  19062. *
  19063. * @see http://doc.babylonjs.com/how_to/shader_material
  19064. */
  19065. export class ShaderMaterial extends Material {
  19066. private _shaderPath;
  19067. private _options;
  19068. private _textures;
  19069. private _textureArrays;
  19070. private _floats;
  19071. private _ints;
  19072. private _floatsArrays;
  19073. private _colors3;
  19074. private _colors3Arrays;
  19075. private _colors4;
  19076. private _colors4Arrays;
  19077. private _vectors2;
  19078. private _vectors3;
  19079. private _vectors4;
  19080. private _matrices;
  19081. private _matrices3x3;
  19082. private _matrices2x2;
  19083. private _vectors2Arrays;
  19084. private _vectors3Arrays;
  19085. private _vectors4Arrays;
  19086. private _cachedWorldViewMatrix;
  19087. private _cachedWorldViewProjectionMatrix;
  19088. private _renderId;
  19089. /**
  19090. * Instantiate a new shader material.
  19091. * 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.
  19092. * This returned material effects how the mesh will look based on the code in the shaders.
  19093. * @see http://doc.babylonjs.com/how_to/shader_material
  19094. * @param name Define the name of the material in the scene
  19095. * @param scene Define the scene the material belongs to
  19096. * @param shaderPath Defines the route to the shader code in one of three ways:
  19097. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19098. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19099. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19100. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19101. * @param options Define the options used to create the shader
  19102. */
  19103. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19104. /**
  19105. * Gets the options used to compile the shader.
  19106. * They can be modified to trigger a new compilation
  19107. */
  19108. readonly options: IShaderMaterialOptions;
  19109. /**
  19110. * Gets the current class name of the material e.g. "ShaderMaterial"
  19111. * Mainly use in serialization.
  19112. * @returns the class name
  19113. */
  19114. getClassName(): string;
  19115. /**
  19116. * Specifies if the material will require alpha blending
  19117. * @returns a boolean specifying if alpha blending is needed
  19118. */
  19119. needAlphaBlending(): boolean;
  19120. /**
  19121. * Specifies if this material should be rendered in alpha test mode
  19122. * @returns a boolean specifying if an alpha test is needed.
  19123. */
  19124. needAlphaTesting(): boolean;
  19125. private _checkUniform;
  19126. /**
  19127. * Set a texture in the shader.
  19128. * @param name Define the name of the uniform samplers as defined in the shader
  19129. * @param texture Define the texture to bind to this sampler
  19130. * @return the material itself allowing "fluent" like uniform updates
  19131. */
  19132. setTexture(name: string, texture: Texture): ShaderMaterial;
  19133. /**
  19134. * Set a texture array in the shader.
  19135. * @param name Define the name of the uniform sampler array as defined in the shader
  19136. * @param textures Define the list of textures to bind to this sampler
  19137. * @return the material itself allowing "fluent" like uniform updates
  19138. */
  19139. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19140. /**
  19141. * Set a float in the shader.
  19142. * @param name Define the name of the uniform as defined in the shader
  19143. * @param value Define the value to give to the uniform
  19144. * @return the material itself allowing "fluent" like uniform updates
  19145. */
  19146. setFloat(name: string, value: number): ShaderMaterial;
  19147. /**
  19148. * Set a int in the shader.
  19149. * @param name Define the name of the uniform as defined in the shader
  19150. * @param value Define the value to give to the uniform
  19151. * @return the material itself allowing "fluent" like uniform updates
  19152. */
  19153. setInt(name: string, value: number): ShaderMaterial;
  19154. /**
  19155. * Set an array of floats in the shader.
  19156. * @param name Define the name of the uniform as defined in the shader
  19157. * @param value Define the value to give to the uniform
  19158. * @return the material itself allowing "fluent" like uniform updates
  19159. */
  19160. setFloats(name: string, value: number[]): ShaderMaterial;
  19161. /**
  19162. * Set a vec3 in the shader from a Color3.
  19163. * @param name Define the name of the uniform as defined in the shader
  19164. * @param value Define the value to give to the uniform
  19165. * @return the material itself allowing "fluent" like uniform updates
  19166. */
  19167. setColor3(name: string, value: Color3): ShaderMaterial;
  19168. /**
  19169. * Set a vec3 array in the shader from a Color3 array.
  19170. * @param name Define the name of the uniform as defined in the shader
  19171. * @param value Define the value to give to the uniform
  19172. * @return the material itself allowing "fluent" like uniform updates
  19173. */
  19174. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19175. /**
  19176. * Set a vec4 in the shader from a Color4.
  19177. * @param name Define the name of the uniform as defined in the shader
  19178. * @param value Define the value to give to the uniform
  19179. * @return the material itself allowing "fluent" like uniform updates
  19180. */
  19181. setColor4(name: string, value: Color4): ShaderMaterial;
  19182. /**
  19183. * Set a vec4 array in the shader from a Color4 array.
  19184. * @param name Define the name of the uniform as defined in the shader
  19185. * @param value Define the value to give to the uniform
  19186. * @return the material itself allowing "fluent" like uniform updates
  19187. */
  19188. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19189. /**
  19190. * Set a vec2 in the shader from a Vector2.
  19191. * @param name Define the name of the uniform as defined in the shader
  19192. * @param value Define the value to give to the uniform
  19193. * @return the material itself allowing "fluent" like uniform updates
  19194. */
  19195. setVector2(name: string, value: Vector2): ShaderMaterial;
  19196. /**
  19197. * Set a vec3 in the shader from a Vector3.
  19198. * @param name Define the name of the uniform as defined in the shader
  19199. * @param value Define the value to give to the uniform
  19200. * @return the material itself allowing "fluent" like uniform updates
  19201. */
  19202. setVector3(name: string, value: Vector3): ShaderMaterial;
  19203. /**
  19204. * Set a vec4 in the shader from a Vector4.
  19205. * @param name Define the name of the uniform as defined in the shader
  19206. * @param value Define the value to give to the uniform
  19207. * @return the material itself allowing "fluent" like uniform updates
  19208. */
  19209. setVector4(name: string, value: Vector4): ShaderMaterial;
  19210. /**
  19211. * Set a mat4 in the shader from a Matrix.
  19212. * @param name Define the name of the uniform as defined in the shader
  19213. * @param value Define the value to give to the uniform
  19214. * @return the material itself allowing "fluent" like uniform updates
  19215. */
  19216. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19217. /**
  19218. * Set a mat3 in the shader from a Float32Array.
  19219. * @param name Define the name of the uniform as defined in the shader
  19220. * @param value Define the value to give to the uniform
  19221. * @return the material itself allowing "fluent" like uniform updates
  19222. */
  19223. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19224. /**
  19225. * Set a mat2 in the shader from a Float32Array.
  19226. * @param name Define the name of the uniform as defined in the shader
  19227. * @param value Define the value to give to the uniform
  19228. * @return the material itself allowing "fluent" like uniform updates
  19229. */
  19230. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19231. /**
  19232. * Set a vec2 array in the shader from a number array.
  19233. * @param name Define the name of the uniform as defined in the shader
  19234. * @param value Define the value to give to the uniform
  19235. * @return the material itself allowing "fluent" like uniform updates
  19236. */
  19237. setArray2(name: string, value: number[]): ShaderMaterial;
  19238. /**
  19239. * Set a vec3 array in the shader from a number array.
  19240. * @param name Define the name of the uniform as defined in the shader
  19241. * @param value Define the value to give to the uniform
  19242. * @return the material itself allowing "fluent" like uniform updates
  19243. */
  19244. setArray3(name: string, value: number[]): ShaderMaterial;
  19245. /**
  19246. * Set a vec4 array in the shader from a number array.
  19247. * @param name Define the name of the uniform as defined in the shader
  19248. * @param value Define the value to give to the uniform
  19249. * @return the material itself allowing "fluent" like uniform updates
  19250. */
  19251. setArray4(name: string, value: number[]): ShaderMaterial;
  19252. private _checkCache;
  19253. /**
  19254. * Specifies that the submesh is ready to be used
  19255. * @param mesh defines the mesh to check
  19256. * @param subMesh defines which submesh to check
  19257. * @param useInstances specifies that instances should be used
  19258. * @returns a boolean indicating that the submesh is ready or not
  19259. */
  19260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19261. /**
  19262. * Checks if the material is ready to render the requested mesh
  19263. * @param mesh Define the mesh to render
  19264. * @param useInstances Define whether or not the material is used with instances
  19265. * @returns true if ready, otherwise false
  19266. */
  19267. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19268. /**
  19269. * Binds the world matrix to the material
  19270. * @param world defines the world transformation matrix
  19271. */
  19272. bindOnlyWorldMatrix(world: Matrix): void;
  19273. /**
  19274. * Binds the material to the mesh
  19275. * @param world defines the world transformation matrix
  19276. * @param mesh defines the mesh to bind the material to
  19277. */
  19278. bind(world: Matrix, mesh?: Mesh): void;
  19279. /**
  19280. * Gets the active textures from the material
  19281. * @returns an array of textures
  19282. */
  19283. getActiveTextures(): BaseTexture[];
  19284. /**
  19285. * Specifies if the material uses a texture
  19286. * @param texture defines the texture to check against the material
  19287. * @returns a boolean specifying if the material uses the texture
  19288. */
  19289. hasTexture(texture: BaseTexture): boolean;
  19290. /**
  19291. * Makes a duplicate of the material, and gives it a new name
  19292. * @param name defines the new name for the duplicated material
  19293. * @returns the cloned material
  19294. */
  19295. clone(name: string): ShaderMaterial;
  19296. /**
  19297. * Disposes the material
  19298. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19299. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19300. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19301. */
  19302. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19303. /**
  19304. * Serializes this material in a JSON representation
  19305. * @returns the serialized material object
  19306. */
  19307. serialize(): any;
  19308. /**
  19309. * Creates a shader material from parsed shader material data
  19310. * @param source defines the JSON represnetation of the material
  19311. * @param scene defines the hosting scene
  19312. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19313. * @returns a new material
  19314. */
  19315. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19316. }
  19317. }
  19318. declare module BABYLON {
  19319. /** @hidden */
  19320. export var colorPixelShader: {
  19321. name: string;
  19322. shader: string;
  19323. };
  19324. }
  19325. declare module BABYLON {
  19326. /** @hidden */
  19327. export var colorVertexShader: {
  19328. name: string;
  19329. shader: string;
  19330. };
  19331. }
  19332. declare module BABYLON {
  19333. /**
  19334. * Line mesh
  19335. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19336. */
  19337. export class LinesMesh extends Mesh {
  19338. /**
  19339. * If vertex color should be applied to the mesh
  19340. */
  19341. readonly useVertexColor?: boolean | undefined;
  19342. /**
  19343. * If vertex alpha should be applied to the mesh
  19344. */
  19345. readonly useVertexAlpha?: boolean | undefined;
  19346. /**
  19347. * Color of the line (Default: White)
  19348. */
  19349. color: Color3;
  19350. /**
  19351. * Alpha of the line (Default: 1)
  19352. */
  19353. alpha: number;
  19354. /**
  19355. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19356. * This margin is expressed in world space coordinates, so its value may vary.
  19357. * Default value is 0.1
  19358. */
  19359. intersectionThreshold: number;
  19360. private _colorShader;
  19361. private color4;
  19362. /**
  19363. * Creates a new LinesMesh
  19364. * @param name defines the name
  19365. * @param scene defines the hosting scene
  19366. * @param parent defines the parent mesh if any
  19367. * @param source defines the optional source LinesMesh used to clone data from
  19368. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19369. * When false, achieved by calling a clone(), also passing False.
  19370. * This will make creation of children, recursive.
  19371. * @param useVertexColor defines if this LinesMesh supports vertex color
  19372. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19373. */
  19374. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19375. /**
  19376. * If vertex color should be applied to the mesh
  19377. */
  19378. useVertexColor?: boolean | undefined,
  19379. /**
  19380. * If vertex alpha should be applied to the mesh
  19381. */
  19382. useVertexAlpha?: boolean | undefined);
  19383. private _addClipPlaneDefine;
  19384. private _removeClipPlaneDefine;
  19385. isReady(): boolean;
  19386. /**
  19387. * Returns the string "LineMesh"
  19388. */
  19389. getClassName(): string;
  19390. /**
  19391. * @hidden
  19392. */
  19393. /**
  19394. * @hidden
  19395. */
  19396. material: Material;
  19397. /**
  19398. * @hidden
  19399. */
  19400. readonly checkCollisions: boolean;
  19401. /** @hidden */
  19402. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19403. /** @hidden */
  19404. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19405. /**
  19406. * Disposes of the line mesh
  19407. * @param doNotRecurse If children should be disposed
  19408. */
  19409. dispose(doNotRecurse?: boolean): void;
  19410. /**
  19411. * Returns a new LineMesh object cloned from the current one.
  19412. */
  19413. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19414. /**
  19415. * Creates a new InstancedLinesMesh object from the mesh model.
  19416. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19417. * @param name defines the name of the new instance
  19418. * @returns a new InstancedLinesMesh
  19419. */
  19420. createInstance(name: string): InstancedLinesMesh;
  19421. }
  19422. /**
  19423. * Creates an instance based on a source LinesMesh
  19424. */
  19425. export class InstancedLinesMesh extends InstancedMesh {
  19426. /**
  19427. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19428. * This margin is expressed in world space coordinates, so its value may vary.
  19429. * Initilized with the intersectionThreshold value of the source LinesMesh
  19430. */
  19431. intersectionThreshold: number;
  19432. constructor(name: string, source: LinesMesh);
  19433. /**
  19434. * Returns the string "InstancedLinesMesh".
  19435. */
  19436. getClassName(): string;
  19437. }
  19438. }
  19439. declare module BABYLON {
  19440. /** @hidden */
  19441. export var linePixelShader: {
  19442. name: string;
  19443. shader: string;
  19444. };
  19445. }
  19446. declare module BABYLON {
  19447. /** @hidden */
  19448. export var lineVertexShader: {
  19449. name: string;
  19450. shader: string;
  19451. };
  19452. }
  19453. declare module BABYLON {
  19454. interface AbstractMesh {
  19455. /**
  19456. * Gets the edgesRenderer associated with the mesh
  19457. */
  19458. edgesRenderer: Nullable<EdgesRenderer>;
  19459. }
  19460. interface LinesMesh {
  19461. /**
  19462. * Enables the edge rendering mode on the mesh.
  19463. * This mode makes the mesh edges visible
  19464. * @param epsilon defines the maximal distance between two angles to detect a face
  19465. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19466. * @returns the currentAbstractMesh
  19467. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19468. */
  19469. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19470. }
  19471. interface InstancedLinesMesh {
  19472. /**
  19473. * Enables the edge rendering mode on the mesh.
  19474. * This mode makes the mesh edges visible
  19475. * @param epsilon defines the maximal distance between two angles to detect a face
  19476. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19477. * @returns the current InstancedLinesMesh
  19478. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19479. */
  19480. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19481. }
  19482. /**
  19483. * Defines the minimum contract an Edges renderer should follow.
  19484. */
  19485. export interface IEdgesRenderer extends IDisposable {
  19486. /**
  19487. * Gets or sets a boolean indicating if the edgesRenderer is active
  19488. */
  19489. isEnabled: boolean;
  19490. /**
  19491. * Renders the edges of the attached mesh,
  19492. */
  19493. render(): void;
  19494. /**
  19495. * Checks wether or not the edges renderer is ready to render.
  19496. * @return true if ready, otherwise false.
  19497. */
  19498. isReady(): boolean;
  19499. }
  19500. /**
  19501. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19502. */
  19503. export class EdgesRenderer implements IEdgesRenderer {
  19504. /**
  19505. * Define the size of the edges with an orthographic camera
  19506. */
  19507. edgesWidthScalerForOrthographic: number;
  19508. /**
  19509. * Define the size of the edges with a perspective camera
  19510. */
  19511. edgesWidthScalerForPerspective: number;
  19512. protected _source: AbstractMesh;
  19513. protected _linesPositions: number[];
  19514. protected _linesNormals: number[];
  19515. protected _linesIndices: number[];
  19516. protected _epsilon: number;
  19517. protected _indicesCount: number;
  19518. protected _lineShader: ShaderMaterial;
  19519. protected _ib: DataBuffer;
  19520. protected _buffers: {
  19521. [key: string]: Nullable<VertexBuffer>;
  19522. };
  19523. protected _checkVerticesInsteadOfIndices: boolean;
  19524. private _meshRebuildObserver;
  19525. private _meshDisposeObserver;
  19526. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19527. isEnabled: boolean;
  19528. /**
  19529. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19530. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19531. * @param source Mesh used to create edges
  19532. * @param epsilon sum of angles in adjacency to check for edge
  19533. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19534. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19535. */
  19536. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19537. protected _prepareRessources(): void;
  19538. /** @hidden */
  19539. _rebuild(): void;
  19540. /**
  19541. * Releases the required resources for the edges renderer
  19542. */
  19543. dispose(): void;
  19544. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19545. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19546. /**
  19547. * Checks if the pair of p0 and p1 is en edge
  19548. * @param faceIndex
  19549. * @param edge
  19550. * @param faceNormals
  19551. * @param p0
  19552. * @param p1
  19553. * @private
  19554. */
  19555. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19556. /**
  19557. * push line into the position, normal and index buffer
  19558. * @protected
  19559. */
  19560. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19561. /**
  19562. * Generates lines edges from adjacencjes
  19563. * @private
  19564. */
  19565. _generateEdgesLines(): void;
  19566. /**
  19567. * Checks wether or not the edges renderer is ready to render.
  19568. * @return true if ready, otherwise false.
  19569. */
  19570. isReady(): boolean;
  19571. /**
  19572. * Renders the edges of the attached mesh,
  19573. */
  19574. render(): void;
  19575. }
  19576. /**
  19577. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19578. */
  19579. export class LineEdgesRenderer extends EdgesRenderer {
  19580. /**
  19581. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19582. * @param source LineMesh used to generate edges
  19583. * @param epsilon not important (specified angle for edge detection)
  19584. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19585. */
  19586. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19587. /**
  19588. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19589. */
  19590. _generateEdgesLines(): void;
  19591. }
  19592. }
  19593. declare module BABYLON {
  19594. /**
  19595. * This represents the object necessary to create a rendering group.
  19596. * This is exclusively used and created by the rendering manager.
  19597. * To modify the behavior, you use the available helpers in your scene or meshes.
  19598. * @hidden
  19599. */
  19600. export class RenderingGroup {
  19601. index: number;
  19602. private static _zeroVector;
  19603. private _scene;
  19604. private _opaqueSubMeshes;
  19605. private _transparentSubMeshes;
  19606. private _alphaTestSubMeshes;
  19607. private _depthOnlySubMeshes;
  19608. private _particleSystems;
  19609. private _spriteManagers;
  19610. private _opaqueSortCompareFn;
  19611. private _alphaTestSortCompareFn;
  19612. private _transparentSortCompareFn;
  19613. private _renderOpaque;
  19614. private _renderAlphaTest;
  19615. private _renderTransparent;
  19616. /** @hidden */
  19617. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19618. onBeforeTransparentRendering: () => void;
  19619. /**
  19620. * Set the opaque sort comparison function.
  19621. * If null the sub meshes will be render in the order they were created
  19622. */
  19623. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19624. /**
  19625. * Set the alpha test sort comparison function.
  19626. * If null the sub meshes will be render in the order they were created
  19627. */
  19628. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19629. /**
  19630. * Set the transparent sort comparison function.
  19631. * If null the sub meshes will be render in the order they were created
  19632. */
  19633. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19634. /**
  19635. * Creates a new rendering group.
  19636. * @param index The rendering group index
  19637. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19638. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19639. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19640. */
  19641. 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>);
  19642. /**
  19643. * Render all the sub meshes contained in the group.
  19644. * @param customRenderFunction Used to override the default render behaviour of the group.
  19645. * @returns true if rendered some submeshes.
  19646. */
  19647. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19648. /**
  19649. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19650. * @param subMeshes The submeshes to render
  19651. */
  19652. private renderOpaqueSorted;
  19653. /**
  19654. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19655. * @param subMeshes The submeshes to render
  19656. */
  19657. private renderAlphaTestSorted;
  19658. /**
  19659. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19660. * @param subMeshes The submeshes to render
  19661. */
  19662. private renderTransparentSorted;
  19663. /**
  19664. * Renders the submeshes in a specified order.
  19665. * @param subMeshes The submeshes to sort before render
  19666. * @param sortCompareFn The comparison function use to sort
  19667. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19668. * @param transparent Specifies to activate blending if true
  19669. */
  19670. private static renderSorted;
  19671. /**
  19672. * Renders the submeshes in the order they were dispatched (no sort applied).
  19673. * @param subMeshes The submeshes to render
  19674. */
  19675. private static renderUnsorted;
  19676. /**
  19677. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19678. * are rendered back to front if in the same alpha index.
  19679. *
  19680. * @param a The first submesh
  19681. * @param b The second submesh
  19682. * @returns The result of the comparison
  19683. */
  19684. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19685. /**
  19686. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19687. * are rendered back to front.
  19688. *
  19689. * @param a The first submesh
  19690. * @param b The second submesh
  19691. * @returns The result of the comparison
  19692. */
  19693. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19694. /**
  19695. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19696. * are rendered front to back (prevent overdraw).
  19697. *
  19698. * @param a The first submesh
  19699. * @param b The second submesh
  19700. * @returns The result of the comparison
  19701. */
  19702. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19703. /**
  19704. * Resets the different lists of submeshes to prepare a new frame.
  19705. */
  19706. prepare(): void;
  19707. dispose(): void;
  19708. /**
  19709. * Inserts the submesh in its correct queue depending on its material.
  19710. * @param subMesh The submesh to dispatch
  19711. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19712. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19713. */
  19714. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19715. dispatchSprites(spriteManager: ISpriteManager): void;
  19716. dispatchParticles(particleSystem: IParticleSystem): void;
  19717. private _renderParticles;
  19718. private _renderSprites;
  19719. }
  19720. }
  19721. declare module BABYLON {
  19722. /**
  19723. * Interface describing the different options available in the rendering manager
  19724. * regarding Auto Clear between groups.
  19725. */
  19726. export interface IRenderingManagerAutoClearSetup {
  19727. /**
  19728. * Defines whether or not autoclear is enable.
  19729. */
  19730. autoClear: boolean;
  19731. /**
  19732. * Defines whether or not to autoclear the depth buffer.
  19733. */
  19734. depth: boolean;
  19735. /**
  19736. * Defines whether or not to autoclear the stencil buffer.
  19737. */
  19738. stencil: boolean;
  19739. }
  19740. /**
  19741. * This class is used by the onRenderingGroupObservable
  19742. */
  19743. export class RenderingGroupInfo {
  19744. /**
  19745. * The Scene that being rendered
  19746. */
  19747. scene: Scene;
  19748. /**
  19749. * The camera currently used for the rendering pass
  19750. */
  19751. camera: Nullable<Camera>;
  19752. /**
  19753. * The ID of the renderingGroup being processed
  19754. */
  19755. renderingGroupId: number;
  19756. }
  19757. /**
  19758. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19759. * It is enable to manage the different groups as well as the different necessary sort functions.
  19760. * This should not be used directly aside of the few static configurations
  19761. */
  19762. export class RenderingManager {
  19763. /**
  19764. * The max id used for rendering groups (not included)
  19765. */
  19766. static MAX_RENDERINGGROUPS: number;
  19767. /**
  19768. * The min id used for rendering groups (included)
  19769. */
  19770. static MIN_RENDERINGGROUPS: number;
  19771. /**
  19772. * Used to globally prevent autoclearing scenes.
  19773. */
  19774. static AUTOCLEAR: boolean;
  19775. /**
  19776. * @hidden
  19777. */
  19778. _useSceneAutoClearSetup: boolean;
  19779. private _scene;
  19780. private _renderingGroups;
  19781. private _depthStencilBufferAlreadyCleaned;
  19782. private _autoClearDepthStencil;
  19783. private _customOpaqueSortCompareFn;
  19784. private _customAlphaTestSortCompareFn;
  19785. private _customTransparentSortCompareFn;
  19786. private _renderingGroupInfo;
  19787. /**
  19788. * Instantiates a new rendering group for a particular scene
  19789. * @param scene Defines the scene the groups belongs to
  19790. */
  19791. constructor(scene: Scene);
  19792. private _clearDepthStencilBuffer;
  19793. /**
  19794. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19795. * @hidden
  19796. */
  19797. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19798. /**
  19799. * Resets the different information of the group to prepare a new frame
  19800. * @hidden
  19801. */
  19802. reset(): void;
  19803. /**
  19804. * Dispose and release the group and its associated resources.
  19805. * @hidden
  19806. */
  19807. dispose(): void;
  19808. /**
  19809. * Clear the info related to rendering groups preventing retention points during dispose.
  19810. */
  19811. freeRenderingGroups(): void;
  19812. private _prepareRenderingGroup;
  19813. /**
  19814. * Add a sprite manager to the rendering manager in order to render it this frame.
  19815. * @param spriteManager Define the sprite manager to render
  19816. */
  19817. dispatchSprites(spriteManager: ISpriteManager): void;
  19818. /**
  19819. * Add a particle system to the rendering manager in order to render it this frame.
  19820. * @param particleSystem Define the particle system to render
  19821. */
  19822. dispatchParticles(particleSystem: IParticleSystem): void;
  19823. /**
  19824. * Add a submesh to the manager in order to render it this frame
  19825. * @param subMesh The submesh to dispatch
  19826. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19827. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19828. */
  19829. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19830. /**
  19831. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19832. * This allowed control for front to back rendering or reversly depending of the special needs.
  19833. *
  19834. * @param renderingGroupId The rendering group id corresponding to its index
  19835. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19836. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19837. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19838. */
  19839. 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;
  19840. /**
  19841. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19842. *
  19843. * @param renderingGroupId The rendering group id corresponding to its index
  19844. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19845. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19846. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19847. */
  19848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19849. /**
  19850. * Gets the current auto clear configuration for one rendering group of the rendering
  19851. * manager.
  19852. * @param index the rendering group index to get the information for
  19853. * @returns The auto clear setup for the requested rendering group
  19854. */
  19855. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19856. }
  19857. }
  19858. declare module BABYLON {
  19859. /**
  19860. * This Helps creating a texture that will be created from a camera in your scene.
  19861. * It is basically a dynamic texture that could be used to create special effects for instance.
  19862. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19863. */
  19864. export class RenderTargetTexture extends Texture {
  19865. isCube: boolean;
  19866. /**
  19867. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19868. */
  19869. static readonly REFRESHRATE_RENDER_ONCE: number;
  19870. /**
  19871. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19872. */
  19873. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19874. /**
  19875. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19876. * the central point of your effect and can save a lot of performances.
  19877. */
  19878. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19879. /**
  19880. * Use this predicate to dynamically define the list of mesh you want to render.
  19881. * If set, the renderList property will be overwritten.
  19882. */
  19883. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19884. private _renderList;
  19885. /**
  19886. * Use this list to define the list of mesh you want to render.
  19887. */
  19888. renderList: Nullable<Array<AbstractMesh>>;
  19889. private _hookArray;
  19890. /**
  19891. * Define if particles should be rendered in your texture.
  19892. */
  19893. renderParticles: boolean;
  19894. /**
  19895. * Define if sprites should be rendered in your texture.
  19896. */
  19897. renderSprites: boolean;
  19898. /**
  19899. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19900. */
  19901. coordinatesMode: number;
  19902. /**
  19903. * Define the camera used to render the texture.
  19904. */
  19905. activeCamera: Nullable<Camera>;
  19906. /**
  19907. * Override the render function of the texture with your own one.
  19908. */
  19909. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19910. /**
  19911. * Define if camera post processes should be use while rendering the texture.
  19912. */
  19913. useCameraPostProcesses: boolean;
  19914. /**
  19915. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19916. */
  19917. ignoreCameraViewport: boolean;
  19918. private _postProcessManager;
  19919. private _postProcesses;
  19920. private _resizeObserver;
  19921. /**
  19922. * An event triggered when the texture is unbind.
  19923. */
  19924. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19925. /**
  19926. * An event triggered when the texture is unbind.
  19927. */
  19928. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19929. private _onAfterUnbindObserver;
  19930. /**
  19931. * Set a after unbind callback in the texture.
  19932. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19933. */
  19934. onAfterUnbind: () => void;
  19935. /**
  19936. * An event triggered before rendering the texture
  19937. */
  19938. onBeforeRenderObservable: Observable<number>;
  19939. private _onBeforeRenderObserver;
  19940. /**
  19941. * Set a before render callback in the texture.
  19942. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19943. */
  19944. onBeforeRender: (faceIndex: number) => void;
  19945. /**
  19946. * An event triggered after rendering the texture
  19947. */
  19948. onAfterRenderObservable: Observable<number>;
  19949. private _onAfterRenderObserver;
  19950. /**
  19951. * Set a after render callback in the texture.
  19952. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19953. */
  19954. onAfterRender: (faceIndex: number) => void;
  19955. /**
  19956. * An event triggered after the texture clear
  19957. */
  19958. onClearObservable: Observable<Engine>;
  19959. private _onClearObserver;
  19960. /**
  19961. * Set a clear callback in the texture.
  19962. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19963. */
  19964. onClear: (Engine: Engine) => void;
  19965. /**
  19966. * An event triggered when the texture is resized.
  19967. */
  19968. onResizeObservable: Observable<RenderTargetTexture>;
  19969. /**
  19970. * Define the clear color of the Render Target if it should be different from the scene.
  19971. */
  19972. clearColor: Color4;
  19973. protected _size: number | {
  19974. width: number;
  19975. height: number;
  19976. };
  19977. protected _initialSizeParameter: number | {
  19978. width: number;
  19979. height: number;
  19980. } | {
  19981. ratio: number;
  19982. };
  19983. protected _sizeRatio: Nullable<number>;
  19984. /** @hidden */
  19985. _generateMipMaps: boolean;
  19986. protected _renderingManager: RenderingManager;
  19987. /** @hidden */
  19988. _waitingRenderList: string[];
  19989. protected _doNotChangeAspectRatio: boolean;
  19990. protected _currentRefreshId: number;
  19991. protected _refreshRate: number;
  19992. protected _textureMatrix: Matrix;
  19993. protected _samples: number;
  19994. protected _renderTargetOptions: RenderTargetCreationOptions;
  19995. /**
  19996. * Gets render target creation options that were used.
  19997. */
  19998. readonly renderTargetOptions: RenderTargetCreationOptions;
  19999. protected _engine: Engine;
  20000. protected _onRatioRescale(): void;
  20001. /**
  20002. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20003. * It must define where the camera used to render the texture is set
  20004. */
  20005. boundingBoxPosition: Vector3;
  20006. private _boundingBoxSize;
  20007. /**
  20008. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20009. * When defined, the cubemap will switch to local mode
  20010. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20011. * @example https://www.babylonjs-playground.com/#RNASML
  20012. */
  20013. boundingBoxSize: Vector3;
  20014. /**
  20015. * In case the RTT has been created with a depth texture, get the associated
  20016. * depth texture.
  20017. * Otherwise, return null.
  20018. */
  20019. depthStencilTexture: Nullable<InternalTexture>;
  20020. /**
  20021. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20022. * or used a shadow, depth texture...
  20023. * @param name The friendly name of the texture
  20024. * @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)
  20025. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20026. * @param generateMipMaps True if mip maps need to be generated after render.
  20027. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20028. * @param type The type of the buffer in the RTT (int, half float, float...)
  20029. * @param isCube True if a cube texture needs to be created
  20030. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20031. * @param generateDepthBuffer True to generate a depth buffer
  20032. * @param generateStencilBuffer True to generate a stencil buffer
  20033. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20034. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20035. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20036. */
  20037. constructor(name: string, size: number | {
  20038. width: number;
  20039. height: number;
  20040. } | {
  20041. ratio: number;
  20042. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20043. /**
  20044. * Creates a depth stencil texture.
  20045. * This is only available in WebGL 2 or with the depth texture extension available.
  20046. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20047. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20048. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20049. */
  20050. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20051. private _processSizeParameter;
  20052. /**
  20053. * Define the number of samples to use in case of MSAA.
  20054. * It defaults to one meaning no MSAA has been enabled.
  20055. */
  20056. samples: number;
  20057. /**
  20058. * Resets the refresh counter of the texture and start bak from scratch.
  20059. * Could be useful to regenerate the texture if it is setup to render only once.
  20060. */
  20061. resetRefreshCounter(): void;
  20062. /**
  20063. * Define the refresh rate of the texture or the rendering frequency.
  20064. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20065. */
  20066. refreshRate: number;
  20067. /**
  20068. * Adds a post process to the render target rendering passes.
  20069. * @param postProcess define the post process to add
  20070. */
  20071. addPostProcess(postProcess: PostProcess): void;
  20072. /**
  20073. * Clear all the post processes attached to the render target
  20074. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20075. */
  20076. clearPostProcesses(dispose?: boolean): void;
  20077. /**
  20078. * Remove one of the post process from the list of attached post processes to the texture
  20079. * @param postProcess define the post process to remove from the list
  20080. */
  20081. removePostProcess(postProcess: PostProcess): void;
  20082. /** @hidden */
  20083. _shouldRender(): boolean;
  20084. /**
  20085. * Gets the actual render size of the texture.
  20086. * @returns the width of the render size
  20087. */
  20088. getRenderSize(): number;
  20089. /**
  20090. * Gets the actual render width of the texture.
  20091. * @returns the width of the render size
  20092. */
  20093. getRenderWidth(): number;
  20094. /**
  20095. * Gets the actual render height of the texture.
  20096. * @returns the height of the render size
  20097. */
  20098. getRenderHeight(): number;
  20099. /**
  20100. * Get if the texture can be rescaled or not.
  20101. */
  20102. readonly canRescale: boolean;
  20103. /**
  20104. * Resize the texture using a ratio.
  20105. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20106. */
  20107. scale(ratio: number): void;
  20108. /**
  20109. * Get the texture reflection matrix used to rotate/transform the reflection.
  20110. * @returns the reflection matrix
  20111. */
  20112. getReflectionTextureMatrix(): Matrix;
  20113. /**
  20114. * Resize the texture to a new desired size.
  20115. * Be carrefull as it will recreate all the data in the new texture.
  20116. * @param size Define the new size. It can be:
  20117. * - a number for squared texture,
  20118. * - an object containing { width: number, height: number }
  20119. * - or an object containing a ratio { ratio: number }
  20120. */
  20121. resize(size: number | {
  20122. width: number;
  20123. height: number;
  20124. } | {
  20125. ratio: number;
  20126. }): void;
  20127. /**
  20128. * Renders all the objects from the render list into the texture.
  20129. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20130. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20131. */
  20132. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20133. private _bestReflectionRenderTargetDimension;
  20134. /**
  20135. * @hidden
  20136. * @param faceIndex face index to bind to if this is a cubetexture
  20137. */
  20138. _bindFrameBuffer(faceIndex?: number): void;
  20139. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20140. private renderToTarget;
  20141. /**
  20142. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20143. * This allowed control for front to back rendering or reversly depending of the special needs.
  20144. *
  20145. * @param renderingGroupId The rendering group id corresponding to its index
  20146. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20147. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20148. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20149. */
  20150. 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;
  20151. /**
  20152. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20153. *
  20154. * @param renderingGroupId The rendering group id corresponding to its index
  20155. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20156. */
  20157. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20158. /**
  20159. * Clones the texture.
  20160. * @returns the cloned texture
  20161. */
  20162. clone(): RenderTargetTexture;
  20163. /**
  20164. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20165. * @returns The JSON representation of the texture
  20166. */
  20167. serialize(): any;
  20168. /**
  20169. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20170. */
  20171. disposeFramebufferObjects(): void;
  20172. /**
  20173. * Dispose the texture and release its associated resources.
  20174. */
  20175. dispose(): void;
  20176. /** @hidden */
  20177. _rebuild(): void;
  20178. /**
  20179. * Clear the info related to rendering groups preventing retention point in material dispose.
  20180. */
  20181. freeRenderingGroups(): void;
  20182. /**
  20183. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20184. * @returns the view count
  20185. */
  20186. getViewCount(): number;
  20187. }
  20188. }
  20189. declare module BABYLON {
  20190. /**
  20191. * Base class for the main features of a material in Babylon.js
  20192. */
  20193. export class Material implements IAnimatable {
  20194. /**
  20195. * Returns the triangle fill mode
  20196. */
  20197. static readonly TriangleFillMode: number;
  20198. /**
  20199. * Returns the wireframe mode
  20200. */
  20201. static readonly WireFrameFillMode: number;
  20202. /**
  20203. * Returns the point fill mode
  20204. */
  20205. static readonly PointFillMode: number;
  20206. /**
  20207. * Returns the point list draw mode
  20208. */
  20209. static readonly PointListDrawMode: number;
  20210. /**
  20211. * Returns the line list draw mode
  20212. */
  20213. static readonly LineListDrawMode: number;
  20214. /**
  20215. * Returns the line loop draw mode
  20216. */
  20217. static readonly LineLoopDrawMode: number;
  20218. /**
  20219. * Returns the line strip draw mode
  20220. */
  20221. static readonly LineStripDrawMode: number;
  20222. /**
  20223. * Returns the triangle strip draw mode
  20224. */
  20225. static readonly TriangleStripDrawMode: number;
  20226. /**
  20227. * Returns the triangle fan draw mode
  20228. */
  20229. static readonly TriangleFanDrawMode: number;
  20230. /**
  20231. * Stores the clock-wise side orientation
  20232. */
  20233. static readonly ClockWiseSideOrientation: number;
  20234. /**
  20235. * Stores the counter clock-wise side orientation
  20236. */
  20237. static readonly CounterClockWiseSideOrientation: number;
  20238. /**
  20239. * The dirty texture flag value
  20240. */
  20241. static readonly TextureDirtyFlag: number;
  20242. /**
  20243. * The dirty light flag value
  20244. */
  20245. static readonly LightDirtyFlag: number;
  20246. /**
  20247. * The dirty fresnel flag value
  20248. */
  20249. static readonly FresnelDirtyFlag: number;
  20250. /**
  20251. * The dirty attribute flag value
  20252. */
  20253. static readonly AttributesDirtyFlag: number;
  20254. /**
  20255. * The dirty misc flag value
  20256. */
  20257. static readonly MiscDirtyFlag: number;
  20258. /**
  20259. * The all dirty flag value
  20260. */
  20261. static readonly AllDirtyFlag: number;
  20262. /**
  20263. * The ID of the material
  20264. */
  20265. id: string;
  20266. /**
  20267. * Gets or sets the unique id of the material
  20268. */
  20269. uniqueId: number;
  20270. /**
  20271. * The name of the material
  20272. */
  20273. name: string;
  20274. /**
  20275. * Gets or sets user defined metadata
  20276. */
  20277. metadata: any;
  20278. /**
  20279. * For internal use only. Please do not use.
  20280. */
  20281. reservedDataStore: any;
  20282. /**
  20283. * Specifies if the ready state should be checked on each call
  20284. */
  20285. checkReadyOnEveryCall: boolean;
  20286. /**
  20287. * Specifies if the ready state should be checked once
  20288. */
  20289. checkReadyOnlyOnce: boolean;
  20290. /**
  20291. * The state of the material
  20292. */
  20293. state: string;
  20294. /**
  20295. * The alpha value of the material
  20296. */
  20297. protected _alpha: number;
  20298. /**
  20299. * List of inspectable custom properties (used by the Inspector)
  20300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20301. */
  20302. inspectableCustomProperties: IInspectable[];
  20303. /**
  20304. * Sets the alpha value of the material
  20305. */
  20306. /**
  20307. * Gets the alpha value of the material
  20308. */
  20309. alpha: number;
  20310. /**
  20311. * Specifies if back face culling is enabled
  20312. */
  20313. protected _backFaceCulling: boolean;
  20314. /**
  20315. * Sets the back-face culling state
  20316. */
  20317. /**
  20318. * Gets the back-face culling state
  20319. */
  20320. backFaceCulling: boolean;
  20321. /**
  20322. * Stores the value for side orientation
  20323. */
  20324. sideOrientation: number;
  20325. /**
  20326. * Callback triggered when the material is compiled
  20327. */
  20328. onCompiled: Nullable<(effect: Effect) => void>;
  20329. /**
  20330. * Callback triggered when an error occurs
  20331. */
  20332. onError: Nullable<(effect: Effect, errors: string) => void>;
  20333. /**
  20334. * Callback triggered to get the render target textures
  20335. */
  20336. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20337. /**
  20338. * Gets a boolean indicating that current material needs to register RTT
  20339. */
  20340. readonly hasRenderTargetTextures: boolean;
  20341. /**
  20342. * Specifies if the material should be serialized
  20343. */
  20344. doNotSerialize: boolean;
  20345. /**
  20346. * @hidden
  20347. */
  20348. _storeEffectOnSubMeshes: boolean;
  20349. /**
  20350. * Stores the animations for the material
  20351. */
  20352. animations: Nullable<Array<Animation>>;
  20353. /**
  20354. * An event triggered when the material is disposed
  20355. */
  20356. onDisposeObservable: Observable<Material>;
  20357. /**
  20358. * An observer which watches for dispose events
  20359. */
  20360. private _onDisposeObserver;
  20361. private _onUnBindObservable;
  20362. /**
  20363. * Called during a dispose event
  20364. */
  20365. onDispose: () => void;
  20366. private _onBindObservable;
  20367. /**
  20368. * An event triggered when the material is bound
  20369. */
  20370. readonly onBindObservable: Observable<AbstractMesh>;
  20371. /**
  20372. * An observer which watches for bind events
  20373. */
  20374. private _onBindObserver;
  20375. /**
  20376. * Called during a bind event
  20377. */
  20378. onBind: (Mesh: AbstractMesh) => void;
  20379. /**
  20380. * An event triggered when the material is unbound
  20381. */
  20382. readonly onUnBindObservable: Observable<Material>;
  20383. /**
  20384. * Stores the value of the alpha mode
  20385. */
  20386. private _alphaMode;
  20387. /**
  20388. * Sets the value of the alpha mode.
  20389. *
  20390. * | Value | Type | Description |
  20391. * | --- | --- | --- |
  20392. * | 0 | ALPHA_DISABLE | |
  20393. * | 1 | ALPHA_ADD | |
  20394. * | 2 | ALPHA_COMBINE | |
  20395. * | 3 | ALPHA_SUBTRACT | |
  20396. * | 4 | ALPHA_MULTIPLY | |
  20397. * | 5 | ALPHA_MAXIMIZED | |
  20398. * | 6 | ALPHA_ONEONE | |
  20399. * | 7 | ALPHA_PREMULTIPLIED | |
  20400. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20401. * | 9 | ALPHA_INTERPOLATE | |
  20402. * | 10 | ALPHA_SCREENMODE | |
  20403. *
  20404. */
  20405. /**
  20406. * Gets the value of the alpha mode
  20407. */
  20408. alphaMode: number;
  20409. /**
  20410. * Stores the state of the need depth pre-pass value
  20411. */
  20412. private _needDepthPrePass;
  20413. /**
  20414. * Sets the need depth pre-pass value
  20415. */
  20416. /**
  20417. * Gets the depth pre-pass value
  20418. */
  20419. needDepthPrePass: boolean;
  20420. /**
  20421. * Specifies if depth writing should be disabled
  20422. */
  20423. disableDepthWrite: boolean;
  20424. /**
  20425. * Specifies if depth writing should be forced
  20426. */
  20427. forceDepthWrite: boolean;
  20428. /**
  20429. * Specifies if there should be a separate pass for culling
  20430. */
  20431. separateCullingPass: boolean;
  20432. /**
  20433. * Stores the state specifing if fog should be enabled
  20434. */
  20435. private _fogEnabled;
  20436. /**
  20437. * Sets the state for enabling fog
  20438. */
  20439. /**
  20440. * Gets the value of the fog enabled state
  20441. */
  20442. fogEnabled: boolean;
  20443. /**
  20444. * Stores the size of points
  20445. */
  20446. pointSize: number;
  20447. /**
  20448. * Stores the z offset value
  20449. */
  20450. zOffset: number;
  20451. /**
  20452. * Gets a value specifying if wireframe mode is enabled
  20453. */
  20454. /**
  20455. * Sets the state of wireframe mode
  20456. */
  20457. wireframe: boolean;
  20458. /**
  20459. * Gets the value specifying if point clouds are enabled
  20460. */
  20461. /**
  20462. * Sets the state of point cloud mode
  20463. */
  20464. pointsCloud: boolean;
  20465. /**
  20466. * Gets the material fill mode
  20467. */
  20468. /**
  20469. * Sets the material fill mode
  20470. */
  20471. fillMode: number;
  20472. /**
  20473. * @hidden
  20474. * Stores the effects for the material
  20475. */
  20476. _effect: Nullable<Effect>;
  20477. /**
  20478. * @hidden
  20479. * Specifies if the material was previously ready
  20480. */
  20481. _wasPreviouslyReady: boolean;
  20482. /**
  20483. * Specifies if uniform buffers should be used
  20484. */
  20485. private _useUBO;
  20486. /**
  20487. * Stores a reference to the scene
  20488. */
  20489. private _scene;
  20490. /**
  20491. * Stores the fill mode state
  20492. */
  20493. private _fillMode;
  20494. /**
  20495. * Specifies if the depth write state should be cached
  20496. */
  20497. private _cachedDepthWriteState;
  20498. /**
  20499. * Stores the uniform buffer
  20500. */
  20501. protected _uniformBuffer: UniformBuffer;
  20502. /** @hidden */
  20503. _indexInSceneMaterialArray: number;
  20504. /** @hidden */
  20505. meshMap: Nullable<{
  20506. [id: string]: AbstractMesh | undefined;
  20507. }>;
  20508. /**
  20509. * Creates a material instance
  20510. * @param name defines the name of the material
  20511. * @param scene defines the scene to reference
  20512. * @param doNotAdd specifies if the material should be added to the scene
  20513. */
  20514. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20515. /**
  20516. * Returns a string representation of the current material
  20517. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20518. * @returns a string with material information
  20519. */
  20520. toString(fullDetails?: boolean): string;
  20521. /**
  20522. * Gets the class name of the material
  20523. * @returns a string with the class name of the material
  20524. */
  20525. getClassName(): string;
  20526. /**
  20527. * Specifies if updates for the material been locked
  20528. */
  20529. readonly isFrozen: boolean;
  20530. /**
  20531. * Locks updates for the material
  20532. */
  20533. freeze(): void;
  20534. /**
  20535. * Unlocks updates for the material
  20536. */
  20537. unfreeze(): void;
  20538. /**
  20539. * Specifies if the material is ready to be used
  20540. * @param mesh defines the mesh to check
  20541. * @param useInstances specifies if instances should be used
  20542. * @returns a boolean indicating if the material is ready to be used
  20543. */
  20544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20545. /**
  20546. * Specifies that the submesh is ready to be used
  20547. * @param mesh defines the mesh to check
  20548. * @param subMesh defines which submesh to check
  20549. * @param useInstances specifies that instances should be used
  20550. * @returns a boolean indicating that the submesh is ready or not
  20551. */
  20552. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20553. /**
  20554. * Returns the material effect
  20555. * @returns the effect associated with the material
  20556. */
  20557. getEffect(): Nullable<Effect>;
  20558. /**
  20559. * Returns the current scene
  20560. * @returns a Scene
  20561. */
  20562. getScene(): Scene;
  20563. /**
  20564. * Specifies if the material will require alpha blending
  20565. * @returns a boolean specifying if alpha blending is needed
  20566. */
  20567. needAlphaBlending(): boolean;
  20568. /**
  20569. * Specifies if the mesh will require alpha blending
  20570. * @param mesh defines the mesh to check
  20571. * @returns a boolean specifying if alpha blending is needed for the mesh
  20572. */
  20573. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20574. /**
  20575. * Specifies if this material should be rendered in alpha test mode
  20576. * @returns a boolean specifying if an alpha test is needed.
  20577. */
  20578. needAlphaTesting(): boolean;
  20579. /**
  20580. * Gets the texture used for the alpha test
  20581. * @returns the texture to use for alpha testing
  20582. */
  20583. getAlphaTestTexture(): Nullable<BaseTexture>;
  20584. /**
  20585. * Marks the material to indicate that it needs to be re-calculated
  20586. */
  20587. markDirty(): void;
  20588. /** @hidden */
  20589. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20590. /**
  20591. * Binds the material to the mesh
  20592. * @param world defines the world transformation matrix
  20593. * @param mesh defines the mesh to bind the material to
  20594. */
  20595. bind(world: Matrix, mesh?: Mesh): void;
  20596. /**
  20597. * Binds the submesh to the material
  20598. * @param world defines the world transformation matrix
  20599. * @param mesh defines the mesh containing the submesh
  20600. * @param subMesh defines the submesh to bind the material to
  20601. */
  20602. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20603. /**
  20604. * Binds the world matrix to the material
  20605. * @param world defines the world transformation matrix
  20606. */
  20607. bindOnlyWorldMatrix(world: Matrix): void;
  20608. /**
  20609. * Binds the scene's uniform buffer to the effect.
  20610. * @param effect defines the effect to bind to the scene uniform buffer
  20611. * @param sceneUbo defines the uniform buffer storing scene data
  20612. */
  20613. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20614. /**
  20615. * Binds the view matrix to the effect
  20616. * @param effect defines the effect to bind the view matrix to
  20617. */
  20618. bindView(effect: Effect): void;
  20619. /**
  20620. * Binds the view projection matrix to the effect
  20621. * @param effect defines the effect to bind the view projection matrix to
  20622. */
  20623. bindViewProjection(effect: Effect): void;
  20624. /**
  20625. * Specifies if material alpha testing should be turned on for the mesh
  20626. * @param mesh defines the mesh to check
  20627. */
  20628. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20629. /**
  20630. * Processes to execute after binding the material to a mesh
  20631. * @param mesh defines the rendered mesh
  20632. */
  20633. protected _afterBind(mesh?: Mesh): void;
  20634. /**
  20635. * Unbinds the material from the mesh
  20636. */
  20637. unbind(): void;
  20638. /**
  20639. * Gets the active textures from the material
  20640. * @returns an array of textures
  20641. */
  20642. getActiveTextures(): BaseTexture[];
  20643. /**
  20644. * Specifies if the material uses a texture
  20645. * @param texture defines the texture to check against the material
  20646. * @returns a boolean specifying if the material uses the texture
  20647. */
  20648. hasTexture(texture: BaseTexture): boolean;
  20649. /**
  20650. * Makes a duplicate of the material, and gives it a new name
  20651. * @param name defines the new name for the duplicated material
  20652. * @returns the cloned material
  20653. */
  20654. clone(name: string): Nullable<Material>;
  20655. /**
  20656. * Gets the meshes bound to the material
  20657. * @returns an array of meshes bound to the material
  20658. */
  20659. getBindedMeshes(): AbstractMesh[];
  20660. /**
  20661. * Force shader compilation
  20662. * @param mesh defines the mesh associated with this material
  20663. * @param onCompiled defines a function to execute once the material is compiled
  20664. * @param options defines the options to configure the compilation
  20665. */
  20666. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20667. clipPlane: boolean;
  20668. }>): void;
  20669. /**
  20670. * Force shader compilation
  20671. * @param mesh defines the mesh that will use this material
  20672. * @param options defines additional options for compiling the shaders
  20673. * @returns a promise that resolves when the compilation completes
  20674. */
  20675. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20676. clipPlane: boolean;
  20677. }>): Promise<void>;
  20678. private static readonly _AllDirtyCallBack;
  20679. private static readonly _ImageProcessingDirtyCallBack;
  20680. private static readonly _TextureDirtyCallBack;
  20681. private static readonly _FresnelDirtyCallBack;
  20682. private static readonly _MiscDirtyCallBack;
  20683. private static readonly _LightsDirtyCallBack;
  20684. private static readonly _AttributeDirtyCallBack;
  20685. private static _FresnelAndMiscDirtyCallBack;
  20686. private static _TextureAndMiscDirtyCallBack;
  20687. private static readonly _DirtyCallbackArray;
  20688. private static readonly _RunDirtyCallBacks;
  20689. /**
  20690. * Marks a define in the material to indicate that it needs to be re-computed
  20691. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20692. */
  20693. markAsDirty(flag: number): void;
  20694. /**
  20695. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20696. * @param func defines a function which checks material defines against the submeshes
  20697. */
  20698. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20699. /**
  20700. * Indicates that we need to re-calculated for all submeshes
  20701. */
  20702. protected _markAllSubMeshesAsAllDirty(): void;
  20703. /**
  20704. * Indicates that image processing needs to be re-calculated for all submeshes
  20705. */
  20706. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20707. /**
  20708. * Indicates that textures need to be re-calculated for all submeshes
  20709. */
  20710. protected _markAllSubMeshesAsTexturesDirty(): void;
  20711. /**
  20712. * Indicates that fresnel needs to be re-calculated for all submeshes
  20713. */
  20714. protected _markAllSubMeshesAsFresnelDirty(): void;
  20715. /**
  20716. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20717. */
  20718. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20719. /**
  20720. * Indicates that lights need to be re-calculated for all submeshes
  20721. */
  20722. protected _markAllSubMeshesAsLightsDirty(): void;
  20723. /**
  20724. * Indicates that attributes need to be re-calculated for all submeshes
  20725. */
  20726. protected _markAllSubMeshesAsAttributesDirty(): void;
  20727. /**
  20728. * Indicates that misc needs to be re-calculated for all submeshes
  20729. */
  20730. protected _markAllSubMeshesAsMiscDirty(): void;
  20731. /**
  20732. * Indicates that textures and misc need to be re-calculated for all submeshes
  20733. */
  20734. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20735. /**
  20736. * Disposes the material
  20737. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20738. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20739. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20740. */
  20741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20742. /** @hidden */
  20743. private releaseVertexArrayObject;
  20744. /**
  20745. * Serializes this material
  20746. * @returns the serialized material object
  20747. */
  20748. serialize(): any;
  20749. /**
  20750. * Creates a material from parsed material data
  20751. * @param parsedMaterial defines parsed material data
  20752. * @param scene defines the hosting scene
  20753. * @param rootUrl defines the root URL to use to load textures
  20754. * @returns a new material
  20755. */
  20756. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20762. * separate meshes. This can be use to improve performances.
  20763. * @see http://doc.babylonjs.com/how_to/multi_materials
  20764. */
  20765. export class MultiMaterial extends Material {
  20766. private _subMaterials;
  20767. /**
  20768. * Gets or Sets the list of Materials used within the multi material.
  20769. * They need to be ordered according to the submeshes order in the associated mesh
  20770. */
  20771. subMaterials: Nullable<Material>[];
  20772. /**
  20773. * Function used to align with Node.getChildren()
  20774. * @returns the list of Materials used within the multi material
  20775. */
  20776. getChildren(): Nullable<Material>[];
  20777. /**
  20778. * Instantiates a new Multi Material
  20779. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20780. * separate meshes. This can be use to improve performances.
  20781. * @see http://doc.babylonjs.com/how_to/multi_materials
  20782. * @param name Define the name in the scene
  20783. * @param scene Define the scene the material belongs to
  20784. */
  20785. constructor(name: string, scene: Scene);
  20786. private _hookArray;
  20787. /**
  20788. * Get one of the submaterial by its index in the submaterials array
  20789. * @param index The index to look the sub material at
  20790. * @returns The Material if the index has been defined
  20791. */
  20792. getSubMaterial(index: number): Nullable<Material>;
  20793. /**
  20794. * Get the list of active textures for the whole sub materials list.
  20795. * @returns All the textures that will be used during the rendering
  20796. */
  20797. getActiveTextures(): BaseTexture[];
  20798. /**
  20799. * Gets the current class name of the material e.g. "MultiMaterial"
  20800. * Mainly use in serialization.
  20801. * @returns the class name
  20802. */
  20803. getClassName(): string;
  20804. /**
  20805. * Checks if the material is ready to render the requested sub mesh
  20806. * @param mesh Define the mesh the submesh belongs to
  20807. * @param subMesh Define the sub mesh to look readyness for
  20808. * @param useInstances Define whether or not the material is used with instances
  20809. * @returns true if ready, otherwise false
  20810. */
  20811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20812. /**
  20813. * Clones the current material and its related sub materials
  20814. * @param name Define the name of the newly cloned material
  20815. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20816. * @returns the cloned material
  20817. */
  20818. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20819. /**
  20820. * Serializes the materials into a JSON representation.
  20821. * @returns the JSON representation
  20822. */
  20823. serialize(): any;
  20824. /**
  20825. * Dispose the material and release its associated resources
  20826. * @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)
  20827. * @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)
  20828. * @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)
  20829. */
  20830. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20831. /**
  20832. * Creates a MultiMaterial from parsed MultiMaterial data.
  20833. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20834. * @param scene defines the hosting scene
  20835. * @returns a new MultiMaterial
  20836. */
  20837. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20838. }
  20839. }
  20840. declare module BABYLON {
  20841. /**
  20842. * Base class for submeshes
  20843. */
  20844. export class BaseSubMesh {
  20845. /** @hidden */
  20846. _materialDefines: Nullable<MaterialDefines>;
  20847. /** @hidden */
  20848. _materialEffect: Nullable<Effect>;
  20849. /**
  20850. * Gets associated effect
  20851. */
  20852. readonly effect: Nullable<Effect>;
  20853. /**
  20854. * Sets associated effect (effect used to render this submesh)
  20855. * @param effect defines the effect to associate with
  20856. * @param defines defines the set of defines used to compile this effect
  20857. */
  20858. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20859. }
  20860. /**
  20861. * Defines a subdivision inside a mesh
  20862. */
  20863. export class SubMesh extends BaseSubMesh implements ICullable {
  20864. /** the material index to use */
  20865. materialIndex: number;
  20866. /** vertex index start */
  20867. verticesStart: number;
  20868. /** vertices count */
  20869. verticesCount: number;
  20870. /** index start */
  20871. indexStart: number;
  20872. /** indices count */
  20873. indexCount: number;
  20874. /** @hidden */
  20875. _linesIndexCount: number;
  20876. private _mesh;
  20877. private _renderingMesh;
  20878. private _boundingInfo;
  20879. private _linesIndexBuffer;
  20880. /** @hidden */
  20881. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20882. /** @hidden */
  20883. _trianglePlanes: Plane[];
  20884. /** @hidden */
  20885. _lastColliderTransformMatrix: Nullable<Matrix>;
  20886. /** @hidden */
  20887. _renderId: number;
  20888. /** @hidden */
  20889. _alphaIndex: number;
  20890. /** @hidden */
  20891. _distanceToCamera: number;
  20892. /** @hidden */
  20893. _id: number;
  20894. private _currentMaterial;
  20895. /**
  20896. * Add a new submesh to a mesh
  20897. * @param materialIndex defines the material index to use
  20898. * @param verticesStart defines vertex index start
  20899. * @param verticesCount defines vertices count
  20900. * @param indexStart defines index start
  20901. * @param indexCount defines indices count
  20902. * @param mesh defines the parent mesh
  20903. * @param renderingMesh defines an optional rendering mesh
  20904. * @param createBoundingBox defines if bounding box should be created for this submesh
  20905. * @returns the new submesh
  20906. */
  20907. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20908. /**
  20909. * Creates a new submesh
  20910. * @param materialIndex defines the material index to use
  20911. * @param verticesStart defines vertex index start
  20912. * @param verticesCount defines vertices count
  20913. * @param indexStart defines index start
  20914. * @param indexCount defines indices count
  20915. * @param mesh defines the parent mesh
  20916. * @param renderingMesh defines an optional rendering mesh
  20917. * @param createBoundingBox defines if bounding box should be created for this submesh
  20918. */
  20919. constructor(
  20920. /** the material index to use */
  20921. materialIndex: number,
  20922. /** vertex index start */
  20923. verticesStart: number,
  20924. /** vertices count */
  20925. verticesCount: number,
  20926. /** index start */
  20927. indexStart: number,
  20928. /** indices count */
  20929. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20930. /**
  20931. * Returns true if this submesh covers the entire parent mesh
  20932. * @ignorenaming
  20933. */
  20934. readonly IsGlobal: boolean;
  20935. /**
  20936. * Returns the submesh BoudingInfo object
  20937. * @returns current bounding info (or mesh's one if the submesh is global)
  20938. */
  20939. getBoundingInfo(): BoundingInfo;
  20940. /**
  20941. * Sets the submesh BoundingInfo
  20942. * @param boundingInfo defines the new bounding info to use
  20943. * @returns the SubMesh
  20944. */
  20945. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20946. /**
  20947. * Returns the mesh of the current submesh
  20948. * @return the parent mesh
  20949. */
  20950. getMesh(): AbstractMesh;
  20951. /**
  20952. * Returns the rendering mesh of the submesh
  20953. * @returns the rendering mesh (could be different from parent mesh)
  20954. */
  20955. getRenderingMesh(): Mesh;
  20956. /**
  20957. * Returns the submesh material
  20958. * @returns null or the current material
  20959. */
  20960. getMaterial(): Nullable<Material>;
  20961. /**
  20962. * Sets a new updated BoundingInfo object to the submesh
  20963. * @param data defines an optional position array to use to determine the bounding info
  20964. * @returns the SubMesh
  20965. */
  20966. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20967. /** @hidden */
  20968. _checkCollision(collider: Collider): boolean;
  20969. /**
  20970. * Updates the submesh BoundingInfo
  20971. * @param world defines the world matrix to use to update the bounding info
  20972. * @returns the submesh
  20973. */
  20974. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20975. /**
  20976. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20977. * @param frustumPlanes defines the frustum planes
  20978. * @returns true if the submesh is intersecting with the frustum
  20979. */
  20980. isInFrustum(frustumPlanes: Plane[]): boolean;
  20981. /**
  20982. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20983. * @param frustumPlanes defines the frustum planes
  20984. * @returns true if the submesh is inside the frustum
  20985. */
  20986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20987. /**
  20988. * Renders the submesh
  20989. * @param enableAlphaMode defines if alpha needs to be used
  20990. * @returns the submesh
  20991. */
  20992. render(enableAlphaMode: boolean): SubMesh;
  20993. /**
  20994. * @hidden
  20995. */
  20996. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20997. /**
  20998. * Checks if the submesh intersects with a ray
  20999. * @param ray defines the ray to test
  21000. * @returns true is the passed ray intersects the submesh bounding box
  21001. */
  21002. canIntersects(ray: Ray): boolean;
  21003. /**
  21004. * Intersects current submesh with a ray
  21005. * @param ray defines the ray to test
  21006. * @param positions defines mesh's positions array
  21007. * @param indices defines mesh's indices array
  21008. * @param fastCheck defines if only bounding info should be used
  21009. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21010. * @returns intersection info or null if no intersection
  21011. */
  21012. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21013. /** @hidden */
  21014. private _intersectLines;
  21015. /** @hidden */
  21016. private _intersectUnIndexedLines;
  21017. /** @hidden */
  21018. private _intersectTriangles;
  21019. /** @hidden */
  21020. private _intersectUnIndexedTriangles;
  21021. /** @hidden */
  21022. _rebuild(): void;
  21023. /**
  21024. * Creates a new submesh from the passed mesh
  21025. * @param newMesh defines the new hosting mesh
  21026. * @param newRenderingMesh defines an optional rendering mesh
  21027. * @returns the new submesh
  21028. */
  21029. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21030. /**
  21031. * Release associated resources
  21032. */
  21033. dispose(): void;
  21034. /**
  21035. * Gets the class name
  21036. * @returns the string "SubMesh".
  21037. */
  21038. getClassName(): string;
  21039. /**
  21040. * Creates a new submesh from indices data
  21041. * @param materialIndex the index of the main mesh material
  21042. * @param startIndex the index where to start the copy in the mesh indices array
  21043. * @param indexCount the number of indices to copy then from the startIndex
  21044. * @param mesh the main mesh to create the submesh from
  21045. * @param renderingMesh the optional rendering mesh
  21046. * @returns a new submesh
  21047. */
  21048. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21049. }
  21050. }
  21051. declare module BABYLON {
  21052. /**
  21053. * Class used to represent data loading progression
  21054. */
  21055. export class SceneLoaderFlags {
  21056. private static _ForceFullSceneLoadingForIncremental;
  21057. private static _ShowLoadingScreen;
  21058. private static _CleanBoneMatrixWeights;
  21059. private static _loggingLevel;
  21060. /**
  21061. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21062. */
  21063. static ForceFullSceneLoadingForIncremental: boolean;
  21064. /**
  21065. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21066. */
  21067. static ShowLoadingScreen: boolean;
  21068. /**
  21069. * Defines the current logging level (while loading the scene)
  21070. * @ignorenaming
  21071. */
  21072. static loggingLevel: number;
  21073. /**
  21074. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21075. */
  21076. static CleanBoneMatrixWeights: boolean;
  21077. }
  21078. }
  21079. declare module BABYLON {
  21080. /**
  21081. * Class used to store geometry data (vertex buffers + index buffer)
  21082. */
  21083. export class Geometry implements IGetSetVerticesData {
  21084. /**
  21085. * Gets or sets the ID of the geometry
  21086. */
  21087. id: string;
  21088. /**
  21089. * Gets or sets the unique ID of the geometry
  21090. */
  21091. uniqueId: number;
  21092. /**
  21093. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21094. */
  21095. delayLoadState: number;
  21096. /**
  21097. * Gets the file containing the data to load when running in delay load state
  21098. */
  21099. delayLoadingFile: Nullable<string>;
  21100. /**
  21101. * Callback called when the geometry is updated
  21102. */
  21103. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21104. private _scene;
  21105. private _engine;
  21106. private _meshes;
  21107. private _totalVertices;
  21108. /** @hidden */
  21109. _indices: IndicesArray;
  21110. /** @hidden */
  21111. _vertexBuffers: {
  21112. [key: string]: VertexBuffer;
  21113. };
  21114. private _isDisposed;
  21115. private _extend;
  21116. private _boundingBias;
  21117. /** @hidden */
  21118. _delayInfo: Array<string>;
  21119. private _indexBuffer;
  21120. private _indexBufferIsUpdatable;
  21121. /** @hidden */
  21122. _boundingInfo: Nullable<BoundingInfo>;
  21123. /** @hidden */
  21124. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21125. /** @hidden */
  21126. _softwareSkinningFrameId: number;
  21127. private _vertexArrayObjects;
  21128. private _updatable;
  21129. /** @hidden */
  21130. _positions: Nullable<Vector3[]>;
  21131. /**
  21132. * 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
  21133. */
  21134. /**
  21135. * 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
  21136. */
  21137. boundingBias: Vector2;
  21138. /**
  21139. * Static function used to attach a new empty geometry to a mesh
  21140. * @param mesh defines the mesh to attach the geometry to
  21141. * @returns the new Geometry
  21142. */
  21143. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21144. /**
  21145. * Creates a new geometry
  21146. * @param id defines the unique ID
  21147. * @param scene defines the hosting scene
  21148. * @param vertexData defines the VertexData used to get geometry data
  21149. * @param updatable defines if geometry must be updatable (false by default)
  21150. * @param mesh defines the mesh that will be associated with the geometry
  21151. */
  21152. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21153. /**
  21154. * Gets the current extend of the geometry
  21155. */
  21156. readonly extend: {
  21157. minimum: Vector3;
  21158. maximum: Vector3;
  21159. };
  21160. /**
  21161. * Gets the hosting scene
  21162. * @returns the hosting Scene
  21163. */
  21164. getScene(): Scene;
  21165. /**
  21166. * Gets the hosting engine
  21167. * @returns the hosting Engine
  21168. */
  21169. getEngine(): Engine;
  21170. /**
  21171. * Defines if the geometry is ready to use
  21172. * @returns true if the geometry is ready to be used
  21173. */
  21174. isReady(): boolean;
  21175. /**
  21176. * Gets a value indicating that the geometry should not be serialized
  21177. */
  21178. readonly doNotSerialize: boolean;
  21179. /** @hidden */
  21180. _rebuild(): void;
  21181. /**
  21182. * Affects all geometry data in one call
  21183. * @param vertexData defines the geometry data
  21184. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21185. */
  21186. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21187. /**
  21188. * Set specific vertex data
  21189. * @param kind defines the data kind (Position, normal, etc...)
  21190. * @param data defines the vertex data to use
  21191. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21192. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21193. */
  21194. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21195. /**
  21196. * Removes a specific vertex data
  21197. * @param kind defines the data kind (Position, normal, etc...)
  21198. */
  21199. removeVerticesData(kind: string): void;
  21200. /**
  21201. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21202. * @param buffer defines the vertex buffer to use
  21203. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21204. */
  21205. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21206. /**
  21207. * Update a specific vertex buffer
  21208. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21209. * It will do nothing if the buffer is not updatable
  21210. * @param kind defines the data kind (Position, normal, etc...)
  21211. * @param data defines the data to use
  21212. * @param offset defines the offset in the target buffer where to store the data
  21213. * @param useBytes set to true if the offset is in bytes
  21214. */
  21215. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21216. /**
  21217. * Update a specific vertex buffer
  21218. * This function will create a new buffer if the current one is not updatable
  21219. * @param kind defines the data kind (Position, normal, etc...)
  21220. * @param data defines the data to use
  21221. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21222. */
  21223. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21224. private _updateBoundingInfo;
  21225. /** @hidden */
  21226. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21227. /**
  21228. * Gets total number of vertices
  21229. * @returns the total number of vertices
  21230. */
  21231. getTotalVertices(): number;
  21232. /**
  21233. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21234. * @param kind defines the data kind (Position, normal, etc...)
  21235. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21236. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21237. * @returns a float array containing vertex data
  21238. */
  21239. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21240. /**
  21241. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21242. * @param kind defines the data kind (Position, normal, etc...)
  21243. * @returns true if the vertex buffer with the specified kind is updatable
  21244. */
  21245. isVertexBufferUpdatable(kind: string): boolean;
  21246. /**
  21247. * Gets a specific vertex buffer
  21248. * @param kind defines the data kind (Position, normal, etc...)
  21249. * @returns a VertexBuffer
  21250. */
  21251. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21252. /**
  21253. * Returns all vertex buffers
  21254. * @return an object holding all vertex buffers indexed by kind
  21255. */
  21256. getVertexBuffers(): Nullable<{
  21257. [key: string]: VertexBuffer;
  21258. }>;
  21259. /**
  21260. * Gets a boolean indicating if specific vertex buffer is present
  21261. * @param kind defines the data kind (Position, normal, etc...)
  21262. * @returns true if data is present
  21263. */
  21264. isVerticesDataPresent(kind: string): boolean;
  21265. /**
  21266. * Gets a list of all attached data kinds (Position, normal, etc...)
  21267. * @returns a list of string containing all kinds
  21268. */
  21269. getVerticesDataKinds(): string[];
  21270. /**
  21271. * Update index buffer
  21272. * @param indices defines the indices to store in the index buffer
  21273. * @param offset defines the offset in the target buffer where to store the data
  21274. * @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)
  21275. */
  21276. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21277. /**
  21278. * Creates a new index buffer
  21279. * @param indices defines the indices to store in the index buffer
  21280. * @param totalVertices defines the total number of vertices (could be null)
  21281. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21282. */
  21283. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21284. /**
  21285. * Return the total number of indices
  21286. * @returns the total number of indices
  21287. */
  21288. getTotalIndices(): number;
  21289. /**
  21290. * Gets the index buffer array
  21291. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21293. * @returns the index buffer array
  21294. */
  21295. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21296. /**
  21297. * Gets the index buffer
  21298. * @return the index buffer
  21299. */
  21300. getIndexBuffer(): Nullable<DataBuffer>;
  21301. /** @hidden */
  21302. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21303. /**
  21304. * Release the associated resources for a specific mesh
  21305. * @param mesh defines the source mesh
  21306. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21307. */
  21308. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21309. /**
  21310. * Apply current geometry to a given mesh
  21311. * @param mesh defines the mesh to apply geometry to
  21312. */
  21313. applyToMesh(mesh: Mesh): void;
  21314. private _updateExtend;
  21315. private _applyToMesh;
  21316. private notifyUpdate;
  21317. /**
  21318. * Load the geometry if it was flagged as delay loaded
  21319. * @param scene defines the hosting scene
  21320. * @param onLoaded defines a callback called when the geometry is loaded
  21321. */
  21322. load(scene: Scene, onLoaded?: () => void): void;
  21323. private _queueLoad;
  21324. /**
  21325. * Invert the geometry to move from a right handed system to a left handed one.
  21326. */
  21327. toLeftHanded(): void;
  21328. /** @hidden */
  21329. _resetPointsArrayCache(): void;
  21330. /** @hidden */
  21331. _generatePointsArray(): boolean;
  21332. /**
  21333. * Gets a value indicating if the geometry is disposed
  21334. * @returns true if the geometry was disposed
  21335. */
  21336. isDisposed(): boolean;
  21337. private _disposeVertexArrayObjects;
  21338. /**
  21339. * Free all associated resources
  21340. */
  21341. dispose(): void;
  21342. /**
  21343. * Clone the current geometry into a new geometry
  21344. * @param id defines the unique ID of the new geometry
  21345. * @returns a new geometry object
  21346. */
  21347. copy(id: string): Geometry;
  21348. /**
  21349. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21350. * @return a JSON representation of the current geometry data (without the vertices data)
  21351. */
  21352. serialize(): any;
  21353. private toNumberArray;
  21354. /**
  21355. * Serialize all vertices data into a JSON oject
  21356. * @returns a JSON representation of the current geometry data
  21357. */
  21358. serializeVerticeData(): any;
  21359. /**
  21360. * Extracts a clone of a mesh geometry
  21361. * @param mesh defines the source mesh
  21362. * @param id defines the unique ID of the new geometry object
  21363. * @returns the new geometry object
  21364. */
  21365. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21366. /**
  21367. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21368. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21369. * Be aware Math.random() could cause collisions, but:
  21370. * "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"
  21371. * @returns a string containing a new GUID
  21372. */
  21373. static RandomId(): string;
  21374. /** @hidden */
  21375. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21376. private static _CleanMatricesWeights;
  21377. /**
  21378. * Create a new geometry from persisted data (Using .babylon file format)
  21379. * @param parsedVertexData defines the persisted data
  21380. * @param scene defines the hosting scene
  21381. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21382. * @returns the new geometry object
  21383. */
  21384. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21385. }
  21386. }
  21387. declare module BABYLON {
  21388. /**
  21389. * Define an interface for all classes that will get and set the data on vertices
  21390. */
  21391. export interface IGetSetVerticesData {
  21392. /**
  21393. * Gets a boolean indicating if specific vertex data is present
  21394. * @param kind defines the vertex data kind to use
  21395. * @returns true is data kind is present
  21396. */
  21397. isVerticesDataPresent(kind: string): boolean;
  21398. /**
  21399. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21400. * @param kind defines the data kind (Position, normal, etc...)
  21401. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21402. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21403. * @returns a float array containing vertex data
  21404. */
  21405. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21406. /**
  21407. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21408. * @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.
  21409. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21410. * @returns the indices array or an empty array if the mesh has no geometry
  21411. */
  21412. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21413. /**
  21414. * Set specific vertex data
  21415. * @param kind defines the data kind (Position, normal, etc...)
  21416. * @param data defines the vertex data to use
  21417. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21418. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21419. */
  21420. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21421. /**
  21422. * Update a specific associated vertex buffer
  21423. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21424. * - VertexBuffer.PositionKind
  21425. * - VertexBuffer.UVKind
  21426. * - VertexBuffer.UV2Kind
  21427. * - VertexBuffer.UV3Kind
  21428. * - VertexBuffer.UV4Kind
  21429. * - VertexBuffer.UV5Kind
  21430. * - VertexBuffer.UV6Kind
  21431. * - VertexBuffer.ColorKind
  21432. * - VertexBuffer.MatricesIndicesKind
  21433. * - VertexBuffer.MatricesIndicesExtraKind
  21434. * - VertexBuffer.MatricesWeightsKind
  21435. * - VertexBuffer.MatricesWeightsExtraKind
  21436. * @param data defines the data source
  21437. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21438. * @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)
  21439. */
  21440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21441. /**
  21442. * Creates a new index buffer
  21443. * @param indices defines the indices to store in the index buffer
  21444. * @param totalVertices defines the total number of vertices (could be null)
  21445. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21446. */
  21447. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21448. }
  21449. /**
  21450. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21451. */
  21452. export class VertexData {
  21453. /**
  21454. * Mesh side orientation : usually the external or front surface
  21455. */
  21456. static readonly FRONTSIDE: number;
  21457. /**
  21458. * Mesh side orientation : usually the internal or back surface
  21459. */
  21460. static readonly BACKSIDE: number;
  21461. /**
  21462. * Mesh side orientation : both internal and external or front and back surfaces
  21463. */
  21464. static readonly DOUBLESIDE: number;
  21465. /**
  21466. * Mesh side orientation : by default, `FRONTSIDE`
  21467. */
  21468. static readonly DEFAULTSIDE: number;
  21469. /**
  21470. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21471. */
  21472. positions: Nullable<FloatArray>;
  21473. /**
  21474. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21475. */
  21476. normals: Nullable<FloatArray>;
  21477. /**
  21478. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21479. */
  21480. tangents: Nullable<FloatArray>;
  21481. /**
  21482. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21483. */
  21484. uvs: Nullable<FloatArray>;
  21485. /**
  21486. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21487. */
  21488. uvs2: Nullable<FloatArray>;
  21489. /**
  21490. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21491. */
  21492. uvs3: Nullable<FloatArray>;
  21493. /**
  21494. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21495. */
  21496. uvs4: Nullable<FloatArray>;
  21497. /**
  21498. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21499. */
  21500. uvs5: Nullable<FloatArray>;
  21501. /**
  21502. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21503. */
  21504. uvs6: Nullable<FloatArray>;
  21505. /**
  21506. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21507. */
  21508. colors: Nullable<FloatArray>;
  21509. /**
  21510. * 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).
  21511. */
  21512. matricesIndices: Nullable<FloatArray>;
  21513. /**
  21514. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21515. */
  21516. matricesWeights: Nullable<FloatArray>;
  21517. /**
  21518. * An array extending the number of possible indices
  21519. */
  21520. matricesIndicesExtra: Nullable<FloatArray>;
  21521. /**
  21522. * An array extending the number of possible weights when the number of indices is extended
  21523. */
  21524. matricesWeightsExtra: Nullable<FloatArray>;
  21525. /**
  21526. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21527. */
  21528. indices: Nullable<IndicesArray>;
  21529. /**
  21530. * Uses the passed data array to set the set the values for the specified kind of data
  21531. * @param data a linear array of floating numbers
  21532. * @param kind the type of data that is being set, eg positions, colors etc
  21533. */
  21534. set(data: FloatArray, kind: string): void;
  21535. /**
  21536. * Associates the vertexData to the passed Mesh.
  21537. * Sets it as updatable or not (default `false`)
  21538. * @param mesh the mesh the vertexData is applied to
  21539. * @param updatable when used and having the value true allows new data to update the vertexData
  21540. * @returns the VertexData
  21541. */
  21542. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21543. /**
  21544. * Associates the vertexData to the passed Geometry.
  21545. * Sets it as updatable or not (default `false`)
  21546. * @param geometry the geometry the vertexData is applied to
  21547. * @param updatable when used and having the value true allows new data to update the vertexData
  21548. * @returns VertexData
  21549. */
  21550. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21551. /**
  21552. * Updates the associated mesh
  21553. * @param mesh the mesh to be updated
  21554. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21555. * @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
  21556. * @returns VertexData
  21557. */
  21558. updateMesh(mesh: Mesh): VertexData;
  21559. /**
  21560. * Updates the associated geometry
  21561. * @param geometry the geometry to be updated
  21562. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21563. * @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
  21564. * @returns VertexData.
  21565. */
  21566. updateGeometry(geometry: Geometry): VertexData;
  21567. private _applyTo;
  21568. private _update;
  21569. /**
  21570. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21571. * @param matrix the transforming matrix
  21572. * @returns the VertexData
  21573. */
  21574. transform(matrix: Matrix): VertexData;
  21575. /**
  21576. * Merges the passed VertexData into the current one
  21577. * @param other the VertexData to be merged into the current one
  21578. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21579. * @returns the modified VertexData
  21580. */
  21581. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21582. private _mergeElement;
  21583. private _validate;
  21584. /**
  21585. * Serializes the VertexData
  21586. * @returns a serialized object
  21587. */
  21588. serialize(): any;
  21589. /**
  21590. * Extracts the vertexData from a mesh
  21591. * @param mesh the mesh from which to extract the VertexData
  21592. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21593. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21594. * @returns the object VertexData associated to the passed mesh
  21595. */
  21596. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21597. /**
  21598. * Extracts the vertexData from the geometry
  21599. * @param geometry the geometry from which to extract the VertexData
  21600. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21601. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21602. * @returns the object VertexData associated to the passed mesh
  21603. */
  21604. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21605. private static _ExtractFrom;
  21606. /**
  21607. * Creates the VertexData for a Ribbon
  21608. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21609. * * pathArray array of paths, each of which an array of successive Vector3
  21610. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21611. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21612. * * 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
  21613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21614. * * 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)
  21615. * * 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)
  21616. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21617. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21618. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21619. * @returns the VertexData of the ribbon
  21620. */
  21621. static CreateRibbon(options: {
  21622. pathArray: Vector3[][];
  21623. closeArray?: boolean;
  21624. closePath?: boolean;
  21625. offset?: number;
  21626. sideOrientation?: number;
  21627. frontUVs?: Vector4;
  21628. backUVs?: Vector4;
  21629. invertUV?: boolean;
  21630. uvs?: Vector2[];
  21631. colors?: Color4[];
  21632. }): VertexData;
  21633. /**
  21634. * Creates the VertexData for a box
  21635. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21636. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21637. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21638. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21639. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21640. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21641. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21643. * * 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)
  21644. * * 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)
  21645. * @returns the VertexData of the box
  21646. */
  21647. static CreateBox(options: {
  21648. size?: number;
  21649. width?: number;
  21650. height?: number;
  21651. depth?: number;
  21652. faceUV?: Vector4[];
  21653. faceColors?: Color4[];
  21654. sideOrientation?: number;
  21655. frontUVs?: Vector4;
  21656. backUVs?: Vector4;
  21657. }): VertexData;
  21658. /**
  21659. * Creates the VertexData for a tiled box
  21660. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21661. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21662. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21663. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21665. * @returns the VertexData of the box
  21666. */
  21667. static CreateTiledBox(options: {
  21668. pattern?: number;
  21669. width?: number;
  21670. height?: number;
  21671. depth?: number;
  21672. tileSize?: number;
  21673. tileWidth?: number;
  21674. tileHeight?: number;
  21675. alignHorizontal?: number;
  21676. alignVertical?: number;
  21677. faceUV?: Vector4[];
  21678. faceColors?: Color4[];
  21679. sideOrientation?: number;
  21680. }): VertexData;
  21681. /**
  21682. * Creates the VertexData for a tiled plane
  21683. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21684. * * pattern a limited pattern arrangement depending on the number
  21685. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21686. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21687. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21689. * * 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)
  21690. * * 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)
  21691. * @returns the VertexData of the tiled plane
  21692. */
  21693. static CreateTiledPlane(options: {
  21694. pattern?: number;
  21695. tileSize?: number;
  21696. tileWidth?: number;
  21697. tileHeight?: number;
  21698. size?: number;
  21699. width?: number;
  21700. height?: number;
  21701. alignHorizontal?: number;
  21702. alignVertical?: number;
  21703. sideOrientation?: number;
  21704. frontUVs?: Vector4;
  21705. backUVs?: Vector4;
  21706. }): VertexData;
  21707. /**
  21708. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21710. * * segments sets the number of horizontal strips optional, default 32
  21711. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21712. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21713. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21714. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21715. * * 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
  21716. * * 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
  21717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21718. * * 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)
  21719. * * 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)
  21720. * @returns the VertexData of the ellipsoid
  21721. */
  21722. static CreateSphere(options: {
  21723. segments?: number;
  21724. diameter?: number;
  21725. diameterX?: number;
  21726. diameterY?: number;
  21727. diameterZ?: number;
  21728. arc?: number;
  21729. slice?: number;
  21730. sideOrientation?: number;
  21731. frontUVs?: Vector4;
  21732. backUVs?: Vector4;
  21733. }): VertexData;
  21734. /**
  21735. * Creates the VertexData for a cylinder, cone or prism
  21736. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21737. * * height sets the height (y direction) of the cylinder, optional, default 2
  21738. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21739. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21740. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21741. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21742. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21743. * * 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
  21744. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21745. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21746. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21747. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21749. * * 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)
  21750. * * 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)
  21751. * @returns the VertexData of the cylinder, cone or prism
  21752. */
  21753. static CreateCylinder(options: {
  21754. height?: number;
  21755. diameterTop?: number;
  21756. diameterBottom?: number;
  21757. diameter?: number;
  21758. tessellation?: number;
  21759. subdivisions?: number;
  21760. arc?: number;
  21761. faceColors?: Color4[];
  21762. faceUV?: Vector4[];
  21763. hasRings?: boolean;
  21764. enclose?: boolean;
  21765. sideOrientation?: number;
  21766. frontUVs?: Vector4;
  21767. backUVs?: Vector4;
  21768. }): VertexData;
  21769. /**
  21770. * Creates the VertexData for a torus
  21771. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21772. * * diameter the diameter of the torus, optional default 1
  21773. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21774. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21776. * * 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)
  21777. * * 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)
  21778. * @returns the VertexData of the torus
  21779. */
  21780. static CreateTorus(options: {
  21781. diameter?: number;
  21782. thickness?: number;
  21783. tessellation?: number;
  21784. sideOrientation?: number;
  21785. frontUVs?: Vector4;
  21786. backUVs?: Vector4;
  21787. }): VertexData;
  21788. /**
  21789. * Creates the VertexData of the LineSystem
  21790. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21791. * - lines an array of lines, each line being an array of successive Vector3
  21792. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21793. * @returns the VertexData of the LineSystem
  21794. */
  21795. static CreateLineSystem(options: {
  21796. lines: Vector3[][];
  21797. colors?: Nullable<Color4[][]>;
  21798. }): VertexData;
  21799. /**
  21800. * Create the VertexData for a DashedLines
  21801. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21802. * - points an array successive Vector3
  21803. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21804. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21805. * - dashNb the intended total number of dashes, optional, default 200
  21806. * @returns the VertexData for the DashedLines
  21807. */
  21808. static CreateDashedLines(options: {
  21809. points: Vector3[];
  21810. dashSize?: number;
  21811. gapSize?: number;
  21812. dashNb?: number;
  21813. }): VertexData;
  21814. /**
  21815. * Creates the VertexData for a Ground
  21816. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21817. * - width the width (x direction) of the ground, optional, default 1
  21818. * - height the height (z direction) of the ground, optional, default 1
  21819. * - subdivisions the number of subdivisions per side, optional, default 1
  21820. * @returns the VertexData of the Ground
  21821. */
  21822. static CreateGround(options: {
  21823. width?: number;
  21824. height?: number;
  21825. subdivisions?: number;
  21826. subdivisionsX?: number;
  21827. subdivisionsY?: number;
  21828. }): VertexData;
  21829. /**
  21830. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21831. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21832. * * xmin the ground minimum X coordinate, optional, default -1
  21833. * * zmin the ground minimum Z coordinate, optional, default -1
  21834. * * xmax the ground maximum X coordinate, optional, default 1
  21835. * * zmax the ground maximum Z coordinate, optional, default 1
  21836. * * 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}
  21837. * * 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}
  21838. * @returns the VertexData of the TiledGround
  21839. */
  21840. static CreateTiledGround(options: {
  21841. xmin: number;
  21842. zmin: number;
  21843. xmax: number;
  21844. zmax: number;
  21845. subdivisions?: {
  21846. w: number;
  21847. h: number;
  21848. };
  21849. precision?: {
  21850. w: number;
  21851. h: number;
  21852. };
  21853. }): VertexData;
  21854. /**
  21855. * Creates the VertexData of the Ground designed from a heightmap
  21856. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21857. * * width the width (x direction) of the ground
  21858. * * height the height (z direction) of the ground
  21859. * * subdivisions the number of subdivisions per side
  21860. * * minHeight the minimum altitude on the ground, optional, default 0
  21861. * * maxHeight the maximum altitude on the ground, optional default 1
  21862. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21863. * * buffer the array holding the image color data
  21864. * * bufferWidth the width of image
  21865. * * bufferHeight the height of image
  21866. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21867. * @returns the VertexData of the Ground designed from a heightmap
  21868. */
  21869. static CreateGroundFromHeightMap(options: {
  21870. width: number;
  21871. height: number;
  21872. subdivisions: number;
  21873. minHeight: number;
  21874. maxHeight: number;
  21875. colorFilter: Color3;
  21876. buffer: Uint8Array;
  21877. bufferWidth: number;
  21878. bufferHeight: number;
  21879. alphaFilter: number;
  21880. }): VertexData;
  21881. /**
  21882. * Creates the VertexData for a Plane
  21883. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21884. * * size sets the width and height of the plane to the value of size, optional default 1
  21885. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21886. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21888. * * 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)
  21889. * * 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)
  21890. * @returns the VertexData of the box
  21891. */
  21892. static CreatePlane(options: {
  21893. size?: number;
  21894. width?: number;
  21895. height?: number;
  21896. sideOrientation?: number;
  21897. frontUVs?: Vector4;
  21898. backUVs?: Vector4;
  21899. }): VertexData;
  21900. /**
  21901. * Creates the VertexData of the Disc or regular Polygon
  21902. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21903. * * radius the radius of the disc, optional default 0.5
  21904. * * tessellation the number of polygon sides, optional, default 64
  21905. * * 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
  21906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21907. * * 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)
  21908. * * 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)
  21909. * @returns the VertexData of the box
  21910. */
  21911. static CreateDisc(options: {
  21912. radius?: number;
  21913. tessellation?: number;
  21914. arc?: number;
  21915. sideOrientation?: number;
  21916. frontUVs?: Vector4;
  21917. backUVs?: Vector4;
  21918. }): VertexData;
  21919. /**
  21920. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21921. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21922. * @param polygon a mesh built from polygonTriangulation.build()
  21923. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21924. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21925. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21926. * @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)
  21927. * @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)
  21928. * @returns the VertexData of the Polygon
  21929. */
  21930. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21931. /**
  21932. * Creates the VertexData of the IcoSphere
  21933. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21934. * * radius the radius of the IcoSphere, optional default 1
  21935. * * radiusX allows stretching in the x direction, optional, default radius
  21936. * * radiusY allows stretching in the y direction, optional, default radius
  21937. * * radiusZ allows stretching in the z direction, optional, default radius
  21938. * * flat when true creates a flat shaded mesh, optional, default true
  21939. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21941. * * 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)
  21942. * * 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)
  21943. * @returns the VertexData of the IcoSphere
  21944. */
  21945. static CreateIcoSphere(options: {
  21946. radius?: number;
  21947. radiusX?: number;
  21948. radiusY?: number;
  21949. radiusZ?: number;
  21950. flat?: boolean;
  21951. subdivisions?: number;
  21952. sideOrientation?: number;
  21953. frontUVs?: Vector4;
  21954. backUVs?: Vector4;
  21955. }): VertexData;
  21956. /**
  21957. * Creates the VertexData for a Polyhedron
  21958. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21959. * * type provided types are:
  21960. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21961. * * 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)
  21962. * * size the size of the IcoSphere, optional default 1
  21963. * * sizeX allows stretching in the x direction, optional, default size
  21964. * * sizeY allows stretching in the y direction, optional, default size
  21965. * * sizeZ allows stretching in the z direction, optional, default size
  21966. * * 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
  21967. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21968. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21969. * * flat when true creates a flat shaded mesh, optional, default true
  21970. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21972. * * 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)
  21973. * * 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)
  21974. * @returns the VertexData of the Polyhedron
  21975. */
  21976. static CreatePolyhedron(options: {
  21977. type?: number;
  21978. size?: number;
  21979. sizeX?: number;
  21980. sizeY?: number;
  21981. sizeZ?: number;
  21982. custom?: any;
  21983. faceUV?: Vector4[];
  21984. faceColors?: Color4[];
  21985. flat?: boolean;
  21986. sideOrientation?: number;
  21987. frontUVs?: Vector4;
  21988. backUVs?: Vector4;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for a TorusKnot
  21992. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21993. * * radius the radius of the torus knot, optional, default 2
  21994. * * tube the thickness of the tube, optional, default 0.5
  21995. * * radialSegments the number of sides on each tube segments, optional, default 32
  21996. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21997. * * p the number of windings around the z axis, optional, default 2
  21998. * * q the number of windings around the x axis, optional, default 3
  21999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22000. * * 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)
  22001. * * 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)
  22002. * @returns the VertexData of the Torus Knot
  22003. */
  22004. static CreateTorusKnot(options: {
  22005. radius?: number;
  22006. tube?: number;
  22007. radialSegments?: number;
  22008. tubularSegments?: number;
  22009. p?: number;
  22010. q?: number;
  22011. sideOrientation?: number;
  22012. frontUVs?: Vector4;
  22013. backUVs?: Vector4;
  22014. }): VertexData;
  22015. /**
  22016. * Compute normals for given positions and indices
  22017. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22018. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22019. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22020. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22021. * * facetNormals : optional array of facet normals (vector3)
  22022. * * facetPositions : optional array of facet positions (vector3)
  22023. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22024. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22025. * * bInfo : optional bounding info, required for facetPartitioning computation
  22026. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22027. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22028. * * useRightHandedSystem: optional boolean to for right handed system computation
  22029. * * depthSort : optional boolean to enable the facet depth sort computation
  22030. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22031. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22032. */
  22033. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22034. facetNormals?: any;
  22035. facetPositions?: any;
  22036. facetPartitioning?: any;
  22037. ratio?: number;
  22038. bInfo?: any;
  22039. bbSize?: Vector3;
  22040. subDiv?: any;
  22041. useRightHandedSystem?: boolean;
  22042. depthSort?: boolean;
  22043. distanceTo?: Vector3;
  22044. depthSortedFacets?: any;
  22045. }): void;
  22046. /** @hidden */
  22047. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22048. /**
  22049. * Applies VertexData created from the imported parameters to the geometry
  22050. * @param parsedVertexData the parsed data from an imported file
  22051. * @param geometry the geometry to apply the VertexData to
  22052. */
  22053. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22054. }
  22055. }
  22056. declare module BABYLON {
  22057. /**
  22058. * Defines a target to use with MorphTargetManager
  22059. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22060. */
  22061. export class MorphTarget implements IAnimatable {
  22062. /** defines the name of the target */
  22063. name: string;
  22064. /**
  22065. * Gets or sets the list of animations
  22066. */
  22067. animations: Animation[];
  22068. private _scene;
  22069. private _positions;
  22070. private _normals;
  22071. private _tangents;
  22072. private _uvs;
  22073. private _influence;
  22074. /**
  22075. * Observable raised when the influence changes
  22076. */
  22077. onInfluenceChanged: Observable<boolean>;
  22078. /** @hidden */
  22079. _onDataLayoutChanged: Observable<void>;
  22080. /**
  22081. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22082. */
  22083. influence: number;
  22084. /**
  22085. * Gets or sets the id of the morph Target
  22086. */
  22087. id: string;
  22088. private _animationPropertiesOverride;
  22089. /**
  22090. * Gets or sets the animation properties override
  22091. */
  22092. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22093. /**
  22094. * Creates a new MorphTarget
  22095. * @param name defines the name of the target
  22096. * @param influence defines the influence to use
  22097. * @param scene defines the scene the morphtarget belongs to
  22098. */
  22099. constructor(
  22100. /** defines the name of the target */
  22101. name: string, influence?: number, scene?: Nullable<Scene>);
  22102. /**
  22103. * Gets a boolean defining if the target contains position data
  22104. */
  22105. readonly hasPositions: boolean;
  22106. /**
  22107. * Gets a boolean defining if the target contains normal data
  22108. */
  22109. readonly hasNormals: boolean;
  22110. /**
  22111. * Gets a boolean defining if the target contains tangent data
  22112. */
  22113. readonly hasTangents: boolean;
  22114. /**
  22115. * Gets a boolean defining if the target contains texture coordinates data
  22116. */
  22117. readonly hasUVs: boolean;
  22118. /**
  22119. * Affects position data to this target
  22120. * @param data defines the position data to use
  22121. */
  22122. setPositions(data: Nullable<FloatArray>): void;
  22123. /**
  22124. * Gets the position data stored in this target
  22125. * @returns a FloatArray containing the position data (or null if not present)
  22126. */
  22127. getPositions(): Nullable<FloatArray>;
  22128. /**
  22129. * Affects normal data to this target
  22130. * @param data defines the normal data to use
  22131. */
  22132. setNormals(data: Nullable<FloatArray>): void;
  22133. /**
  22134. * Gets the normal data stored in this target
  22135. * @returns a FloatArray containing the normal data (or null if not present)
  22136. */
  22137. getNormals(): Nullable<FloatArray>;
  22138. /**
  22139. * Affects tangent data to this target
  22140. * @param data defines the tangent data to use
  22141. */
  22142. setTangents(data: Nullable<FloatArray>): void;
  22143. /**
  22144. * Gets the tangent data stored in this target
  22145. * @returns a FloatArray containing the tangent data (or null if not present)
  22146. */
  22147. getTangents(): Nullable<FloatArray>;
  22148. /**
  22149. * Affects texture coordinates data to this target
  22150. * @param data defines the texture coordinates data to use
  22151. */
  22152. setUVs(data: Nullable<FloatArray>): void;
  22153. /**
  22154. * Gets the texture coordinates data stored in this target
  22155. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22156. */
  22157. getUVs(): Nullable<FloatArray>;
  22158. /**
  22159. * Serializes the current target into a Serialization object
  22160. * @returns the serialized object
  22161. */
  22162. serialize(): any;
  22163. /**
  22164. * Returns the string "MorphTarget"
  22165. * @returns "MorphTarget"
  22166. */
  22167. getClassName(): string;
  22168. /**
  22169. * Creates a new target from serialized data
  22170. * @param serializationObject defines the serialized data to use
  22171. * @returns a new MorphTarget
  22172. */
  22173. static Parse(serializationObject: any): MorphTarget;
  22174. /**
  22175. * Creates a MorphTarget from mesh data
  22176. * @param mesh defines the source mesh
  22177. * @param name defines the name to use for the new target
  22178. * @param influence defines the influence to attach to the target
  22179. * @returns a new MorphTarget
  22180. */
  22181. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22182. }
  22183. }
  22184. declare module BABYLON {
  22185. /**
  22186. * This class is used to deform meshes using morphing between different targets
  22187. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22188. */
  22189. export class MorphTargetManager {
  22190. private _targets;
  22191. private _targetInfluenceChangedObservers;
  22192. private _targetDataLayoutChangedObservers;
  22193. private _activeTargets;
  22194. private _scene;
  22195. private _influences;
  22196. private _supportsNormals;
  22197. private _supportsTangents;
  22198. private _supportsUVs;
  22199. private _vertexCount;
  22200. private _uniqueId;
  22201. private _tempInfluences;
  22202. /**
  22203. * Gets or sets a boolean indicating if normals must be morphed
  22204. */
  22205. enableNormalMorphing: boolean;
  22206. /**
  22207. * Gets or sets a boolean indicating if tangents must be morphed
  22208. */
  22209. enableTangentMorphing: boolean;
  22210. /**
  22211. * Gets or sets a boolean indicating if UV must be morphed
  22212. */
  22213. enableUVMorphing: boolean;
  22214. /**
  22215. * Creates a new MorphTargetManager
  22216. * @param scene defines the current scene
  22217. */
  22218. constructor(scene?: Nullable<Scene>);
  22219. /**
  22220. * Gets the unique ID of this manager
  22221. */
  22222. readonly uniqueId: number;
  22223. /**
  22224. * Gets the number of vertices handled by this manager
  22225. */
  22226. readonly vertexCount: number;
  22227. /**
  22228. * Gets a boolean indicating if this manager supports morphing of normals
  22229. */
  22230. readonly supportsNormals: boolean;
  22231. /**
  22232. * Gets a boolean indicating if this manager supports morphing of tangents
  22233. */
  22234. readonly supportsTangents: boolean;
  22235. /**
  22236. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22237. */
  22238. readonly supportsUVs: boolean;
  22239. /**
  22240. * Gets the number of targets stored in this manager
  22241. */
  22242. readonly numTargets: number;
  22243. /**
  22244. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22245. */
  22246. readonly numInfluencers: number;
  22247. /**
  22248. * Gets the list of influences (one per target)
  22249. */
  22250. readonly influences: Float32Array;
  22251. /**
  22252. * Gets the active target at specified index. An active target is a target with an influence > 0
  22253. * @param index defines the index to check
  22254. * @returns the requested target
  22255. */
  22256. getActiveTarget(index: number): MorphTarget;
  22257. /**
  22258. * Gets the target at specified index
  22259. * @param index defines the index to check
  22260. * @returns the requested target
  22261. */
  22262. getTarget(index: number): MorphTarget;
  22263. /**
  22264. * Add a new target to this manager
  22265. * @param target defines the target to add
  22266. */
  22267. addTarget(target: MorphTarget): void;
  22268. /**
  22269. * Removes a target from the manager
  22270. * @param target defines the target to remove
  22271. */
  22272. removeTarget(target: MorphTarget): void;
  22273. /**
  22274. * Serializes the current manager into a Serialization object
  22275. * @returns the serialized object
  22276. */
  22277. serialize(): any;
  22278. private _syncActiveTargets;
  22279. /**
  22280. * Syncrhonize the targets with all the meshes using this morph target manager
  22281. */
  22282. synchronize(): void;
  22283. /**
  22284. * Creates a new MorphTargetManager from serialized data
  22285. * @param serializationObject defines the serialized data
  22286. * @param scene defines the hosting scene
  22287. * @returns the new MorphTargetManager
  22288. */
  22289. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22290. }
  22291. }
  22292. declare module BABYLON {
  22293. /**
  22294. * Class used to represent a specific level of detail of a mesh
  22295. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22296. */
  22297. export class MeshLODLevel {
  22298. /** Defines the distance where this level should start being displayed */
  22299. distance: number;
  22300. /** Defines the mesh to use to render this level */
  22301. mesh: Nullable<Mesh>;
  22302. /**
  22303. * Creates a new LOD level
  22304. * @param distance defines the distance where this level should star being displayed
  22305. * @param mesh defines the mesh to use to render this level
  22306. */
  22307. constructor(
  22308. /** Defines the distance where this level should start being displayed */
  22309. distance: number,
  22310. /** Defines the mesh to use to render this level */
  22311. mesh: Nullable<Mesh>);
  22312. }
  22313. }
  22314. declare module BABYLON {
  22315. /**
  22316. * Mesh representing the gorund
  22317. */
  22318. export class GroundMesh extends Mesh {
  22319. /** If octree should be generated */
  22320. generateOctree: boolean;
  22321. private _heightQuads;
  22322. /** @hidden */
  22323. _subdivisionsX: number;
  22324. /** @hidden */
  22325. _subdivisionsY: number;
  22326. /** @hidden */
  22327. _width: number;
  22328. /** @hidden */
  22329. _height: number;
  22330. /** @hidden */
  22331. _minX: number;
  22332. /** @hidden */
  22333. _maxX: number;
  22334. /** @hidden */
  22335. _minZ: number;
  22336. /** @hidden */
  22337. _maxZ: number;
  22338. constructor(name: string, scene: Scene);
  22339. /**
  22340. * "GroundMesh"
  22341. * @returns "GroundMesh"
  22342. */
  22343. getClassName(): string;
  22344. /**
  22345. * The minimum of x and y subdivisions
  22346. */
  22347. readonly subdivisions: number;
  22348. /**
  22349. * X subdivisions
  22350. */
  22351. readonly subdivisionsX: number;
  22352. /**
  22353. * Y subdivisions
  22354. */
  22355. readonly subdivisionsY: number;
  22356. /**
  22357. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22358. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22359. * @param chunksCount the number of subdivisions for x and y
  22360. * @param octreeBlocksSize (Default: 32)
  22361. */
  22362. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22363. /**
  22364. * Returns a height (y) value in the Worl system :
  22365. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22366. * @param x x coordinate
  22367. * @param z z coordinate
  22368. * @returns the ground y position if (x, z) are outside the ground surface.
  22369. */
  22370. getHeightAtCoordinates(x: number, z: number): number;
  22371. /**
  22372. * Returns a normalized vector (Vector3) orthogonal to the ground
  22373. * at the ground coordinates (x, z) expressed in the World system.
  22374. * @param x x coordinate
  22375. * @param z z coordinate
  22376. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22377. */
  22378. getNormalAtCoordinates(x: number, z: number): Vector3;
  22379. /**
  22380. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22381. * at the ground coordinates (x, z) expressed in the World system.
  22382. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22383. * @param x x coordinate
  22384. * @param z z coordinate
  22385. * @param ref vector to store the result
  22386. * @returns the GroundMesh.
  22387. */
  22388. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22389. /**
  22390. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22391. * if the ground has been updated.
  22392. * This can be used in the render loop.
  22393. * @returns the GroundMesh.
  22394. */
  22395. updateCoordinateHeights(): GroundMesh;
  22396. private _getFacetAt;
  22397. private _initHeightQuads;
  22398. private _computeHeightQuads;
  22399. /**
  22400. * Serializes this ground mesh
  22401. * @param serializationObject object to write serialization to
  22402. */
  22403. serialize(serializationObject: any): void;
  22404. /**
  22405. * Parses a serialized ground mesh
  22406. * @param parsedMesh the serialized mesh
  22407. * @param scene the scene to create the ground mesh in
  22408. * @returns the created ground mesh
  22409. */
  22410. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22411. }
  22412. }
  22413. declare module BABYLON {
  22414. /**
  22415. * Interface for Physics-Joint data
  22416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22417. */
  22418. export interface PhysicsJointData {
  22419. /**
  22420. * The main pivot of the joint
  22421. */
  22422. mainPivot?: Vector3;
  22423. /**
  22424. * The connected pivot of the joint
  22425. */
  22426. connectedPivot?: Vector3;
  22427. /**
  22428. * The main axis of the joint
  22429. */
  22430. mainAxis?: Vector3;
  22431. /**
  22432. * The connected axis of the joint
  22433. */
  22434. connectedAxis?: Vector3;
  22435. /**
  22436. * The collision of the joint
  22437. */
  22438. collision?: boolean;
  22439. /**
  22440. * Native Oimo/Cannon/Energy data
  22441. */
  22442. nativeParams?: any;
  22443. }
  22444. /**
  22445. * This is a holder class for the physics joint created by the physics plugin
  22446. * It holds a set of functions to control the underlying joint
  22447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22448. */
  22449. export class PhysicsJoint {
  22450. /**
  22451. * The type of the physics joint
  22452. */
  22453. type: number;
  22454. /**
  22455. * The data for the physics joint
  22456. */
  22457. jointData: PhysicsJointData;
  22458. private _physicsJoint;
  22459. protected _physicsPlugin: IPhysicsEnginePlugin;
  22460. /**
  22461. * Initializes the physics joint
  22462. * @param type The type of the physics joint
  22463. * @param jointData The data for the physics joint
  22464. */
  22465. constructor(
  22466. /**
  22467. * The type of the physics joint
  22468. */
  22469. type: number,
  22470. /**
  22471. * The data for the physics joint
  22472. */
  22473. jointData: PhysicsJointData);
  22474. /**
  22475. * Gets the physics joint
  22476. */
  22477. /**
  22478. * Sets the physics joint
  22479. */
  22480. physicsJoint: any;
  22481. /**
  22482. * Sets the physics plugin
  22483. */
  22484. physicsPlugin: IPhysicsEnginePlugin;
  22485. /**
  22486. * Execute a function that is physics-plugin specific.
  22487. * @param {Function} func the function that will be executed.
  22488. * It accepts two parameters: the physics world and the physics joint
  22489. */
  22490. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22491. /**
  22492. * Distance-Joint type
  22493. */
  22494. static DistanceJoint: number;
  22495. /**
  22496. * Hinge-Joint type
  22497. */
  22498. static HingeJoint: number;
  22499. /**
  22500. * Ball-and-Socket joint type
  22501. */
  22502. static BallAndSocketJoint: number;
  22503. /**
  22504. * Wheel-Joint type
  22505. */
  22506. static WheelJoint: number;
  22507. /**
  22508. * Slider-Joint type
  22509. */
  22510. static SliderJoint: number;
  22511. /**
  22512. * Prismatic-Joint type
  22513. */
  22514. static PrismaticJoint: number;
  22515. /**
  22516. * Universal-Joint type
  22517. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22518. */
  22519. static UniversalJoint: number;
  22520. /**
  22521. * Hinge-Joint 2 type
  22522. */
  22523. static Hinge2Joint: number;
  22524. /**
  22525. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22526. */
  22527. static PointToPointJoint: number;
  22528. /**
  22529. * Spring-Joint type
  22530. */
  22531. static SpringJoint: number;
  22532. /**
  22533. * Lock-Joint type
  22534. */
  22535. static LockJoint: number;
  22536. }
  22537. /**
  22538. * A class representing a physics distance joint
  22539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22540. */
  22541. export class DistanceJoint extends PhysicsJoint {
  22542. /**
  22543. *
  22544. * @param jointData The data for the Distance-Joint
  22545. */
  22546. constructor(jointData: DistanceJointData);
  22547. /**
  22548. * Update the predefined distance.
  22549. * @param maxDistance The maximum preferred distance
  22550. * @param minDistance The minimum preferred distance
  22551. */
  22552. updateDistance(maxDistance: number, minDistance?: number): void;
  22553. }
  22554. /**
  22555. * Represents a Motor-Enabled Joint
  22556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22557. */
  22558. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22559. /**
  22560. * Initializes the Motor-Enabled Joint
  22561. * @param type The type of the joint
  22562. * @param jointData The physica joint data for the joint
  22563. */
  22564. constructor(type: number, jointData: PhysicsJointData);
  22565. /**
  22566. * Set the motor values.
  22567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22568. * @param force the force to apply
  22569. * @param maxForce max force for this motor.
  22570. */
  22571. setMotor(force?: number, maxForce?: number): void;
  22572. /**
  22573. * Set the motor's limits.
  22574. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22575. * @param upperLimit The upper limit of the motor
  22576. * @param lowerLimit The lower limit of the motor
  22577. */
  22578. setLimit(upperLimit: number, lowerLimit?: number): void;
  22579. }
  22580. /**
  22581. * This class represents a single physics Hinge-Joint
  22582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22583. */
  22584. export class HingeJoint extends MotorEnabledJoint {
  22585. /**
  22586. * Initializes the Hinge-Joint
  22587. * @param jointData The joint data for the Hinge-Joint
  22588. */
  22589. constructor(jointData: PhysicsJointData);
  22590. /**
  22591. * Set the motor values.
  22592. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22593. * @param {number} force the force to apply
  22594. * @param {number} maxForce max force for this motor.
  22595. */
  22596. setMotor(force?: number, maxForce?: number): void;
  22597. /**
  22598. * Set the motor's limits.
  22599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22600. * @param upperLimit The upper limit of the motor
  22601. * @param lowerLimit The lower limit of the motor
  22602. */
  22603. setLimit(upperLimit: number, lowerLimit?: number): void;
  22604. }
  22605. /**
  22606. * This class represents a dual hinge physics joint (same as wheel joint)
  22607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22608. */
  22609. export class Hinge2Joint extends MotorEnabledJoint {
  22610. /**
  22611. * Initializes the Hinge2-Joint
  22612. * @param jointData The joint data for the Hinge2-Joint
  22613. */
  22614. constructor(jointData: PhysicsJointData);
  22615. /**
  22616. * Set the motor values.
  22617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22618. * @param {number} targetSpeed the speed the motor is to reach
  22619. * @param {number} maxForce max force for this motor.
  22620. * @param {motorIndex} the motor's index, 0 or 1.
  22621. */
  22622. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22623. /**
  22624. * Set the motor limits.
  22625. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22626. * @param {number} upperLimit the upper limit
  22627. * @param {number} lowerLimit lower limit
  22628. * @param {motorIndex} the motor's index, 0 or 1.
  22629. */
  22630. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22631. }
  22632. /**
  22633. * Interface for a motor enabled joint
  22634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22635. */
  22636. export interface IMotorEnabledJoint {
  22637. /**
  22638. * Physics joint
  22639. */
  22640. physicsJoint: any;
  22641. /**
  22642. * Sets the motor of the motor-enabled joint
  22643. * @param force The force of the motor
  22644. * @param maxForce The maximum force of the motor
  22645. * @param motorIndex The index of the motor
  22646. */
  22647. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22648. /**
  22649. * Sets the limit of the motor
  22650. * @param upperLimit The upper limit of the motor
  22651. * @param lowerLimit The lower limit of the motor
  22652. * @param motorIndex The index of the motor
  22653. */
  22654. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22655. }
  22656. /**
  22657. * Joint data for a Distance-Joint
  22658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22659. */
  22660. export interface DistanceJointData extends PhysicsJointData {
  22661. /**
  22662. * Max distance the 2 joint objects can be apart
  22663. */
  22664. maxDistance: number;
  22665. }
  22666. /**
  22667. * Joint data from a spring joint
  22668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22669. */
  22670. export interface SpringJointData extends PhysicsJointData {
  22671. /**
  22672. * Length of the spring
  22673. */
  22674. length: number;
  22675. /**
  22676. * Stiffness of the spring
  22677. */
  22678. stiffness: number;
  22679. /**
  22680. * Damping of the spring
  22681. */
  22682. damping: number;
  22683. /** this callback will be called when applying the force to the impostors. */
  22684. forceApplicationCallback: () => void;
  22685. }
  22686. }
  22687. declare module BABYLON {
  22688. /**
  22689. * Holds the data for the raycast result
  22690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22691. */
  22692. export class PhysicsRaycastResult {
  22693. private _hasHit;
  22694. private _hitDistance;
  22695. private _hitNormalWorld;
  22696. private _hitPointWorld;
  22697. private _rayFromWorld;
  22698. private _rayToWorld;
  22699. /**
  22700. * Gets if there was a hit
  22701. */
  22702. readonly hasHit: boolean;
  22703. /**
  22704. * Gets the distance from the hit
  22705. */
  22706. readonly hitDistance: number;
  22707. /**
  22708. * Gets the hit normal/direction in the world
  22709. */
  22710. readonly hitNormalWorld: Vector3;
  22711. /**
  22712. * Gets the hit point in the world
  22713. */
  22714. readonly hitPointWorld: Vector3;
  22715. /**
  22716. * Gets the ray "start point" of the ray in the world
  22717. */
  22718. readonly rayFromWorld: Vector3;
  22719. /**
  22720. * Gets the ray "end point" of the ray in the world
  22721. */
  22722. readonly rayToWorld: Vector3;
  22723. /**
  22724. * Sets the hit data (normal & point in world space)
  22725. * @param hitNormalWorld defines the normal in world space
  22726. * @param hitPointWorld defines the point in world space
  22727. */
  22728. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22729. /**
  22730. * Sets the distance from the start point to the hit point
  22731. * @param distance
  22732. */
  22733. setHitDistance(distance: number): void;
  22734. /**
  22735. * Calculates the distance manually
  22736. */
  22737. calculateHitDistance(): void;
  22738. /**
  22739. * Resets all the values to default
  22740. * @param from The from point on world space
  22741. * @param to The to point on world space
  22742. */
  22743. reset(from?: Vector3, to?: Vector3): void;
  22744. }
  22745. /**
  22746. * Interface for the size containing width and height
  22747. */
  22748. interface IXYZ {
  22749. /**
  22750. * X
  22751. */
  22752. x: number;
  22753. /**
  22754. * Y
  22755. */
  22756. y: number;
  22757. /**
  22758. * Z
  22759. */
  22760. z: number;
  22761. }
  22762. }
  22763. declare module BABYLON {
  22764. /**
  22765. * Interface used to describe a physics joint
  22766. */
  22767. export interface PhysicsImpostorJoint {
  22768. /** Defines the main impostor to which the joint is linked */
  22769. mainImpostor: PhysicsImpostor;
  22770. /** Defines the impostor that is connected to the main impostor using this joint */
  22771. connectedImpostor: PhysicsImpostor;
  22772. /** Defines the joint itself */
  22773. joint: PhysicsJoint;
  22774. }
  22775. /** @hidden */
  22776. export interface IPhysicsEnginePlugin {
  22777. world: any;
  22778. name: string;
  22779. setGravity(gravity: Vector3): void;
  22780. setTimeStep(timeStep: number): void;
  22781. getTimeStep(): number;
  22782. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22783. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22784. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22785. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22786. removePhysicsBody(impostor: PhysicsImpostor): void;
  22787. generateJoint(joint: PhysicsImpostorJoint): void;
  22788. removeJoint(joint: PhysicsImpostorJoint): void;
  22789. isSupported(): boolean;
  22790. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22791. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22792. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22796. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22797. getBodyMass(impostor: PhysicsImpostor): number;
  22798. getBodyFriction(impostor: PhysicsImpostor): number;
  22799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22800. getBodyRestitution(impostor: PhysicsImpostor): number;
  22801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22802. getBodyPressure?(impostor: PhysicsImpostor): number;
  22803. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22804. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22805. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22806. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22807. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22808. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22809. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22810. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22811. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22812. sleepBody(impostor: PhysicsImpostor): void;
  22813. wakeUpBody(impostor: PhysicsImpostor): void;
  22814. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22815. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22816. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22817. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22818. getRadius(impostor: PhysicsImpostor): number;
  22819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22820. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22821. dispose(): void;
  22822. }
  22823. /**
  22824. * Interface used to define a physics engine
  22825. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22826. */
  22827. export interface IPhysicsEngine {
  22828. /**
  22829. * Gets the gravity vector used by the simulation
  22830. */
  22831. gravity: Vector3;
  22832. /**
  22833. * Sets the gravity vector used by the simulation
  22834. * @param gravity defines the gravity vector to use
  22835. */
  22836. setGravity(gravity: Vector3): void;
  22837. /**
  22838. * Set the time step of the physics engine.
  22839. * Default is 1/60.
  22840. * To slow it down, enter 1/600 for example.
  22841. * To speed it up, 1/30
  22842. * @param newTimeStep the new timestep to apply to this world.
  22843. */
  22844. setTimeStep(newTimeStep: number): void;
  22845. /**
  22846. * Get the time step of the physics engine.
  22847. * @returns the current time step
  22848. */
  22849. getTimeStep(): number;
  22850. /**
  22851. * Release all resources
  22852. */
  22853. dispose(): void;
  22854. /**
  22855. * Gets the name of the current physics plugin
  22856. * @returns the name of the plugin
  22857. */
  22858. getPhysicsPluginName(): string;
  22859. /**
  22860. * Adding a new impostor for the impostor tracking.
  22861. * This will be done by the impostor itself.
  22862. * @param impostor the impostor to add
  22863. */
  22864. addImpostor(impostor: PhysicsImpostor): void;
  22865. /**
  22866. * Remove an impostor from the engine.
  22867. * This impostor and its mesh will not longer be updated by the physics engine.
  22868. * @param impostor the impostor to remove
  22869. */
  22870. removeImpostor(impostor: PhysicsImpostor): void;
  22871. /**
  22872. * Add a joint to the physics engine
  22873. * @param mainImpostor defines the main impostor to which the joint is added.
  22874. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22875. * @param joint defines the joint that will connect both impostors.
  22876. */
  22877. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22878. /**
  22879. * Removes a joint from the simulation
  22880. * @param mainImpostor defines the impostor used with the joint
  22881. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22882. * @param joint defines the joint to remove
  22883. */
  22884. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22885. /**
  22886. * Gets the current plugin used to run the simulation
  22887. * @returns current plugin
  22888. */
  22889. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22890. /**
  22891. * Gets the list of physic impostors
  22892. * @returns an array of PhysicsImpostor
  22893. */
  22894. getImpostors(): Array<PhysicsImpostor>;
  22895. /**
  22896. * Gets the impostor for a physics enabled object
  22897. * @param object defines the object impersonated by the impostor
  22898. * @returns the PhysicsImpostor or null if not found
  22899. */
  22900. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22901. /**
  22902. * Gets the impostor for a physics body object
  22903. * @param body defines physics body used by the impostor
  22904. * @returns the PhysicsImpostor or null if not found
  22905. */
  22906. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22907. /**
  22908. * Does a raycast in the physics world
  22909. * @param from when should the ray start?
  22910. * @param to when should the ray end?
  22911. * @returns PhysicsRaycastResult
  22912. */
  22913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22914. /**
  22915. * Called by the scene. No need to call it.
  22916. * @param delta defines the timespam between frames
  22917. */
  22918. _step(delta: number): void;
  22919. }
  22920. }
  22921. declare module BABYLON {
  22922. /**
  22923. * The interface for the physics imposter parameters
  22924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22925. */
  22926. export interface PhysicsImpostorParameters {
  22927. /**
  22928. * The mass of the physics imposter
  22929. */
  22930. mass: number;
  22931. /**
  22932. * The friction of the physics imposter
  22933. */
  22934. friction?: number;
  22935. /**
  22936. * The coefficient of restitution of the physics imposter
  22937. */
  22938. restitution?: number;
  22939. /**
  22940. * The native options of the physics imposter
  22941. */
  22942. nativeOptions?: any;
  22943. /**
  22944. * Specifies if the parent should be ignored
  22945. */
  22946. ignoreParent?: boolean;
  22947. /**
  22948. * Specifies if bi-directional transformations should be disabled
  22949. */
  22950. disableBidirectionalTransformation?: boolean;
  22951. /**
  22952. * The pressure inside the physics imposter, soft object only
  22953. */
  22954. pressure?: number;
  22955. /**
  22956. * The stiffness the physics imposter, soft object only
  22957. */
  22958. stiffness?: number;
  22959. /**
  22960. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22961. */
  22962. velocityIterations?: number;
  22963. /**
  22964. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22965. */
  22966. positionIterations?: number;
  22967. /**
  22968. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22969. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22970. * Add to fix multiple points
  22971. */
  22972. fixedPoints?: number;
  22973. /**
  22974. * The collision margin around a soft object
  22975. */
  22976. margin?: number;
  22977. /**
  22978. * The collision margin around a soft object
  22979. */
  22980. damping?: number;
  22981. /**
  22982. * The path for a rope based on an extrusion
  22983. */
  22984. path?: any;
  22985. /**
  22986. * The shape of an extrusion used for a rope based on an extrusion
  22987. */
  22988. shape?: any;
  22989. }
  22990. /**
  22991. * Interface for a physics-enabled object
  22992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22993. */
  22994. export interface IPhysicsEnabledObject {
  22995. /**
  22996. * The position of the physics-enabled object
  22997. */
  22998. position: Vector3;
  22999. /**
  23000. * The rotation of the physics-enabled object
  23001. */
  23002. rotationQuaternion: Nullable<Quaternion>;
  23003. /**
  23004. * The scale of the physics-enabled object
  23005. */
  23006. scaling: Vector3;
  23007. /**
  23008. * The rotation of the physics-enabled object
  23009. */
  23010. rotation?: Vector3;
  23011. /**
  23012. * The parent of the physics-enabled object
  23013. */
  23014. parent?: any;
  23015. /**
  23016. * The bounding info of the physics-enabled object
  23017. * @returns The bounding info of the physics-enabled object
  23018. */
  23019. getBoundingInfo(): BoundingInfo;
  23020. /**
  23021. * Computes the world matrix
  23022. * @param force Specifies if the world matrix should be computed by force
  23023. * @returns A world matrix
  23024. */
  23025. computeWorldMatrix(force: boolean): Matrix;
  23026. /**
  23027. * Gets the world matrix
  23028. * @returns A world matrix
  23029. */
  23030. getWorldMatrix?(): Matrix;
  23031. /**
  23032. * Gets the child meshes
  23033. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23034. * @returns An array of abstract meshes
  23035. */
  23036. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23037. /**
  23038. * Gets the vertex data
  23039. * @param kind The type of vertex data
  23040. * @returns A nullable array of numbers, or a float32 array
  23041. */
  23042. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23043. /**
  23044. * Gets the indices from the mesh
  23045. * @returns A nullable array of index arrays
  23046. */
  23047. getIndices?(): Nullable<IndicesArray>;
  23048. /**
  23049. * Gets the scene from the mesh
  23050. * @returns the indices array or null
  23051. */
  23052. getScene?(): Scene;
  23053. /**
  23054. * Gets the absolute position from the mesh
  23055. * @returns the absolute position
  23056. */
  23057. getAbsolutePosition(): Vector3;
  23058. /**
  23059. * Gets the absolute pivot point from the mesh
  23060. * @returns the absolute pivot point
  23061. */
  23062. getAbsolutePivotPoint(): Vector3;
  23063. /**
  23064. * Rotates the mesh
  23065. * @param axis The axis of rotation
  23066. * @param amount The amount of rotation
  23067. * @param space The space of the rotation
  23068. * @returns The rotation transform node
  23069. */
  23070. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23071. /**
  23072. * Translates the mesh
  23073. * @param axis The axis of translation
  23074. * @param distance The distance of translation
  23075. * @param space The space of the translation
  23076. * @returns The transform node
  23077. */
  23078. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23079. /**
  23080. * Sets the absolute position of the mesh
  23081. * @param absolutePosition The absolute position of the mesh
  23082. * @returns The transform node
  23083. */
  23084. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23085. /**
  23086. * Gets the class name of the mesh
  23087. * @returns The class name
  23088. */
  23089. getClassName(): string;
  23090. }
  23091. /**
  23092. * Represents a physics imposter
  23093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23094. */
  23095. export class PhysicsImpostor {
  23096. /**
  23097. * The physics-enabled object used as the physics imposter
  23098. */
  23099. object: IPhysicsEnabledObject;
  23100. /**
  23101. * The type of the physics imposter
  23102. */
  23103. type: number;
  23104. private _options;
  23105. private _scene?;
  23106. /**
  23107. * The default object size of the imposter
  23108. */
  23109. static DEFAULT_OBJECT_SIZE: Vector3;
  23110. /**
  23111. * The identity quaternion of the imposter
  23112. */
  23113. static IDENTITY_QUATERNION: Quaternion;
  23114. /** @hidden */
  23115. _pluginData: any;
  23116. private _physicsEngine;
  23117. private _physicsBody;
  23118. private _bodyUpdateRequired;
  23119. private _onBeforePhysicsStepCallbacks;
  23120. private _onAfterPhysicsStepCallbacks;
  23121. /** @hidden */
  23122. _onPhysicsCollideCallbacks: Array<{
  23123. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23124. otherImpostors: Array<PhysicsImpostor>;
  23125. }>;
  23126. private _deltaPosition;
  23127. private _deltaRotation;
  23128. private _deltaRotationConjugated;
  23129. /** @hidden */
  23130. _isFromLine: boolean;
  23131. private _parent;
  23132. private _isDisposed;
  23133. private static _tmpVecs;
  23134. private static _tmpQuat;
  23135. /**
  23136. * Specifies if the physics imposter is disposed
  23137. */
  23138. readonly isDisposed: boolean;
  23139. /**
  23140. * Gets the mass of the physics imposter
  23141. */
  23142. mass: number;
  23143. /**
  23144. * Gets the coefficient of friction
  23145. */
  23146. /**
  23147. * Sets the coefficient of friction
  23148. */
  23149. friction: number;
  23150. /**
  23151. * Gets the coefficient of restitution
  23152. */
  23153. /**
  23154. * Sets the coefficient of restitution
  23155. */
  23156. restitution: number;
  23157. /**
  23158. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23159. */
  23160. /**
  23161. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23162. */
  23163. pressure: number;
  23164. /**
  23165. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23166. */
  23167. /**
  23168. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23169. */
  23170. stiffness: number;
  23171. /**
  23172. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23173. */
  23174. /**
  23175. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23176. */
  23177. velocityIterations: number;
  23178. /**
  23179. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23180. */
  23181. /**
  23182. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23183. */
  23184. positionIterations: number;
  23185. /**
  23186. * The unique id of the physics imposter
  23187. * set by the physics engine when adding this impostor to the array
  23188. */
  23189. uniqueId: number;
  23190. /**
  23191. * @hidden
  23192. */
  23193. soft: boolean;
  23194. /**
  23195. * @hidden
  23196. */
  23197. segments: number;
  23198. private _joints;
  23199. /**
  23200. * Initializes the physics imposter
  23201. * @param object The physics-enabled object used as the physics imposter
  23202. * @param type The type of the physics imposter
  23203. * @param _options The options for the physics imposter
  23204. * @param _scene The Babylon scene
  23205. */
  23206. constructor(
  23207. /**
  23208. * The physics-enabled object used as the physics imposter
  23209. */
  23210. object: IPhysicsEnabledObject,
  23211. /**
  23212. * The type of the physics imposter
  23213. */
  23214. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23215. /**
  23216. * This function will completly initialize this impostor.
  23217. * It will create a new body - but only if this mesh has no parent.
  23218. * If it has, this impostor will not be used other than to define the impostor
  23219. * of the child mesh.
  23220. * @hidden
  23221. */
  23222. _init(): void;
  23223. private _getPhysicsParent;
  23224. /**
  23225. * Should a new body be generated.
  23226. * @returns boolean specifying if body initialization is required
  23227. */
  23228. isBodyInitRequired(): boolean;
  23229. /**
  23230. * Sets the updated scaling
  23231. * @param updated Specifies if the scaling is updated
  23232. */
  23233. setScalingUpdated(): void;
  23234. /**
  23235. * Force a regeneration of this or the parent's impostor's body.
  23236. * Use under cautious - This will remove all joints already implemented.
  23237. */
  23238. forceUpdate(): void;
  23239. /**
  23240. * Gets the body that holds this impostor. Either its own, or its parent.
  23241. */
  23242. /**
  23243. * Set the physics body. Used mainly by the physics engine/plugin
  23244. */
  23245. physicsBody: any;
  23246. /**
  23247. * Get the parent of the physics imposter
  23248. * @returns Physics imposter or null
  23249. */
  23250. /**
  23251. * Sets the parent of the physics imposter
  23252. */
  23253. parent: Nullable<PhysicsImpostor>;
  23254. /**
  23255. * Resets the update flags
  23256. */
  23257. resetUpdateFlags(): void;
  23258. /**
  23259. * Gets the object extend size
  23260. * @returns the object extend size
  23261. */
  23262. getObjectExtendSize(): Vector3;
  23263. /**
  23264. * Gets the object center
  23265. * @returns The object center
  23266. */
  23267. getObjectCenter(): Vector3;
  23268. /**
  23269. * Get a specific parametes from the options parameter
  23270. * @param paramName The object parameter name
  23271. * @returns The object parameter
  23272. */
  23273. getParam(paramName: string): any;
  23274. /**
  23275. * Sets a specific parameter in the options given to the physics plugin
  23276. * @param paramName The parameter name
  23277. * @param value The value of the parameter
  23278. */
  23279. setParam(paramName: string, value: number): void;
  23280. /**
  23281. * Specifically change the body's mass option. Won't recreate the physics body object
  23282. * @param mass The mass of the physics imposter
  23283. */
  23284. setMass(mass: number): void;
  23285. /**
  23286. * Gets the linear velocity
  23287. * @returns linear velocity or null
  23288. */
  23289. getLinearVelocity(): Nullable<Vector3>;
  23290. /**
  23291. * Sets the linear velocity
  23292. * @param velocity linear velocity or null
  23293. */
  23294. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23295. /**
  23296. * Gets the angular velocity
  23297. * @returns angular velocity or null
  23298. */
  23299. getAngularVelocity(): Nullable<Vector3>;
  23300. /**
  23301. * Sets the angular velocity
  23302. * @param velocity The velocity or null
  23303. */
  23304. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23305. /**
  23306. * Execute a function with the physics plugin native code
  23307. * Provide a function the will have two variables - the world object and the physics body object
  23308. * @param func The function to execute with the physics plugin native code
  23309. */
  23310. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23311. /**
  23312. * Register a function that will be executed before the physics world is stepping forward
  23313. * @param func The function to execute before the physics world is stepped forward
  23314. */
  23315. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23316. /**
  23317. * Unregister a function that will be executed before the physics world is stepping forward
  23318. * @param func The function to execute before the physics world is stepped forward
  23319. */
  23320. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23321. /**
  23322. * Register a function that will be executed after the physics step
  23323. * @param func The function to execute after physics step
  23324. */
  23325. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23326. /**
  23327. * Unregisters a function that will be executed after the physics step
  23328. * @param func The function to execute after physics step
  23329. */
  23330. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23331. /**
  23332. * register a function that will be executed when this impostor collides against a different body
  23333. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23334. * @param func Callback that is executed on collision
  23335. */
  23336. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23337. /**
  23338. * Unregisters the physics imposter on contact
  23339. * @param collideAgainst The physics object to collide against
  23340. * @param func Callback to execute on collision
  23341. */
  23342. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23343. private _tmpQuat;
  23344. private _tmpQuat2;
  23345. /**
  23346. * Get the parent rotation
  23347. * @returns The parent rotation
  23348. */
  23349. getParentsRotation(): Quaternion;
  23350. /**
  23351. * this function is executed by the physics engine.
  23352. */
  23353. beforeStep: () => void;
  23354. /**
  23355. * this function is executed by the physics engine
  23356. */
  23357. afterStep: () => void;
  23358. /**
  23359. * Legacy collision detection event support
  23360. */
  23361. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23362. /**
  23363. * event and body object due to cannon's event-based architecture.
  23364. */
  23365. onCollide: (e: {
  23366. body: any;
  23367. }) => void;
  23368. /**
  23369. * Apply a force
  23370. * @param force The force to apply
  23371. * @param contactPoint The contact point for the force
  23372. * @returns The physics imposter
  23373. */
  23374. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23375. /**
  23376. * Apply an impulse
  23377. * @param force The impulse force
  23378. * @param contactPoint The contact point for the impulse force
  23379. * @returns The physics imposter
  23380. */
  23381. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23382. /**
  23383. * A help function to create a joint
  23384. * @param otherImpostor A physics imposter used to create a joint
  23385. * @param jointType The type of joint
  23386. * @param jointData The data for the joint
  23387. * @returns The physics imposter
  23388. */
  23389. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23390. /**
  23391. * Add a joint to this impostor with a different impostor
  23392. * @param otherImpostor A physics imposter used to add a joint
  23393. * @param joint The joint to add
  23394. * @returns The physics imposter
  23395. */
  23396. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23397. /**
  23398. * Add an anchor to a cloth impostor
  23399. * @param otherImpostor rigid impostor to anchor to
  23400. * @param width ratio across width from 0 to 1
  23401. * @param height ratio up height from 0 to 1
  23402. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23403. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23404. * @returns impostor the soft imposter
  23405. */
  23406. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23407. /**
  23408. * Add a hook to a rope impostor
  23409. * @param otherImpostor rigid impostor to anchor to
  23410. * @param length ratio across rope from 0 to 1
  23411. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23413. * @returns impostor the rope imposter
  23414. */
  23415. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23416. /**
  23417. * Will keep this body still, in a sleep mode.
  23418. * @returns the physics imposter
  23419. */
  23420. sleep(): PhysicsImpostor;
  23421. /**
  23422. * Wake the body up.
  23423. * @returns The physics imposter
  23424. */
  23425. wakeUp(): PhysicsImpostor;
  23426. /**
  23427. * Clones the physics imposter
  23428. * @param newObject The physics imposter clones to this physics-enabled object
  23429. * @returns A nullable physics imposter
  23430. */
  23431. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23432. /**
  23433. * Disposes the physics imposter
  23434. */
  23435. dispose(): void;
  23436. /**
  23437. * Sets the delta position
  23438. * @param position The delta position amount
  23439. */
  23440. setDeltaPosition(position: Vector3): void;
  23441. /**
  23442. * Sets the delta rotation
  23443. * @param rotation The delta rotation amount
  23444. */
  23445. setDeltaRotation(rotation: Quaternion): void;
  23446. /**
  23447. * Gets the box size of the physics imposter and stores the result in the input parameter
  23448. * @param result Stores the box size
  23449. * @returns The physics imposter
  23450. */
  23451. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23452. /**
  23453. * Gets the radius of the physics imposter
  23454. * @returns Radius of the physics imposter
  23455. */
  23456. getRadius(): number;
  23457. /**
  23458. * Sync a bone with this impostor
  23459. * @param bone The bone to sync to the impostor.
  23460. * @param boneMesh The mesh that the bone is influencing.
  23461. * @param jointPivot The pivot of the joint / bone in local space.
  23462. * @param distToJoint Optional distance from the impostor to the joint.
  23463. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23464. */
  23465. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23466. /**
  23467. * Sync impostor to a bone
  23468. * @param bone The bone that the impostor will be synced to.
  23469. * @param boneMesh The mesh that the bone is influencing.
  23470. * @param jointPivot The pivot of the joint / bone in local space.
  23471. * @param distToJoint Optional distance from the impostor to the joint.
  23472. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23473. * @param boneAxis Optional vector3 axis the bone is aligned with
  23474. */
  23475. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23476. /**
  23477. * No-Imposter type
  23478. */
  23479. static NoImpostor: number;
  23480. /**
  23481. * Sphere-Imposter type
  23482. */
  23483. static SphereImpostor: number;
  23484. /**
  23485. * Box-Imposter type
  23486. */
  23487. static BoxImpostor: number;
  23488. /**
  23489. * Plane-Imposter type
  23490. */
  23491. static PlaneImpostor: number;
  23492. /**
  23493. * Mesh-imposter type
  23494. */
  23495. static MeshImpostor: number;
  23496. /**
  23497. * Capsule-Impostor type (Ammo.js plugin only)
  23498. */
  23499. static CapsuleImpostor: number;
  23500. /**
  23501. * Cylinder-Imposter type
  23502. */
  23503. static CylinderImpostor: number;
  23504. /**
  23505. * Particle-Imposter type
  23506. */
  23507. static ParticleImpostor: number;
  23508. /**
  23509. * Heightmap-Imposter type
  23510. */
  23511. static HeightmapImpostor: number;
  23512. /**
  23513. * ConvexHull-Impostor type (Ammo.js plugin only)
  23514. */
  23515. static ConvexHullImpostor: number;
  23516. /**
  23517. * Rope-Imposter type
  23518. */
  23519. static RopeImpostor: number;
  23520. /**
  23521. * Cloth-Imposter type
  23522. */
  23523. static ClothImpostor: number;
  23524. /**
  23525. * Softbody-Imposter type
  23526. */
  23527. static SoftbodyImpostor: number;
  23528. }
  23529. }
  23530. declare module BABYLON {
  23531. /**
  23532. * @hidden
  23533. **/
  23534. export class _CreationDataStorage {
  23535. closePath?: boolean;
  23536. closeArray?: boolean;
  23537. idx: number[];
  23538. dashSize: number;
  23539. gapSize: number;
  23540. path3D: Path3D;
  23541. pathArray: Vector3[][];
  23542. arc: number;
  23543. radius: number;
  23544. cap: number;
  23545. tessellation: number;
  23546. }
  23547. /**
  23548. * @hidden
  23549. **/
  23550. class _InstanceDataStorage {
  23551. visibleInstances: any;
  23552. batchCache: _InstancesBatch;
  23553. instancesBufferSize: number;
  23554. instancesBuffer: Nullable<Buffer>;
  23555. instancesData: Float32Array;
  23556. overridenInstanceCount: number;
  23557. isFrozen: boolean;
  23558. previousBatch: Nullable<_InstancesBatch>;
  23559. hardwareInstancedRendering: boolean;
  23560. sideOrientation: number;
  23561. }
  23562. /**
  23563. * @hidden
  23564. **/
  23565. export class _InstancesBatch {
  23566. mustReturn: boolean;
  23567. visibleInstances: Nullable<InstancedMesh[]>[];
  23568. renderSelf: boolean[];
  23569. hardwareInstancedRendering: boolean[];
  23570. }
  23571. /**
  23572. * Class used to represent renderable models
  23573. */
  23574. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23575. /**
  23576. * Mesh side orientation : usually the external or front surface
  23577. */
  23578. static readonly FRONTSIDE: number;
  23579. /**
  23580. * Mesh side orientation : usually the internal or back surface
  23581. */
  23582. static readonly BACKSIDE: number;
  23583. /**
  23584. * Mesh side orientation : both internal and external or front and back surfaces
  23585. */
  23586. static readonly DOUBLESIDE: number;
  23587. /**
  23588. * Mesh side orientation : by default, `FRONTSIDE`
  23589. */
  23590. static readonly DEFAULTSIDE: number;
  23591. /**
  23592. * Mesh cap setting : no cap
  23593. */
  23594. static readonly NO_CAP: number;
  23595. /**
  23596. * Mesh cap setting : one cap at the beginning of the mesh
  23597. */
  23598. static readonly CAP_START: number;
  23599. /**
  23600. * Mesh cap setting : one cap at the end of the mesh
  23601. */
  23602. static readonly CAP_END: number;
  23603. /**
  23604. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23605. */
  23606. static readonly CAP_ALL: number;
  23607. /**
  23608. * Mesh pattern setting : no flip or rotate
  23609. */
  23610. static readonly NO_FLIP: number;
  23611. /**
  23612. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23613. */
  23614. static readonly FLIP_TILE: number;
  23615. /**
  23616. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23617. */
  23618. static readonly ROTATE_TILE: number;
  23619. /**
  23620. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23621. */
  23622. static readonly FLIP_ROW: number;
  23623. /**
  23624. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23625. */
  23626. static readonly ROTATE_ROW: number;
  23627. /**
  23628. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23629. */
  23630. static readonly FLIP_N_ROTATE_TILE: number;
  23631. /**
  23632. * Mesh pattern setting : rotate pattern and rotate
  23633. */
  23634. static readonly FLIP_N_ROTATE_ROW: number;
  23635. /**
  23636. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23637. */
  23638. static readonly CENTER: number;
  23639. /**
  23640. * Mesh tile positioning : part tiles on left
  23641. */
  23642. static readonly LEFT: number;
  23643. /**
  23644. * Mesh tile positioning : part tiles on right
  23645. */
  23646. static readonly RIGHT: number;
  23647. /**
  23648. * Mesh tile positioning : part tiles on top
  23649. */
  23650. static readonly TOP: number;
  23651. /**
  23652. * Mesh tile positioning : part tiles on bottom
  23653. */
  23654. static readonly BOTTOM: number;
  23655. /**
  23656. * Gets the default side orientation.
  23657. * @param orientation the orientation to value to attempt to get
  23658. * @returns the default orientation
  23659. * @hidden
  23660. */
  23661. static _GetDefaultSideOrientation(orientation?: number): number;
  23662. private _internalMeshDataInfo;
  23663. /**
  23664. * An event triggered before rendering the mesh
  23665. */
  23666. readonly onBeforeRenderObservable: Observable<Mesh>;
  23667. /**
  23668. * An event triggered before binding the mesh
  23669. */
  23670. readonly onBeforeBindObservable: Observable<Mesh>;
  23671. /**
  23672. * An event triggered after rendering the mesh
  23673. */
  23674. readonly onAfterRenderObservable: Observable<Mesh>;
  23675. /**
  23676. * An event triggered before drawing the mesh
  23677. */
  23678. readonly onBeforeDrawObservable: Observable<Mesh>;
  23679. private _onBeforeDrawObserver;
  23680. /**
  23681. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23682. */
  23683. onBeforeDraw: () => void;
  23684. readonly hasInstances: boolean;
  23685. /**
  23686. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23687. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23688. */
  23689. delayLoadState: number;
  23690. /**
  23691. * Gets the list of instances created from this mesh
  23692. * it is not supposed to be modified manually.
  23693. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23694. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23695. */
  23696. instances: InstancedMesh[];
  23697. /**
  23698. * Gets the file containing delay loading data for this mesh
  23699. */
  23700. delayLoadingFile: string;
  23701. /** @hidden */
  23702. _binaryInfo: any;
  23703. /**
  23704. * User defined function used to change how LOD level selection is done
  23705. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23706. */
  23707. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23708. /**
  23709. * Gets or sets the morph target manager
  23710. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23711. */
  23712. morphTargetManager: Nullable<MorphTargetManager>;
  23713. /** @hidden */
  23714. _creationDataStorage: Nullable<_CreationDataStorage>;
  23715. /** @hidden */
  23716. _geometry: Nullable<Geometry>;
  23717. /** @hidden */
  23718. _delayInfo: Array<string>;
  23719. /** @hidden */
  23720. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23721. /** @hidden */
  23722. _instanceDataStorage: _InstanceDataStorage;
  23723. private _effectiveMaterial;
  23724. /** @hidden */
  23725. _shouldGenerateFlatShading: boolean;
  23726. /** @hidden */
  23727. _originalBuilderSideOrientation: number;
  23728. /**
  23729. * Use this property to change the original side orientation defined at construction time
  23730. */
  23731. overrideMaterialSideOrientation: Nullable<number>;
  23732. /**
  23733. * Gets the source mesh (the one used to clone this one from)
  23734. */
  23735. readonly source: Nullable<Mesh>;
  23736. /**
  23737. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23738. */
  23739. isUnIndexed: boolean;
  23740. /**
  23741. * @constructor
  23742. * @param name The value used by scene.getMeshByName() to do a lookup.
  23743. * @param scene The scene to add this mesh to.
  23744. * @param parent The parent of this mesh, if it has one
  23745. * @param source An optional Mesh from which geometry is shared, cloned.
  23746. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23747. * When false, achieved by calling a clone(), also passing False.
  23748. * This will make creation of children, recursive.
  23749. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23750. */
  23751. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23752. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23753. /**
  23754. * Gets the class name
  23755. * @returns the string "Mesh".
  23756. */
  23757. getClassName(): string;
  23758. /** @hidden */
  23759. readonly _isMesh: boolean;
  23760. /**
  23761. * Returns a description of this mesh
  23762. * @param fullDetails define if full details about this mesh must be used
  23763. * @returns a descriptive string representing this mesh
  23764. */
  23765. toString(fullDetails?: boolean): string;
  23766. /** @hidden */
  23767. _unBindEffect(): void;
  23768. /**
  23769. * Gets a boolean indicating if this mesh has LOD
  23770. */
  23771. readonly hasLODLevels: boolean;
  23772. /**
  23773. * Gets the list of MeshLODLevel associated with the current mesh
  23774. * @returns an array of MeshLODLevel
  23775. */
  23776. getLODLevels(): MeshLODLevel[];
  23777. private _sortLODLevels;
  23778. /**
  23779. * Add a mesh as LOD level triggered at the given distance.
  23780. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23781. * @param distance The distance from the center of the object to show this level
  23782. * @param mesh The mesh to be added as LOD level (can be null)
  23783. * @return This mesh (for chaining)
  23784. */
  23785. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23786. /**
  23787. * Returns the LOD level mesh at the passed distance or null if not found.
  23788. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23789. * @param distance The distance from the center of the object to show this level
  23790. * @returns a Mesh or `null`
  23791. */
  23792. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23793. /**
  23794. * Remove a mesh from the LOD array
  23795. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23796. * @param mesh defines the mesh to be removed
  23797. * @return This mesh (for chaining)
  23798. */
  23799. removeLODLevel(mesh: Mesh): Mesh;
  23800. /**
  23801. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23802. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23803. * @param camera defines the camera to use to compute distance
  23804. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23805. * @return This mesh (for chaining)
  23806. */
  23807. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23808. /**
  23809. * Gets the mesh internal Geometry object
  23810. */
  23811. readonly geometry: Nullable<Geometry>;
  23812. /**
  23813. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23814. * @returns the total number of vertices
  23815. */
  23816. getTotalVertices(): number;
  23817. /**
  23818. * Returns the content of an associated vertex buffer
  23819. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23820. * - VertexBuffer.PositionKind
  23821. * - VertexBuffer.UVKind
  23822. * - VertexBuffer.UV2Kind
  23823. * - VertexBuffer.UV3Kind
  23824. * - VertexBuffer.UV4Kind
  23825. * - VertexBuffer.UV5Kind
  23826. * - VertexBuffer.UV6Kind
  23827. * - VertexBuffer.ColorKind
  23828. * - VertexBuffer.MatricesIndicesKind
  23829. * - VertexBuffer.MatricesIndicesExtraKind
  23830. * - VertexBuffer.MatricesWeightsKind
  23831. * - VertexBuffer.MatricesWeightsExtraKind
  23832. * @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
  23833. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23834. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23835. */
  23836. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23837. /**
  23838. * Returns the mesh VertexBuffer object from the requested `kind`
  23839. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23840. * - VertexBuffer.PositionKind
  23841. * - VertexBuffer.NormalKind
  23842. * - VertexBuffer.UVKind
  23843. * - VertexBuffer.UV2Kind
  23844. * - VertexBuffer.UV3Kind
  23845. * - VertexBuffer.UV4Kind
  23846. * - VertexBuffer.UV5Kind
  23847. * - VertexBuffer.UV6Kind
  23848. * - VertexBuffer.ColorKind
  23849. * - VertexBuffer.MatricesIndicesKind
  23850. * - VertexBuffer.MatricesIndicesExtraKind
  23851. * - VertexBuffer.MatricesWeightsKind
  23852. * - VertexBuffer.MatricesWeightsExtraKind
  23853. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23854. */
  23855. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23856. /**
  23857. * Tests if a specific vertex buffer is associated with this mesh
  23858. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23859. * - VertexBuffer.PositionKind
  23860. * - VertexBuffer.NormalKind
  23861. * - VertexBuffer.UVKind
  23862. * - VertexBuffer.UV2Kind
  23863. * - VertexBuffer.UV3Kind
  23864. * - VertexBuffer.UV4Kind
  23865. * - VertexBuffer.UV5Kind
  23866. * - VertexBuffer.UV6Kind
  23867. * - VertexBuffer.ColorKind
  23868. * - VertexBuffer.MatricesIndicesKind
  23869. * - VertexBuffer.MatricesIndicesExtraKind
  23870. * - VertexBuffer.MatricesWeightsKind
  23871. * - VertexBuffer.MatricesWeightsExtraKind
  23872. * @returns a boolean
  23873. */
  23874. isVerticesDataPresent(kind: string): boolean;
  23875. /**
  23876. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23877. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23878. * - VertexBuffer.PositionKind
  23879. * - VertexBuffer.UVKind
  23880. * - VertexBuffer.UV2Kind
  23881. * - VertexBuffer.UV3Kind
  23882. * - VertexBuffer.UV4Kind
  23883. * - VertexBuffer.UV5Kind
  23884. * - VertexBuffer.UV6Kind
  23885. * - VertexBuffer.ColorKind
  23886. * - VertexBuffer.MatricesIndicesKind
  23887. * - VertexBuffer.MatricesIndicesExtraKind
  23888. * - VertexBuffer.MatricesWeightsKind
  23889. * - VertexBuffer.MatricesWeightsExtraKind
  23890. * @returns a boolean
  23891. */
  23892. isVertexBufferUpdatable(kind: string): boolean;
  23893. /**
  23894. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23895. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23896. * - VertexBuffer.PositionKind
  23897. * - VertexBuffer.NormalKind
  23898. * - VertexBuffer.UVKind
  23899. * - VertexBuffer.UV2Kind
  23900. * - VertexBuffer.UV3Kind
  23901. * - VertexBuffer.UV4Kind
  23902. * - VertexBuffer.UV5Kind
  23903. * - VertexBuffer.UV6Kind
  23904. * - VertexBuffer.ColorKind
  23905. * - VertexBuffer.MatricesIndicesKind
  23906. * - VertexBuffer.MatricesIndicesExtraKind
  23907. * - VertexBuffer.MatricesWeightsKind
  23908. * - VertexBuffer.MatricesWeightsExtraKind
  23909. * @returns an array of strings
  23910. */
  23911. getVerticesDataKinds(): string[];
  23912. /**
  23913. * Returns a positive integer : the total number of indices in this mesh geometry.
  23914. * @returns the numner of indices or zero if the mesh has no geometry.
  23915. */
  23916. getTotalIndices(): number;
  23917. /**
  23918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23919. * @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.
  23920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23921. * @returns the indices array or an empty array if the mesh has no geometry
  23922. */
  23923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23924. readonly isBlocked: boolean;
  23925. /**
  23926. * Determine if the current mesh is ready to be rendered
  23927. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23928. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23929. * @returns true if all associated assets are ready (material, textures, shaders)
  23930. */
  23931. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23932. /**
  23933. * 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.
  23934. */
  23935. readonly areNormalsFrozen: boolean;
  23936. /**
  23937. * 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.
  23938. * @returns the current mesh
  23939. */
  23940. freezeNormals(): Mesh;
  23941. /**
  23942. * 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
  23943. * @returns the current mesh
  23944. */
  23945. unfreezeNormals(): Mesh;
  23946. /**
  23947. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23948. */
  23949. overridenInstanceCount: number;
  23950. /** @hidden */
  23951. _preActivate(): Mesh;
  23952. /** @hidden */
  23953. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23954. /** @hidden */
  23955. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23956. /**
  23957. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23958. * This means the mesh underlying bounding box and sphere are recomputed.
  23959. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23960. * @returns the current mesh
  23961. */
  23962. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23963. /** @hidden */
  23964. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23965. /**
  23966. * This function will subdivide the mesh into multiple submeshes
  23967. * @param count defines the expected number of submeshes
  23968. */
  23969. subdivide(count: number): void;
  23970. /**
  23971. * Copy a FloatArray into a specific associated vertex buffer
  23972. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23973. * - VertexBuffer.PositionKind
  23974. * - VertexBuffer.UVKind
  23975. * - VertexBuffer.UV2Kind
  23976. * - VertexBuffer.UV3Kind
  23977. * - VertexBuffer.UV4Kind
  23978. * - VertexBuffer.UV5Kind
  23979. * - VertexBuffer.UV6Kind
  23980. * - VertexBuffer.ColorKind
  23981. * - VertexBuffer.MatricesIndicesKind
  23982. * - VertexBuffer.MatricesIndicesExtraKind
  23983. * - VertexBuffer.MatricesWeightsKind
  23984. * - VertexBuffer.MatricesWeightsExtraKind
  23985. * @param data defines the data source
  23986. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23987. * @param stride defines the data stride size (can be null)
  23988. * @returns the current mesh
  23989. */
  23990. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23991. /**
  23992. * Flags an associated vertex buffer as updatable
  23993. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23994. * - VertexBuffer.PositionKind
  23995. * - VertexBuffer.UVKind
  23996. * - VertexBuffer.UV2Kind
  23997. * - VertexBuffer.UV3Kind
  23998. * - VertexBuffer.UV4Kind
  23999. * - VertexBuffer.UV5Kind
  24000. * - VertexBuffer.UV6Kind
  24001. * - VertexBuffer.ColorKind
  24002. * - VertexBuffer.MatricesIndicesKind
  24003. * - VertexBuffer.MatricesIndicesExtraKind
  24004. * - VertexBuffer.MatricesWeightsKind
  24005. * - VertexBuffer.MatricesWeightsExtraKind
  24006. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24007. */
  24008. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24009. /**
  24010. * Sets the mesh global Vertex Buffer
  24011. * @param buffer defines the buffer to use
  24012. * @returns the current mesh
  24013. */
  24014. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24015. /**
  24016. * Update a specific associated vertex buffer
  24017. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24018. * - VertexBuffer.PositionKind
  24019. * - VertexBuffer.UVKind
  24020. * - VertexBuffer.UV2Kind
  24021. * - VertexBuffer.UV3Kind
  24022. * - VertexBuffer.UV4Kind
  24023. * - VertexBuffer.UV5Kind
  24024. * - VertexBuffer.UV6Kind
  24025. * - VertexBuffer.ColorKind
  24026. * - VertexBuffer.MatricesIndicesKind
  24027. * - VertexBuffer.MatricesIndicesExtraKind
  24028. * - VertexBuffer.MatricesWeightsKind
  24029. * - VertexBuffer.MatricesWeightsExtraKind
  24030. * @param data defines the data source
  24031. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24032. * @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)
  24033. * @returns the current mesh
  24034. */
  24035. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24036. /**
  24037. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24038. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24039. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24040. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24041. * @returns the current mesh
  24042. */
  24043. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24044. /**
  24045. * Creates a un-shared specific occurence of the geometry for the mesh.
  24046. * @returns the current mesh
  24047. */
  24048. makeGeometryUnique(): Mesh;
  24049. /**
  24050. * Set the index buffer of this mesh
  24051. * @param indices defines the source data
  24052. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24053. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24054. * @returns the current mesh
  24055. */
  24056. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24057. /**
  24058. * Update the current index buffer
  24059. * @param indices defines the source data
  24060. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24061. * @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)
  24062. * @returns the current mesh
  24063. */
  24064. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24065. /**
  24066. * Invert the geometry to move from a right handed system to a left handed one.
  24067. * @returns the current mesh
  24068. */
  24069. toLeftHanded(): Mesh;
  24070. /** @hidden */
  24071. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24072. /** @hidden */
  24073. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24074. /**
  24075. * Registers for this mesh a javascript function called just before the rendering process
  24076. * @param func defines the function to call before rendering this mesh
  24077. * @returns the current mesh
  24078. */
  24079. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24080. /**
  24081. * Disposes a previously registered javascript function called before the rendering
  24082. * @param func defines the function to remove
  24083. * @returns the current mesh
  24084. */
  24085. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24086. /**
  24087. * Registers for this mesh a javascript function called just after the rendering is complete
  24088. * @param func defines the function to call after rendering this mesh
  24089. * @returns the current mesh
  24090. */
  24091. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24092. /**
  24093. * Disposes a previously registered javascript function called after the rendering.
  24094. * @param func defines the function to remove
  24095. * @returns the current mesh
  24096. */
  24097. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24098. /** @hidden */
  24099. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24100. /** @hidden */
  24101. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24102. /** @hidden */
  24103. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24104. /** @hidden */
  24105. _rebuild(): void;
  24106. /** @hidden */
  24107. _freeze(): void;
  24108. /** @hidden */
  24109. _unFreeze(): void;
  24110. /**
  24111. * 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
  24112. * @param subMesh defines the subMesh to render
  24113. * @param enableAlphaMode defines if alpha mode can be changed
  24114. * @returns the current mesh
  24115. */
  24116. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24117. private _onBeforeDraw;
  24118. /**
  24119. * Renormalize the mesh and patch it up if there are no weights
  24120. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24121. * However in the case of zero weights then we set just a single influence to 1.
  24122. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24123. */
  24124. cleanMatrixWeights(): void;
  24125. private normalizeSkinFourWeights;
  24126. private normalizeSkinWeightsAndExtra;
  24127. /**
  24128. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24129. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24130. * the user know there was an issue with importing the mesh
  24131. * @returns a validation object with skinned, valid and report string
  24132. */
  24133. validateSkinning(): {
  24134. skinned: boolean;
  24135. valid: boolean;
  24136. report: string;
  24137. };
  24138. /** @hidden */
  24139. _checkDelayState(): Mesh;
  24140. private _queueLoad;
  24141. /**
  24142. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24143. * A mesh is in the frustum if its bounding box intersects the frustum
  24144. * @param frustumPlanes defines the frustum to test
  24145. * @returns true if the mesh is in the frustum planes
  24146. */
  24147. isInFrustum(frustumPlanes: Plane[]): boolean;
  24148. /**
  24149. * Sets the mesh material by the material or multiMaterial `id` property
  24150. * @param id is a string identifying the material or the multiMaterial
  24151. * @returns the current mesh
  24152. */
  24153. setMaterialByID(id: string): Mesh;
  24154. /**
  24155. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24156. * @returns an array of IAnimatable
  24157. */
  24158. getAnimatables(): IAnimatable[];
  24159. /**
  24160. * Modifies the mesh geometry according to the passed transformation matrix.
  24161. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24162. * The mesh normals are modified using the same transformation.
  24163. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24164. * @param transform defines the transform matrix to use
  24165. * @see http://doc.babylonjs.com/resources/baking_transformations
  24166. * @returns the current mesh
  24167. */
  24168. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24169. /**
  24170. * Modifies the mesh geometry according to its own current World Matrix.
  24171. * The mesh World Matrix is then reset.
  24172. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24173. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24174. * @see http://doc.babylonjs.com/resources/baking_transformations
  24175. * @returns the current mesh
  24176. */
  24177. bakeCurrentTransformIntoVertices(): Mesh;
  24178. /** @hidden */
  24179. readonly _positions: Nullable<Vector3[]>;
  24180. /** @hidden */
  24181. _resetPointsArrayCache(): Mesh;
  24182. /** @hidden */
  24183. _generatePointsArray(): boolean;
  24184. /**
  24185. * Returns a new Mesh object generated from the current mesh properties.
  24186. * This method must not get confused with createInstance()
  24187. * @param name is a string, the name given to the new mesh
  24188. * @param newParent can be any Node object (default `null`)
  24189. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24190. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24191. * @returns a new mesh
  24192. */
  24193. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24194. /**
  24195. * Releases resources associated with this mesh.
  24196. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24197. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24198. */
  24199. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24200. /**
  24201. * Modifies the mesh geometry according to a displacement map.
  24202. * 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.
  24203. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24204. * @param url is a string, the URL from the image file is to be downloaded.
  24205. * @param minHeight is the lower limit of the displacement.
  24206. * @param maxHeight is the upper limit of the displacement.
  24207. * @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.
  24208. * @param uvOffset is an optional vector2 used to offset UV.
  24209. * @param uvScale is an optional vector2 used to scale UV.
  24210. * @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.
  24211. * @returns the Mesh.
  24212. */
  24213. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24214. /**
  24215. * Modifies the mesh geometry according to a displacementMap buffer.
  24216. * 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.
  24217. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24218. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24219. * @param heightMapWidth is the width of the buffer image.
  24220. * @param heightMapHeight is the height of the buffer image.
  24221. * @param minHeight is the lower limit of the displacement.
  24222. * @param maxHeight is the upper limit of the displacement.
  24223. * @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.
  24224. * @param uvOffset is an optional vector2 used to offset UV.
  24225. * @param uvScale is an optional vector2 used to scale UV.
  24226. * @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.
  24227. * @returns the Mesh.
  24228. */
  24229. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24230. /**
  24231. * Modify the mesh to get a flat shading rendering.
  24232. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24233. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24234. * @returns current mesh
  24235. */
  24236. convertToFlatShadedMesh(): Mesh;
  24237. /**
  24238. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24239. * In other words, more vertices, no more indices and a single bigger VBO.
  24240. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24241. * @returns current mesh
  24242. */
  24243. convertToUnIndexedMesh(): Mesh;
  24244. /**
  24245. * Inverses facet orientations.
  24246. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24247. * @param flipNormals will also inverts the normals
  24248. * @returns current mesh
  24249. */
  24250. flipFaces(flipNormals?: boolean): Mesh;
  24251. /**
  24252. * Increase the number of facets and hence vertices in a mesh
  24253. * Vertex normals are interpolated from existing vertex normals
  24254. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24255. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24256. */
  24257. increaseVertices(numberPerEdge: number): void;
  24258. /**
  24259. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24260. * This will undo any application of covertToFlatShadedMesh
  24261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24262. */
  24263. forceSharedVertices(): void;
  24264. /** @hidden */
  24265. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24266. /** @hidden */
  24267. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24268. /**
  24269. * Creates a new InstancedMesh object from the mesh model.
  24270. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24271. * @param name defines the name of the new instance
  24272. * @returns a new InstancedMesh
  24273. */
  24274. createInstance(name: string): InstancedMesh;
  24275. /**
  24276. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24277. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24278. * @returns the current mesh
  24279. */
  24280. synchronizeInstances(): Mesh;
  24281. /**
  24282. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24283. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24284. * This should be used together with the simplification to avoid disappearing triangles.
  24285. * @param successCallback an optional success callback to be called after the optimization finished.
  24286. * @returns the current mesh
  24287. */
  24288. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24289. /**
  24290. * Serialize current mesh
  24291. * @param serializationObject defines the object which will receive the serialization data
  24292. */
  24293. serialize(serializationObject: any): void;
  24294. /** @hidden */
  24295. _syncGeometryWithMorphTargetManager(): void;
  24296. /** @hidden */
  24297. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24298. /**
  24299. * Returns a new Mesh object parsed from the source provided.
  24300. * @param parsedMesh is the source
  24301. * @param scene defines the hosting scene
  24302. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24303. * @returns a new Mesh
  24304. */
  24305. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24306. /**
  24307. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24308. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24309. * @param name defines the name of the mesh to create
  24310. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24311. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24312. * @param closePath creates a seam between the first and the last points of each path of the path array
  24313. * @param offset is taken in account only if the `pathArray` is containing a single path
  24314. * @param scene defines the hosting scene
  24315. * @param updatable defines if the mesh must be flagged as updatable
  24316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24317. * @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)
  24318. * @returns a new Mesh
  24319. */
  24320. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24321. /**
  24322. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24323. * @param name defines the name of the mesh to create
  24324. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24325. * @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
  24326. * @param scene defines the hosting scene
  24327. * @param updatable defines if the mesh must be flagged as updatable
  24328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24329. * @returns a new Mesh
  24330. */
  24331. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24332. /**
  24333. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24334. * @param name defines the name of the mesh to create
  24335. * @param size sets the size (float) of each box side (default 1)
  24336. * @param scene defines the hosting scene
  24337. * @param updatable defines if the mesh must be flagged as updatable
  24338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24339. * @returns a new Mesh
  24340. */
  24341. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24342. /**
  24343. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24344. * @param name defines the name of the mesh to create
  24345. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24346. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24347. * @param scene defines the hosting scene
  24348. * @param updatable defines if the mesh must be flagged as updatable
  24349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24350. * @returns a new Mesh
  24351. */
  24352. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24353. /**
  24354. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24355. * @param name defines the name of the mesh to create
  24356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24358. * @param scene defines the hosting scene
  24359. * @returns a new Mesh
  24360. */
  24361. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24362. /**
  24363. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24364. * @param name defines the name of the mesh to create
  24365. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24366. * @param diameterTop set the top cap diameter (floats, default 1)
  24367. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24368. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24369. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24370. * @param scene defines the hosting scene
  24371. * @param updatable defines if the mesh must be flagged as updatable
  24372. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24373. * @returns a new Mesh
  24374. */
  24375. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24376. /**
  24377. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24378. * @param name defines the name of the mesh to create
  24379. * @param diameter sets the diameter size (float) of the torus (default 1)
  24380. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24381. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24382. * @param scene defines the hosting scene
  24383. * @param updatable defines if the mesh must be flagged as updatable
  24384. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24385. * @returns a new Mesh
  24386. */
  24387. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24388. /**
  24389. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24390. * @param name defines the name of the mesh to create
  24391. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24392. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24393. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24394. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24395. * @param p the number of windings on X axis (positive integers, default 2)
  24396. * @param q the number of windings on Y axis (positive integers, default 3)
  24397. * @param scene defines the hosting scene
  24398. * @param updatable defines if the mesh must be flagged as updatable
  24399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24400. * @returns a new Mesh
  24401. */
  24402. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24403. /**
  24404. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24405. * @param name defines the name of the mesh to create
  24406. * @param points is an array successive Vector3
  24407. * @param scene defines the hosting scene
  24408. * @param updatable defines if the mesh must be flagged as updatable
  24409. * @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).
  24410. * @returns a new Mesh
  24411. */
  24412. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24413. /**
  24414. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24415. * @param name defines the name of the mesh to create
  24416. * @param points is an array successive Vector3
  24417. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24418. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24419. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24420. * @param scene defines the hosting scene
  24421. * @param updatable defines if the mesh must be flagged as updatable
  24422. * @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)
  24423. * @returns a new Mesh
  24424. */
  24425. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24426. /**
  24427. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24429. * 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.
  24430. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24431. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24432. * Remember you can only change the shape positions, not their number when updating a polygon.
  24433. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24434. * @param name defines the name of the mesh to create
  24435. * @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
  24436. * @param scene defines the hosting scene
  24437. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24438. * @param updatable defines if the mesh must be flagged as updatable
  24439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24440. * @param earcutInjection can be used to inject your own earcut reference
  24441. * @returns a new Mesh
  24442. */
  24443. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24444. /**
  24445. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24446. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24447. * @param name defines the name of the mesh to create
  24448. * @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
  24449. * @param depth defines the height of extrusion
  24450. * @param scene defines the hosting scene
  24451. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24452. * @param updatable defines if the mesh must be flagged as updatable
  24453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24454. * @param earcutInjection can be used to inject your own earcut reference
  24455. * @returns a new Mesh
  24456. */
  24457. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24458. /**
  24459. * Creates an extruded shape mesh.
  24460. * 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
  24461. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24462. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24463. * @param name defines the name of the mesh to create
  24464. * @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
  24465. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24466. * @param scale is the value to scale the shape
  24467. * @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
  24468. * @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
  24469. * @param scene defines the hosting scene
  24470. * @param updatable defines if the mesh must be flagged as updatable
  24471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24472. * @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)
  24473. * @returns a new Mesh
  24474. */
  24475. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24476. /**
  24477. * Creates an custom extruded shape mesh.
  24478. * The custom extrusion is a parametric shape.
  24479. * It has no predefined shape. Its final shape will depend on the input parameters.
  24480. * Please consider using the same method from the MeshBuilder class instead
  24481. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24482. * @param name defines the name of the mesh to create
  24483. * @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
  24484. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24485. * @param scaleFunction is a custom Javascript function called on each path point
  24486. * @param rotationFunction is a custom Javascript function called on each path point
  24487. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24488. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24489. * @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
  24490. * @param scene defines the hosting scene
  24491. * @param updatable defines if the mesh must be flagged as updatable
  24492. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24493. * @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)
  24494. * @returns a new Mesh
  24495. */
  24496. 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;
  24497. /**
  24498. * Creates lathe mesh.
  24499. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24500. * Please consider using the same method from the MeshBuilder class instead
  24501. * @param name defines the name of the mesh to create
  24502. * @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
  24503. * @param radius is the radius value of the lathe
  24504. * @param tessellation is the side number of the lathe.
  24505. * @param scene defines the hosting scene
  24506. * @param updatable defines if the mesh must be flagged as updatable
  24507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24508. * @returns a new Mesh
  24509. */
  24510. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24511. /**
  24512. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24513. * @param name defines the name of the mesh to create
  24514. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24515. * @param scene defines the hosting scene
  24516. * @param updatable defines if the mesh must be flagged as updatable
  24517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24518. * @returns a new Mesh
  24519. */
  24520. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24521. /**
  24522. * Creates a ground mesh.
  24523. * Please consider using the same method from the MeshBuilder class instead
  24524. * @param name defines the name of the mesh to create
  24525. * @param width set the width of the ground
  24526. * @param height set the height of the ground
  24527. * @param subdivisions sets the number of subdivisions per side
  24528. * @param scene defines the hosting scene
  24529. * @param updatable defines if the mesh must be flagged as updatable
  24530. * @returns a new Mesh
  24531. */
  24532. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24533. /**
  24534. * Creates a tiled ground mesh.
  24535. * Please consider using the same method from the MeshBuilder class instead
  24536. * @param name defines the name of the mesh to create
  24537. * @param xmin set the ground minimum X coordinate
  24538. * @param zmin set the ground minimum Y coordinate
  24539. * @param xmax set the ground maximum X coordinate
  24540. * @param zmax set the ground maximum Z coordinate
  24541. * @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
  24542. * @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
  24543. * @param scene defines the hosting scene
  24544. * @param updatable defines if the mesh must be flagged as updatable
  24545. * @returns a new Mesh
  24546. */
  24547. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24548. w: number;
  24549. h: number;
  24550. }, precision: {
  24551. w: number;
  24552. h: number;
  24553. }, scene: Scene, updatable?: boolean): Mesh;
  24554. /**
  24555. * Creates a ground mesh from a height map.
  24556. * Please consider using the same method from the MeshBuilder class instead
  24557. * @see http://doc.babylonjs.com/babylon101/height_map
  24558. * @param name defines the name of the mesh to create
  24559. * @param url sets the URL of the height map image resource
  24560. * @param width set the ground width size
  24561. * @param height set the ground height size
  24562. * @param subdivisions sets the number of subdivision per side
  24563. * @param minHeight is the minimum altitude on the ground
  24564. * @param maxHeight is the maximum altitude on the ground
  24565. * @param scene defines the hosting scene
  24566. * @param updatable defines if the mesh must be flagged as updatable
  24567. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24568. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24569. * @returns a new Mesh
  24570. */
  24571. 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;
  24572. /**
  24573. * Creates a tube mesh.
  24574. * The tube is a parametric shape.
  24575. * It has no predefined shape. Its final shape will depend on the input parameters.
  24576. * Please consider using the same method from the MeshBuilder class instead
  24577. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24578. * @param name defines the name of the mesh to create
  24579. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24580. * @param radius sets the tube radius size
  24581. * @param tessellation is the number of sides on the tubular surface
  24582. * @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
  24583. * @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
  24584. * @param scene defines the hosting scene
  24585. * @param updatable defines if the mesh must be flagged as updatable
  24586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24587. * @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)
  24588. * @returns a new Mesh
  24589. */
  24590. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24591. (i: number, distance: number): number;
  24592. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24593. /**
  24594. * Creates a polyhedron mesh.
  24595. * Please consider using the same method from the MeshBuilder class instead.
  24596. * * 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
  24597. * * The parameter `size` (positive float, default 1) sets the polygon size
  24598. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24599. * * 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`
  24600. * * 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
  24601. * * 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)`)
  24602. * * 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
  24603. * * 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
  24604. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24605. * * 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
  24606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24607. * @param name defines the name of the mesh to create
  24608. * @param options defines the options used to create the mesh
  24609. * @param scene defines the hosting scene
  24610. * @returns a new Mesh
  24611. */
  24612. static CreatePolyhedron(name: string, options: {
  24613. type?: number;
  24614. size?: number;
  24615. sizeX?: number;
  24616. sizeY?: number;
  24617. sizeZ?: number;
  24618. custom?: any;
  24619. faceUV?: Vector4[];
  24620. faceColors?: Color4[];
  24621. updatable?: boolean;
  24622. sideOrientation?: number;
  24623. }, scene: Scene): Mesh;
  24624. /**
  24625. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24626. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24627. * * 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`)
  24628. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24629. * * 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
  24630. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24631. * * 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
  24632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24633. * @param name defines the name of the mesh
  24634. * @param options defines the options used to create the mesh
  24635. * @param scene defines the hosting scene
  24636. * @returns a new Mesh
  24637. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24638. */
  24639. static CreateIcoSphere(name: string, options: {
  24640. radius?: number;
  24641. flat?: boolean;
  24642. subdivisions?: number;
  24643. sideOrientation?: number;
  24644. updatable?: boolean;
  24645. }, scene: Scene): Mesh;
  24646. /**
  24647. * Creates a decal mesh.
  24648. * Please consider using the same method from the MeshBuilder class instead.
  24649. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24650. * @param name defines the name of the mesh
  24651. * @param sourceMesh defines the mesh receiving the decal
  24652. * @param position sets the position of the decal in world coordinates
  24653. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24654. * @param size sets the decal scaling
  24655. * @param angle sets the angle to rotate the decal
  24656. * @returns a new Mesh
  24657. */
  24658. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24659. /**
  24660. * Prepare internal position array for software CPU skinning
  24661. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24662. */
  24663. setPositionsForCPUSkinning(): Float32Array;
  24664. /**
  24665. * Prepare internal normal array for software CPU skinning
  24666. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24667. */
  24668. setNormalsForCPUSkinning(): Float32Array;
  24669. /**
  24670. * Updates the vertex buffer by applying transformation from the bones
  24671. * @param skeleton defines the skeleton to apply to current mesh
  24672. * @returns the current mesh
  24673. */
  24674. applySkeleton(skeleton: Skeleton): Mesh;
  24675. /**
  24676. * 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
  24677. * @param meshes defines the list of meshes to scan
  24678. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24679. */
  24680. static MinMax(meshes: AbstractMesh[]): {
  24681. min: Vector3;
  24682. max: Vector3;
  24683. };
  24684. /**
  24685. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24686. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24687. * @returns a vector3
  24688. */
  24689. static Center(meshesOrMinMaxVector: {
  24690. min: Vector3;
  24691. max: Vector3;
  24692. } | AbstractMesh[]): Vector3;
  24693. /**
  24694. * Merge the array of meshes into a single mesh for performance reasons.
  24695. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24696. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24697. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24698. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24699. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24700. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24701. * @returns a new mesh
  24702. */
  24703. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24704. /** @hidden */
  24705. addInstance(instance: InstancedMesh): void;
  24706. /** @hidden */
  24707. removeInstance(instance: InstancedMesh): void;
  24708. }
  24709. }
  24710. declare module BABYLON {
  24711. /**
  24712. * This is the base class of all the camera used in the application.
  24713. * @see http://doc.babylonjs.com/features/cameras
  24714. */
  24715. export class Camera extends Node {
  24716. /** @hidden */
  24717. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24718. /**
  24719. * This is the default projection mode used by the cameras.
  24720. * It helps recreating a feeling of perspective and better appreciate depth.
  24721. * This is the best way to simulate real life cameras.
  24722. */
  24723. static readonly PERSPECTIVE_CAMERA: number;
  24724. /**
  24725. * This helps creating camera with an orthographic mode.
  24726. * 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.
  24727. */
  24728. static readonly ORTHOGRAPHIC_CAMERA: number;
  24729. /**
  24730. * This is the default FOV mode for perspective cameras.
  24731. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24732. */
  24733. static readonly FOVMODE_VERTICAL_FIXED: number;
  24734. /**
  24735. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24736. */
  24737. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24738. /**
  24739. * This specifies ther is no need for a camera rig.
  24740. * Basically only one eye is rendered corresponding to the camera.
  24741. */
  24742. static readonly RIG_MODE_NONE: number;
  24743. /**
  24744. * Simulates a camera Rig with one blue eye and one red eye.
  24745. * This can be use with 3d blue and red glasses.
  24746. */
  24747. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24748. /**
  24749. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24750. */
  24751. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24752. /**
  24753. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24754. */
  24755. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24756. /**
  24757. * Defines that both eyes of the camera will be rendered over under each other.
  24758. */
  24759. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24760. /**
  24761. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24762. */
  24763. static readonly RIG_MODE_VR: number;
  24764. /**
  24765. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24766. */
  24767. static readonly RIG_MODE_WEBVR: number;
  24768. /**
  24769. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24770. */
  24771. static readonly RIG_MODE_CUSTOM: number;
  24772. /**
  24773. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24774. */
  24775. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24776. /**
  24777. * Define the input manager associated with the camera.
  24778. */
  24779. inputs: CameraInputsManager<Camera>;
  24780. /** @hidden */
  24781. _position: Vector3;
  24782. /**
  24783. * Define the current local position of the camera in the scene
  24784. */
  24785. position: Vector3;
  24786. /**
  24787. * The vector the camera should consider as up.
  24788. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24789. */
  24790. upVector: Vector3;
  24791. /**
  24792. * Define the current limit on the left side for an orthographic camera
  24793. * In scene unit
  24794. */
  24795. orthoLeft: Nullable<number>;
  24796. /**
  24797. * Define the current limit on the right side for an orthographic camera
  24798. * In scene unit
  24799. */
  24800. orthoRight: Nullable<number>;
  24801. /**
  24802. * Define the current limit on the bottom side for an orthographic camera
  24803. * In scene unit
  24804. */
  24805. orthoBottom: Nullable<number>;
  24806. /**
  24807. * Define the current limit on the top side for an orthographic camera
  24808. * In scene unit
  24809. */
  24810. orthoTop: Nullable<number>;
  24811. /**
  24812. * Field Of View is set in Radians. (default is 0.8)
  24813. */
  24814. fov: number;
  24815. /**
  24816. * Define the minimum distance the camera can see from.
  24817. * This is important to note that the depth buffer are not infinite and the closer it starts
  24818. * the more your scene might encounter depth fighting issue.
  24819. */
  24820. minZ: number;
  24821. /**
  24822. * Define the maximum distance the camera can see to.
  24823. * This is important to note that the depth buffer are not infinite and the further it end
  24824. * the more your scene might encounter depth fighting issue.
  24825. */
  24826. maxZ: number;
  24827. /**
  24828. * Define the default inertia of the camera.
  24829. * This helps giving a smooth feeling to the camera movement.
  24830. */
  24831. inertia: number;
  24832. /**
  24833. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24834. */
  24835. mode: number;
  24836. /**
  24837. * Define wether the camera is intermediate.
  24838. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24839. */
  24840. isIntermediate: boolean;
  24841. /**
  24842. * Define the viewport of the camera.
  24843. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24844. */
  24845. viewport: Viewport;
  24846. /**
  24847. * Restricts the camera to viewing objects with the same layerMask.
  24848. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24849. */
  24850. layerMask: number;
  24851. /**
  24852. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24853. */
  24854. fovMode: number;
  24855. /**
  24856. * Rig mode of the camera.
  24857. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24858. * This is normally controlled byt the camera themselves as internal use.
  24859. */
  24860. cameraRigMode: number;
  24861. /**
  24862. * Defines the distance between both "eyes" in case of a RIG
  24863. */
  24864. interaxialDistance: number;
  24865. /**
  24866. * Defines if stereoscopic rendering is done side by side or over under.
  24867. */
  24868. isStereoscopicSideBySide: boolean;
  24869. /**
  24870. * 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
  24871. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24872. * else in the scene. (Eg. security camera)
  24873. *
  24874. * 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)
  24875. */
  24876. customRenderTargets: RenderTargetTexture[];
  24877. /**
  24878. * When set, the camera will render to this render target instead of the default canvas
  24879. *
  24880. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24881. */
  24882. outputRenderTarget: Nullable<RenderTargetTexture>;
  24883. /**
  24884. * Observable triggered when the camera view matrix has changed.
  24885. */
  24886. onViewMatrixChangedObservable: Observable<Camera>;
  24887. /**
  24888. * Observable triggered when the camera Projection matrix has changed.
  24889. */
  24890. onProjectionMatrixChangedObservable: Observable<Camera>;
  24891. /**
  24892. * Observable triggered when the inputs have been processed.
  24893. */
  24894. onAfterCheckInputsObservable: Observable<Camera>;
  24895. /**
  24896. * Observable triggered when reset has been called and applied to the camera.
  24897. */
  24898. onRestoreStateObservable: Observable<Camera>;
  24899. /** @hidden */
  24900. _cameraRigParams: any;
  24901. /** @hidden */
  24902. _rigCameras: Camera[];
  24903. /** @hidden */
  24904. _rigPostProcess: Nullable<PostProcess>;
  24905. protected _webvrViewMatrix: Matrix;
  24906. /** @hidden */
  24907. _skipRendering: boolean;
  24908. /** @hidden */
  24909. _projectionMatrix: Matrix;
  24910. /** @hidden */
  24911. _postProcesses: Nullable<PostProcess>[];
  24912. /** @hidden */
  24913. _activeMeshes: SmartArray<AbstractMesh>;
  24914. protected _globalPosition: Vector3;
  24915. /** @hidden */
  24916. _computedViewMatrix: Matrix;
  24917. private _doNotComputeProjectionMatrix;
  24918. private _transformMatrix;
  24919. private _frustumPlanes;
  24920. private _refreshFrustumPlanes;
  24921. private _storedFov;
  24922. private _stateStored;
  24923. /**
  24924. * Instantiates a new camera object.
  24925. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24926. * @see http://doc.babylonjs.com/features/cameras
  24927. * @param name Defines the name of the camera in the scene
  24928. * @param position Defines the position of the camera
  24929. * @param scene Defines the scene the camera belongs too
  24930. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24931. */
  24932. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24933. /**
  24934. * Store current camera state (fov, position, etc..)
  24935. * @returns the camera
  24936. */
  24937. storeState(): Camera;
  24938. /**
  24939. * Restores the camera state values if it has been stored. You must call storeState() first
  24940. */
  24941. protected _restoreStateValues(): boolean;
  24942. /**
  24943. * Restored camera state. You must call storeState() first.
  24944. * @returns true if restored and false otherwise
  24945. */
  24946. restoreState(): boolean;
  24947. /**
  24948. * Gets the class name of the camera.
  24949. * @returns the class name
  24950. */
  24951. getClassName(): string;
  24952. /** @hidden */
  24953. readonly _isCamera: boolean;
  24954. /**
  24955. * Gets a string representation of the camera useful for debug purpose.
  24956. * @param fullDetails Defines that a more verboe level of logging is required
  24957. * @returns the string representation
  24958. */
  24959. toString(fullDetails?: boolean): string;
  24960. /**
  24961. * Gets the current world space position of the camera.
  24962. */
  24963. readonly globalPosition: Vector3;
  24964. /**
  24965. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24966. * @returns the active meshe list
  24967. */
  24968. getActiveMeshes(): SmartArray<AbstractMesh>;
  24969. /**
  24970. * Check wether a mesh is part of the current active mesh list of the camera
  24971. * @param mesh Defines the mesh to check
  24972. * @returns true if active, false otherwise
  24973. */
  24974. isActiveMesh(mesh: Mesh): boolean;
  24975. /**
  24976. * Is this camera ready to be used/rendered
  24977. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24978. * @return true if the camera is ready
  24979. */
  24980. isReady(completeCheck?: boolean): boolean;
  24981. /** @hidden */
  24982. _initCache(): void;
  24983. /** @hidden */
  24984. _updateCache(ignoreParentClass?: boolean): void;
  24985. /** @hidden */
  24986. _isSynchronized(): boolean;
  24987. /** @hidden */
  24988. _isSynchronizedViewMatrix(): boolean;
  24989. /** @hidden */
  24990. _isSynchronizedProjectionMatrix(): boolean;
  24991. /**
  24992. * Attach the input controls to a specific dom element to get the input from.
  24993. * @param element Defines the element the controls should be listened from
  24994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24995. */
  24996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24997. /**
  24998. * Detach the current controls from the specified dom element.
  24999. * @param element Defines the element to stop listening the inputs from
  25000. */
  25001. detachControl(element: HTMLElement): void;
  25002. /**
  25003. * Update the camera state according to the different inputs gathered during the frame.
  25004. */
  25005. update(): void;
  25006. /** @hidden */
  25007. _checkInputs(): void;
  25008. /** @hidden */
  25009. readonly rigCameras: Camera[];
  25010. /**
  25011. * Gets the post process used by the rig cameras
  25012. */
  25013. readonly rigPostProcess: Nullable<PostProcess>;
  25014. /**
  25015. * Internal, gets the first post proces.
  25016. * @returns the first post process to be run on this camera.
  25017. */
  25018. _getFirstPostProcess(): Nullable<PostProcess>;
  25019. private _cascadePostProcessesToRigCams;
  25020. /**
  25021. * Attach a post process to the camera.
  25022. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25023. * @param postProcess The post process to attach to the camera
  25024. * @param insertAt The position of the post process in case several of them are in use in the scene
  25025. * @returns the position the post process has been inserted at
  25026. */
  25027. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25028. /**
  25029. * Detach a post process to the camera.
  25030. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25031. * @param postProcess The post process to detach from the camera
  25032. */
  25033. detachPostProcess(postProcess: PostProcess): void;
  25034. /**
  25035. * Gets the current world matrix of the camera
  25036. */
  25037. getWorldMatrix(): Matrix;
  25038. /** @hidden */
  25039. _getViewMatrix(): Matrix;
  25040. /**
  25041. * Gets the current view matrix of the camera.
  25042. * @param force forces the camera to recompute the matrix without looking at the cached state
  25043. * @returns the view matrix
  25044. */
  25045. getViewMatrix(force?: boolean): Matrix;
  25046. /**
  25047. * Freeze the projection matrix.
  25048. * It will prevent the cache check of the camera projection compute and can speed up perf
  25049. * if no parameter of the camera are meant to change
  25050. * @param projection Defines manually a projection if necessary
  25051. */
  25052. freezeProjectionMatrix(projection?: Matrix): void;
  25053. /**
  25054. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25055. */
  25056. unfreezeProjectionMatrix(): void;
  25057. /**
  25058. * Gets the current projection matrix of the camera.
  25059. * @param force forces the camera to recompute the matrix without looking at the cached state
  25060. * @returns the projection matrix
  25061. */
  25062. getProjectionMatrix(force?: boolean): Matrix;
  25063. /**
  25064. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25065. * @returns a Matrix
  25066. */
  25067. getTransformationMatrix(): Matrix;
  25068. private _updateFrustumPlanes;
  25069. /**
  25070. * Checks if a cullable object (mesh...) is in the camera frustum
  25071. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25072. * @param target The object to check
  25073. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25074. * @returns true if the object is in frustum otherwise false
  25075. */
  25076. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25077. /**
  25078. * Checks if a cullable object (mesh...) is in the camera frustum
  25079. * Unlike isInFrustum this cheks the full bounding box
  25080. * @param target The object to check
  25081. * @returns true if the object is in frustum otherwise false
  25082. */
  25083. isCompletelyInFrustum(target: ICullable): boolean;
  25084. /**
  25085. * Gets a ray in the forward direction from the camera.
  25086. * @param length Defines the length of the ray to create
  25087. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25088. * @param origin Defines the start point of the ray which defaults to the camera position
  25089. * @returns the forward ray
  25090. */
  25091. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25092. /**
  25093. * Releases resources associated with this node.
  25094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25096. */
  25097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25098. /** @hidden */
  25099. _isLeftCamera: boolean;
  25100. /**
  25101. * Gets the left camera of a rig setup in case of Rigged Camera
  25102. */
  25103. readonly isLeftCamera: boolean;
  25104. /** @hidden */
  25105. _isRightCamera: boolean;
  25106. /**
  25107. * Gets the right camera of a rig setup in case of Rigged Camera
  25108. */
  25109. readonly isRightCamera: boolean;
  25110. /**
  25111. * Gets the left camera of a rig setup in case of Rigged Camera
  25112. */
  25113. readonly leftCamera: Nullable<FreeCamera>;
  25114. /**
  25115. * Gets the right camera of a rig setup in case of Rigged Camera
  25116. */
  25117. readonly rightCamera: Nullable<FreeCamera>;
  25118. /**
  25119. * Gets the left camera target of a rig setup in case of Rigged Camera
  25120. * @returns the target position
  25121. */
  25122. getLeftTarget(): Nullable<Vector3>;
  25123. /**
  25124. * Gets the right camera target of a rig setup in case of Rigged Camera
  25125. * @returns the target position
  25126. */
  25127. getRightTarget(): Nullable<Vector3>;
  25128. /**
  25129. * @hidden
  25130. */
  25131. setCameraRigMode(mode: number, rigParams: any): void;
  25132. /** @hidden */
  25133. static _setStereoscopicRigMode(camera: Camera): void;
  25134. /** @hidden */
  25135. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25136. /** @hidden */
  25137. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25138. /** @hidden */
  25139. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25140. /** @hidden */
  25141. _getVRProjectionMatrix(): Matrix;
  25142. protected _updateCameraRotationMatrix(): void;
  25143. protected _updateWebVRCameraRotationMatrix(): void;
  25144. /**
  25145. * This function MUST be overwritten by the different WebVR cameras available.
  25146. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25147. * @hidden
  25148. */
  25149. _getWebVRProjectionMatrix(): Matrix;
  25150. /**
  25151. * This function MUST be overwritten by the different WebVR cameras available.
  25152. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25153. * @hidden
  25154. */
  25155. _getWebVRViewMatrix(): Matrix;
  25156. /** @hidden */
  25157. setCameraRigParameter(name: string, value: any): void;
  25158. /**
  25159. * needs to be overridden by children so sub has required properties to be copied
  25160. * @hidden
  25161. */
  25162. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25163. /**
  25164. * May need to be overridden by children
  25165. * @hidden
  25166. */
  25167. _updateRigCameras(): void;
  25168. /** @hidden */
  25169. _setupInputs(): void;
  25170. /**
  25171. * Serialiaze the camera setup to a json represention
  25172. * @returns the JSON representation
  25173. */
  25174. serialize(): any;
  25175. /**
  25176. * Clones the current camera.
  25177. * @param name The cloned camera name
  25178. * @returns the cloned camera
  25179. */
  25180. clone(name: string): Camera;
  25181. /**
  25182. * Gets the direction of the camera relative to a given local axis.
  25183. * @param localAxis Defines the reference axis to provide a relative direction.
  25184. * @return the direction
  25185. */
  25186. getDirection(localAxis: Vector3): Vector3;
  25187. /**
  25188. * Returns the current camera absolute rotation
  25189. */
  25190. readonly absoluteRotation: Quaternion;
  25191. /**
  25192. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25193. * @param localAxis Defines the reference axis to provide a relative direction.
  25194. * @param result Defines the vector to store the result in
  25195. */
  25196. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25197. /**
  25198. * Gets a camera constructor for a given camera type
  25199. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25200. * @param name The name of the camera the result will be able to instantiate
  25201. * @param scene The scene the result will construct the camera in
  25202. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25203. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25204. * @returns a factory method to construc the camera
  25205. */
  25206. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25207. /**
  25208. * Compute the world matrix of the camera.
  25209. * @returns the camera workd matrix
  25210. */
  25211. computeWorldMatrix(): Matrix;
  25212. /**
  25213. * Parse a JSON and creates the camera from the parsed information
  25214. * @param parsedCamera The JSON to parse
  25215. * @param scene The scene to instantiate the camera in
  25216. * @returns the newly constructed camera
  25217. */
  25218. static Parse(parsedCamera: any, scene: Scene): Camera;
  25219. }
  25220. }
  25221. declare module BABYLON {
  25222. /**
  25223. * Class containing static functions to help procedurally build meshes
  25224. */
  25225. export class DiscBuilder {
  25226. /**
  25227. * Creates a plane polygonal mesh. By default, this is a disc
  25228. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25229. * * 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
  25230. * * 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
  25231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25232. * * 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
  25233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25234. * @param name defines the name of the mesh
  25235. * @param options defines the options used to create the mesh
  25236. * @param scene defines the hosting scene
  25237. * @returns the plane polygonal mesh
  25238. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25239. */
  25240. static CreateDisc(name: string, options: {
  25241. radius?: number;
  25242. tessellation?: number;
  25243. arc?: number;
  25244. updatable?: boolean;
  25245. sideOrientation?: number;
  25246. frontUVs?: Vector4;
  25247. backUVs?: Vector4;
  25248. }, scene?: Nullable<Scene>): Mesh;
  25249. }
  25250. }
  25251. declare module BABYLON {
  25252. /**
  25253. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25254. *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.
  25255. * The SPS is also a particle system. It provides some methods to manage the particles.
  25256. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25257. *
  25258. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25259. */
  25260. export class SolidParticleSystem implements IDisposable {
  25261. /**
  25262. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25263. * Example : var p = SPS.particles[i];
  25264. */
  25265. particles: SolidParticle[];
  25266. /**
  25267. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25268. */
  25269. nbParticles: number;
  25270. /**
  25271. * If the particles must ever face the camera (default false). Useful for planar particles.
  25272. */
  25273. billboard: boolean;
  25274. /**
  25275. * Recompute normals when adding a shape
  25276. */
  25277. recomputeNormals: boolean;
  25278. /**
  25279. * This a counter ofr your own usage. It's not set by any SPS functions.
  25280. */
  25281. counter: number;
  25282. /**
  25283. * The SPS name. This name is also given to the underlying mesh.
  25284. */
  25285. name: string;
  25286. /**
  25287. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25288. */
  25289. mesh: Mesh;
  25290. /**
  25291. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25292. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25293. */
  25294. vars: any;
  25295. /**
  25296. * This array is populated when the SPS is set as 'pickable'.
  25297. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25298. * Each element of this array is an object `{idx: int, faceId: int}`.
  25299. * `idx` is the picked particle index in the `SPS.particles` array
  25300. * `faceId` is the picked face index counted within this particle.
  25301. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25302. */
  25303. pickedParticles: {
  25304. idx: number;
  25305. faceId: number;
  25306. }[];
  25307. /**
  25308. * This array is populated when `enableDepthSort` is set to true.
  25309. * Each element of this array is an instance of the class DepthSortedParticle.
  25310. */
  25311. depthSortedParticles: DepthSortedParticle[];
  25312. /**
  25313. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25314. * @hidden
  25315. */
  25316. _bSphereOnly: boolean;
  25317. /**
  25318. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25319. * @hidden
  25320. */
  25321. _bSphereRadiusFactor: number;
  25322. private _scene;
  25323. private _positions;
  25324. private _indices;
  25325. private _normals;
  25326. private _colors;
  25327. private _uvs;
  25328. private _indices32;
  25329. private _positions32;
  25330. private _normals32;
  25331. private _fixedNormal32;
  25332. private _colors32;
  25333. private _uvs32;
  25334. private _index;
  25335. private _updatable;
  25336. private _pickable;
  25337. private _isVisibilityBoxLocked;
  25338. private _alwaysVisible;
  25339. private _depthSort;
  25340. private _shapeCounter;
  25341. private _copy;
  25342. private _color;
  25343. private _computeParticleColor;
  25344. private _computeParticleTexture;
  25345. private _computeParticleRotation;
  25346. private _computeParticleVertex;
  25347. private _computeBoundingBox;
  25348. private _depthSortParticles;
  25349. private _camera;
  25350. private _mustUnrotateFixedNormals;
  25351. private _particlesIntersect;
  25352. private _needs32Bits;
  25353. /**
  25354. * Creates a SPS (Solid Particle System) object.
  25355. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25356. * @param scene (Scene) is the scene in which the SPS is added.
  25357. * @param options defines the options of the sps e.g.
  25358. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25359. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25360. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25361. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25362. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25363. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25364. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25365. */
  25366. constructor(name: string, scene: Scene, options?: {
  25367. updatable?: boolean;
  25368. isPickable?: boolean;
  25369. enableDepthSort?: boolean;
  25370. particleIntersection?: boolean;
  25371. boundingSphereOnly?: boolean;
  25372. bSphereRadiusFactor?: number;
  25373. });
  25374. /**
  25375. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25376. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25377. * @returns the created mesh
  25378. */
  25379. buildMesh(): Mesh;
  25380. /**
  25381. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25382. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25383. * Thus the particles generated from `digest()` have their property `position` set yet.
  25384. * @param mesh ( Mesh ) is the mesh to be digested
  25385. * @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
  25386. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25387. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25388. * @returns the current SPS
  25389. */
  25390. digest(mesh: Mesh, options?: {
  25391. facetNb?: number;
  25392. number?: number;
  25393. delta?: number;
  25394. }): SolidParticleSystem;
  25395. private _unrotateFixedNormals;
  25396. private _resetCopy;
  25397. private _meshBuilder;
  25398. private _posToShape;
  25399. private _uvsToShapeUV;
  25400. private _addParticle;
  25401. /**
  25402. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25403. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25404. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25405. * @param nb (positive integer) the number of particles to be created from this model
  25406. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25407. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25408. * @returns the number of shapes in the system
  25409. */
  25410. addShape(mesh: Mesh, nb: number, options?: {
  25411. positionFunction?: any;
  25412. vertexFunction?: any;
  25413. }): number;
  25414. private _rebuildParticle;
  25415. /**
  25416. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25417. * @returns the SPS.
  25418. */
  25419. rebuildMesh(): SolidParticleSystem;
  25420. /**
  25421. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25422. * This method calls `updateParticle()` for each particle of the SPS.
  25423. * For an animated SPS, it is usually called within the render loop.
  25424. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25425. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25426. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25427. * @returns the SPS.
  25428. */
  25429. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25430. /**
  25431. * Disposes the SPS.
  25432. */
  25433. dispose(): void;
  25434. /**
  25435. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25437. * @returns the SPS.
  25438. */
  25439. refreshVisibleSize(): SolidParticleSystem;
  25440. /**
  25441. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25442. * @param size the size (float) of the visibility box
  25443. * note : this doesn't lock the SPS mesh bounding box.
  25444. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25445. */
  25446. setVisibilityBox(size: number): void;
  25447. /**
  25448. * Gets whether the SPS as always visible or not
  25449. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25450. */
  25451. /**
  25452. * Sets the SPS as always visible or not
  25453. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25454. */
  25455. isAlwaysVisible: boolean;
  25456. /**
  25457. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25458. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25459. */
  25460. /**
  25461. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25462. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25463. */
  25464. isVisibilityBoxLocked: boolean;
  25465. /**
  25466. * Tells to `setParticles()` to compute the particle rotations or not.
  25467. * Default value : true. The SPS is faster when it's set to false.
  25468. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25469. */
  25470. /**
  25471. * Gets if `setParticles()` computes the particle rotations or not.
  25472. * Default value : true. The SPS is faster when it's set to false.
  25473. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25474. */
  25475. computeParticleRotation: boolean;
  25476. /**
  25477. * Tells to `setParticles()` to compute the particle colors or not.
  25478. * Default value : true. The SPS is faster when it's set to false.
  25479. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25480. */
  25481. /**
  25482. * Gets if `setParticles()` computes the particle colors or not.
  25483. * Default value : true. The SPS is faster when it's set to false.
  25484. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25485. */
  25486. computeParticleColor: boolean;
  25487. /**
  25488. * Gets if `setParticles()` computes the particle textures or not.
  25489. * Default value : true. The SPS is faster when it's set to false.
  25490. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25491. */
  25492. computeParticleTexture: boolean;
  25493. /**
  25494. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25495. * Default value : false. The SPS is faster when it's set to false.
  25496. * Note : the particle custom vertex positions aren't stored values.
  25497. */
  25498. /**
  25499. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25500. * Default value : false. The SPS is faster when it's set to false.
  25501. * Note : the particle custom vertex positions aren't stored values.
  25502. */
  25503. computeParticleVertex: boolean;
  25504. /**
  25505. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25506. */
  25507. /**
  25508. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25509. */
  25510. computeBoundingBox: boolean;
  25511. /**
  25512. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25513. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25514. * Default : `true`
  25515. */
  25516. /**
  25517. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25518. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25519. * Default : `true`
  25520. */
  25521. depthSortParticles: boolean;
  25522. /**
  25523. * This function does nothing. It may be overwritten to set all the particle first values.
  25524. * The SPS doesn't call this function, you may have to call it by your own.
  25525. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25526. */
  25527. initParticles(): void;
  25528. /**
  25529. * This function does nothing. It may be overwritten to recycle a particle.
  25530. * The SPS doesn't call this function, you may have to call it by your own.
  25531. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25532. * @param particle The particle to recycle
  25533. * @returns the recycled particle
  25534. */
  25535. recycleParticle(particle: SolidParticle): SolidParticle;
  25536. /**
  25537. * Updates a particle : this function should be overwritten by the user.
  25538. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25540. * @example : just set a particle position or velocity and recycle conditions
  25541. * @param particle The particle to update
  25542. * @returns the updated particle
  25543. */
  25544. updateParticle(particle: SolidParticle): SolidParticle;
  25545. /**
  25546. * Updates a vertex of a particle : it can be overwritten by the user.
  25547. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25548. * @param particle the current particle
  25549. * @param vertex the current index of the current particle
  25550. * @param pt the index of the current vertex in the particle shape
  25551. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25552. * @example : just set a vertex particle position
  25553. * @returns the updated vertex
  25554. */
  25555. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25556. /**
  25557. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25558. * This does nothing and may be overwritten by the user.
  25559. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25560. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25561. * @param update the boolean update value actually passed to setParticles()
  25562. */
  25563. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25564. /**
  25565. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25566. * This will be passed three parameters.
  25567. * This does nothing and may be overwritten by the user.
  25568. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25569. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25570. * @param update the boolean update value actually passed to setParticles()
  25571. */
  25572. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25573. }
  25574. }
  25575. declare module BABYLON {
  25576. /**
  25577. * Represents one particle of a solid particle system.
  25578. */
  25579. export class SolidParticle {
  25580. /**
  25581. * particle global index
  25582. */
  25583. idx: number;
  25584. /**
  25585. * The color of the particle
  25586. */
  25587. color: Nullable<Color4>;
  25588. /**
  25589. * The world space position of the particle.
  25590. */
  25591. position: Vector3;
  25592. /**
  25593. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25594. */
  25595. rotation: Vector3;
  25596. /**
  25597. * The world space rotation quaternion of the particle.
  25598. */
  25599. rotationQuaternion: Nullable<Quaternion>;
  25600. /**
  25601. * The scaling of the particle.
  25602. */
  25603. scaling: Vector3;
  25604. /**
  25605. * The uvs of the particle.
  25606. */
  25607. uvs: Vector4;
  25608. /**
  25609. * The current speed of the particle.
  25610. */
  25611. velocity: Vector3;
  25612. /**
  25613. * The pivot point in the particle local space.
  25614. */
  25615. pivot: Vector3;
  25616. /**
  25617. * Must the particle be translated from its pivot point in its local space ?
  25618. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25619. * Default : false
  25620. */
  25621. translateFromPivot: boolean;
  25622. /**
  25623. * Is the particle active or not ?
  25624. */
  25625. alive: boolean;
  25626. /**
  25627. * Is the particle visible or not ?
  25628. */
  25629. isVisible: boolean;
  25630. /**
  25631. * Index of this particle in the global "positions" array (Internal use)
  25632. * @hidden
  25633. */
  25634. _pos: number;
  25635. /**
  25636. * @hidden Index of this particle in the global "indices" array (Internal use)
  25637. */
  25638. _ind: number;
  25639. /**
  25640. * @hidden ModelShape of this particle (Internal use)
  25641. */
  25642. _model: ModelShape;
  25643. /**
  25644. * ModelShape id of this particle
  25645. */
  25646. shapeId: number;
  25647. /**
  25648. * Index of the particle in its shape id
  25649. */
  25650. idxInShape: number;
  25651. /**
  25652. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25653. */
  25654. _modelBoundingInfo: BoundingInfo;
  25655. /**
  25656. * @hidden Particle BoundingInfo object (Internal use)
  25657. */
  25658. _boundingInfo: BoundingInfo;
  25659. /**
  25660. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25661. */
  25662. _sps: SolidParticleSystem;
  25663. /**
  25664. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25665. */
  25666. _stillInvisible: boolean;
  25667. /**
  25668. * @hidden Last computed particle rotation matrix
  25669. */
  25670. _rotationMatrix: number[];
  25671. /**
  25672. * Parent particle Id, if any.
  25673. * Default null.
  25674. */
  25675. parentId: Nullable<number>;
  25676. /**
  25677. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25678. * The possible values are :
  25679. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25680. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25681. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25682. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25683. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25684. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25685. * */
  25686. cullingStrategy: number;
  25687. /**
  25688. * @hidden Internal global position in the SPS.
  25689. */
  25690. _globalPosition: Vector3;
  25691. /**
  25692. * Creates a Solid Particle object.
  25693. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25694. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25695. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25696. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25697. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25698. * @param shapeId (integer) is the model shape identifier in the SPS.
  25699. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25700. * @param sps defines the sps it is associated to
  25701. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25702. */
  25703. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25704. /**
  25705. * Legacy support, changed scale to scaling
  25706. */
  25707. /**
  25708. * Legacy support, changed scale to scaling
  25709. */
  25710. scale: Vector3;
  25711. /**
  25712. * Legacy support, changed quaternion to rotationQuaternion
  25713. */
  25714. /**
  25715. * Legacy support, changed quaternion to rotationQuaternion
  25716. */
  25717. quaternion: Nullable<Quaternion>;
  25718. /**
  25719. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25720. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25721. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25722. * @returns true if it intersects
  25723. */
  25724. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25725. /**
  25726. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25727. * A particle is in the frustum if its bounding box intersects the frustum
  25728. * @param frustumPlanes defines the frustum to test
  25729. * @returns true if the particle is in the frustum planes
  25730. */
  25731. isInFrustum(frustumPlanes: Plane[]): boolean;
  25732. /**
  25733. * get the rotation matrix of the particle
  25734. * @hidden
  25735. */
  25736. getRotationMatrix(m: Matrix): void;
  25737. }
  25738. /**
  25739. * Represents the shape of the model used by one particle of a solid particle system.
  25740. * SPS internal tool, don't use it manually.
  25741. */
  25742. export class ModelShape {
  25743. /**
  25744. * The shape id
  25745. * @hidden
  25746. */
  25747. shapeID: number;
  25748. /**
  25749. * flat array of model positions (internal use)
  25750. * @hidden
  25751. */
  25752. _shape: Vector3[];
  25753. /**
  25754. * flat array of model UVs (internal use)
  25755. * @hidden
  25756. */
  25757. _shapeUV: number[];
  25758. /**
  25759. * length of the shape in the model indices array (internal use)
  25760. * @hidden
  25761. */
  25762. _indicesLength: number;
  25763. /**
  25764. * Custom position function (internal use)
  25765. * @hidden
  25766. */
  25767. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25768. /**
  25769. * Custom vertex function (internal use)
  25770. * @hidden
  25771. */
  25772. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25773. /**
  25774. * 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.
  25775. * SPS internal tool, don't use it manually.
  25776. * @hidden
  25777. */
  25778. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25779. }
  25780. /**
  25781. * Represents a Depth Sorted Particle in the solid particle system.
  25782. */
  25783. export class DepthSortedParticle {
  25784. /**
  25785. * Index of the particle in the "indices" array
  25786. */
  25787. ind: number;
  25788. /**
  25789. * Length of the particle shape in the "indices" array
  25790. */
  25791. indicesLength: number;
  25792. /**
  25793. * Squared distance from the particle to the camera
  25794. */
  25795. sqDistance: number;
  25796. }
  25797. }
  25798. declare module BABYLON {
  25799. /**
  25800. * @hidden
  25801. */
  25802. export class _MeshCollisionData {
  25803. _checkCollisions: boolean;
  25804. _collisionMask: number;
  25805. _collisionGroup: number;
  25806. _collider: Nullable<Collider>;
  25807. _oldPositionForCollisions: Vector3;
  25808. _diffPositionForCollisions: Vector3;
  25809. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25810. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25811. }
  25812. }
  25813. declare module BABYLON {
  25814. /** @hidden */
  25815. class _FacetDataStorage {
  25816. facetPositions: Vector3[];
  25817. facetNormals: Vector3[];
  25818. facetPartitioning: number[][];
  25819. facetNb: number;
  25820. partitioningSubdivisions: number;
  25821. partitioningBBoxRatio: number;
  25822. facetDataEnabled: boolean;
  25823. facetParameters: any;
  25824. bbSize: Vector3;
  25825. subDiv: {
  25826. max: number;
  25827. X: number;
  25828. Y: number;
  25829. Z: number;
  25830. };
  25831. facetDepthSort: boolean;
  25832. facetDepthSortEnabled: boolean;
  25833. depthSortedIndices: IndicesArray;
  25834. depthSortedFacets: {
  25835. ind: number;
  25836. sqDistance: number;
  25837. }[];
  25838. facetDepthSortFunction: (f1: {
  25839. ind: number;
  25840. sqDistance: number;
  25841. }, f2: {
  25842. ind: number;
  25843. sqDistance: number;
  25844. }) => number;
  25845. facetDepthSortFrom: Vector3;
  25846. facetDepthSortOrigin: Vector3;
  25847. invertedMatrix: Matrix;
  25848. }
  25849. /**
  25850. * @hidden
  25851. **/
  25852. class _InternalAbstractMeshDataInfo {
  25853. _hasVertexAlpha: boolean;
  25854. _useVertexColors: boolean;
  25855. _numBoneInfluencers: number;
  25856. _applyFog: boolean;
  25857. _receiveShadows: boolean;
  25858. _facetData: _FacetDataStorage;
  25859. _visibility: number;
  25860. _skeleton: Nullable<Skeleton>;
  25861. _layerMask: number;
  25862. _computeBonesUsingShaders: boolean;
  25863. _isActive: boolean;
  25864. _onlyForInstances: boolean;
  25865. _isActiveIntermediate: boolean;
  25866. _onlyForInstancesIntermediate: boolean;
  25867. }
  25868. /**
  25869. * Class used to store all common mesh properties
  25870. */
  25871. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25872. /** No occlusion */
  25873. static OCCLUSION_TYPE_NONE: number;
  25874. /** Occlusion set to optimisitic */
  25875. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25876. /** Occlusion set to strict */
  25877. static OCCLUSION_TYPE_STRICT: number;
  25878. /** Use an accurante occlusion algorithm */
  25879. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25880. /** Use a conservative occlusion algorithm */
  25881. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25882. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25883. * Test order :
  25884. * Is the bounding sphere outside the frustum ?
  25885. * If not, are the bounding box vertices outside the frustum ?
  25886. * It not, then the cullable object is in the frustum.
  25887. */
  25888. static readonly CULLINGSTRATEGY_STANDARD: number;
  25889. /** Culling strategy : Bounding Sphere Only.
  25890. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25891. * It's also less accurate than the standard because some not visible objects can still be selected.
  25892. * Test : is the bounding sphere outside the frustum ?
  25893. * If not, then the cullable object is in the frustum.
  25894. */
  25895. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25896. /** Culling strategy : Optimistic Inclusion.
  25897. * This in an inclusion test first, then the standard exclusion test.
  25898. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25899. * 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.
  25900. * Anyway, it's as accurate as the standard strategy.
  25901. * Test :
  25902. * Is the cullable object bounding sphere center in the frustum ?
  25903. * If not, apply the default culling strategy.
  25904. */
  25905. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25906. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25907. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25908. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25909. * 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.
  25910. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25911. * Test :
  25912. * Is the cullable object bounding sphere center in the frustum ?
  25913. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25914. */
  25915. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25916. /**
  25917. * No billboard
  25918. */
  25919. static readonly BILLBOARDMODE_NONE: number;
  25920. /** Billboard on X axis */
  25921. static readonly BILLBOARDMODE_X: number;
  25922. /** Billboard on Y axis */
  25923. static readonly BILLBOARDMODE_Y: number;
  25924. /** Billboard on Z axis */
  25925. static readonly BILLBOARDMODE_Z: number;
  25926. /** Billboard on all axes */
  25927. static readonly BILLBOARDMODE_ALL: number;
  25928. /** Billboard on using position instead of orientation */
  25929. static readonly BILLBOARDMODE_USE_POSITION: number;
  25930. /** @hidden */
  25931. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25932. /**
  25933. * The culling strategy to use to check whether the mesh must be rendered or not.
  25934. * This value can be changed at any time and will be used on the next render mesh selection.
  25935. * The possible values are :
  25936. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25937. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25940. * Please read each static variable documentation to get details about the culling process.
  25941. * */
  25942. cullingStrategy: number;
  25943. /**
  25944. * Gets the number of facets in the mesh
  25945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25946. */
  25947. readonly facetNb: number;
  25948. /**
  25949. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25951. */
  25952. partitioningSubdivisions: number;
  25953. /**
  25954. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25955. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25957. */
  25958. partitioningBBoxRatio: number;
  25959. /**
  25960. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25961. * Works only for updatable meshes.
  25962. * Doesn't work with multi-materials
  25963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25964. */
  25965. mustDepthSortFacets: boolean;
  25966. /**
  25967. * The location (Vector3) where the facet depth sort must be computed from.
  25968. * By default, the active camera position.
  25969. * Used only when facet depth sort is enabled
  25970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25971. */
  25972. facetDepthSortFrom: Vector3;
  25973. /**
  25974. * gets a boolean indicating if facetData is enabled
  25975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25976. */
  25977. readonly isFacetDataEnabled: boolean;
  25978. /** @hidden */
  25979. _updateNonUniformScalingState(value: boolean): boolean;
  25980. /**
  25981. * An event triggered when this mesh collides with another one
  25982. */
  25983. onCollideObservable: Observable<AbstractMesh>;
  25984. /** Set a function to call when this mesh collides with another one */
  25985. onCollide: () => void;
  25986. /**
  25987. * An event triggered when the collision's position changes
  25988. */
  25989. onCollisionPositionChangeObservable: Observable<Vector3>;
  25990. /** Set a function to call when the collision's position changes */
  25991. onCollisionPositionChange: () => void;
  25992. /**
  25993. * An event triggered when material is changed
  25994. */
  25995. onMaterialChangedObservable: Observable<AbstractMesh>;
  25996. /**
  25997. * Gets or sets the orientation for POV movement & rotation
  25998. */
  25999. definedFacingForward: boolean;
  26000. /** @hidden */
  26001. _occlusionQuery: Nullable<WebGLQuery>;
  26002. /** @hidden */
  26003. _renderingGroup: Nullable<RenderingGroup>;
  26004. /**
  26005. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26006. */
  26007. /**
  26008. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26009. */
  26010. visibility: number;
  26011. /** Gets or sets the alpha index used to sort transparent meshes
  26012. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26013. */
  26014. alphaIndex: number;
  26015. /**
  26016. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26017. */
  26018. isVisible: boolean;
  26019. /**
  26020. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26021. */
  26022. isPickable: boolean;
  26023. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26024. showSubMeshesBoundingBox: boolean;
  26025. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26026. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26027. */
  26028. isBlocker: boolean;
  26029. /**
  26030. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26031. */
  26032. enablePointerMoveEvents: boolean;
  26033. /**
  26034. * Specifies the rendering group id for this mesh (0 by default)
  26035. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26036. */
  26037. renderingGroupId: number;
  26038. private _material;
  26039. /** Gets or sets current material */
  26040. material: Nullable<Material>;
  26041. /**
  26042. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26043. * @see http://doc.babylonjs.com/babylon101/shadows
  26044. */
  26045. receiveShadows: boolean;
  26046. /** Defines color to use when rendering outline */
  26047. outlineColor: Color3;
  26048. /** Define width to use when rendering outline */
  26049. outlineWidth: number;
  26050. /** Defines color to use when rendering overlay */
  26051. overlayColor: Color3;
  26052. /** Defines alpha to use when rendering overlay */
  26053. overlayAlpha: number;
  26054. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26055. hasVertexAlpha: boolean;
  26056. /** 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) */
  26057. useVertexColors: boolean;
  26058. /**
  26059. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26060. */
  26061. computeBonesUsingShaders: boolean;
  26062. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26063. numBoneInfluencers: number;
  26064. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26065. applyFog: boolean;
  26066. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26067. useOctreeForRenderingSelection: boolean;
  26068. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26069. useOctreeForPicking: boolean;
  26070. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26071. useOctreeForCollisions: boolean;
  26072. /**
  26073. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26074. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26075. */
  26076. layerMask: number;
  26077. /**
  26078. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26079. */
  26080. alwaysSelectAsActiveMesh: boolean;
  26081. /**
  26082. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26083. */
  26084. doNotSyncBoundingInfo: boolean;
  26085. /**
  26086. * Gets or sets the current action manager
  26087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26088. */
  26089. actionManager: Nullable<AbstractActionManager>;
  26090. private _meshCollisionData;
  26091. /**
  26092. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26094. */
  26095. ellipsoid: Vector3;
  26096. /**
  26097. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26099. */
  26100. ellipsoidOffset: Vector3;
  26101. /**
  26102. * Gets or sets a collision mask used to mask collisions (default is -1).
  26103. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26104. */
  26105. collisionMask: number;
  26106. /**
  26107. * Gets or sets the current collision group mask (-1 by default).
  26108. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26109. */
  26110. collisionGroup: number;
  26111. /**
  26112. * Defines edge width used when edgesRenderer is enabled
  26113. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26114. */
  26115. edgesWidth: number;
  26116. /**
  26117. * Defines edge color used when edgesRenderer is enabled
  26118. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26119. */
  26120. edgesColor: Color4;
  26121. /** @hidden */
  26122. _edgesRenderer: Nullable<IEdgesRenderer>;
  26123. /** @hidden */
  26124. _masterMesh: Nullable<AbstractMesh>;
  26125. /** @hidden */
  26126. _boundingInfo: Nullable<BoundingInfo>;
  26127. /** @hidden */
  26128. _renderId: number;
  26129. /**
  26130. * Gets or sets the list of subMeshes
  26131. * @see http://doc.babylonjs.com/how_to/multi_materials
  26132. */
  26133. subMeshes: SubMesh[];
  26134. /** @hidden */
  26135. _intersectionsInProgress: AbstractMesh[];
  26136. /** @hidden */
  26137. _unIndexed: boolean;
  26138. /** @hidden */
  26139. _lightSources: Light[];
  26140. /** Gets the list of lights affecting that mesh */
  26141. readonly lightSources: Light[];
  26142. /** @hidden */
  26143. readonly _positions: Nullable<Vector3[]>;
  26144. /** @hidden */
  26145. _waitingData: {
  26146. lods: Nullable<any>;
  26147. actions: Nullable<any>;
  26148. freezeWorldMatrix: Nullable<boolean>;
  26149. };
  26150. /** @hidden */
  26151. _bonesTransformMatrices: Nullable<Float32Array>;
  26152. /** @hidden */
  26153. _transformMatrixTexture: Nullable<RawTexture>;
  26154. /**
  26155. * Gets or sets a skeleton to apply skining transformations
  26156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26157. */
  26158. skeleton: Nullable<Skeleton>;
  26159. /**
  26160. * An event triggered when the mesh is rebuilt.
  26161. */
  26162. onRebuildObservable: Observable<AbstractMesh>;
  26163. /**
  26164. * Creates a new AbstractMesh
  26165. * @param name defines the name of the mesh
  26166. * @param scene defines the hosting scene
  26167. */
  26168. constructor(name: string, scene?: Nullable<Scene>);
  26169. /**
  26170. * Returns the string "AbstractMesh"
  26171. * @returns "AbstractMesh"
  26172. */
  26173. getClassName(): string;
  26174. /**
  26175. * Gets a string representation of the current mesh
  26176. * @param fullDetails defines a boolean indicating if full details must be included
  26177. * @returns a string representation of the current mesh
  26178. */
  26179. toString(fullDetails?: boolean): string;
  26180. /**
  26181. * @hidden
  26182. */
  26183. protected _getEffectiveParent(): Nullable<Node>;
  26184. /** @hidden */
  26185. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26186. /** @hidden */
  26187. _rebuild(): void;
  26188. /** @hidden */
  26189. _resyncLightSources(): void;
  26190. /** @hidden */
  26191. _resyncLighSource(light: Light): void;
  26192. /** @hidden */
  26193. _unBindEffect(): void;
  26194. /** @hidden */
  26195. _removeLightSource(light: Light, dispose: boolean): void;
  26196. private _markSubMeshesAsDirty;
  26197. /** @hidden */
  26198. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26199. /** @hidden */
  26200. _markSubMeshesAsAttributesDirty(): void;
  26201. /** @hidden */
  26202. _markSubMeshesAsMiscDirty(): void;
  26203. /**
  26204. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26205. */
  26206. scaling: Vector3;
  26207. /**
  26208. * Returns true if the mesh is blocked. Implemented by child classes
  26209. */
  26210. readonly isBlocked: boolean;
  26211. /**
  26212. * Returns the mesh itself by default. Implemented by child classes
  26213. * @param camera defines the camera to use to pick the right LOD level
  26214. * @returns the currentAbstractMesh
  26215. */
  26216. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26217. /**
  26218. * Returns 0 by default. Implemented by child classes
  26219. * @returns an integer
  26220. */
  26221. getTotalVertices(): number;
  26222. /**
  26223. * Returns a positive integer : the total number of indices in this mesh geometry.
  26224. * @returns the numner of indices or zero if the mesh has no geometry.
  26225. */
  26226. getTotalIndices(): number;
  26227. /**
  26228. * Returns null by default. Implemented by child classes
  26229. * @returns null
  26230. */
  26231. getIndices(): Nullable<IndicesArray>;
  26232. /**
  26233. * Returns the array of the requested vertex data kind. Implemented by child classes
  26234. * @param kind defines the vertex data kind to use
  26235. * @returns null
  26236. */
  26237. getVerticesData(kind: string): Nullable<FloatArray>;
  26238. /**
  26239. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26240. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26241. * Note that a new underlying VertexBuffer object is created each call.
  26242. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26243. * @param kind defines vertex data kind:
  26244. * * VertexBuffer.PositionKind
  26245. * * VertexBuffer.UVKind
  26246. * * VertexBuffer.UV2Kind
  26247. * * VertexBuffer.UV3Kind
  26248. * * VertexBuffer.UV4Kind
  26249. * * VertexBuffer.UV5Kind
  26250. * * VertexBuffer.UV6Kind
  26251. * * VertexBuffer.ColorKind
  26252. * * VertexBuffer.MatricesIndicesKind
  26253. * * VertexBuffer.MatricesIndicesExtraKind
  26254. * * VertexBuffer.MatricesWeightsKind
  26255. * * VertexBuffer.MatricesWeightsExtraKind
  26256. * @param data defines the data source
  26257. * @param updatable defines if the data must be flagged as updatable (or static)
  26258. * @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
  26259. * @returns the current mesh
  26260. */
  26261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26262. /**
  26263. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26264. * If the mesh has no geometry, it is simply returned as it is.
  26265. * @param kind defines vertex data kind:
  26266. * * VertexBuffer.PositionKind
  26267. * * VertexBuffer.UVKind
  26268. * * VertexBuffer.UV2Kind
  26269. * * VertexBuffer.UV3Kind
  26270. * * VertexBuffer.UV4Kind
  26271. * * VertexBuffer.UV5Kind
  26272. * * VertexBuffer.UV6Kind
  26273. * * VertexBuffer.ColorKind
  26274. * * VertexBuffer.MatricesIndicesKind
  26275. * * VertexBuffer.MatricesIndicesExtraKind
  26276. * * VertexBuffer.MatricesWeightsKind
  26277. * * VertexBuffer.MatricesWeightsExtraKind
  26278. * @param data defines the data source
  26279. * @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
  26280. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26281. * @returns the current mesh
  26282. */
  26283. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26284. /**
  26285. * Sets the mesh indices,
  26286. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26287. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26288. * @param totalVertices Defines the total number of vertices
  26289. * @returns the current mesh
  26290. */
  26291. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26292. /**
  26293. * Gets a boolean indicating if specific vertex data is present
  26294. * @param kind defines the vertex data kind to use
  26295. * @returns true is data kind is present
  26296. */
  26297. isVerticesDataPresent(kind: string): boolean;
  26298. /**
  26299. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26300. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26301. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26302. * @returns a BoundingInfo
  26303. */
  26304. getBoundingInfo(): BoundingInfo;
  26305. /**
  26306. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26307. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26308. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26309. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26310. * @returns the current mesh
  26311. */
  26312. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26313. /**
  26314. * Overwrite the current bounding info
  26315. * @param boundingInfo defines the new bounding info
  26316. * @returns the current mesh
  26317. */
  26318. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26319. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26320. readonly useBones: boolean;
  26321. /** @hidden */
  26322. _preActivate(): void;
  26323. /** @hidden */
  26324. _preActivateForIntermediateRendering(renderId: number): void;
  26325. /** @hidden */
  26326. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26327. /** @hidden */
  26328. _postActivate(): void;
  26329. /** @hidden */
  26330. _freeze(): void;
  26331. /** @hidden */
  26332. _unFreeze(): void;
  26333. /**
  26334. * Gets the current world matrix
  26335. * @returns a Matrix
  26336. */
  26337. getWorldMatrix(): Matrix;
  26338. /** @hidden */
  26339. _getWorldMatrixDeterminant(): number;
  26340. /**
  26341. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26342. */
  26343. readonly isAnInstance: boolean;
  26344. /**
  26345. * Gets a boolean indicating if this mesh has instances
  26346. */
  26347. readonly hasInstances: boolean;
  26348. /**
  26349. * Perform relative position change from the point of view of behind the front of the mesh.
  26350. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26351. * Supports definition of mesh facing forward or backward
  26352. * @param amountRight defines the distance on the right axis
  26353. * @param amountUp defines the distance on the up axis
  26354. * @param amountForward defines the distance on the forward axis
  26355. * @returns the current mesh
  26356. */
  26357. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26358. /**
  26359. * Calculate relative position change from the point of view of behind the front of the mesh.
  26360. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26361. * Supports definition of mesh facing forward or backward
  26362. * @param amountRight defines the distance on the right axis
  26363. * @param amountUp defines the distance on the up axis
  26364. * @param amountForward defines the distance on the forward axis
  26365. * @returns the new displacement vector
  26366. */
  26367. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26368. /**
  26369. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26370. * Supports definition of mesh facing forward or backward
  26371. * @param flipBack defines the flip
  26372. * @param twirlClockwise defines the twirl
  26373. * @param tiltRight defines the tilt
  26374. * @returns the current mesh
  26375. */
  26376. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26377. /**
  26378. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26379. * Supports definition of mesh facing forward or backward.
  26380. * @param flipBack defines the flip
  26381. * @param twirlClockwise defines the twirl
  26382. * @param tiltRight defines the tilt
  26383. * @returns the new rotation vector
  26384. */
  26385. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26386. /**
  26387. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26388. * This means the mesh underlying bounding box and sphere are recomputed.
  26389. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26390. * @returns the current mesh
  26391. */
  26392. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26393. /** @hidden */
  26394. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26395. /** @hidden */
  26396. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26397. /** @hidden */
  26398. _updateBoundingInfo(): AbstractMesh;
  26399. /** @hidden */
  26400. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26401. /** @hidden */
  26402. protected _afterComputeWorldMatrix(): void;
  26403. /** @hidden */
  26404. readonly _effectiveMesh: AbstractMesh;
  26405. /**
  26406. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26407. * A mesh is in the frustum if its bounding box intersects the frustum
  26408. * @param frustumPlanes defines the frustum to test
  26409. * @returns true if the mesh is in the frustum planes
  26410. */
  26411. isInFrustum(frustumPlanes: Plane[]): boolean;
  26412. /**
  26413. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26414. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26415. * @param frustumPlanes defines the frustum to test
  26416. * @returns true if the mesh is completely in the frustum planes
  26417. */
  26418. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26419. /**
  26420. * True if the mesh intersects another mesh or a SolidParticle object
  26421. * @param mesh defines a target mesh or SolidParticle to test
  26422. * @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)
  26423. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26424. * @returns true if there is an intersection
  26425. */
  26426. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26427. /**
  26428. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26429. * @param point defines the point to test
  26430. * @returns true if there is an intersection
  26431. */
  26432. intersectsPoint(point: Vector3): boolean;
  26433. /**
  26434. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26436. */
  26437. checkCollisions: boolean;
  26438. /**
  26439. * Gets Collider object used to compute collisions (not physics)
  26440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26441. */
  26442. readonly collider: Nullable<Collider>;
  26443. /**
  26444. * Move the mesh using collision engine
  26445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26446. * @param displacement defines the requested displacement vector
  26447. * @returns the current mesh
  26448. */
  26449. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26450. private _onCollisionPositionChange;
  26451. /** @hidden */
  26452. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26453. /** @hidden */
  26454. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26455. /** @hidden */
  26456. _checkCollision(collider: Collider): AbstractMesh;
  26457. /** @hidden */
  26458. _generatePointsArray(): boolean;
  26459. /**
  26460. * Checks if the passed Ray intersects with the mesh
  26461. * @param ray defines the ray to use
  26462. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26463. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26464. * @returns the picking info
  26465. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26466. */
  26467. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26468. /**
  26469. * Clones the current mesh
  26470. * @param name defines the mesh name
  26471. * @param newParent defines the new mesh parent
  26472. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26473. * @returns the new mesh
  26474. */
  26475. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26476. /**
  26477. * Disposes all the submeshes of the current meshnp
  26478. * @returns the current mesh
  26479. */
  26480. releaseSubMeshes(): AbstractMesh;
  26481. /**
  26482. * Releases resources associated with this abstract mesh.
  26483. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26484. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26485. */
  26486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26487. /**
  26488. * Adds the passed mesh as a child to the current mesh
  26489. * @param mesh defines the child mesh
  26490. * @returns the current mesh
  26491. */
  26492. addChild(mesh: AbstractMesh): AbstractMesh;
  26493. /**
  26494. * Removes the passed mesh from the current mesh children list
  26495. * @param mesh defines the child mesh
  26496. * @returns the current mesh
  26497. */
  26498. removeChild(mesh: AbstractMesh): AbstractMesh;
  26499. /** @hidden */
  26500. private _initFacetData;
  26501. /**
  26502. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26503. * This method can be called within the render loop.
  26504. * 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
  26505. * @returns the current mesh
  26506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26507. */
  26508. updateFacetData(): AbstractMesh;
  26509. /**
  26510. * Returns the facetLocalNormals array.
  26511. * The normals are expressed in the mesh local spac
  26512. * @returns an array of Vector3
  26513. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26514. */
  26515. getFacetLocalNormals(): Vector3[];
  26516. /**
  26517. * Returns the facetLocalPositions array.
  26518. * The facet positions are expressed in the mesh local space
  26519. * @returns an array of Vector3
  26520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26521. */
  26522. getFacetLocalPositions(): Vector3[];
  26523. /**
  26524. * Returns the facetLocalPartioning array
  26525. * @returns an array of array of numbers
  26526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26527. */
  26528. getFacetLocalPartitioning(): number[][];
  26529. /**
  26530. * Returns the i-th facet position in the world system.
  26531. * This method allocates a new Vector3 per call
  26532. * @param i defines the facet index
  26533. * @returns a new Vector3
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26535. */
  26536. getFacetPosition(i: number): Vector3;
  26537. /**
  26538. * Sets the reference Vector3 with the i-th facet position in the world system
  26539. * @param i defines the facet index
  26540. * @param ref defines the target vector
  26541. * @returns the current mesh
  26542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26543. */
  26544. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26545. /**
  26546. * Returns the i-th facet normal in the world system.
  26547. * This method allocates a new Vector3 per call
  26548. * @param i defines the facet index
  26549. * @returns a new Vector3
  26550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26551. */
  26552. getFacetNormal(i: number): Vector3;
  26553. /**
  26554. * Sets the reference Vector3 with the i-th facet normal in the world system
  26555. * @param i defines the facet index
  26556. * @param ref defines the target vector
  26557. * @returns the current mesh
  26558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26559. */
  26560. getFacetNormalToRef(i: number, ref: Vector3): this;
  26561. /**
  26562. * 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)
  26563. * @param x defines x coordinate
  26564. * @param y defines y coordinate
  26565. * @param z defines z coordinate
  26566. * @returns the array of facet indexes
  26567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26568. */
  26569. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26570. /**
  26571. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26572. * @param projected sets as the (x,y,z) world projection on the facet
  26573. * @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
  26574. * @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
  26575. * @param x defines x coordinate
  26576. * @param y defines y coordinate
  26577. * @param z defines z coordinate
  26578. * @returns the face index if found (or null instead)
  26579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26580. */
  26581. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26582. /**
  26583. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26584. * @param projected sets as the (x,y,z) local projection on the facet
  26585. * @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
  26586. * @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
  26587. * @param x defines x coordinate
  26588. * @param y defines y coordinate
  26589. * @param z defines z coordinate
  26590. * @returns the face index if found (or null instead)
  26591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26592. */
  26593. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26594. /**
  26595. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26596. * @returns the parameters
  26597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26598. */
  26599. getFacetDataParameters(): any;
  26600. /**
  26601. * Disables the feature FacetData and frees the related memory
  26602. * @returns the current mesh
  26603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26604. */
  26605. disableFacetData(): AbstractMesh;
  26606. /**
  26607. * Updates the AbstractMesh indices array
  26608. * @param indices defines the data source
  26609. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26610. * @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)
  26611. * @returns the current mesh
  26612. */
  26613. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26614. /**
  26615. * Creates new normals data for the mesh
  26616. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26617. * @returns the current mesh
  26618. */
  26619. createNormals(updatable: boolean): AbstractMesh;
  26620. /**
  26621. * Align the mesh with a normal
  26622. * @param normal defines the normal to use
  26623. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26624. * @returns the current mesh
  26625. */
  26626. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26627. /** @hidden */
  26628. _checkOcclusionQuery(): boolean;
  26629. /**
  26630. * Disables the mesh edge rendering mode
  26631. * @returns the currentAbstractMesh
  26632. */
  26633. disableEdgesRendering(): AbstractMesh;
  26634. /**
  26635. * Enables the edge rendering mode on the mesh.
  26636. * This mode makes the mesh edges visible
  26637. * @param epsilon defines the maximal distance between two angles to detect a face
  26638. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26639. * @returns the currentAbstractMesh
  26640. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26641. */
  26642. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26643. }
  26644. }
  26645. declare module BABYLON {
  26646. /**
  26647. * Interface used to define ActionEvent
  26648. */
  26649. export interface IActionEvent {
  26650. /** The mesh or sprite that triggered the action */
  26651. source: any;
  26652. /** The X mouse cursor position at the time of the event */
  26653. pointerX: number;
  26654. /** The Y mouse cursor position at the time of the event */
  26655. pointerY: number;
  26656. /** The mesh that is currently pointed at (can be null) */
  26657. meshUnderPointer: Nullable<AbstractMesh>;
  26658. /** the original (browser) event that triggered the ActionEvent */
  26659. sourceEvent?: any;
  26660. /** additional data for the event */
  26661. additionalData?: any;
  26662. }
  26663. /**
  26664. * ActionEvent is the event being sent when an action is triggered.
  26665. */
  26666. export class ActionEvent implements IActionEvent {
  26667. /** The mesh or sprite that triggered the action */
  26668. source: any;
  26669. /** The X mouse cursor position at the time of the event */
  26670. pointerX: number;
  26671. /** The Y mouse cursor position at the time of the event */
  26672. pointerY: number;
  26673. /** The mesh that is currently pointed at (can be null) */
  26674. meshUnderPointer: Nullable<AbstractMesh>;
  26675. /** the original (browser) event that triggered the ActionEvent */
  26676. sourceEvent?: any;
  26677. /** additional data for the event */
  26678. additionalData?: any;
  26679. /**
  26680. * Creates a new ActionEvent
  26681. * @param source The mesh or sprite that triggered the action
  26682. * @param pointerX The X mouse cursor position at the time of the event
  26683. * @param pointerY The Y mouse cursor position at the time of the event
  26684. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26685. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26686. * @param additionalData additional data for the event
  26687. */
  26688. constructor(
  26689. /** The mesh or sprite that triggered the action */
  26690. source: any,
  26691. /** The X mouse cursor position at the time of the event */
  26692. pointerX: number,
  26693. /** The Y mouse cursor position at the time of the event */
  26694. pointerY: number,
  26695. /** The mesh that is currently pointed at (can be null) */
  26696. meshUnderPointer: Nullable<AbstractMesh>,
  26697. /** the original (browser) event that triggered the ActionEvent */
  26698. sourceEvent?: any,
  26699. /** additional data for the event */
  26700. additionalData?: any);
  26701. /**
  26702. * Helper function to auto-create an ActionEvent from a source mesh.
  26703. * @param source The source mesh that triggered the event
  26704. * @param evt The original (browser) event
  26705. * @param additionalData additional data for the event
  26706. * @returns the new ActionEvent
  26707. */
  26708. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26709. /**
  26710. * Helper function to auto-create an ActionEvent from a source sprite
  26711. * @param source The source sprite that triggered the event
  26712. * @param scene Scene associated with the sprite
  26713. * @param evt The original (browser) event
  26714. * @param additionalData additional data for the event
  26715. * @returns the new ActionEvent
  26716. */
  26717. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26718. /**
  26719. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26720. * @param scene the scene where the event occurred
  26721. * @param evt The original (browser) event
  26722. * @returns the new ActionEvent
  26723. */
  26724. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26725. /**
  26726. * Helper function to auto-create an ActionEvent from a primitive
  26727. * @param prim defines the target primitive
  26728. * @param pointerPos defines the pointer position
  26729. * @param evt The original (browser) event
  26730. * @param additionalData additional data for the event
  26731. * @returns the new ActionEvent
  26732. */
  26733. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26734. }
  26735. }
  26736. declare module BABYLON {
  26737. /**
  26738. * Abstract class used to decouple action Manager from scene and meshes.
  26739. * Do not instantiate.
  26740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26741. */
  26742. export abstract class AbstractActionManager implements IDisposable {
  26743. /** Gets the list of active triggers */
  26744. static Triggers: {
  26745. [key: string]: number;
  26746. };
  26747. /** Gets the cursor to use when hovering items */
  26748. hoverCursor: string;
  26749. /** Gets the list of actions */
  26750. actions: IAction[];
  26751. /**
  26752. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26753. */
  26754. isRecursive: boolean;
  26755. /**
  26756. * Releases all associated resources
  26757. */
  26758. abstract dispose(): void;
  26759. /**
  26760. * Does this action manager has pointer triggers
  26761. */
  26762. abstract readonly hasPointerTriggers: boolean;
  26763. /**
  26764. * Does this action manager has pick triggers
  26765. */
  26766. abstract readonly hasPickTriggers: boolean;
  26767. /**
  26768. * Process a specific trigger
  26769. * @param trigger defines the trigger to process
  26770. * @param evt defines the event details to be processed
  26771. */
  26772. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26773. /**
  26774. * Does this action manager handles actions of any of the given triggers
  26775. * @param triggers defines the triggers to be tested
  26776. * @return a boolean indicating whether one (or more) of the triggers is handled
  26777. */
  26778. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26779. /**
  26780. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26781. * speed.
  26782. * @param triggerA defines the trigger to be tested
  26783. * @param triggerB defines the trigger to be tested
  26784. * @return a boolean indicating whether one (or more) of the triggers is handled
  26785. */
  26786. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26787. /**
  26788. * Does this action manager handles actions of a given trigger
  26789. * @param trigger defines the trigger to be tested
  26790. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26791. * @return whether the trigger is handled
  26792. */
  26793. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26794. /**
  26795. * Serialize this manager to a JSON object
  26796. * @param name defines the property name to store this manager
  26797. * @returns a JSON representation of this manager
  26798. */
  26799. abstract serialize(name: string): any;
  26800. /**
  26801. * Registers an action to this action manager
  26802. * @param action defines the action to be registered
  26803. * @return the action amended (prepared) after registration
  26804. */
  26805. abstract registerAction(action: IAction): Nullable<IAction>;
  26806. /**
  26807. * Unregisters an action to this action manager
  26808. * @param action defines the action to be unregistered
  26809. * @return a boolean indicating whether the action has been unregistered
  26810. */
  26811. abstract unregisterAction(action: IAction): Boolean;
  26812. /**
  26813. * Does exist one action manager with at least one trigger
  26814. **/
  26815. static readonly HasTriggers: boolean;
  26816. /**
  26817. * Does exist one action manager with at least one pick trigger
  26818. **/
  26819. static readonly HasPickTriggers: boolean;
  26820. /**
  26821. * Does exist one action manager that handles actions of a given trigger
  26822. * @param trigger defines the trigger to be tested
  26823. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26824. **/
  26825. static HasSpecificTrigger(trigger: number): boolean;
  26826. }
  26827. }
  26828. declare module BABYLON {
  26829. /**
  26830. * Defines how a node can be built from a string name.
  26831. */
  26832. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26833. /**
  26834. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26835. */
  26836. export class Node implements IBehaviorAware<Node> {
  26837. /** @hidden */
  26838. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26839. private static _NodeConstructors;
  26840. /**
  26841. * Add a new node constructor
  26842. * @param type defines the type name of the node to construct
  26843. * @param constructorFunc defines the constructor function
  26844. */
  26845. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26846. /**
  26847. * Returns a node constructor based on type name
  26848. * @param type defines the type name
  26849. * @param name defines the new node name
  26850. * @param scene defines the hosting scene
  26851. * @param options defines optional options to transmit to constructors
  26852. * @returns the new constructor or null
  26853. */
  26854. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26855. /**
  26856. * Gets or sets the name of the node
  26857. */
  26858. name: string;
  26859. /**
  26860. * Gets or sets the id of the node
  26861. */
  26862. id: string;
  26863. /**
  26864. * Gets or sets the unique id of the node
  26865. */
  26866. uniqueId: number;
  26867. /**
  26868. * Gets or sets a string used to store user defined state for the node
  26869. */
  26870. state: string;
  26871. /**
  26872. * Gets or sets an object used to store user defined information for the node
  26873. */
  26874. metadata: any;
  26875. /**
  26876. * For internal use only. Please do not use.
  26877. */
  26878. reservedDataStore: any;
  26879. /**
  26880. * List of inspectable custom properties (used by the Inspector)
  26881. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26882. */
  26883. inspectableCustomProperties: IInspectable[];
  26884. /**
  26885. * Gets or sets a boolean used to define if the node must be serialized
  26886. */
  26887. doNotSerialize: boolean;
  26888. /** @hidden */
  26889. _isDisposed: boolean;
  26890. /**
  26891. * Gets a list of Animations associated with the node
  26892. */
  26893. animations: Animation[];
  26894. protected _ranges: {
  26895. [name: string]: Nullable<AnimationRange>;
  26896. };
  26897. /**
  26898. * Callback raised when the node is ready to be used
  26899. */
  26900. onReady: Nullable<(node: Node) => void>;
  26901. private _isEnabled;
  26902. private _isParentEnabled;
  26903. private _isReady;
  26904. /** @hidden */
  26905. _currentRenderId: number;
  26906. private _parentUpdateId;
  26907. /** @hidden */
  26908. _childUpdateId: number;
  26909. /** @hidden */
  26910. _waitingParentId: Nullable<string>;
  26911. /** @hidden */
  26912. _scene: Scene;
  26913. /** @hidden */
  26914. _cache: any;
  26915. private _parentNode;
  26916. private _children;
  26917. /** @hidden */
  26918. _worldMatrix: Matrix;
  26919. /** @hidden */
  26920. _worldMatrixDeterminant: number;
  26921. /** @hidden */
  26922. _worldMatrixDeterminantIsDirty: boolean;
  26923. /** @hidden */
  26924. private _sceneRootNodesIndex;
  26925. /**
  26926. * Gets a boolean indicating if the node has been disposed
  26927. * @returns true if the node was disposed
  26928. */
  26929. isDisposed(): boolean;
  26930. /**
  26931. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26932. * @see https://doc.babylonjs.com/how_to/parenting
  26933. */
  26934. parent: Nullable<Node>;
  26935. private addToSceneRootNodes;
  26936. private removeFromSceneRootNodes;
  26937. private _animationPropertiesOverride;
  26938. /**
  26939. * Gets or sets the animation properties override
  26940. */
  26941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26942. /**
  26943. * Gets a string idenfifying the name of the class
  26944. * @returns "Node" string
  26945. */
  26946. getClassName(): string;
  26947. /** @hidden */
  26948. readonly _isNode: boolean;
  26949. /**
  26950. * An event triggered when the mesh is disposed
  26951. */
  26952. onDisposeObservable: Observable<Node>;
  26953. private _onDisposeObserver;
  26954. /**
  26955. * Sets a callback that will be raised when the node will be disposed
  26956. */
  26957. onDispose: () => void;
  26958. /**
  26959. * Creates a new Node
  26960. * @param name the name and id to be given to this node
  26961. * @param scene the scene this node will be added to
  26962. * @param addToRootNodes the node will be added to scene.rootNodes
  26963. */
  26964. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26965. /**
  26966. * Gets the scene of the node
  26967. * @returns a scene
  26968. */
  26969. getScene(): Scene;
  26970. /**
  26971. * Gets the engine of the node
  26972. * @returns a Engine
  26973. */
  26974. getEngine(): Engine;
  26975. private _behaviors;
  26976. /**
  26977. * Attach a behavior to the node
  26978. * @see http://doc.babylonjs.com/features/behaviour
  26979. * @param behavior defines the behavior to attach
  26980. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26981. * @returns the current Node
  26982. */
  26983. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26984. /**
  26985. * Remove an attached behavior
  26986. * @see http://doc.babylonjs.com/features/behaviour
  26987. * @param behavior defines the behavior to attach
  26988. * @returns the current Node
  26989. */
  26990. removeBehavior(behavior: Behavior<Node>): Node;
  26991. /**
  26992. * Gets the list of attached behaviors
  26993. * @see http://doc.babylonjs.com/features/behaviour
  26994. */
  26995. readonly behaviors: Behavior<Node>[];
  26996. /**
  26997. * Gets an attached behavior by name
  26998. * @param name defines the name of the behavior to look for
  26999. * @see http://doc.babylonjs.com/features/behaviour
  27000. * @returns null if behavior was not found else the requested behavior
  27001. */
  27002. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27003. /**
  27004. * Returns the latest update of the World matrix
  27005. * @returns a Matrix
  27006. */
  27007. getWorldMatrix(): Matrix;
  27008. /** @hidden */
  27009. _getWorldMatrixDeterminant(): number;
  27010. /**
  27011. * Returns directly the latest state of the mesh World matrix.
  27012. * A Matrix is returned.
  27013. */
  27014. readonly worldMatrixFromCache: Matrix;
  27015. /** @hidden */
  27016. _initCache(): void;
  27017. /** @hidden */
  27018. updateCache(force?: boolean): void;
  27019. /** @hidden */
  27020. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27021. /** @hidden */
  27022. _updateCache(ignoreParentClass?: boolean): void;
  27023. /** @hidden */
  27024. _isSynchronized(): boolean;
  27025. /** @hidden */
  27026. _markSyncedWithParent(): void;
  27027. /** @hidden */
  27028. isSynchronizedWithParent(): boolean;
  27029. /** @hidden */
  27030. isSynchronized(): boolean;
  27031. /**
  27032. * Is this node ready to be used/rendered
  27033. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27034. * @return true if the node is ready
  27035. */
  27036. isReady(completeCheck?: boolean): boolean;
  27037. /**
  27038. * Is this node enabled?
  27039. * 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
  27040. * @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
  27041. * @return whether this node (and its parent) is enabled
  27042. */
  27043. isEnabled(checkAncestors?: boolean): boolean;
  27044. /** @hidden */
  27045. protected _syncParentEnabledState(): void;
  27046. /**
  27047. * Set the enabled state of this node
  27048. * @param value defines the new enabled state
  27049. */
  27050. setEnabled(value: boolean): void;
  27051. /**
  27052. * Is this node a descendant of the given node?
  27053. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27054. * @param ancestor defines the parent node to inspect
  27055. * @returns a boolean indicating if this node is a descendant of the given node
  27056. */
  27057. isDescendantOf(ancestor: Node): boolean;
  27058. /** @hidden */
  27059. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27060. /**
  27061. * Will return all nodes that have this node as ascendant
  27062. * @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
  27063. * @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
  27064. * @return all children nodes of all types
  27065. */
  27066. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27067. /**
  27068. * Get all child-meshes of this node
  27069. * @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)
  27070. * @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
  27071. * @returns an array of AbstractMesh
  27072. */
  27073. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27074. /**
  27075. * Get all direct children of this node
  27076. * @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
  27077. * @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)
  27078. * @returns an array of Node
  27079. */
  27080. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27081. /** @hidden */
  27082. _setReady(state: boolean): void;
  27083. /**
  27084. * Get an animation by name
  27085. * @param name defines the name of the animation to look for
  27086. * @returns null if not found else the requested animation
  27087. */
  27088. getAnimationByName(name: string): Nullable<Animation>;
  27089. /**
  27090. * Creates an animation range for this node
  27091. * @param name defines the name of the range
  27092. * @param from defines the starting key
  27093. * @param to defines the end key
  27094. */
  27095. createAnimationRange(name: string, from: number, to: number): void;
  27096. /**
  27097. * Delete a specific animation range
  27098. * @param name defines the name of the range to delete
  27099. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27100. */
  27101. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27102. /**
  27103. * Get an animation range by name
  27104. * @param name defines the name of the animation range to look for
  27105. * @returns null if not found else the requested animation range
  27106. */
  27107. getAnimationRange(name: string): Nullable<AnimationRange>;
  27108. /**
  27109. * Gets the list of all animation ranges defined on this node
  27110. * @returns an array
  27111. */
  27112. getAnimationRanges(): Nullable<AnimationRange>[];
  27113. /**
  27114. * Will start the animation sequence
  27115. * @param name defines the range frames for animation sequence
  27116. * @param loop defines if the animation should loop (false by default)
  27117. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27118. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27119. * @returns the object created for this animation. If range does not exist, it will return null
  27120. */
  27121. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27122. /**
  27123. * Serialize animation ranges into a JSON compatible object
  27124. * @returns serialization object
  27125. */
  27126. serializeAnimationRanges(): any;
  27127. /**
  27128. * Computes the world matrix of the node
  27129. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27130. * @returns the world matrix
  27131. */
  27132. computeWorldMatrix(force?: boolean): Matrix;
  27133. /**
  27134. * Releases resources associated with this node.
  27135. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27136. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27137. */
  27138. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27139. /**
  27140. * Parse animation range data from a serialization object and store them into a given node
  27141. * @param node defines where to store the animation ranges
  27142. * @param parsedNode defines the serialization object to read data from
  27143. * @param scene defines the hosting scene
  27144. */
  27145. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27146. /**
  27147. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27148. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27149. * @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
  27150. * @returns the new bounding vectors
  27151. */
  27152. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27153. min: Vector3;
  27154. max: Vector3;
  27155. };
  27156. }
  27157. }
  27158. declare module BABYLON {
  27159. /**
  27160. * @hidden
  27161. */
  27162. export class _IAnimationState {
  27163. key: number;
  27164. repeatCount: number;
  27165. workValue?: any;
  27166. loopMode?: number;
  27167. offsetValue?: any;
  27168. highLimitValue?: any;
  27169. }
  27170. /**
  27171. * Class used to store any kind of animation
  27172. */
  27173. export class Animation {
  27174. /**Name of the animation */
  27175. name: string;
  27176. /**Property to animate */
  27177. targetProperty: string;
  27178. /**The frames per second of the animation */
  27179. framePerSecond: number;
  27180. /**The data type of the animation */
  27181. dataType: number;
  27182. /**The loop mode of the animation */
  27183. loopMode?: number | undefined;
  27184. /**Specifies if blending should be enabled */
  27185. enableBlending?: boolean | undefined;
  27186. /**
  27187. * Use matrix interpolation instead of using direct key value when animating matrices
  27188. */
  27189. static AllowMatricesInterpolation: boolean;
  27190. /**
  27191. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27192. */
  27193. static AllowMatrixDecomposeForInterpolation: boolean;
  27194. /**
  27195. * Stores the key frames of the animation
  27196. */
  27197. private _keys;
  27198. /**
  27199. * Stores the easing function of the animation
  27200. */
  27201. private _easingFunction;
  27202. /**
  27203. * @hidden Internal use only
  27204. */
  27205. _runtimeAnimations: RuntimeAnimation[];
  27206. /**
  27207. * The set of event that will be linked to this animation
  27208. */
  27209. private _events;
  27210. /**
  27211. * Stores an array of target property paths
  27212. */
  27213. targetPropertyPath: string[];
  27214. /**
  27215. * Stores the blending speed of the animation
  27216. */
  27217. blendingSpeed: number;
  27218. /**
  27219. * Stores the animation ranges for the animation
  27220. */
  27221. private _ranges;
  27222. /**
  27223. * @hidden Internal use
  27224. */
  27225. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27226. /**
  27227. * Sets up an animation
  27228. * @param property The property to animate
  27229. * @param animationType The animation type to apply
  27230. * @param framePerSecond The frames per second of the animation
  27231. * @param easingFunction The easing function used in the animation
  27232. * @returns The created animation
  27233. */
  27234. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27235. /**
  27236. * Create and start an animation on a node
  27237. * @param name defines the name of the global animation that will be run on all nodes
  27238. * @param node defines the root node where the animation will take place
  27239. * @param targetProperty defines property to animate
  27240. * @param framePerSecond defines the number of frame per second yo use
  27241. * @param totalFrame defines the number of frames in total
  27242. * @param from defines the initial value
  27243. * @param to defines the final value
  27244. * @param loopMode defines which loop mode you want to use (off by default)
  27245. * @param easingFunction defines the easing function to use (linear by default)
  27246. * @param onAnimationEnd defines the callback to call when animation end
  27247. * @returns the animatable created for this animation
  27248. */
  27249. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27250. /**
  27251. * Create and start an animation on a node and its descendants
  27252. * @param name defines the name of the global animation that will be run on all nodes
  27253. * @param node defines the root node where the animation will take place
  27254. * @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
  27255. * @param targetProperty defines property to animate
  27256. * @param framePerSecond defines the number of frame per second to use
  27257. * @param totalFrame defines the number of frames in total
  27258. * @param from defines the initial value
  27259. * @param to defines the final value
  27260. * @param loopMode defines which loop mode you want to use (off by default)
  27261. * @param easingFunction defines the easing function to use (linear by default)
  27262. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27263. * @returns the list of animatables created for all nodes
  27264. * @example https://www.babylonjs-playground.com/#MH0VLI
  27265. */
  27266. 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[]>;
  27267. /**
  27268. * Creates a new animation, merges it with the existing animations and starts it
  27269. * @param name Name of the animation
  27270. * @param node Node which contains the scene that begins the animations
  27271. * @param targetProperty Specifies which property to animate
  27272. * @param framePerSecond The frames per second of the animation
  27273. * @param totalFrame The total number of frames
  27274. * @param from The frame at the beginning of the animation
  27275. * @param to The frame at the end of the animation
  27276. * @param loopMode Specifies the loop mode of the animation
  27277. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27278. * @param onAnimationEnd Callback to run once the animation is complete
  27279. * @returns Nullable animation
  27280. */
  27281. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27282. /**
  27283. * Transition property of an host to the target Value
  27284. * @param property The property to transition
  27285. * @param targetValue The target Value of the property
  27286. * @param host The object where the property to animate belongs
  27287. * @param scene Scene used to run the animation
  27288. * @param frameRate Framerate (in frame/s) to use
  27289. * @param transition The transition type we want to use
  27290. * @param duration The duration of the animation, in milliseconds
  27291. * @param onAnimationEnd Callback trigger at the end of the animation
  27292. * @returns Nullable animation
  27293. */
  27294. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27295. /**
  27296. * Return the array of runtime animations currently using this animation
  27297. */
  27298. readonly runtimeAnimations: RuntimeAnimation[];
  27299. /**
  27300. * Specifies if any of the runtime animations are currently running
  27301. */
  27302. readonly hasRunningRuntimeAnimations: boolean;
  27303. /**
  27304. * Initializes the animation
  27305. * @param name Name of the animation
  27306. * @param targetProperty Property to animate
  27307. * @param framePerSecond The frames per second of the animation
  27308. * @param dataType The data type of the animation
  27309. * @param loopMode The loop mode of the animation
  27310. * @param enableBlending Specifies if blending should be enabled
  27311. */
  27312. constructor(
  27313. /**Name of the animation */
  27314. name: string,
  27315. /**Property to animate */
  27316. targetProperty: string,
  27317. /**The frames per second of the animation */
  27318. framePerSecond: number,
  27319. /**The data type of the animation */
  27320. dataType: number,
  27321. /**The loop mode of the animation */
  27322. loopMode?: number | undefined,
  27323. /**Specifies if blending should be enabled */
  27324. enableBlending?: boolean | undefined);
  27325. /**
  27326. * Converts the animation to a string
  27327. * @param fullDetails support for multiple levels of logging within scene loading
  27328. * @returns String form of the animation
  27329. */
  27330. toString(fullDetails?: boolean): string;
  27331. /**
  27332. * Add an event to this animation
  27333. * @param event Event to add
  27334. */
  27335. addEvent(event: AnimationEvent): void;
  27336. /**
  27337. * Remove all events found at the given frame
  27338. * @param frame The frame to remove events from
  27339. */
  27340. removeEvents(frame: number): void;
  27341. /**
  27342. * Retrieves all the events from the animation
  27343. * @returns Events from the animation
  27344. */
  27345. getEvents(): AnimationEvent[];
  27346. /**
  27347. * Creates an animation range
  27348. * @param name Name of the animation range
  27349. * @param from Starting frame of the animation range
  27350. * @param to Ending frame of the animation
  27351. */
  27352. createRange(name: string, from: number, to: number): void;
  27353. /**
  27354. * Deletes an animation range by name
  27355. * @param name Name of the animation range to delete
  27356. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27357. */
  27358. deleteRange(name: string, deleteFrames?: boolean): void;
  27359. /**
  27360. * Gets the animation range by name, or null if not defined
  27361. * @param name Name of the animation range
  27362. * @returns Nullable animation range
  27363. */
  27364. getRange(name: string): Nullable<AnimationRange>;
  27365. /**
  27366. * Gets the key frames from the animation
  27367. * @returns The key frames of the animation
  27368. */
  27369. getKeys(): Array<IAnimationKey>;
  27370. /**
  27371. * Gets the highest frame rate of the animation
  27372. * @returns Highest frame rate of the animation
  27373. */
  27374. getHighestFrame(): number;
  27375. /**
  27376. * Gets the easing function of the animation
  27377. * @returns Easing function of the animation
  27378. */
  27379. getEasingFunction(): IEasingFunction;
  27380. /**
  27381. * Sets the easing function of the animation
  27382. * @param easingFunction A custom mathematical formula for animation
  27383. */
  27384. setEasingFunction(easingFunction: EasingFunction): void;
  27385. /**
  27386. * Interpolates a scalar linearly
  27387. * @param startValue Start value of the animation curve
  27388. * @param endValue End value of the animation curve
  27389. * @param gradient Scalar amount to interpolate
  27390. * @returns Interpolated scalar value
  27391. */
  27392. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27393. /**
  27394. * Interpolates a scalar cubically
  27395. * @param startValue Start value of the animation curve
  27396. * @param outTangent End tangent of the animation
  27397. * @param endValue End value of the animation curve
  27398. * @param inTangent Start tangent of the animation curve
  27399. * @param gradient Scalar amount to interpolate
  27400. * @returns Interpolated scalar value
  27401. */
  27402. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27403. /**
  27404. * Interpolates a quaternion using a spherical linear interpolation
  27405. * @param startValue Start value of the animation curve
  27406. * @param endValue End value of the animation curve
  27407. * @param gradient Scalar amount to interpolate
  27408. * @returns Interpolated quaternion value
  27409. */
  27410. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27411. /**
  27412. * Interpolates a quaternion cubically
  27413. * @param startValue Start value of the animation curve
  27414. * @param outTangent End tangent of the animation curve
  27415. * @param endValue End value of the animation curve
  27416. * @param inTangent Start tangent of the animation curve
  27417. * @param gradient Scalar amount to interpolate
  27418. * @returns Interpolated quaternion value
  27419. */
  27420. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27421. /**
  27422. * Interpolates a Vector3 linearl
  27423. * @param startValue Start value of the animation curve
  27424. * @param endValue End value of the animation curve
  27425. * @param gradient Scalar amount to interpolate
  27426. * @returns Interpolated scalar value
  27427. */
  27428. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27429. /**
  27430. * Interpolates a Vector3 cubically
  27431. * @param startValue Start value of the animation curve
  27432. * @param outTangent End tangent of the animation
  27433. * @param endValue End value of the animation curve
  27434. * @param inTangent Start tangent of the animation curve
  27435. * @param gradient Scalar amount to interpolate
  27436. * @returns InterpolatedVector3 value
  27437. */
  27438. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27439. /**
  27440. * Interpolates a Vector2 linearly
  27441. * @param startValue Start value of the animation curve
  27442. * @param endValue End value of the animation curve
  27443. * @param gradient Scalar amount to interpolate
  27444. * @returns Interpolated Vector2 value
  27445. */
  27446. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27447. /**
  27448. * Interpolates a Vector2 cubically
  27449. * @param startValue Start value of the animation curve
  27450. * @param outTangent End tangent of the animation
  27451. * @param endValue End value of the animation curve
  27452. * @param inTangent Start tangent of the animation curve
  27453. * @param gradient Scalar amount to interpolate
  27454. * @returns Interpolated Vector2 value
  27455. */
  27456. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27457. /**
  27458. * Interpolates a size linearly
  27459. * @param startValue Start value of the animation curve
  27460. * @param endValue End value of the animation curve
  27461. * @param gradient Scalar amount to interpolate
  27462. * @returns Interpolated Size value
  27463. */
  27464. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27465. /**
  27466. * Interpolates a Color3 linearly
  27467. * @param startValue Start value of the animation curve
  27468. * @param endValue End value of the animation curve
  27469. * @param gradient Scalar amount to interpolate
  27470. * @returns Interpolated Color3 value
  27471. */
  27472. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27473. /**
  27474. * @hidden Internal use only
  27475. */
  27476. _getKeyValue(value: any): any;
  27477. /**
  27478. * @hidden Internal use only
  27479. */
  27480. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27481. /**
  27482. * Defines the function to use to interpolate matrices
  27483. * @param startValue defines the start matrix
  27484. * @param endValue defines the end matrix
  27485. * @param gradient defines the gradient between both matrices
  27486. * @param result defines an optional target matrix where to store the interpolation
  27487. * @returns the interpolated matrix
  27488. */
  27489. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27490. /**
  27491. * Makes a copy of the animation
  27492. * @returns Cloned animation
  27493. */
  27494. clone(): Animation;
  27495. /**
  27496. * Sets the key frames of the animation
  27497. * @param values The animation key frames to set
  27498. */
  27499. setKeys(values: Array<IAnimationKey>): void;
  27500. /**
  27501. * Serializes the animation to an object
  27502. * @returns Serialized object
  27503. */
  27504. serialize(): any;
  27505. /**
  27506. * Float animation type
  27507. */
  27508. private static _ANIMATIONTYPE_FLOAT;
  27509. /**
  27510. * Vector3 animation type
  27511. */
  27512. private static _ANIMATIONTYPE_VECTOR3;
  27513. /**
  27514. * Quaternion animation type
  27515. */
  27516. private static _ANIMATIONTYPE_QUATERNION;
  27517. /**
  27518. * Matrix animation type
  27519. */
  27520. private static _ANIMATIONTYPE_MATRIX;
  27521. /**
  27522. * Color3 animation type
  27523. */
  27524. private static _ANIMATIONTYPE_COLOR3;
  27525. /**
  27526. * Vector2 animation type
  27527. */
  27528. private static _ANIMATIONTYPE_VECTOR2;
  27529. /**
  27530. * Size animation type
  27531. */
  27532. private static _ANIMATIONTYPE_SIZE;
  27533. /**
  27534. * Relative Loop Mode
  27535. */
  27536. private static _ANIMATIONLOOPMODE_RELATIVE;
  27537. /**
  27538. * Cycle Loop Mode
  27539. */
  27540. private static _ANIMATIONLOOPMODE_CYCLE;
  27541. /**
  27542. * Constant Loop Mode
  27543. */
  27544. private static _ANIMATIONLOOPMODE_CONSTANT;
  27545. /**
  27546. * Get the float animation type
  27547. */
  27548. static readonly ANIMATIONTYPE_FLOAT: number;
  27549. /**
  27550. * Get the Vector3 animation type
  27551. */
  27552. static readonly ANIMATIONTYPE_VECTOR3: number;
  27553. /**
  27554. * Get the Vector2 animation type
  27555. */
  27556. static readonly ANIMATIONTYPE_VECTOR2: number;
  27557. /**
  27558. * Get the Size animation type
  27559. */
  27560. static readonly ANIMATIONTYPE_SIZE: number;
  27561. /**
  27562. * Get the Quaternion animation type
  27563. */
  27564. static readonly ANIMATIONTYPE_QUATERNION: number;
  27565. /**
  27566. * Get the Matrix animation type
  27567. */
  27568. static readonly ANIMATIONTYPE_MATRIX: number;
  27569. /**
  27570. * Get the Color3 animation type
  27571. */
  27572. static readonly ANIMATIONTYPE_COLOR3: number;
  27573. /**
  27574. * Get the Relative Loop Mode
  27575. */
  27576. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27577. /**
  27578. * Get the Cycle Loop Mode
  27579. */
  27580. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27581. /**
  27582. * Get the Constant Loop Mode
  27583. */
  27584. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27585. /** @hidden */
  27586. static _UniversalLerp(left: any, right: any, amount: number): any;
  27587. /**
  27588. * Parses an animation object and creates an animation
  27589. * @param parsedAnimation Parsed animation object
  27590. * @returns Animation object
  27591. */
  27592. static Parse(parsedAnimation: any): Animation;
  27593. /**
  27594. * Appends the serialized animations from the source animations
  27595. * @param source Source containing the animations
  27596. * @param destination Target to store the animations
  27597. */
  27598. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27599. }
  27600. }
  27601. declare module BABYLON {
  27602. /**
  27603. * Interface containing an array of animations
  27604. */
  27605. export interface IAnimatable {
  27606. /**
  27607. * Array of animations
  27608. */
  27609. animations: Nullable<Array<Animation>>;
  27610. }
  27611. }
  27612. declare module BABYLON {
  27613. /**
  27614. * This represents all the required information to add a fresnel effect on a material:
  27615. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27616. */
  27617. export class FresnelParameters {
  27618. private _isEnabled;
  27619. /**
  27620. * Define if the fresnel effect is enable or not.
  27621. */
  27622. isEnabled: boolean;
  27623. /**
  27624. * Define the color used on edges (grazing angle)
  27625. */
  27626. leftColor: Color3;
  27627. /**
  27628. * Define the color used on center
  27629. */
  27630. rightColor: Color3;
  27631. /**
  27632. * Define bias applied to computed fresnel term
  27633. */
  27634. bias: number;
  27635. /**
  27636. * Defined the power exponent applied to fresnel term
  27637. */
  27638. power: number;
  27639. /**
  27640. * Clones the current fresnel and its valuues
  27641. * @returns a clone fresnel configuration
  27642. */
  27643. clone(): FresnelParameters;
  27644. /**
  27645. * Serializes the current fresnel parameters to a JSON representation.
  27646. * @return the JSON serialization
  27647. */
  27648. serialize(): any;
  27649. /**
  27650. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27651. * @param parsedFresnelParameters Define the JSON representation
  27652. * @returns the parsed parameters
  27653. */
  27654. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27655. }
  27656. }
  27657. declare module BABYLON {
  27658. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27659. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27660. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27661. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27662. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27663. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27664. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27665. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27666. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27667. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27668. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27669. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27670. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27671. /**
  27672. * Decorator used to define property that can be serialized as reference to a camera
  27673. * @param sourceName defines the name of the property to decorate
  27674. */
  27675. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27676. /**
  27677. * Class used to help serialization objects
  27678. */
  27679. export class SerializationHelper {
  27680. /** @hidden */
  27681. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27682. /** @hidden */
  27683. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27684. /** @hidden */
  27685. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27686. /** @hidden */
  27687. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27688. /**
  27689. * Appends the serialized animations from the source animations
  27690. * @param source Source containing the animations
  27691. * @param destination Target to store the animations
  27692. */
  27693. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27694. /**
  27695. * Static function used to serialized a specific entity
  27696. * @param entity defines the entity to serialize
  27697. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27698. * @returns a JSON compatible object representing the serialization of the entity
  27699. */
  27700. static Serialize<T>(entity: T, serializationObject?: any): any;
  27701. /**
  27702. * Creates a new entity from a serialization data object
  27703. * @param creationFunction defines a function used to instanciated the new entity
  27704. * @param source defines the source serialization data
  27705. * @param scene defines the hosting scene
  27706. * @param rootUrl defines the root url for resources
  27707. * @returns a new entity
  27708. */
  27709. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27710. /**
  27711. * Clones an object
  27712. * @param creationFunction defines the function used to instanciate the new object
  27713. * @param source defines the source object
  27714. * @returns the cloned object
  27715. */
  27716. static Clone<T>(creationFunction: () => T, source: T): T;
  27717. /**
  27718. * Instanciates a new object based on a source one (some data will be shared between both object)
  27719. * @param creationFunction defines the function used to instanciate the new object
  27720. * @param source defines the source object
  27721. * @returns the new object
  27722. */
  27723. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27724. }
  27725. }
  27726. declare module BABYLON {
  27727. /**
  27728. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27729. */
  27730. export interface CubeMapInfo {
  27731. /**
  27732. * The pixel array for the front face.
  27733. * This is stored in format, left to right, up to down format.
  27734. */
  27735. front: Nullable<ArrayBufferView>;
  27736. /**
  27737. * The pixel array for the back face.
  27738. * This is stored in format, left to right, up to down format.
  27739. */
  27740. back: Nullable<ArrayBufferView>;
  27741. /**
  27742. * The pixel array for the left face.
  27743. * This is stored in format, left to right, up to down format.
  27744. */
  27745. left: Nullable<ArrayBufferView>;
  27746. /**
  27747. * The pixel array for the right face.
  27748. * This is stored in format, left to right, up to down format.
  27749. */
  27750. right: Nullable<ArrayBufferView>;
  27751. /**
  27752. * The pixel array for the up face.
  27753. * This is stored in format, left to right, up to down format.
  27754. */
  27755. up: Nullable<ArrayBufferView>;
  27756. /**
  27757. * The pixel array for the down face.
  27758. * This is stored in format, left to right, up to down format.
  27759. */
  27760. down: Nullable<ArrayBufferView>;
  27761. /**
  27762. * The size of the cubemap stored.
  27763. *
  27764. * Each faces will be size * size pixels.
  27765. */
  27766. size: number;
  27767. /**
  27768. * The format of the texture.
  27769. *
  27770. * RGBA, RGB.
  27771. */
  27772. format: number;
  27773. /**
  27774. * The type of the texture data.
  27775. *
  27776. * UNSIGNED_INT, FLOAT.
  27777. */
  27778. type: number;
  27779. /**
  27780. * Specifies whether the texture is in gamma space.
  27781. */
  27782. gammaSpace: boolean;
  27783. }
  27784. /**
  27785. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27786. */
  27787. export class PanoramaToCubeMapTools {
  27788. private static FACE_FRONT;
  27789. private static FACE_BACK;
  27790. private static FACE_RIGHT;
  27791. private static FACE_LEFT;
  27792. private static FACE_DOWN;
  27793. private static FACE_UP;
  27794. /**
  27795. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27796. *
  27797. * @param float32Array The source data.
  27798. * @param inputWidth The width of the input panorama.
  27799. * @param inputHeight The height of the input panorama.
  27800. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27801. * @return The cubemap data
  27802. */
  27803. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27804. private static CreateCubemapTexture;
  27805. private static CalcProjectionSpherical;
  27806. }
  27807. }
  27808. declare module BABYLON {
  27809. /**
  27810. * Helper class dealing with the extraction of spherical polynomial dataArray
  27811. * from a cube map.
  27812. */
  27813. export class CubeMapToSphericalPolynomialTools {
  27814. private static FileFaces;
  27815. /**
  27816. * Converts a texture to the according Spherical Polynomial data.
  27817. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27818. *
  27819. * @param texture The texture to extract the information from.
  27820. * @return The Spherical Polynomial data.
  27821. */
  27822. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27823. /**
  27824. * Converts a cubemap to the according Spherical Polynomial data.
  27825. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27826. *
  27827. * @param cubeInfo The Cube map to extract the information from.
  27828. * @return The Spherical Polynomial data.
  27829. */
  27830. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27831. }
  27832. }
  27833. declare module BABYLON {
  27834. /**
  27835. * Class used to manipulate GUIDs
  27836. */
  27837. export class GUID {
  27838. /**
  27839. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27840. * Be aware Math.random() could cause collisions, but:
  27841. * "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"
  27842. * @returns a pseudo random id
  27843. */
  27844. static RandomId(): string;
  27845. }
  27846. }
  27847. declare module BABYLON {
  27848. /**
  27849. * Base class of all the textures in babylon.
  27850. * It groups all the common properties the materials, post process, lights... might need
  27851. * in order to make a correct use of the texture.
  27852. */
  27853. export class BaseTexture implements IAnimatable {
  27854. /**
  27855. * Default anisotropic filtering level for the application.
  27856. * It is set to 4 as a good tradeoff between perf and quality.
  27857. */
  27858. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27859. /**
  27860. * Gets or sets the unique id of the texture
  27861. */
  27862. uniqueId: number;
  27863. /**
  27864. * Define the name of the texture.
  27865. */
  27866. name: string;
  27867. /**
  27868. * Gets or sets an object used to store user defined information.
  27869. */
  27870. metadata: any;
  27871. /**
  27872. * For internal use only. Please do not use.
  27873. */
  27874. reservedDataStore: any;
  27875. private _hasAlpha;
  27876. /**
  27877. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27878. */
  27879. hasAlpha: boolean;
  27880. /**
  27881. * Defines if the alpha value should be determined via the rgb values.
  27882. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27883. */
  27884. getAlphaFromRGB: boolean;
  27885. /**
  27886. * Intensity or strength of the texture.
  27887. * It is commonly used by materials to fine tune the intensity of the texture
  27888. */
  27889. level: number;
  27890. /**
  27891. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27892. * This is part of the texture as textures usually maps to one uv set.
  27893. */
  27894. coordinatesIndex: number;
  27895. private _coordinatesMode;
  27896. /**
  27897. * How a texture is mapped.
  27898. *
  27899. * | Value | Type | Description |
  27900. * | ----- | ----------------------------------- | ----------- |
  27901. * | 0 | EXPLICIT_MODE | |
  27902. * | 1 | SPHERICAL_MODE | |
  27903. * | 2 | PLANAR_MODE | |
  27904. * | 3 | CUBIC_MODE | |
  27905. * | 4 | PROJECTION_MODE | |
  27906. * | 5 | SKYBOX_MODE | |
  27907. * | 6 | INVCUBIC_MODE | |
  27908. * | 7 | EQUIRECTANGULAR_MODE | |
  27909. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27910. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27911. */
  27912. coordinatesMode: number;
  27913. /**
  27914. * | Value | Type | Description |
  27915. * | ----- | ------------------ | ----------- |
  27916. * | 0 | CLAMP_ADDRESSMODE | |
  27917. * | 1 | WRAP_ADDRESSMODE | |
  27918. * | 2 | MIRROR_ADDRESSMODE | |
  27919. */
  27920. wrapU: number;
  27921. /**
  27922. * | Value | Type | Description |
  27923. * | ----- | ------------------ | ----------- |
  27924. * | 0 | CLAMP_ADDRESSMODE | |
  27925. * | 1 | WRAP_ADDRESSMODE | |
  27926. * | 2 | MIRROR_ADDRESSMODE | |
  27927. */
  27928. wrapV: number;
  27929. /**
  27930. * | Value | Type | Description |
  27931. * | ----- | ------------------ | ----------- |
  27932. * | 0 | CLAMP_ADDRESSMODE | |
  27933. * | 1 | WRAP_ADDRESSMODE | |
  27934. * | 2 | MIRROR_ADDRESSMODE | |
  27935. */
  27936. wrapR: number;
  27937. /**
  27938. * With compliant hardware and browser (supporting anisotropic filtering)
  27939. * this defines the level of anisotropic filtering in the texture.
  27940. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27941. */
  27942. anisotropicFilteringLevel: number;
  27943. /**
  27944. * Define if the texture is a cube texture or if false a 2d texture.
  27945. */
  27946. isCube: boolean;
  27947. /**
  27948. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27949. */
  27950. is3D: boolean;
  27951. /**
  27952. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27953. * HDR texture are usually stored in linear space.
  27954. * This only impacts the PBR and Background materials
  27955. */
  27956. gammaSpace: boolean;
  27957. /**
  27958. * Gets or sets whether or not the texture contains RGBD data.
  27959. */
  27960. isRGBD: boolean;
  27961. /**
  27962. * Is Z inverted in the texture (useful in a cube texture).
  27963. */
  27964. invertZ: boolean;
  27965. /**
  27966. * Are mip maps generated for this texture or not.
  27967. */
  27968. readonly noMipmap: boolean;
  27969. /**
  27970. * @hidden
  27971. */
  27972. lodLevelInAlpha: boolean;
  27973. /**
  27974. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27975. */
  27976. lodGenerationOffset: number;
  27977. /**
  27978. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27979. */
  27980. lodGenerationScale: number;
  27981. /**
  27982. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27983. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27984. * average roughness values.
  27985. */
  27986. linearSpecularLOD: boolean;
  27987. /**
  27988. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27989. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27990. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27991. */
  27992. irradianceTexture: Nullable<BaseTexture>;
  27993. /**
  27994. * Define if the texture is a render target.
  27995. */
  27996. isRenderTarget: boolean;
  27997. /**
  27998. * Define the unique id of the texture in the scene.
  27999. */
  28000. readonly uid: string;
  28001. /**
  28002. * Return a string representation of the texture.
  28003. * @returns the texture as a string
  28004. */
  28005. toString(): string;
  28006. /**
  28007. * Get the class name of the texture.
  28008. * @returns "BaseTexture"
  28009. */
  28010. getClassName(): string;
  28011. /**
  28012. * Define the list of animation attached to the texture.
  28013. */
  28014. animations: Animation[];
  28015. /**
  28016. * An event triggered when the texture is disposed.
  28017. */
  28018. onDisposeObservable: Observable<BaseTexture>;
  28019. private _onDisposeObserver;
  28020. /**
  28021. * Callback triggered when the texture has been disposed.
  28022. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28023. */
  28024. onDispose: () => void;
  28025. /**
  28026. * Define the current state of the loading sequence when in delayed load mode.
  28027. */
  28028. delayLoadState: number;
  28029. private _scene;
  28030. /** @hidden */
  28031. _texture: Nullable<InternalTexture>;
  28032. private _uid;
  28033. /**
  28034. * Define if the texture is preventinga material to render or not.
  28035. * If not and the texture is not ready, the engine will use a default black texture instead.
  28036. */
  28037. readonly isBlocking: boolean;
  28038. /**
  28039. * Instantiates a new BaseTexture.
  28040. * Base class of all the textures in babylon.
  28041. * It groups all the common properties the materials, post process, lights... might need
  28042. * in order to make a correct use of the texture.
  28043. * @param scene Define the scene the texture blongs to
  28044. */
  28045. constructor(scene: Nullable<Scene>);
  28046. /**
  28047. * Get the scene the texture belongs to.
  28048. * @returns the scene or null if undefined
  28049. */
  28050. getScene(): Nullable<Scene>;
  28051. /**
  28052. * Get the texture transform matrix used to offset tile the texture for istance.
  28053. * @returns the transformation matrix
  28054. */
  28055. getTextureMatrix(): Matrix;
  28056. /**
  28057. * Get the texture reflection matrix used to rotate/transform the reflection.
  28058. * @returns the reflection matrix
  28059. */
  28060. getReflectionTextureMatrix(): Matrix;
  28061. /**
  28062. * Get the underlying lower level texture from Babylon.
  28063. * @returns the insternal texture
  28064. */
  28065. getInternalTexture(): Nullable<InternalTexture>;
  28066. /**
  28067. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28068. * @returns true if ready or not blocking
  28069. */
  28070. isReadyOrNotBlocking(): boolean;
  28071. /**
  28072. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28073. * @returns true if fully ready
  28074. */
  28075. isReady(): boolean;
  28076. private _cachedSize;
  28077. /**
  28078. * Get the size of the texture.
  28079. * @returns the texture size.
  28080. */
  28081. getSize(): ISize;
  28082. /**
  28083. * Get the base size of the texture.
  28084. * It can be different from the size if the texture has been resized for POT for instance
  28085. * @returns the base size
  28086. */
  28087. getBaseSize(): ISize;
  28088. /**
  28089. * Update the sampling mode of the texture.
  28090. * Default is Trilinear mode.
  28091. *
  28092. * | Value | Type | Description |
  28093. * | ----- | ------------------ | ----------- |
  28094. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28095. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28096. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28097. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28098. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28099. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28100. * | 7 | NEAREST_LINEAR | |
  28101. * | 8 | NEAREST_NEAREST | |
  28102. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28103. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28104. * | 11 | LINEAR_LINEAR | |
  28105. * | 12 | LINEAR_NEAREST | |
  28106. *
  28107. * > _mag_: magnification filter (close to the viewer)
  28108. * > _min_: minification filter (far from the viewer)
  28109. * > _mip_: filter used between mip map levels
  28110. *@param samplingMode Define the new sampling mode of the texture
  28111. */
  28112. updateSamplingMode(samplingMode: number): void;
  28113. /**
  28114. * Scales the texture if is `canRescale()`
  28115. * @param ratio the resize factor we want to use to rescale
  28116. */
  28117. scale(ratio: number): void;
  28118. /**
  28119. * Get if the texture can rescale.
  28120. */
  28121. readonly canRescale: boolean;
  28122. /** @hidden */
  28123. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28124. /** @hidden */
  28125. _rebuild(): void;
  28126. /**
  28127. * Triggers the load sequence in delayed load mode.
  28128. */
  28129. delayLoad(): void;
  28130. /**
  28131. * Clones the texture.
  28132. * @returns the cloned texture
  28133. */
  28134. clone(): Nullable<BaseTexture>;
  28135. /**
  28136. * Get the texture underlying type (INT, FLOAT...)
  28137. */
  28138. readonly textureType: number;
  28139. /**
  28140. * Get the texture underlying format (RGB, RGBA...)
  28141. */
  28142. readonly textureFormat: number;
  28143. /**
  28144. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28145. * This will returns an RGBA array buffer containing either in values (0-255) or
  28146. * float values (0-1) depending of the underlying buffer type.
  28147. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28148. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28149. * @param buffer defines a user defined buffer to fill with data (can be null)
  28150. * @returns The Array buffer containing the pixels data.
  28151. */
  28152. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28153. /**
  28154. * Release and destroy the underlying lower level texture aka internalTexture.
  28155. */
  28156. releaseInternalTexture(): void;
  28157. /**
  28158. * Get the polynomial representation of the texture data.
  28159. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28160. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28161. */
  28162. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28163. /** @hidden */
  28164. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28165. /** @hidden */
  28166. readonly _lodTextureMid: Nullable<BaseTexture>;
  28167. /** @hidden */
  28168. readonly _lodTextureLow: Nullable<BaseTexture>;
  28169. /**
  28170. * Dispose the texture and release its associated resources.
  28171. */
  28172. dispose(): void;
  28173. /**
  28174. * Serialize the texture into a JSON representation that can be parsed later on.
  28175. * @returns the JSON representation of the texture
  28176. */
  28177. serialize(): any;
  28178. /**
  28179. * Helper function to be called back once a list of texture contains only ready textures.
  28180. * @param textures Define the list of textures to wait for
  28181. * @param callback Define the callback triggered once the entire list will be ready
  28182. */
  28183. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28184. }
  28185. }
  28186. declare module BABYLON {
  28187. /**
  28188. * Options to be used when creating an effect.
  28189. */
  28190. export class EffectCreationOptions {
  28191. /**
  28192. * Atrributes that will be used in the shader.
  28193. */
  28194. attributes: string[];
  28195. /**
  28196. * Uniform varible names that will be set in the shader.
  28197. */
  28198. uniformsNames: string[];
  28199. /**
  28200. * Uniform buffer varible names that will be set in the shader.
  28201. */
  28202. uniformBuffersNames: string[];
  28203. /**
  28204. * Sampler texture variable names that will be set in the shader.
  28205. */
  28206. samplers: string[];
  28207. /**
  28208. * Define statements that will be set in the shader.
  28209. */
  28210. defines: any;
  28211. /**
  28212. * Possible fallbacks for this effect to improve performance when needed.
  28213. */
  28214. fallbacks: Nullable<IEffectFallbacks>;
  28215. /**
  28216. * Callback that will be called when the shader is compiled.
  28217. */
  28218. onCompiled: Nullable<(effect: Effect) => void>;
  28219. /**
  28220. * Callback that will be called if an error occurs during shader compilation.
  28221. */
  28222. onError: Nullable<(effect: Effect, errors: string) => void>;
  28223. /**
  28224. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28225. */
  28226. indexParameters?: any;
  28227. /**
  28228. * Max number of lights that can be used in the shader.
  28229. */
  28230. maxSimultaneousLights?: number;
  28231. /**
  28232. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28233. */
  28234. transformFeedbackVaryings?: Nullable<string[]>;
  28235. }
  28236. /**
  28237. * Effect containing vertex and fragment shader that can be executed on an object.
  28238. */
  28239. export class Effect implements IDisposable {
  28240. /**
  28241. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28242. */
  28243. static ShadersRepository: string;
  28244. /**
  28245. * Name of the effect.
  28246. */
  28247. name: any;
  28248. /**
  28249. * String container all the define statements that should be set on the shader.
  28250. */
  28251. defines: string;
  28252. /**
  28253. * Callback that will be called when the shader is compiled.
  28254. */
  28255. onCompiled: Nullable<(effect: Effect) => void>;
  28256. /**
  28257. * Callback that will be called if an error occurs during shader compilation.
  28258. */
  28259. onError: Nullable<(effect: Effect, errors: string) => void>;
  28260. /**
  28261. * Callback that will be called when effect is bound.
  28262. */
  28263. onBind: Nullable<(effect: Effect) => void>;
  28264. /**
  28265. * Unique ID of the effect.
  28266. */
  28267. uniqueId: number;
  28268. /**
  28269. * Observable that will be called when the shader is compiled.
  28270. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28271. */
  28272. onCompileObservable: Observable<Effect>;
  28273. /**
  28274. * Observable that will be called if an error occurs during shader compilation.
  28275. */
  28276. onErrorObservable: Observable<Effect>;
  28277. /** @hidden */
  28278. _onBindObservable: Nullable<Observable<Effect>>;
  28279. /**
  28280. * Observable that will be called when effect is bound.
  28281. */
  28282. readonly onBindObservable: Observable<Effect>;
  28283. /** @hidden */
  28284. _bonesComputationForcedToCPU: boolean;
  28285. private static _uniqueIdSeed;
  28286. private _engine;
  28287. private _uniformBuffersNames;
  28288. private _uniformsNames;
  28289. private _samplerList;
  28290. private _samplers;
  28291. private _isReady;
  28292. private _compilationError;
  28293. private _attributesNames;
  28294. private _attributes;
  28295. private _uniforms;
  28296. /**
  28297. * Key for the effect.
  28298. * @hidden
  28299. */
  28300. _key: string;
  28301. private _indexParameters;
  28302. private _fallbacks;
  28303. private _vertexSourceCode;
  28304. private _fragmentSourceCode;
  28305. private _vertexSourceCodeOverride;
  28306. private _fragmentSourceCodeOverride;
  28307. private _transformFeedbackVaryings;
  28308. /**
  28309. * Compiled shader to webGL program.
  28310. * @hidden
  28311. */
  28312. _pipelineContext: Nullable<IPipelineContext>;
  28313. private _valueCache;
  28314. private static _baseCache;
  28315. /**
  28316. * Instantiates an effect.
  28317. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28318. * @param baseName Name of the effect.
  28319. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28320. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28321. * @param samplers List of sampler variables that will be passed to the shader.
  28322. * @param engine Engine to be used to render the effect
  28323. * @param defines Define statements to be added to the shader.
  28324. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28325. * @param onCompiled Callback that will be called when the shader is compiled.
  28326. * @param onError Callback that will be called if an error occurs during shader compilation.
  28327. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28328. */
  28329. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  28330. private _useFinalCode;
  28331. /**
  28332. * Unique key for this effect
  28333. */
  28334. readonly key: string;
  28335. /**
  28336. * If the effect has been compiled and prepared.
  28337. * @returns if the effect is compiled and prepared.
  28338. */
  28339. isReady(): boolean;
  28340. private _isReadyInternal;
  28341. /**
  28342. * The engine the effect was initialized with.
  28343. * @returns the engine.
  28344. */
  28345. getEngine(): Engine;
  28346. /**
  28347. * The pipeline context for this effect
  28348. * @returns the associated pipeline context
  28349. */
  28350. getPipelineContext(): Nullable<IPipelineContext>;
  28351. /**
  28352. * The set of names of attribute variables for the shader.
  28353. * @returns An array of attribute names.
  28354. */
  28355. getAttributesNames(): string[];
  28356. /**
  28357. * Returns the attribute at the given index.
  28358. * @param index The index of the attribute.
  28359. * @returns The location of the attribute.
  28360. */
  28361. getAttributeLocation(index: number): number;
  28362. /**
  28363. * Returns the attribute based on the name of the variable.
  28364. * @param name of the attribute to look up.
  28365. * @returns the attribute location.
  28366. */
  28367. getAttributeLocationByName(name: string): number;
  28368. /**
  28369. * The number of attributes.
  28370. * @returns the numnber of attributes.
  28371. */
  28372. getAttributesCount(): number;
  28373. /**
  28374. * Gets the index of a uniform variable.
  28375. * @param uniformName of the uniform to look up.
  28376. * @returns the index.
  28377. */
  28378. getUniformIndex(uniformName: string): number;
  28379. /**
  28380. * Returns the attribute based on the name of the variable.
  28381. * @param uniformName of the uniform to look up.
  28382. * @returns the location of the uniform.
  28383. */
  28384. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28385. /**
  28386. * Returns an array of sampler variable names
  28387. * @returns The array of sampler variable neames.
  28388. */
  28389. getSamplers(): string[];
  28390. /**
  28391. * The error from the last compilation.
  28392. * @returns the error string.
  28393. */
  28394. getCompilationError(): string;
  28395. /**
  28396. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28397. * @param func The callback to be used.
  28398. */
  28399. executeWhenCompiled(func: (effect: Effect) => void): void;
  28400. private _checkIsReady;
  28401. /** @hidden */
  28402. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28403. /** @hidden */
  28404. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28405. /** @hidden */
  28406. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28407. /**
  28408. * Recompiles the webGL program
  28409. * @param vertexSourceCode The source code for the vertex shader.
  28410. * @param fragmentSourceCode The source code for the fragment shader.
  28411. * @param onCompiled Callback called when completed.
  28412. * @param onError Callback called on error.
  28413. * @hidden
  28414. */
  28415. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28416. /**
  28417. * Prepares the effect
  28418. * @hidden
  28419. */
  28420. _prepareEffect(): void;
  28421. private _processCompilationErrors;
  28422. /**
  28423. * Checks if the effect is supported. (Must be called after compilation)
  28424. */
  28425. readonly isSupported: boolean;
  28426. /**
  28427. * Binds a texture to the engine to be used as output of the shader.
  28428. * @param channel Name of the output variable.
  28429. * @param texture Texture to bind.
  28430. * @hidden
  28431. */
  28432. _bindTexture(channel: string, texture: InternalTexture): void;
  28433. /**
  28434. * Sets a texture on the engine to be used in the shader.
  28435. * @param channel Name of the sampler variable.
  28436. * @param texture Texture to set.
  28437. */
  28438. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28439. /**
  28440. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28441. * @param channel Name of the sampler variable.
  28442. * @param texture Texture to set.
  28443. */
  28444. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28445. /**
  28446. * Sets an array of textures on the engine to be used in the shader.
  28447. * @param channel Name of the variable.
  28448. * @param textures Textures to set.
  28449. */
  28450. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28451. /**
  28452. * 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)
  28453. * @param channel Name of the sampler variable.
  28454. * @param postProcess Post process to get the input texture from.
  28455. */
  28456. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28457. /**
  28458. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28459. * 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)
  28460. * @param channel Name of the sampler variable.
  28461. * @param postProcess Post process to get the output texture from.
  28462. */
  28463. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28464. /** @hidden */
  28465. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28466. /** @hidden */
  28467. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28468. /** @hidden */
  28469. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28470. /** @hidden */
  28471. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28472. /**
  28473. * Binds a buffer to a uniform.
  28474. * @param buffer Buffer to bind.
  28475. * @param name Name of the uniform variable to bind to.
  28476. */
  28477. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28478. /**
  28479. * Binds block to a uniform.
  28480. * @param blockName Name of the block to bind.
  28481. * @param index Index to bind.
  28482. */
  28483. bindUniformBlock(blockName: string, index: number): void;
  28484. /**
  28485. * Sets an interger value on a uniform variable.
  28486. * @param uniformName Name of the variable.
  28487. * @param value Value to be set.
  28488. * @returns this effect.
  28489. */
  28490. setInt(uniformName: string, value: number): Effect;
  28491. /**
  28492. * Sets an int array on a uniform variable.
  28493. * @param uniformName Name of the variable.
  28494. * @param array array to be set.
  28495. * @returns this effect.
  28496. */
  28497. setIntArray(uniformName: string, array: Int32Array): Effect;
  28498. /**
  28499. * 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)
  28500. * @param uniformName Name of the variable.
  28501. * @param array array to be set.
  28502. * @returns this effect.
  28503. */
  28504. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28505. /**
  28506. * 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)
  28507. * @param uniformName Name of the variable.
  28508. * @param array array to be set.
  28509. * @returns this effect.
  28510. */
  28511. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28512. /**
  28513. * 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)
  28514. * @param uniformName Name of the variable.
  28515. * @param array array to be set.
  28516. * @returns this effect.
  28517. */
  28518. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28519. /**
  28520. * Sets an float array on a uniform variable.
  28521. * @param uniformName Name of the variable.
  28522. * @param array array to be set.
  28523. * @returns this effect.
  28524. */
  28525. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28526. /**
  28527. * 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)
  28528. * @param uniformName Name of the variable.
  28529. * @param array array to be set.
  28530. * @returns this effect.
  28531. */
  28532. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28533. /**
  28534. * 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)
  28535. * @param uniformName Name of the variable.
  28536. * @param array array to be set.
  28537. * @returns this effect.
  28538. */
  28539. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28540. /**
  28541. * 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)
  28542. * @param uniformName Name of the variable.
  28543. * @param array array to be set.
  28544. * @returns this effect.
  28545. */
  28546. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28547. /**
  28548. * Sets an array on a uniform variable.
  28549. * @param uniformName Name of the variable.
  28550. * @param array array to be set.
  28551. * @returns this effect.
  28552. */
  28553. setArray(uniformName: string, array: number[]): Effect;
  28554. /**
  28555. * 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)
  28556. * @param uniformName Name of the variable.
  28557. * @param array array to be set.
  28558. * @returns this effect.
  28559. */
  28560. setArray2(uniformName: string, array: number[]): Effect;
  28561. /**
  28562. * 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)
  28563. * @param uniformName Name of the variable.
  28564. * @param array array to be set.
  28565. * @returns this effect.
  28566. */
  28567. setArray3(uniformName: string, array: number[]): Effect;
  28568. /**
  28569. * 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)
  28570. * @param uniformName Name of the variable.
  28571. * @param array array to be set.
  28572. * @returns this effect.
  28573. */
  28574. setArray4(uniformName: string, array: number[]): Effect;
  28575. /**
  28576. * Sets matrices on a uniform variable.
  28577. * @param uniformName Name of the variable.
  28578. * @param matrices matrices to be set.
  28579. * @returns this effect.
  28580. */
  28581. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28582. /**
  28583. * Sets matrix on a uniform variable.
  28584. * @param uniformName Name of the variable.
  28585. * @param matrix matrix to be set.
  28586. * @returns this effect.
  28587. */
  28588. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28589. /**
  28590. * 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)
  28591. * @param uniformName Name of the variable.
  28592. * @param matrix matrix to be set.
  28593. * @returns this effect.
  28594. */
  28595. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28596. /**
  28597. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28598. * @param uniformName Name of the variable.
  28599. * @param matrix matrix to be set.
  28600. * @returns this effect.
  28601. */
  28602. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28603. /**
  28604. * Sets a float on a uniform variable.
  28605. * @param uniformName Name of the variable.
  28606. * @param value value to be set.
  28607. * @returns this effect.
  28608. */
  28609. setFloat(uniformName: string, value: number): Effect;
  28610. /**
  28611. * Sets a boolean on a uniform variable.
  28612. * @param uniformName Name of the variable.
  28613. * @param bool value to be set.
  28614. * @returns this effect.
  28615. */
  28616. setBool(uniformName: string, bool: boolean): Effect;
  28617. /**
  28618. * Sets a Vector2 on a uniform variable.
  28619. * @param uniformName Name of the variable.
  28620. * @param vector2 vector2 to be set.
  28621. * @returns this effect.
  28622. */
  28623. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28624. /**
  28625. * Sets a float2 on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param x First float in float2.
  28628. * @param y Second float in float2.
  28629. * @returns this effect.
  28630. */
  28631. setFloat2(uniformName: string, x: number, y: number): Effect;
  28632. /**
  28633. * Sets a Vector3 on a uniform variable.
  28634. * @param uniformName Name of the variable.
  28635. * @param vector3 Value to be set.
  28636. * @returns this effect.
  28637. */
  28638. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28639. /**
  28640. * Sets a float3 on a uniform variable.
  28641. * @param uniformName Name of the variable.
  28642. * @param x First float in float3.
  28643. * @param y Second float in float3.
  28644. * @param z Third float in float3.
  28645. * @returns this effect.
  28646. */
  28647. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28648. /**
  28649. * Sets a Vector4 on a uniform variable.
  28650. * @param uniformName Name of the variable.
  28651. * @param vector4 Value to be set.
  28652. * @returns this effect.
  28653. */
  28654. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28655. /**
  28656. * Sets a float4 on a uniform variable.
  28657. * @param uniformName Name of the variable.
  28658. * @param x First float in float4.
  28659. * @param y Second float in float4.
  28660. * @param z Third float in float4.
  28661. * @param w Fourth float in float4.
  28662. * @returns this effect.
  28663. */
  28664. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28665. /**
  28666. * Sets a Color3 on a uniform variable.
  28667. * @param uniformName Name of the variable.
  28668. * @param color3 Value to be set.
  28669. * @returns this effect.
  28670. */
  28671. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28672. /**
  28673. * Sets a Color4 on a uniform variable.
  28674. * @param uniformName Name of the variable.
  28675. * @param color3 Value to be set.
  28676. * @param alpha Alpha value to be set.
  28677. * @returns this effect.
  28678. */
  28679. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28680. /**
  28681. * Sets a Color4 on a uniform variable
  28682. * @param uniformName defines the name of the variable
  28683. * @param color4 defines the value to be set
  28684. * @returns this effect.
  28685. */
  28686. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28687. /** Release all associated resources */
  28688. dispose(): void;
  28689. /**
  28690. * This function will add a new shader to the shader store
  28691. * @param name the name of the shader
  28692. * @param pixelShader optional pixel shader content
  28693. * @param vertexShader optional vertex shader content
  28694. */
  28695. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28696. /**
  28697. * Store of each shader (The can be looked up using effect.key)
  28698. */
  28699. static ShadersStore: {
  28700. [key: string]: string;
  28701. };
  28702. /**
  28703. * Store of each included file for a shader (The can be looked up using effect.key)
  28704. */
  28705. static IncludesShadersStore: {
  28706. [key: string]: string;
  28707. };
  28708. /**
  28709. * Resets the cache of effects.
  28710. */
  28711. static ResetCache(): void;
  28712. }
  28713. }
  28714. declare module BABYLON {
  28715. /**
  28716. * Class used to describe the capabilities of the engine relatively to the current browser
  28717. */
  28718. export class EngineCapabilities {
  28719. /** Maximum textures units per fragment shader */
  28720. maxTexturesImageUnits: number;
  28721. /** Maximum texture units per vertex shader */
  28722. maxVertexTextureImageUnits: number;
  28723. /** Maximum textures units in the entire pipeline */
  28724. maxCombinedTexturesImageUnits: number;
  28725. /** Maximum texture size */
  28726. maxTextureSize: number;
  28727. /** Maximum cube texture size */
  28728. maxCubemapTextureSize: number;
  28729. /** Maximum render texture size */
  28730. maxRenderTextureSize: number;
  28731. /** Maximum number of vertex attributes */
  28732. maxVertexAttribs: number;
  28733. /** Maximum number of varyings */
  28734. maxVaryingVectors: number;
  28735. /** Maximum number of uniforms per vertex shader */
  28736. maxVertexUniformVectors: number;
  28737. /** Maximum number of uniforms per fragment shader */
  28738. maxFragmentUniformVectors: number;
  28739. /** Defines if standard derivates (dx/dy) are supported */
  28740. standardDerivatives: boolean;
  28741. /** Defines if s3tc texture compression is supported */
  28742. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28743. /** Defines if pvrtc texture compression is supported */
  28744. pvrtc: any;
  28745. /** Defines if etc1 texture compression is supported */
  28746. etc1: any;
  28747. /** Defines if etc2 texture compression is supported */
  28748. etc2: any;
  28749. /** Defines if astc texture compression is supported */
  28750. astc: any;
  28751. /** Defines if float textures are supported */
  28752. textureFloat: boolean;
  28753. /** Defines if vertex array objects are supported */
  28754. vertexArrayObject: boolean;
  28755. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28756. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28757. /** Gets the maximum level of anisotropy supported */
  28758. maxAnisotropy: number;
  28759. /** Defines if instancing is supported */
  28760. instancedArrays: boolean;
  28761. /** Defines if 32 bits indices are supported */
  28762. uintIndices: boolean;
  28763. /** Defines if high precision shaders are supported */
  28764. highPrecisionShaderSupported: boolean;
  28765. /** Defines if depth reading in the fragment shader is supported */
  28766. fragmentDepthSupported: boolean;
  28767. /** Defines if float texture linear filtering is supported*/
  28768. textureFloatLinearFiltering: boolean;
  28769. /** Defines if rendering to float textures is supported */
  28770. textureFloatRender: boolean;
  28771. /** Defines if half float textures are supported*/
  28772. textureHalfFloat: boolean;
  28773. /** Defines if half float texture linear filtering is supported*/
  28774. textureHalfFloatLinearFiltering: boolean;
  28775. /** Defines if rendering to half float textures is supported */
  28776. textureHalfFloatRender: boolean;
  28777. /** Defines if textureLOD shader command is supported */
  28778. textureLOD: boolean;
  28779. /** Defines if draw buffers extension is supported */
  28780. drawBuffersExtension: boolean;
  28781. /** Defines if depth textures are supported */
  28782. depthTextureExtension: boolean;
  28783. /** Defines if float color buffer are supported */
  28784. colorBufferFloat: boolean;
  28785. /** Gets disjoint timer query extension (null if not supported) */
  28786. timerQuery: EXT_disjoint_timer_query;
  28787. /** Defines if timestamp can be used with timer query */
  28788. canUseTimestampForTimerQuery: boolean;
  28789. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28790. multiview: any;
  28791. /** Function used to let the system compiles shaders in background */
  28792. parallelShaderCompile: {
  28793. COMPLETION_STATUS_KHR: number;
  28794. };
  28795. /** Max number of texture samples for MSAA */
  28796. maxMSAASamples: number;
  28797. /** Defines if the blend min max extension is supported */
  28798. blendMinMax: boolean;
  28799. }
  28800. }
  28801. declare module BABYLON {
  28802. /**
  28803. * This class is used to track a performance counter which is number based.
  28804. * The user has access to many properties which give statistics of different nature.
  28805. *
  28806. * The implementer can track two kinds of Performance Counter: time and count.
  28807. * 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.
  28808. * 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.
  28809. */
  28810. export class PerfCounter {
  28811. /**
  28812. * Gets or sets a global boolean to turn on and off all the counters
  28813. */
  28814. static Enabled: boolean;
  28815. /**
  28816. * Returns the smallest value ever
  28817. */
  28818. readonly min: number;
  28819. /**
  28820. * Returns the biggest value ever
  28821. */
  28822. readonly max: number;
  28823. /**
  28824. * Returns the average value since the performance counter is running
  28825. */
  28826. readonly average: number;
  28827. /**
  28828. * Returns the average value of the last second the counter was monitored
  28829. */
  28830. readonly lastSecAverage: number;
  28831. /**
  28832. * Returns the current value
  28833. */
  28834. readonly current: number;
  28835. /**
  28836. * Gets the accumulated total
  28837. */
  28838. readonly total: number;
  28839. /**
  28840. * Gets the total value count
  28841. */
  28842. readonly count: number;
  28843. /**
  28844. * Creates a new counter
  28845. */
  28846. constructor();
  28847. /**
  28848. * Call this method to start monitoring a new frame.
  28849. * 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.
  28850. */
  28851. fetchNewFrame(): void;
  28852. /**
  28853. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28854. * @param newCount the count value to add to the monitored count
  28855. * @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.
  28856. */
  28857. addCount(newCount: number, fetchResult: boolean): void;
  28858. /**
  28859. * Start monitoring this performance counter
  28860. */
  28861. beginMonitoring(): void;
  28862. /**
  28863. * Compute the time lapsed since the previous beginMonitoring() call.
  28864. * @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
  28865. */
  28866. endMonitoring(newFrame?: boolean): void;
  28867. private _fetchResult;
  28868. private _startMonitoringTime;
  28869. private _min;
  28870. private _max;
  28871. private _average;
  28872. private _current;
  28873. private _totalValueCount;
  28874. private _totalAccumulated;
  28875. private _lastSecAverage;
  28876. private _lastSecAccumulated;
  28877. private _lastSecTime;
  28878. private _lastSecValueCount;
  28879. }
  28880. }
  28881. declare module BABYLON {
  28882. /**
  28883. * @hidden
  28884. **/
  28885. export class DepthCullingState {
  28886. private _isDepthTestDirty;
  28887. private _isDepthMaskDirty;
  28888. private _isDepthFuncDirty;
  28889. private _isCullFaceDirty;
  28890. private _isCullDirty;
  28891. private _isZOffsetDirty;
  28892. private _isFrontFaceDirty;
  28893. private _depthTest;
  28894. private _depthMask;
  28895. private _depthFunc;
  28896. private _cull;
  28897. private _cullFace;
  28898. private _zOffset;
  28899. private _frontFace;
  28900. /**
  28901. * Initializes the state.
  28902. */
  28903. constructor();
  28904. readonly isDirty: boolean;
  28905. zOffset: number;
  28906. cullFace: Nullable<number>;
  28907. cull: Nullable<boolean>;
  28908. depthFunc: Nullable<number>;
  28909. depthMask: boolean;
  28910. depthTest: boolean;
  28911. frontFace: Nullable<number>;
  28912. reset(): void;
  28913. apply(gl: WebGLRenderingContext): void;
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. /**
  28918. * @hidden
  28919. **/
  28920. export class StencilState {
  28921. /** 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 */
  28922. static readonly ALWAYS: number;
  28923. /** Passed to stencilOperation to specify that stencil value must be kept */
  28924. static readonly KEEP: number;
  28925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28926. static readonly REPLACE: number;
  28927. private _isStencilTestDirty;
  28928. private _isStencilMaskDirty;
  28929. private _isStencilFuncDirty;
  28930. private _isStencilOpDirty;
  28931. private _stencilTest;
  28932. private _stencilMask;
  28933. private _stencilFunc;
  28934. private _stencilFuncRef;
  28935. private _stencilFuncMask;
  28936. private _stencilOpStencilFail;
  28937. private _stencilOpDepthFail;
  28938. private _stencilOpStencilDepthPass;
  28939. readonly isDirty: boolean;
  28940. stencilFunc: number;
  28941. stencilFuncRef: number;
  28942. stencilFuncMask: number;
  28943. stencilOpStencilFail: number;
  28944. stencilOpDepthFail: number;
  28945. stencilOpStencilDepthPass: number;
  28946. stencilMask: number;
  28947. stencilTest: boolean;
  28948. constructor();
  28949. reset(): void;
  28950. apply(gl: WebGLRenderingContext): void;
  28951. }
  28952. }
  28953. declare module BABYLON {
  28954. /**
  28955. * @hidden
  28956. **/
  28957. export class AlphaState {
  28958. private _isAlphaBlendDirty;
  28959. private _isBlendFunctionParametersDirty;
  28960. private _isBlendEquationParametersDirty;
  28961. private _isBlendConstantsDirty;
  28962. private _alphaBlend;
  28963. private _blendFunctionParameters;
  28964. private _blendEquationParameters;
  28965. private _blendConstants;
  28966. /**
  28967. * Initializes the state.
  28968. */
  28969. constructor();
  28970. readonly isDirty: boolean;
  28971. alphaBlend: boolean;
  28972. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28973. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28974. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28975. reset(): void;
  28976. apply(gl: WebGLRenderingContext): void;
  28977. }
  28978. }
  28979. declare module BABYLON {
  28980. /** @hidden */
  28981. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28982. attributeProcessor(attribute: string): string;
  28983. varyingProcessor(varying: string, isFragment: boolean): string;
  28984. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28985. }
  28986. }
  28987. declare module BABYLON {
  28988. /**
  28989. * Interface for attribute information associated with buffer instanciation
  28990. */
  28991. export class InstancingAttributeInfo {
  28992. /**
  28993. * Index/offset of the attribute in the vertex shader
  28994. */
  28995. index: number;
  28996. /**
  28997. * size of the attribute, 1, 2, 3 or 4
  28998. */
  28999. attributeSize: number;
  29000. /**
  29001. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29002. * default is FLOAT
  29003. */
  29004. attribyteType: number;
  29005. /**
  29006. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29007. */
  29008. normalized: boolean;
  29009. /**
  29010. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29011. */
  29012. offset: number;
  29013. /**
  29014. * Name of the GLSL attribute, for debugging purpose only
  29015. */
  29016. attributeName: string;
  29017. }
  29018. }
  29019. declare module BABYLON {
  29020. interface ThinEngine {
  29021. /**
  29022. * Update a video texture
  29023. * @param texture defines the texture to update
  29024. * @param video defines the video element to use
  29025. * @param invertY defines if data must be stored with Y axis inverted
  29026. */
  29027. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29028. }
  29029. }
  29030. declare module BABYLON {
  29031. /**
  29032. * Settings for finer control over video usage
  29033. */
  29034. export interface VideoTextureSettings {
  29035. /**
  29036. * Applies `autoplay` to video, if specified
  29037. */
  29038. autoPlay?: boolean;
  29039. /**
  29040. * Applies `loop` to video, if specified
  29041. */
  29042. loop?: boolean;
  29043. /**
  29044. * Automatically updates internal texture from video at every frame in the render loop
  29045. */
  29046. autoUpdateTexture: boolean;
  29047. /**
  29048. * Image src displayed during the video loading or until the user interacts with the video.
  29049. */
  29050. poster?: string;
  29051. }
  29052. /**
  29053. * If you want to display a video in your scene, this is the special texture for that.
  29054. * This special texture works similar to other textures, with the exception of a few parameters.
  29055. * @see https://doc.babylonjs.com/how_to/video_texture
  29056. */
  29057. export class VideoTexture extends Texture {
  29058. /**
  29059. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29060. */
  29061. readonly autoUpdateTexture: boolean;
  29062. /**
  29063. * The video instance used by the texture internally
  29064. */
  29065. readonly video: HTMLVideoElement;
  29066. private _onUserActionRequestedObservable;
  29067. /**
  29068. * Event triggerd when a dom action is required by the user to play the video.
  29069. * This happens due to recent changes in browser policies preventing video to auto start.
  29070. */
  29071. readonly onUserActionRequestedObservable: Observable<Texture>;
  29072. private _generateMipMaps;
  29073. private _engine;
  29074. private _stillImageCaptured;
  29075. private _displayingPosterTexture;
  29076. private _settings;
  29077. private _createInternalTextureOnEvent;
  29078. private _frameId;
  29079. /**
  29080. * Creates a video texture.
  29081. * If you want to display a video in your scene, this is the special texture for that.
  29082. * This special texture works similar to other textures, with the exception of a few parameters.
  29083. * @see https://doc.babylonjs.com/how_to/video_texture
  29084. * @param name optional name, will detect from video source, if not defined
  29085. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29086. * @param scene is obviously the current scene.
  29087. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29088. * @param invertY is false by default but can be used to invert video on Y axis
  29089. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29090. * @param settings allows finer control over video usage
  29091. */
  29092. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29093. private _getName;
  29094. private _getVideo;
  29095. private _createInternalTexture;
  29096. private reset;
  29097. /**
  29098. * @hidden Internal method to initiate `update`.
  29099. */
  29100. _rebuild(): void;
  29101. /**
  29102. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29103. */
  29104. update(): void;
  29105. /**
  29106. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29107. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29108. */
  29109. updateTexture(isVisible: boolean): void;
  29110. protected _updateInternalTexture: () => void;
  29111. /**
  29112. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29113. * @param url New url.
  29114. */
  29115. updateURL(url: string): void;
  29116. /**
  29117. * Dispose the texture and release its associated resources.
  29118. */
  29119. dispose(): void;
  29120. /**
  29121. * Creates a video texture straight from a stream.
  29122. * @param scene Define the scene the texture should be created in
  29123. * @param stream Define the stream the texture should be created from
  29124. * @returns The created video texture as a promise
  29125. */
  29126. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29127. /**
  29128. * Creates a video texture straight from your WebCam video feed.
  29129. * @param scene Define the scene the texture should be created in
  29130. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29131. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29132. * @returns The created video texture as a promise
  29133. */
  29134. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29135. minWidth: number;
  29136. maxWidth: number;
  29137. minHeight: number;
  29138. maxHeight: number;
  29139. deviceId: string;
  29140. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29141. /**
  29142. * Creates a video texture straight from your WebCam video feed.
  29143. * @param scene Define the scene the texture should be created in
  29144. * @param onReady Define a callback to triggered once the texture will be ready
  29145. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29146. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29147. */
  29148. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29149. minWidth: number;
  29150. maxWidth: number;
  29151. minHeight: number;
  29152. maxHeight: number;
  29153. deviceId: string;
  29154. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29155. }
  29156. }
  29157. declare module BABYLON {
  29158. /**
  29159. * Defines the interface used by objects working like Scene
  29160. * @hidden
  29161. */
  29162. interface ISceneLike {
  29163. _addPendingData(data: any): void;
  29164. _removePendingData(data: any): void;
  29165. offlineProvider: IOfflineProvider;
  29166. }
  29167. /** Interface defining initialization parameters for Engine class */
  29168. export interface EngineOptions extends WebGLContextAttributes {
  29169. /**
  29170. * Defines if the engine should no exceed a specified device ratio
  29171. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29172. */
  29173. limitDeviceRatio?: number;
  29174. /**
  29175. * Defines if webvr should be enabled automatically
  29176. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29177. */
  29178. autoEnableWebVR?: boolean;
  29179. /**
  29180. * Defines if webgl2 should be turned off even if supported
  29181. * @see http://doc.babylonjs.com/features/webgl2
  29182. */
  29183. disableWebGL2Support?: boolean;
  29184. /**
  29185. * Defines if webaudio should be initialized as well
  29186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29187. */
  29188. audioEngine?: boolean;
  29189. /**
  29190. * Defines if animations should run using a deterministic lock step
  29191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29192. */
  29193. deterministicLockstep?: boolean;
  29194. /** Defines the maximum steps to use with deterministic lock step mode */
  29195. lockstepMaxSteps?: number;
  29196. /**
  29197. * Defines that engine should ignore context lost events
  29198. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29199. */
  29200. doNotHandleContextLost?: boolean;
  29201. /**
  29202. * Defines that engine should ignore modifying touch action attribute and style
  29203. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29204. */
  29205. doNotHandleTouchAction?: boolean;
  29206. /**
  29207. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29208. */
  29209. useHighPrecisionFloats?: boolean;
  29210. }
  29211. /**
  29212. * The base engine class (root of all engines)
  29213. */
  29214. export class ThinEngine {
  29215. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29216. static ExceptionList: ({
  29217. key: string;
  29218. capture: string;
  29219. captureConstraint: number;
  29220. targets: string[];
  29221. } | {
  29222. key: string;
  29223. capture: null;
  29224. captureConstraint: null;
  29225. targets: string[];
  29226. })[];
  29227. /** @hidden */
  29228. static _TextureLoaders: IInternalTextureLoader[];
  29229. /**
  29230. * Returns the current npm package of the sdk
  29231. */
  29232. static readonly NpmPackage: string;
  29233. /**
  29234. * Returns the current version of the framework
  29235. */
  29236. static readonly Version: string;
  29237. /**
  29238. * Returns a string describing the current engine
  29239. */
  29240. readonly description: string;
  29241. /**
  29242. * Gets or sets the epsilon value used by collision engine
  29243. */
  29244. static CollisionsEpsilon: number;
  29245. /**
  29246. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29247. */
  29248. static ShadersRepository: string;
  29249. /** @hidden */
  29250. _shaderProcessor: IShaderProcessor;
  29251. /**
  29252. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29253. */
  29254. forcePOTTextures: boolean;
  29255. /**
  29256. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29257. */
  29258. isFullscreen: boolean;
  29259. /**
  29260. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29261. */
  29262. cullBackFaces: boolean;
  29263. /**
  29264. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29265. */
  29266. renderEvenInBackground: boolean;
  29267. /**
  29268. * Gets or sets a boolean indicating that cache can be kept between frames
  29269. */
  29270. preventCacheWipeBetweenFrames: boolean;
  29271. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29272. validateShaderPrograms: boolean;
  29273. /**
  29274. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29275. */
  29276. disableUniformBuffers: boolean;
  29277. /** @hidden */
  29278. _uniformBuffers: UniformBuffer[];
  29279. /**
  29280. * Gets a boolean indicating that the engine supports uniform buffers
  29281. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29282. */
  29283. readonly supportsUniformBuffers: boolean;
  29284. /** @hidden */
  29285. _gl: WebGLRenderingContext;
  29286. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29287. protected _windowIsBackground: boolean;
  29288. protected _webGLVersion: number;
  29289. protected _highPrecisionShadersAllowed: boolean;
  29290. /** @hidden */
  29291. readonly _shouldUseHighPrecisionShader: boolean;
  29292. /**
  29293. * Gets a boolean indicating that only power of 2 textures are supported
  29294. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29295. */
  29296. readonly needPOTTextures: boolean;
  29297. /** @hidden */
  29298. _badOS: boolean;
  29299. /** @hidden */
  29300. _badDesktopOS: boolean;
  29301. private _hardwareScalingLevel;
  29302. /** @hidden */
  29303. _caps: EngineCapabilities;
  29304. private _isStencilEnable;
  29305. protected _colorWrite: boolean;
  29306. /** @hidden */
  29307. _drawCalls: PerfCounter;
  29308. private _glVersion;
  29309. private _glRenderer;
  29310. private _glVendor;
  29311. /** @hidden */
  29312. _videoTextureSupported: boolean;
  29313. protected _renderingQueueLaunched: boolean;
  29314. protected _activeRenderLoops: (() => void)[];
  29315. /**
  29316. * Observable signaled when a context lost event is raised
  29317. */
  29318. onContextLostObservable: Observable<ThinEngine>;
  29319. /**
  29320. * Observable signaled when a context restored event is raised
  29321. */
  29322. onContextRestoredObservable: Observable<ThinEngine>;
  29323. private _onContextLost;
  29324. private _onContextRestored;
  29325. protected _contextWasLost: boolean;
  29326. /** @hidden */
  29327. _doNotHandleContextLost: boolean;
  29328. /**
  29329. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29330. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29331. */
  29332. doNotHandleContextLost: boolean;
  29333. /**
  29334. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29335. */
  29336. disableVertexArrayObjects: boolean;
  29337. /** @hidden */
  29338. protected _depthCullingState: DepthCullingState;
  29339. /** @hidden */
  29340. protected _stencilState: StencilState;
  29341. /** @hidden */
  29342. protected _alphaState: AlphaState;
  29343. /** @hidden */
  29344. _internalTexturesCache: InternalTexture[];
  29345. /** @hidden */
  29346. protected _activeChannel: number;
  29347. private _currentTextureChannel;
  29348. /** @hidden */
  29349. protected _boundTexturesCache: {
  29350. [key: string]: Nullable<InternalTexture>;
  29351. };
  29352. /** @hidden */
  29353. protected _currentEffect: Nullable<Effect>;
  29354. /** @hidden */
  29355. protected _currentProgram: Nullable<WebGLProgram>;
  29356. private _compiledEffects;
  29357. private _vertexAttribArraysEnabled;
  29358. /** @hidden */
  29359. protected _cachedViewport: Nullable<IViewportLike>;
  29360. private _cachedVertexArrayObject;
  29361. /** @hidden */
  29362. protected _cachedVertexBuffers: any;
  29363. /** @hidden */
  29364. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29365. /** @hidden */
  29366. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29367. /** @hidden */
  29368. _currentRenderTarget: Nullable<InternalTexture>;
  29369. private _uintIndicesCurrentlySet;
  29370. private _currentBoundBuffer;
  29371. /** @hidden */
  29372. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29373. private _currentBufferPointers;
  29374. private _currentInstanceLocations;
  29375. private _currentInstanceBuffers;
  29376. private _textureUnits;
  29377. /** @hidden */
  29378. _workingCanvas: Nullable<HTMLCanvasElement>;
  29379. /** @hidden */
  29380. _workingContext: Nullable<CanvasRenderingContext2D>;
  29381. /** @hidden */
  29382. _bindedRenderFunction: any;
  29383. private _vaoRecordInProgress;
  29384. private _mustWipeVertexAttributes;
  29385. private _emptyTexture;
  29386. private _emptyCubeTexture;
  29387. private _emptyTexture3D;
  29388. /** @hidden */
  29389. _frameHandler: number;
  29390. private _nextFreeTextureSlots;
  29391. private _maxSimultaneousTextures;
  29392. private _activeRequests;
  29393. protected _texturesSupported: string[];
  29394. /** @hidden */
  29395. _textureFormatInUse: Nullable<string>;
  29396. protected readonly _supportsHardwareTextureRescaling: boolean;
  29397. /**
  29398. * Gets the list of texture formats supported
  29399. */
  29400. readonly texturesSupported: Array<string>;
  29401. /**
  29402. * Gets the list of texture formats in use
  29403. */
  29404. readonly textureFormatInUse: Nullable<string>;
  29405. /**
  29406. * Gets the current viewport
  29407. */
  29408. readonly currentViewport: Nullable<IViewportLike>;
  29409. /**
  29410. * Gets the default empty texture
  29411. */
  29412. readonly emptyTexture: InternalTexture;
  29413. /**
  29414. * Gets the default empty 3D texture
  29415. */
  29416. readonly emptyTexture3D: InternalTexture;
  29417. /**
  29418. * Gets the default empty cube texture
  29419. */
  29420. readonly emptyCubeTexture: InternalTexture;
  29421. /**
  29422. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29423. */
  29424. readonly premultipliedAlpha: boolean;
  29425. /**
  29426. * Creates a new engine
  29427. * @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
  29428. * @param antialias defines enable antialiasing (default: false)
  29429. * @param options defines further options to be sent to the getContext() function
  29430. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29431. */
  29432. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29433. private _rebuildInternalTextures;
  29434. private _rebuildEffects;
  29435. /**
  29436. * Gets a boolean indicating if all created effects are ready
  29437. * @returns true if all effects are ready
  29438. */
  29439. areAllEffectsReady(): boolean;
  29440. protected _rebuildBuffers(): void;
  29441. private _initGLContext;
  29442. /**
  29443. * Gets version of the current webGL context
  29444. */
  29445. readonly webGLVersion: number;
  29446. /**
  29447. * Gets a string idenfifying the name of the class
  29448. * @returns "Engine" string
  29449. */
  29450. getClassName(): string;
  29451. /**
  29452. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29453. */
  29454. readonly isStencilEnable: boolean;
  29455. /** @hidden */
  29456. _prepareWorkingCanvas(): void;
  29457. /**
  29458. * Reset the texture cache to empty state
  29459. */
  29460. resetTextureCache(): void;
  29461. /**
  29462. * Gets an object containing information about the current webGL context
  29463. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29464. */
  29465. getGlInfo(): {
  29466. vendor: string;
  29467. renderer: string;
  29468. version: string;
  29469. };
  29470. /**
  29471. * Defines the hardware scaling level.
  29472. * By default the hardware scaling level is computed from the window device ratio.
  29473. * 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.
  29474. * @param level defines the level to use
  29475. */
  29476. setHardwareScalingLevel(level: number): void;
  29477. /**
  29478. * Gets the current hardware scaling level.
  29479. * By default the hardware scaling level is computed from the window device ratio.
  29480. * 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.
  29481. * @returns a number indicating the current hardware scaling level
  29482. */
  29483. getHardwareScalingLevel(): number;
  29484. /**
  29485. * Gets the list of loaded textures
  29486. * @returns an array containing all loaded textures
  29487. */
  29488. getLoadedTexturesCache(): InternalTexture[];
  29489. /**
  29490. * Gets the object containing all engine capabilities
  29491. * @returns the EngineCapabilities object
  29492. */
  29493. getCaps(): EngineCapabilities;
  29494. /**
  29495. * stop executing a render loop function and remove it from the execution array
  29496. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29497. */
  29498. stopRenderLoop(renderFunction?: () => void): void;
  29499. /** @hidden */
  29500. _renderLoop(): void;
  29501. /**
  29502. * Gets the HTML canvas attached with the current webGL context
  29503. * @returns a HTML canvas
  29504. */
  29505. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29506. /**
  29507. * Gets host window
  29508. * @returns the host window object
  29509. */
  29510. getHostWindow(): Window;
  29511. /**
  29512. * Gets the current render width
  29513. * @param useScreen defines if screen size must be used (or the current render target if any)
  29514. * @returns a number defining the current render width
  29515. */
  29516. getRenderWidth(useScreen?: boolean): number;
  29517. /**
  29518. * Gets the current render height
  29519. * @param useScreen defines if screen size must be used (or the current render target if any)
  29520. * @returns a number defining the current render height
  29521. */
  29522. getRenderHeight(useScreen?: boolean): number;
  29523. /**
  29524. * Can be used to override the current requestAnimationFrame requester.
  29525. * @hidden
  29526. */
  29527. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29528. /**
  29529. * Register and execute a render loop. The engine can have more than one render function
  29530. * @param renderFunction defines the function to continuously execute
  29531. */
  29532. runRenderLoop(renderFunction: () => void): void;
  29533. /**
  29534. * Clear the current render buffer or the current render target (if any is set up)
  29535. * @param color defines the color to use
  29536. * @param backBuffer defines if the back buffer must be cleared
  29537. * @param depth defines if the depth buffer must be cleared
  29538. * @param stencil defines if the stencil buffer must be cleared
  29539. */
  29540. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29541. private _viewportCached;
  29542. /** @hidden */
  29543. _viewport(x: number, y: number, width: number, height: number): void;
  29544. /**
  29545. * Set the WebGL's viewport
  29546. * @param viewport defines the viewport element to be used
  29547. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29548. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29549. */
  29550. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29551. /**
  29552. * Begin a new frame
  29553. */
  29554. beginFrame(): void;
  29555. /**
  29556. * Enf the current frame
  29557. */
  29558. endFrame(): void;
  29559. /**
  29560. * Resize the view according to the canvas' size
  29561. */
  29562. resize(): void;
  29563. /**
  29564. * Force a specific size of the canvas
  29565. * @param width defines the new canvas' width
  29566. * @param height defines the new canvas' height
  29567. */
  29568. setSize(width: number, height: number): void;
  29569. /**
  29570. * Binds the frame buffer to the specified texture.
  29571. * @param texture The texture to render to or null for the default canvas
  29572. * @param faceIndex The face of the texture to render to in case of cube texture
  29573. * @param requiredWidth The width of the target to render to
  29574. * @param requiredHeight The height of the target to render to
  29575. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29576. * @param depthStencilTexture The depth stencil texture to use to render
  29577. * @param lodLevel defines le lod level to bind to the frame buffer
  29578. */
  29579. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29580. /** @hidden */
  29581. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29582. /**
  29583. * Unbind the current render target texture from the webGL context
  29584. * @param texture defines the render target texture to unbind
  29585. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29586. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29587. */
  29588. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29589. /**
  29590. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29591. */
  29592. flushFramebuffer(): void;
  29593. /**
  29594. * Unbind the current render target and bind the default framebuffer
  29595. */
  29596. restoreDefaultFramebuffer(): void;
  29597. private _resetVertexBufferBinding;
  29598. /**
  29599. * Creates a vertex buffer
  29600. * @param data the data for the vertex buffer
  29601. * @returns the new WebGL static buffer
  29602. */
  29603. createVertexBuffer(data: DataArray): DataBuffer;
  29604. private _createVertexBuffer;
  29605. /**
  29606. * Creates a dynamic vertex buffer
  29607. * @param data the data for the dynamic vertex buffer
  29608. * @returns the new WebGL dynamic buffer
  29609. */
  29610. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29611. /**
  29612. * Update a dynamic index buffer
  29613. * @param indexBuffer defines the target index buffer
  29614. * @param indices defines the data to update
  29615. * @param offset defines the offset in the target index buffer where update should start
  29616. */
  29617. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29618. /**
  29619. * Updates a dynamic vertex buffer.
  29620. * @param vertexBuffer the vertex buffer to update
  29621. * @param data the data used to update the vertex buffer
  29622. * @param byteOffset the byte offset of the data
  29623. * @param byteLength the byte length of the data
  29624. */
  29625. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29626. private _resetIndexBufferBinding;
  29627. /**
  29628. * Creates a new index buffer
  29629. * @param indices defines the content of the index buffer
  29630. * @param updatable defines if the index buffer must be updatable
  29631. * @returns a new webGL buffer
  29632. */
  29633. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29634. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29635. /**
  29636. * Bind a webGL buffer to the webGL context
  29637. * @param buffer defines the buffer to bind
  29638. */
  29639. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29640. private bindIndexBuffer;
  29641. private bindBuffer;
  29642. /**
  29643. * update the bound buffer with the given data
  29644. * @param data defines the data to update
  29645. */
  29646. updateArrayBuffer(data: Float32Array): void;
  29647. private _vertexAttribPointer;
  29648. private _bindIndexBufferWithCache;
  29649. private _bindVertexBuffersAttributes;
  29650. /**
  29651. * Records a vertex array object
  29652. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29653. * @param vertexBuffers defines the list of vertex buffers to store
  29654. * @param indexBuffer defines the index buffer to store
  29655. * @param effect defines the effect to store
  29656. * @returns the new vertex array object
  29657. */
  29658. recordVertexArrayObject(vertexBuffers: {
  29659. [key: string]: VertexBuffer;
  29660. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29661. /**
  29662. * Bind a specific vertex array object
  29663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29664. * @param vertexArrayObject defines the vertex array object to bind
  29665. * @param indexBuffer defines the index buffer to bind
  29666. */
  29667. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29668. /**
  29669. * Bind webGl buffers directly to the webGL context
  29670. * @param vertexBuffer defines the vertex buffer to bind
  29671. * @param indexBuffer defines the index buffer to bind
  29672. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29673. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29674. * @param effect defines the effect associated with the vertex buffer
  29675. */
  29676. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29677. private _unbindVertexArrayObject;
  29678. /**
  29679. * Bind a list of vertex buffers to the webGL context
  29680. * @param vertexBuffers defines the list of vertex buffers to bind
  29681. * @param indexBuffer defines the index buffer to bind
  29682. * @param effect defines the effect associated with the vertex buffers
  29683. */
  29684. bindBuffers(vertexBuffers: {
  29685. [key: string]: Nullable<VertexBuffer>;
  29686. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29687. /**
  29688. * Unbind all instance attributes
  29689. */
  29690. unbindInstanceAttributes(): void;
  29691. /**
  29692. * Release and free the memory of a vertex array object
  29693. * @param vao defines the vertex array object to delete
  29694. */
  29695. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29696. /** @hidden */
  29697. _releaseBuffer(buffer: DataBuffer): boolean;
  29698. protected _deleteBuffer(buffer: DataBuffer): void;
  29699. /**
  29700. * Creates a webGL buffer to use with instanciation
  29701. * @param capacity defines the size of the buffer
  29702. * @returns the webGL buffer
  29703. */
  29704. createInstancesBuffer(capacity: number): DataBuffer;
  29705. /**
  29706. * Delete a webGL buffer used with instanciation
  29707. * @param buffer defines the webGL buffer to delete
  29708. */
  29709. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29710. /**
  29711. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29712. * @param instancesBuffer defines the webGL buffer to update and bind
  29713. * @param data defines the data to store in the buffer
  29714. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29715. */
  29716. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29717. /**
  29718. * Apply all cached states (depth, culling, stencil and alpha)
  29719. */
  29720. applyStates(): void;
  29721. /**
  29722. * Send a draw order
  29723. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29724. * @param indexStart defines the starting index
  29725. * @param indexCount defines the number of index to draw
  29726. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29727. */
  29728. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29729. /**
  29730. * Draw a list of points
  29731. * @param verticesStart defines the index of first vertex to draw
  29732. * @param verticesCount defines the count of vertices to draw
  29733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29734. */
  29735. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29736. /**
  29737. * Draw a list of unindexed primitives
  29738. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29739. * @param verticesStart defines the index of first vertex to draw
  29740. * @param verticesCount defines the count of vertices to draw
  29741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29742. */
  29743. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29744. /**
  29745. * Draw a list of indexed primitives
  29746. * @param fillMode defines the primitive to use
  29747. * @param indexStart defines the starting index
  29748. * @param indexCount defines the number of index to draw
  29749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29750. */
  29751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29752. /**
  29753. * Draw a list of unindexed primitives
  29754. * @param fillMode defines the primitive to use
  29755. * @param verticesStart defines the index of first vertex to draw
  29756. * @param verticesCount defines the count of vertices to draw
  29757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29758. */
  29759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29760. private _drawMode;
  29761. /** @hidden */
  29762. _releaseEffect(effect: Effect): void;
  29763. /** @hidden */
  29764. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29765. /**
  29766. * Create a new effect (used to store vertex/fragment shaders)
  29767. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29768. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29769. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29770. * @param samplers defines an array of string used to represent textures
  29771. * @param defines defines the string containing the defines to use to compile the shaders
  29772. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29773. * @param onCompiled defines a function to call when the effect creation is successful
  29774. * @param onError defines a function to call when the effect creation has failed
  29775. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29776. * @returns the new Effect
  29777. */
  29778. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29779. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29780. private _compileShader;
  29781. private _compileRawShader;
  29782. /**
  29783. * Directly creates a webGL program
  29784. * @param pipelineContext defines the pipeline context to attach to
  29785. * @param vertexCode defines the vertex shader code to use
  29786. * @param fragmentCode defines the fragment shader code to use
  29787. * @param context defines the webGL context to use (if not set, the current one will be used)
  29788. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29789. * @returns the new webGL program
  29790. */
  29791. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29792. /**
  29793. * Creates a webGL program
  29794. * @param pipelineContext defines the pipeline context to attach to
  29795. * @param vertexCode defines the vertex shader code to use
  29796. * @param fragmentCode defines the fragment shader code to use
  29797. * @param defines defines the string containing the defines to use to compile the shaders
  29798. * @param context defines the webGL context to use (if not set, the current one will be used)
  29799. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29800. * @returns the new webGL program
  29801. */
  29802. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29803. /**
  29804. * Creates a new pipeline context
  29805. * @returns the new pipeline
  29806. */
  29807. createPipelineContext(): IPipelineContext;
  29808. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29809. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29810. /** @hidden */
  29811. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29812. /** @hidden */
  29813. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29814. /** @hidden */
  29815. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29816. /**
  29817. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29818. * @param pipelineContext defines the pipeline context to use
  29819. * @param uniformsNames defines the list of uniform names
  29820. * @returns an array of webGL uniform locations
  29821. */
  29822. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29823. /**
  29824. * Gets the lsit of active attributes for a given webGL program
  29825. * @param pipelineContext defines the pipeline context to use
  29826. * @param attributesNames defines the list of attribute names to get
  29827. * @returns an array of indices indicating the offset of each attribute
  29828. */
  29829. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29830. /**
  29831. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29832. * @param effect defines the effect to activate
  29833. */
  29834. enableEffect(effect: Nullable<Effect>): void;
  29835. /**
  29836. * Set the value of an uniform to an array of int32
  29837. * @param uniform defines the webGL uniform location where to store the value
  29838. * @param array defines the array of int32 to store
  29839. */
  29840. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29841. /**
  29842. * Set the value of an uniform to an array of int32 (stored as vec2)
  29843. * @param uniform defines the webGL uniform location where to store the value
  29844. * @param array defines the array of int32 to store
  29845. */
  29846. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29847. /**
  29848. * Set the value of an uniform to an array of int32 (stored as vec3)
  29849. * @param uniform defines the webGL uniform location where to store the value
  29850. * @param array defines the array of int32 to store
  29851. */
  29852. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29853. /**
  29854. * Set the value of an uniform to an array of int32 (stored as vec4)
  29855. * @param uniform defines the webGL uniform location where to store the value
  29856. * @param array defines the array of int32 to store
  29857. */
  29858. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29859. /**
  29860. * Set the value of an uniform to an array of float32
  29861. * @param uniform defines the webGL uniform location where to store the value
  29862. * @param array defines the array of float32 to store
  29863. */
  29864. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29865. /**
  29866. * Set the value of an uniform to an array of float32 (stored as vec2)
  29867. * @param uniform defines the webGL uniform location where to store the value
  29868. * @param array defines the array of float32 to store
  29869. */
  29870. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29871. /**
  29872. * Set the value of an uniform to an array of float32 (stored as vec3)
  29873. * @param uniform defines the webGL uniform location where to store the value
  29874. * @param array defines the array of float32 to store
  29875. */
  29876. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29877. /**
  29878. * Set the value of an uniform to an array of float32 (stored as vec4)
  29879. * @param uniform defines the webGL uniform location where to store the value
  29880. * @param array defines the array of float32 to store
  29881. */
  29882. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29883. /**
  29884. * Set the value of an uniform to an array of number
  29885. * @param uniform defines the webGL uniform location where to store the value
  29886. * @param array defines the array of number to store
  29887. */
  29888. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29889. /**
  29890. * Set the value of an uniform to an array of number (stored as vec2)
  29891. * @param uniform defines the webGL uniform location where to store the value
  29892. * @param array defines the array of number to store
  29893. */
  29894. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29895. /**
  29896. * Set the value of an uniform to an array of number (stored as vec3)
  29897. * @param uniform defines the webGL uniform location where to store the value
  29898. * @param array defines the array of number to store
  29899. */
  29900. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29901. /**
  29902. * Set the value of an uniform to an array of number (stored as vec4)
  29903. * @param uniform defines the webGL uniform location where to store the value
  29904. * @param array defines the array of number to store
  29905. */
  29906. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29907. /**
  29908. * Set the value of an uniform to an array of float32 (stored as matrices)
  29909. * @param uniform defines the webGL uniform location where to store the value
  29910. * @param matrices defines the array of float32 to store
  29911. */
  29912. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29913. /**
  29914. * Set the value of an uniform to a matrix (3x3)
  29915. * @param uniform defines the webGL uniform location where to store the value
  29916. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29917. */
  29918. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29919. /**
  29920. * Set the value of an uniform to a matrix (2x2)
  29921. * @param uniform defines the webGL uniform location where to store the value
  29922. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29923. */
  29924. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29925. /**
  29926. * Set the value of an uniform to a number (int)
  29927. * @param uniform defines the webGL uniform location where to store the value
  29928. * @param value defines the int number to store
  29929. */
  29930. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29931. /**
  29932. * Set the value of an uniform to a number (float)
  29933. * @param uniform defines the webGL uniform location where to store the value
  29934. * @param value defines the float number to store
  29935. */
  29936. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29937. /**
  29938. * Set the value of an uniform to a vec2
  29939. * @param uniform defines the webGL uniform location where to store the value
  29940. * @param x defines the 1st component of the value
  29941. * @param y defines the 2nd component of the value
  29942. */
  29943. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29944. /**
  29945. * Set the value of an uniform to a vec3
  29946. * @param uniform defines the webGL uniform location where to store the value
  29947. * @param x defines the 1st component of the value
  29948. * @param y defines the 2nd component of the value
  29949. * @param z defines the 3rd component of the value
  29950. */
  29951. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29952. /**
  29953. * Set the value of an uniform to a boolean
  29954. * @param uniform defines the webGL uniform location where to store the value
  29955. * @param bool defines the boolean to store
  29956. */
  29957. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29958. /**
  29959. * Set the value of an uniform to a vec4
  29960. * @param uniform defines the webGL uniform location where to store the value
  29961. * @param x defines the 1st component of the value
  29962. * @param y defines the 2nd component of the value
  29963. * @param z defines the 3rd component of the value
  29964. * @param w defines the 4th component of the value
  29965. */
  29966. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29967. /**
  29968. * Sets a Color4 on a uniform variable
  29969. * @param uniform defines the uniform location
  29970. * @param color4 defines the value to be set
  29971. */
  29972. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29973. /**
  29974. * Gets the depth culling state manager
  29975. */
  29976. readonly depthCullingState: DepthCullingState;
  29977. /**
  29978. * Gets the alpha state manager
  29979. */
  29980. readonly alphaState: AlphaState;
  29981. /**
  29982. * Gets the stencil state manager
  29983. */
  29984. readonly stencilState: StencilState;
  29985. /**
  29986. * Clears the list of texture accessible through engine.
  29987. * This can help preventing texture load conflict due to name collision.
  29988. */
  29989. clearInternalTexturesCache(): void;
  29990. /**
  29991. * Force the entire cache to be cleared
  29992. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29993. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29994. */
  29995. wipeCaches(bruteForce?: boolean): void;
  29996. /** @hidden */
  29997. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29998. min: number;
  29999. mag: number;
  30000. };
  30001. /** @hidden */
  30002. _createTexture(): WebGLTexture;
  30003. /**
  30004. * Usually called from Texture.ts.
  30005. * Passed information to create a WebGLTexture
  30006. * @param urlArg defines a value which contains one of the following:
  30007. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30008. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30009. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30010. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30011. * @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)
  30012. * @param scene needed for loading to the correct scene
  30013. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30014. * @param onLoad optional callback to be called upon successful completion
  30015. * @param onError optional callback to be called upon failure
  30016. * @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
  30017. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30018. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30019. * @param forcedExtension defines the extension to use to pick the right loader
  30020. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30021. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30022. */
  30023. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30024. /**
  30025. * @hidden
  30026. */
  30027. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30028. /**
  30029. * Creates a raw texture
  30030. * @param data defines the data to store in the texture
  30031. * @param width defines the width of the texture
  30032. * @param height defines the height of the texture
  30033. * @param format defines the format of the data
  30034. * @param generateMipMaps defines if the engine should generate the mip levels
  30035. * @param invertY defines if data must be stored with Y axis inverted
  30036. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30037. * @param compression defines the compression used (null by default)
  30038. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30039. * @returns the raw texture inside an InternalTexture
  30040. */
  30041. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30042. /**
  30043. * Creates a new raw cube texture
  30044. * @param data defines the array of data to use to create each face
  30045. * @param size defines the size of the textures
  30046. * @param format defines the format of the data
  30047. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30048. * @param generateMipMaps defines if the engine should generate the mip levels
  30049. * @param invertY defines if data must be stored with Y axis inverted
  30050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30051. * @param compression defines the compression used (null by default)
  30052. * @returns the cube texture as an InternalTexture
  30053. */
  30054. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30055. /**
  30056. * Creates a new raw 3D texture
  30057. * @param data defines the data used to create the texture
  30058. * @param width defines the width of the texture
  30059. * @param height defines the height of the texture
  30060. * @param depth defines the depth of the texture
  30061. * @param format defines the format of the texture
  30062. * @param generateMipMaps defines if the engine must generate mip levels
  30063. * @param invertY defines if data must be stored with Y axis inverted
  30064. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30065. * @param compression defines the compressed used (can be null)
  30066. * @param textureType defines the compressed used (can be null)
  30067. * @returns a new raw 3D texture (stored in an InternalTexture)
  30068. */
  30069. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30070. private _unpackFlipYCached;
  30071. /**
  30072. * In case you are sharing the context with other applications, it might
  30073. * be interested to not cache the unpack flip y state to ensure a consistent
  30074. * value would be set.
  30075. */
  30076. enableUnpackFlipYCached: boolean;
  30077. /** @hidden */
  30078. _unpackFlipY(value: boolean): void;
  30079. /** @hidden */
  30080. _getUnpackAlignement(): number;
  30081. /**
  30082. * Update the sampling mode of a given texture
  30083. * @param samplingMode defines the required sampling mode
  30084. * @param texture defines the texture to update
  30085. */
  30086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30087. /**
  30088. * Updates a depth texture Comparison Mode and Function.
  30089. * If the comparison Function is equal to 0, the mode will be set to none.
  30090. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30091. * @param texture The texture to set the comparison function for
  30092. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30093. */
  30094. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30095. /** @hidden */
  30096. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30097. width: number;
  30098. height: number;
  30099. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30100. /**
  30101. * Creates a depth stencil texture.
  30102. * This is only available in WebGL 2 or with the depth texture extension available.
  30103. * @param size The size of face edge in the texture.
  30104. * @param options The options defining the texture.
  30105. * @returns The texture
  30106. */
  30107. createDepthStencilTexture(size: number | {
  30108. width: number;
  30109. height: number;
  30110. }, options: DepthTextureCreationOptions): InternalTexture;
  30111. /**
  30112. * Creates a depth stencil texture.
  30113. * This is only available in WebGL 2 or with the depth texture extension available.
  30114. * @param size The size of face edge in the texture.
  30115. * @param options The options defining the texture.
  30116. * @returns The texture
  30117. */
  30118. private _createDepthStencilTexture;
  30119. /**
  30120. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30121. * @param renderTarget The render target to set the frame buffer for
  30122. */
  30123. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30124. /** @hidden */
  30125. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30126. /** @hidden */
  30127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30128. /** @hidden */
  30129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30130. /** @hidden */
  30131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30132. /** @hidden */
  30133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30134. /**
  30135. * @hidden
  30136. */
  30137. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30138. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30139. private _prepareWebGLTexture;
  30140. /** @hidden */
  30141. _releaseFramebufferObjects(texture: InternalTexture): void;
  30142. /** @hidden */
  30143. _releaseTexture(texture: InternalTexture): void;
  30144. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30145. protected _setProgram(program: WebGLProgram): void;
  30146. protected _boundUniforms: {
  30147. [key: number]: WebGLUniformLocation;
  30148. };
  30149. /**
  30150. * Binds an effect to the webGL context
  30151. * @param effect defines the effect to bind
  30152. */
  30153. bindSamplers(effect: Effect): void;
  30154. private _activateCurrentTexture;
  30155. /** @hidden */
  30156. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30157. /** @hidden */
  30158. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30159. /**
  30160. * Unbind all textures from the webGL context
  30161. */
  30162. unbindAllTextures(): void;
  30163. /**
  30164. * Sets a texture to the according uniform.
  30165. * @param channel The texture channel
  30166. * @param uniform The uniform to set
  30167. * @param texture The texture to apply
  30168. */
  30169. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30170. private _bindSamplerUniformToChannel;
  30171. private _getTextureWrapMode;
  30172. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30173. /**
  30174. * Sets an array of texture to the webGL context
  30175. * @param channel defines the channel where the texture array must be set
  30176. * @param uniform defines the associated uniform location
  30177. * @param textures defines the array of textures to bind
  30178. */
  30179. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30180. /** @hidden */
  30181. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30182. private _setTextureParameterFloat;
  30183. private _setTextureParameterInteger;
  30184. /**
  30185. * Unbind all vertex attributes from the webGL context
  30186. */
  30187. unbindAllAttributes(): void;
  30188. /**
  30189. * 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
  30190. */
  30191. releaseEffects(): void;
  30192. /**
  30193. * Dispose and release all associated resources
  30194. */
  30195. dispose(): void;
  30196. /**
  30197. * Attach a new callback raised when context lost event is fired
  30198. * @param callback defines the callback to call
  30199. */
  30200. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30201. /**
  30202. * Attach a new callback raised when context restored event is fired
  30203. * @param callback defines the callback to call
  30204. */
  30205. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30206. /**
  30207. * Get the current error code of the webGL context
  30208. * @returns the error code
  30209. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30210. */
  30211. getError(): number;
  30212. private _canRenderToFloatFramebuffer;
  30213. private _canRenderToHalfFloatFramebuffer;
  30214. private _canRenderToFramebuffer;
  30215. /** @hidden */
  30216. _getWebGLTextureType(type: number): number;
  30217. /** @hidden */
  30218. _getInternalFormat(format: number): number;
  30219. /** @hidden */
  30220. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30221. /** @hidden */
  30222. _getRGBAMultiSampleBufferFormat(type: number): number;
  30223. /** @hidden */
  30224. _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;
  30225. /**
  30226. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30227. * @returns true if the engine can be created
  30228. * @ignorenaming
  30229. */
  30230. static isSupported(): boolean;
  30231. /**
  30232. * Find the next highest power of two.
  30233. * @param x Number to start search from.
  30234. * @return Next highest power of two.
  30235. */
  30236. static CeilingPOT(x: number): number;
  30237. /**
  30238. * Find the next lowest power of two.
  30239. * @param x Number to start search from.
  30240. * @return Next lowest power of two.
  30241. */
  30242. static FloorPOT(x: number): number;
  30243. /**
  30244. * Find the nearest power of two.
  30245. * @param x Number to start search from.
  30246. * @return Next nearest power of two.
  30247. */
  30248. static NearestPOT(x: number): number;
  30249. /**
  30250. * Get the closest exponent of two
  30251. * @param value defines the value to approximate
  30252. * @param max defines the maximum value to return
  30253. * @param mode defines how to define the closest value
  30254. * @returns closest exponent of two of the given value
  30255. */
  30256. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30257. /**
  30258. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30259. * @param func - the function to be called
  30260. * @param requester - the object that will request the next frame. Falls back to window.
  30261. * @returns frame number
  30262. */
  30263. static QueueNewFrame(func: () => void, requester?: any): number;
  30264. }
  30265. }
  30266. declare module BABYLON {
  30267. /**
  30268. * Class used to store data associated with WebGL texture data for the engine
  30269. * This class should not be used directly
  30270. */
  30271. export class InternalTexture {
  30272. /** @hidden */
  30273. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30274. /**
  30275. * The source of the texture data is unknown
  30276. */
  30277. static DATASOURCE_UNKNOWN: number;
  30278. /**
  30279. * Texture data comes from an URL
  30280. */
  30281. static DATASOURCE_URL: number;
  30282. /**
  30283. * Texture data is only used for temporary storage
  30284. */
  30285. static DATASOURCE_TEMP: number;
  30286. /**
  30287. * Texture data comes from raw data (ArrayBuffer)
  30288. */
  30289. static DATASOURCE_RAW: number;
  30290. /**
  30291. * Texture content is dynamic (video or dynamic texture)
  30292. */
  30293. static DATASOURCE_DYNAMIC: number;
  30294. /**
  30295. * Texture content is generated by rendering to it
  30296. */
  30297. static DATASOURCE_RENDERTARGET: number;
  30298. /**
  30299. * Texture content is part of a multi render target process
  30300. */
  30301. static DATASOURCE_MULTIRENDERTARGET: number;
  30302. /**
  30303. * Texture data comes from a cube data file
  30304. */
  30305. static DATASOURCE_CUBE: number;
  30306. /**
  30307. * Texture data comes from a raw cube data
  30308. */
  30309. static DATASOURCE_CUBERAW: number;
  30310. /**
  30311. * Texture data come from a prefiltered cube data file
  30312. */
  30313. static DATASOURCE_CUBEPREFILTERED: number;
  30314. /**
  30315. * Texture content is raw 3D data
  30316. */
  30317. static DATASOURCE_RAW3D: number;
  30318. /**
  30319. * Texture content is a depth texture
  30320. */
  30321. static DATASOURCE_DEPTHTEXTURE: number;
  30322. /**
  30323. * Texture data comes from a raw cube data encoded with RGBD
  30324. */
  30325. static DATASOURCE_CUBERAW_RGBD: number;
  30326. /**
  30327. * Defines if the texture is ready
  30328. */
  30329. isReady: boolean;
  30330. /**
  30331. * Defines if the texture is a cube texture
  30332. */
  30333. isCube: boolean;
  30334. /**
  30335. * Defines if the texture contains 3D data
  30336. */
  30337. is3D: boolean;
  30338. /**
  30339. * Defines if the texture contains multiview data
  30340. */
  30341. isMultiview: boolean;
  30342. /**
  30343. * Gets the URL used to load this texture
  30344. */
  30345. url: string;
  30346. /**
  30347. * Gets the sampling mode of the texture
  30348. */
  30349. samplingMode: number;
  30350. /**
  30351. * Gets a boolean indicating if the texture needs mipmaps generation
  30352. */
  30353. generateMipMaps: boolean;
  30354. /**
  30355. * Gets the number of samples used by the texture (WebGL2+ only)
  30356. */
  30357. samples: number;
  30358. /**
  30359. * Gets the type of the texture (int, float...)
  30360. */
  30361. type: number;
  30362. /**
  30363. * Gets the format of the texture (RGB, RGBA...)
  30364. */
  30365. format: number;
  30366. /**
  30367. * Observable called when the texture is loaded
  30368. */
  30369. onLoadedObservable: Observable<InternalTexture>;
  30370. /**
  30371. * Gets the width of the texture
  30372. */
  30373. width: number;
  30374. /**
  30375. * Gets the height of the texture
  30376. */
  30377. height: number;
  30378. /**
  30379. * Gets the depth of the texture
  30380. */
  30381. depth: number;
  30382. /**
  30383. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30384. */
  30385. baseWidth: number;
  30386. /**
  30387. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30388. */
  30389. baseHeight: number;
  30390. /**
  30391. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30392. */
  30393. baseDepth: number;
  30394. /**
  30395. * Gets a boolean indicating if the texture is inverted on Y axis
  30396. */
  30397. invertY: boolean;
  30398. /** @hidden */
  30399. _invertVScale: boolean;
  30400. /** @hidden */
  30401. _associatedChannel: number;
  30402. /** @hidden */
  30403. _dataSource: number;
  30404. /** @hidden */
  30405. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30406. /** @hidden */
  30407. _bufferView: Nullable<ArrayBufferView>;
  30408. /** @hidden */
  30409. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30410. /** @hidden */
  30411. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30412. /** @hidden */
  30413. _size: number;
  30414. /** @hidden */
  30415. _extension: string;
  30416. /** @hidden */
  30417. _files: Nullable<string[]>;
  30418. /** @hidden */
  30419. _workingCanvas: Nullable<HTMLCanvasElement>;
  30420. /** @hidden */
  30421. _workingContext: Nullable<CanvasRenderingContext2D>;
  30422. /** @hidden */
  30423. _framebuffer: Nullable<WebGLFramebuffer>;
  30424. /** @hidden */
  30425. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30426. /** @hidden */
  30427. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30428. /** @hidden */
  30429. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30430. /** @hidden */
  30431. _attachments: Nullable<number[]>;
  30432. /** @hidden */
  30433. _cachedCoordinatesMode: Nullable<number>;
  30434. /** @hidden */
  30435. _cachedWrapU: Nullable<number>;
  30436. /** @hidden */
  30437. _cachedWrapV: Nullable<number>;
  30438. /** @hidden */
  30439. _cachedWrapR: Nullable<number>;
  30440. /** @hidden */
  30441. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30442. /** @hidden */
  30443. _isDisabled: boolean;
  30444. /** @hidden */
  30445. _compression: Nullable<string>;
  30446. /** @hidden */
  30447. _generateStencilBuffer: boolean;
  30448. /** @hidden */
  30449. _generateDepthBuffer: boolean;
  30450. /** @hidden */
  30451. _comparisonFunction: number;
  30452. /** @hidden */
  30453. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30454. /** @hidden */
  30455. _lodGenerationScale: number;
  30456. /** @hidden */
  30457. _lodGenerationOffset: number;
  30458. /** @hidden */
  30459. _colorTextureArray: Nullable<WebGLTexture>;
  30460. /** @hidden */
  30461. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30462. /** @hidden */
  30463. _lodTextureHigh: Nullable<BaseTexture>;
  30464. /** @hidden */
  30465. _lodTextureMid: Nullable<BaseTexture>;
  30466. /** @hidden */
  30467. _lodTextureLow: Nullable<BaseTexture>;
  30468. /** @hidden */
  30469. _isRGBD: boolean;
  30470. /** @hidden */
  30471. _linearSpecularLOD: boolean;
  30472. /** @hidden */
  30473. _irradianceTexture: Nullable<BaseTexture>;
  30474. /** @hidden */
  30475. _webGLTexture: Nullable<WebGLTexture>;
  30476. /** @hidden */
  30477. _references: number;
  30478. private _engine;
  30479. /**
  30480. * Gets the Engine the texture belongs to.
  30481. * @returns The babylon engine
  30482. */
  30483. getEngine(): ThinEngine;
  30484. /**
  30485. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30486. */
  30487. readonly dataSource: number;
  30488. /**
  30489. * Creates a new InternalTexture
  30490. * @param engine defines the engine to use
  30491. * @param dataSource defines the type of data that will be used
  30492. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30493. */
  30494. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  30495. /**
  30496. * Increments the number of references (ie. the number of Texture that point to it)
  30497. */
  30498. incrementReferences(): void;
  30499. /**
  30500. * Change the size of the texture (not the size of the content)
  30501. * @param width defines the new width
  30502. * @param height defines the new height
  30503. * @param depth defines the new depth (1 by default)
  30504. */
  30505. updateSize(width: int, height: int, depth?: int): void;
  30506. /** @hidden */
  30507. _rebuild(): void;
  30508. /** @hidden */
  30509. _swapAndDie(target: InternalTexture): void;
  30510. /**
  30511. * Dispose the current allocated resources
  30512. */
  30513. dispose(): void;
  30514. }
  30515. }
  30516. declare module BABYLON {
  30517. /**
  30518. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30520. */
  30521. export class Analyser {
  30522. /**
  30523. * Gets or sets the smoothing
  30524. * @ignorenaming
  30525. */
  30526. SMOOTHING: number;
  30527. /**
  30528. * Gets or sets the FFT table size
  30529. * @ignorenaming
  30530. */
  30531. FFT_SIZE: number;
  30532. /**
  30533. * Gets or sets the bar graph amplitude
  30534. * @ignorenaming
  30535. */
  30536. BARGRAPHAMPLITUDE: number;
  30537. /**
  30538. * Gets or sets the position of the debug canvas
  30539. * @ignorenaming
  30540. */
  30541. DEBUGCANVASPOS: {
  30542. x: number;
  30543. y: number;
  30544. };
  30545. /**
  30546. * Gets or sets the debug canvas size
  30547. * @ignorenaming
  30548. */
  30549. DEBUGCANVASSIZE: {
  30550. width: number;
  30551. height: number;
  30552. };
  30553. private _byteFreqs;
  30554. private _byteTime;
  30555. private _floatFreqs;
  30556. private _webAudioAnalyser;
  30557. private _debugCanvas;
  30558. private _debugCanvasContext;
  30559. private _scene;
  30560. private _registerFunc;
  30561. private _audioEngine;
  30562. /**
  30563. * Creates a new analyser
  30564. * @param scene defines hosting scene
  30565. */
  30566. constructor(scene: Scene);
  30567. /**
  30568. * Get the number of data values you will have to play with for the visualization
  30569. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30570. * @returns a number
  30571. */
  30572. getFrequencyBinCount(): number;
  30573. /**
  30574. * Gets the current frequency data as a byte array
  30575. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30576. * @returns a Uint8Array
  30577. */
  30578. getByteFrequencyData(): Uint8Array;
  30579. /**
  30580. * Gets the current waveform as a byte array
  30581. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30582. * @returns a Uint8Array
  30583. */
  30584. getByteTimeDomainData(): Uint8Array;
  30585. /**
  30586. * Gets the current frequency data as a float array
  30587. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30588. * @returns a Float32Array
  30589. */
  30590. getFloatFrequencyData(): Float32Array;
  30591. /**
  30592. * Renders the debug canvas
  30593. */
  30594. drawDebugCanvas(): void;
  30595. /**
  30596. * Stops rendering the debug canvas and removes it
  30597. */
  30598. stopDebugCanvas(): void;
  30599. /**
  30600. * Connects two audio nodes
  30601. * @param inputAudioNode defines first node to connect
  30602. * @param outputAudioNode defines second node to connect
  30603. */
  30604. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30605. /**
  30606. * Releases all associated resources
  30607. */
  30608. dispose(): void;
  30609. }
  30610. }
  30611. declare module BABYLON {
  30612. /**
  30613. * This represents an audio engine and it is responsible
  30614. * to play, synchronize and analyse sounds throughout the application.
  30615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30616. */
  30617. export interface IAudioEngine extends IDisposable {
  30618. /**
  30619. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30620. */
  30621. readonly canUseWebAudio: boolean;
  30622. /**
  30623. * Gets the current AudioContext if available.
  30624. */
  30625. readonly audioContext: Nullable<AudioContext>;
  30626. /**
  30627. * The master gain node defines the global audio volume of your audio engine.
  30628. */
  30629. readonly masterGain: GainNode;
  30630. /**
  30631. * Gets whether or not mp3 are supported by your browser.
  30632. */
  30633. readonly isMP3supported: boolean;
  30634. /**
  30635. * Gets whether or not ogg are supported by your browser.
  30636. */
  30637. readonly isOGGsupported: boolean;
  30638. /**
  30639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30640. * @ignoreNaming
  30641. */
  30642. WarnedWebAudioUnsupported: boolean;
  30643. /**
  30644. * Defines if the audio engine relies on a custom unlocked button.
  30645. * In this case, the embedded button will not be displayed.
  30646. */
  30647. useCustomUnlockedButton: boolean;
  30648. /**
  30649. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30650. */
  30651. readonly unlocked: boolean;
  30652. /**
  30653. * Event raised when audio has been unlocked on the browser.
  30654. */
  30655. onAudioUnlockedObservable: Observable<AudioEngine>;
  30656. /**
  30657. * Event raised when audio has been locked on the browser.
  30658. */
  30659. onAudioLockedObservable: Observable<AudioEngine>;
  30660. /**
  30661. * Flags the audio engine in Locked state.
  30662. * This happens due to new browser policies preventing audio to autoplay.
  30663. */
  30664. lock(): void;
  30665. /**
  30666. * Unlocks the audio engine once a user action has been done on the dom.
  30667. * This is helpful to resume play once browser policies have been satisfied.
  30668. */
  30669. unlock(): void;
  30670. }
  30671. /**
  30672. * This represents the default audio engine used in babylon.
  30673. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30675. */
  30676. export class AudioEngine implements IAudioEngine {
  30677. private _audioContext;
  30678. private _audioContextInitialized;
  30679. private _muteButton;
  30680. private _hostElement;
  30681. /**
  30682. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30683. */
  30684. canUseWebAudio: boolean;
  30685. /**
  30686. * The master gain node defines the global audio volume of your audio engine.
  30687. */
  30688. masterGain: GainNode;
  30689. /**
  30690. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30691. * @ignoreNaming
  30692. */
  30693. WarnedWebAudioUnsupported: boolean;
  30694. /**
  30695. * Gets whether or not mp3 are supported by your browser.
  30696. */
  30697. isMP3supported: boolean;
  30698. /**
  30699. * Gets whether or not ogg are supported by your browser.
  30700. */
  30701. isOGGsupported: boolean;
  30702. /**
  30703. * Gets whether audio has been unlocked on the device.
  30704. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30705. * a user interaction has happened.
  30706. */
  30707. unlocked: boolean;
  30708. /**
  30709. * Defines if the audio engine relies on a custom unlocked button.
  30710. * In this case, the embedded button will not be displayed.
  30711. */
  30712. useCustomUnlockedButton: boolean;
  30713. /**
  30714. * Event raised when audio has been unlocked on the browser.
  30715. */
  30716. onAudioUnlockedObservable: Observable<AudioEngine>;
  30717. /**
  30718. * Event raised when audio has been locked on the browser.
  30719. */
  30720. onAudioLockedObservable: Observable<AudioEngine>;
  30721. /**
  30722. * Gets the current AudioContext if available.
  30723. */
  30724. readonly audioContext: Nullable<AudioContext>;
  30725. private _connectedAnalyser;
  30726. /**
  30727. * Instantiates a new audio engine.
  30728. *
  30729. * There should be only one per page as some browsers restrict the number
  30730. * of audio contexts you can create.
  30731. * @param hostElement defines the host element where to display the mute icon if necessary
  30732. */
  30733. constructor(hostElement?: Nullable<HTMLElement>);
  30734. /**
  30735. * Flags the audio engine in Locked state.
  30736. * This happens due to new browser policies preventing audio to autoplay.
  30737. */
  30738. lock(): void;
  30739. /**
  30740. * Unlocks the audio engine once a user action has been done on the dom.
  30741. * This is helpful to resume play once browser policies have been satisfied.
  30742. */
  30743. unlock(): void;
  30744. private _resumeAudioContext;
  30745. private _initializeAudioContext;
  30746. private _tryToRun;
  30747. private _triggerRunningState;
  30748. private _triggerSuspendedState;
  30749. private _displayMuteButton;
  30750. private _moveButtonToTopLeft;
  30751. private _onResize;
  30752. private _hideMuteButton;
  30753. /**
  30754. * Destroy and release the resources associated with the audio ccontext.
  30755. */
  30756. dispose(): void;
  30757. /**
  30758. * Gets the global volume sets on the master gain.
  30759. * @returns the global volume if set or -1 otherwise
  30760. */
  30761. getGlobalVolume(): number;
  30762. /**
  30763. * Sets the global volume of your experience (sets on the master gain).
  30764. * @param newVolume Defines the new global volume of the application
  30765. */
  30766. setGlobalVolume(newVolume: number): void;
  30767. /**
  30768. * Connect the audio engine to an audio analyser allowing some amazing
  30769. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30771. * @param analyser The analyser to connect to the engine
  30772. */
  30773. connectToAnalyser(analyser: Analyser): void;
  30774. }
  30775. }
  30776. declare module BABYLON {
  30777. /**
  30778. * Interface used to present a loading screen while loading a scene
  30779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30780. */
  30781. export interface ILoadingScreen {
  30782. /**
  30783. * Function called to display the loading screen
  30784. */
  30785. displayLoadingUI: () => void;
  30786. /**
  30787. * Function called to hide the loading screen
  30788. */
  30789. hideLoadingUI: () => void;
  30790. /**
  30791. * Gets or sets the color to use for the background
  30792. */
  30793. loadingUIBackgroundColor: string;
  30794. /**
  30795. * Gets or sets the text to display while loading
  30796. */
  30797. loadingUIText: string;
  30798. }
  30799. /**
  30800. * Class used for the default loading screen
  30801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30802. */
  30803. export class DefaultLoadingScreen implements ILoadingScreen {
  30804. private _renderingCanvas;
  30805. private _loadingText;
  30806. private _loadingDivBackgroundColor;
  30807. private _loadingDiv;
  30808. private _loadingTextDiv;
  30809. /** Gets or sets the logo url to use for the default loading screen */
  30810. static DefaultLogoUrl: string;
  30811. /** Gets or sets the spinner url to use for the default loading screen */
  30812. static DefaultSpinnerUrl: string;
  30813. /**
  30814. * Creates a new default loading screen
  30815. * @param _renderingCanvas defines the canvas used to render the scene
  30816. * @param _loadingText defines the default text to display
  30817. * @param _loadingDivBackgroundColor defines the default background color
  30818. */
  30819. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30820. /**
  30821. * Function called to display the loading screen
  30822. */
  30823. displayLoadingUI(): void;
  30824. /**
  30825. * Function called to hide the loading screen
  30826. */
  30827. hideLoadingUI(): void;
  30828. /**
  30829. * Gets or sets the text to display while loading
  30830. */
  30831. loadingUIText: string;
  30832. /**
  30833. * Gets or sets the color to use for the background
  30834. */
  30835. loadingUIBackgroundColor: string;
  30836. private _resizeLoadingUI;
  30837. }
  30838. }
  30839. declare module BABYLON {
  30840. /**
  30841. * Interface for any object that can request an animation frame
  30842. */
  30843. export interface ICustomAnimationFrameRequester {
  30844. /**
  30845. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30846. */
  30847. renderFunction?: Function;
  30848. /**
  30849. * Called to request the next frame to render to
  30850. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30851. */
  30852. requestAnimationFrame: Function;
  30853. /**
  30854. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30855. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30856. */
  30857. requestID?: number;
  30858. }
  30859. }
  30860. declare module BABYLON {
  30861. /**
  30862. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30863. */
  30864. export class PerformanceMonitor {
  30865. private _enabled;
  30866. private _rollingFrameTime;
  30867. private _lastFrameTimeMs;
  30868. /**
  30869. * constructor
  30870. * @param frameSampleSize The number of samples required to saturate the sliding window
  30871. */
  30872. constructor(frameSampleSize?: number);
  30873. /**
  30874. * Samples current frame
  30875. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30876. */
  30877. sampleFrame(timeMs?: number): void;
  30878. /**
  30879. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30880. */
  30881. readonly averageFrameTime: number;
  30882. /**
  30883. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30884. */
  30885. readonly averageFrameTimeVariance: number;
  30886. /**
  30887. * Returns the frame time of the most recent frame
  30888. */
  30889. readonly instantaneousFrameTime: number;
  30890. /**
  30891. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30892. */
  30893. readonly averageFPS: number;
  30894. /**
  30895. * Returns the average framerate in frames per second using the most recent frame time
  30896. */
  30897. readonly instantaneousFPS: number;
  30898. /**
  30899. * Returns true if enough samples have been taken to completely fill the sliding window
  30900. */
  30901. readonly isSaturated: boolean;
  30902. /**
  30903. * Enables contributions to the sliding window sample set
  30904. */
  30905. enable(): void;
  30906. /**
  30907. * Disables contributions to the sliding window sample set
  30908. * Samples will not be interpolated over the disabled period
  30909. */
  30910. disable(): void;
  30911. /**
  30912. * Returns true if sampling is enabled
  30913. */
  30914. readonly isEnabled: boolean;
  30915. /**
  30916. * Resets performance monitor
  30917. */
  30918. reset(): void;
  30919. }
  30920. /**
  30921. * RollingAverage
  30922. *
  30923. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30924. */
  30925. export class RollingAverage {
  30926. /**
  30927. * Current average
  30928. */
  30929. average: number;
  30930. /**
  30931. * Current variance
  30932. */
  30933. variance: number;
  30934. protected _samples: Array<number>;
  30935. protected _sampleCount: number;
  30936. protected _pos: number;
  30937. protected _m2: number;
  30938. /**
  30939. * constructor
  30940. * @param length The number of samples required to saturate the sliding window
  30941. */
  30942. constructor(length: number);
  30943. /**
  30944. * Adds a sample to the sample set
  30945. * @param v The sample value
  30946. */
  30947. add(v: number): void;
  30948. /**
  30949. * Returns previously added values or null if outside of history or outside the sliding window domain
  30950. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30951. * @return Value previously recorded with add() or null if outside of range
  30952. */
  30953. history(i: number): number;
  30954. /**
  30955. * Returns true if enough samples have been taken to completely fill the sliding window
  30956. * @return true if sample-set saturated
  30957. */
  30958. isSaturated(): boolean;
  30959. /**
  30960. * Resets the rolling average (equivalent to 0 samples taken so far)
  30961. */
  30962. reset(): void;
  30963. /**
  30964. * Wraps a value around the sample range boundaries
  30965. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30966. * @return Wrapped position in sample range
  30967. */
  30968. protected _wrapPosition(i: number): number;
  30969. }
  30970. }
  30971. declare module BABYLON {
  30972. /**
  30973. * Defines the interface used by display changed events
  30974. */
  30975. export interface IDisplayChangedEventArgs {
  30976. /** Gets the vrDisplay object (if any) */
  30977. vrDisplay: Nullable<any>;
  30978. /** Gets a boolean indicating if webVR is supported */
  30979. vrSupported: boolean;
  30980. }
  30981. /**
  30982. * Defines the interface used by objects containing a viewport (like a camera)
  30983. */
  30984. interface IViewportOwnerLike {
  30985. /**
  30986. * Gets or sets the viewport
  30987. */
  30988. viewport: IViewportLike;
  30989. }
  30990. /**
  30991. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30992. */
  30993. export class Engine extends ThinEngine {
  30994. /** Defines that alpha blending is disabled */
  30995. static readonly ALPHA_DISABLE: number;
  30996. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30997. static readonly ALPHA_ADD: number;
  30998. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30999. static readonly ALPHA_COMBINE: number;
  31000. /** Defines that alpha blending to DEST - SRC * DEST */
  31001. static readonly ALPHA_SUBTRACT: number;
  31002. /** Defines that alpha blending to SRC * DEST */
  31003. static readonly ALPHA_MULTIPLY: number;
  31004. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31005. static readonly ALPHA_MAXIMIZED: number;
  31006. /** Defines that alpha blending to SRC + DEST */
  31007. static readonly ALPHA_ONEONE: number;
  31008. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31009. static readonly ALPHA_PREMULTIPLIED: number;
  31010. /**
  31011. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31012. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31013. */
  31014. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31015. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31016. static readonly ALPHA_INTERPOLATE: number;
  31017. /**
  31018. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31019. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31020. */
  31021. static readonly ALPHA_SCREENMODE: number;
  31022. /** Defines that the ressource is not delayed*/
  31023. static readonly DELAYLOADSTATE_NONE: number;
  31024. /** Defines that the ressource was successfully delay loaded */
  31025. static readonly DELAYLOADSTATE_LOADED: number;
  31026. /** Defines that the ressource is currently delay loading */
  31027. static readonly DELAYLOADSTATE_LOADING: number;
  31028. /** Defines that the ressource is delayed and has not started loading */
  31029. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31031. static readonly NEVER: number;
  31032. /** 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 */
  31033. static readonly ALWAYS: number;
  31034. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31035. static readonly LESS: number;
  31036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31037. static readonly EQUAL: number;
  31038. /** 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 */
  31039. static readonly LEQUAL: number;
  31040. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31041. static readonly GREATER: number;
  31042. /** 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 */
  31043. static readonly GEQUAL: number;
  31044. /** 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 */
  31045. static readonly NOTEQUAL: number;
  31046. /** Passed to stencilOperation to specify that stencil value must be kept */
  31047. static readonly KEEP: number;
  31048. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31049. static readonly REPLACE: number;
  31050. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31051. static readonly INCR: number;
  31052. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31053. static readonly DECR: number;
  31054. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31055. static readonly INVERT: number;
  31056. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31057. static readonly INCR_WRAP: number;
  31058. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31059. static readonly DECR_WRAP: number;
  31060. /** Texture is not repeating outside of 0..1 UVs */
  31061. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31062. /** Texture is repeating outside of 0..1 UVs */
  31063. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31064. /** Texture is repeating and mirrored */
  31065. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31066. /** ALPHA */
  31067. static readonly TEXTUREFORMAT_ALPHA: number;
  31068. /** LUMINANCE */
  31069. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31070. /** LUMINANCE_ALPHA */
  31071. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31072. /** RGB */
  31073. static readonly TEXTUREFORMAT_RGB: number;
  31074. /** RGBA */
  31075. static readonly TEXTUREFORMAT_RGBA: number;
  31076. /** RED */
  31077. static readonly TEXTUREFORMAT_RED: number;
  31078. /** RED (2nd reference) */
  31079. static readonly TEXTUREFORMAT_R: number;
  31080. /** RG */
  31081. static readonly TEXTUREFORMAT_RG: number;
  31082. /** RED_INTEGER */
  31083. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31084. /** RED_INTEGER (2nd reference) */
  31085. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31086. /** RG_INTEGER */
  31087. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31088. /** RGB_INTEGER */
  31089. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31090. /** RGBA_INTEGER */
  31091. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31092. /** UNSIGNED_BYTE */
  31093. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31094. /** UNSIGNED_BYTE (2nd reference) */
  31095. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31096. /** FLOAT */
  31097. static readonly TEXTURETYPE_FLOAT: number;
  31098. /** HALF_FLOAT */
  31099. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31100. /** BYTE */
  31101. static readonly TEXTURETYPE_BYTE: number;
  31102. /** SHORT */
  31103. static readonly TEXTURETYPE_SHORT: number;
  31104. /** UNSIGNED_SHORT */
  31105. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31106. /** INT */
  31107. static readonly TEXTURETYPE_INT: number;
  31108. /** UNSIGNED_INT */
  31109. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31110. /** UNSIGNED_SHORT_4_4_4_4 */
  31111. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31112. /** UNSIGNED_SHORT_5_5_5_1 */
  31113. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31114. /** UNSIGNED_SHORT_5_6_5 */
  31115. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31116. /** UNSIGNED_INT_2_10_10_10_REV */
  31117. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31118. /** UNSIGNED_INT_24_8 */
  31119. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31120. /** UNSIGNED_INT_10F_11F_11F_REV */
  31121. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31122. /** UNSIGNED_INT_5_9_9_9_REV */
  31123. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31124. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31125. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31126. /** nearest is mag = nearest and min = nearest and mip = linear */
  31127. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31129. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31130. /** Trilinear is mag = linear and min = linear and mip = linear */
  31131. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31132. /** nearest is mag = nearest and min = nearest and mip = linear */
  31133. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31134. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31135. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31136. /** Trilinear is mag = linear and min = linear and mip = linear */
  31137. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31138. /** mag = nearest and min = nearest and mip = nearest */
  31139. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31140. /** mag = nearest and min = linear and mip = nearest */
  31141. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31142. /** mag = nearest and min = linear and mip = linear */
  31143. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31144. /** mag = nearest and min = linear and mip = none */
  31145. static readonly TEXTURE_NEAREST_LINEAR: number;
  31146. /** mag = nearest and min = nearest and mip = none */
  31147. static readonly TEXTURE_NEAREST_NEAREST: number;
  31148. /** mag = linear and min = nearest and mip = nearest */
  31149. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31150. /** mag = linear and min = nearest and mip = linear */
  31151. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31152. /** mag = linear and min = linear and mip = none */
  31153. static readonly TEXTURE_LINEAR_LINEAR: number;
  31154. /** mag = linear and min = nearest and mip = none */
  31155. static readonly TEXTURE_LINEAR_NEAREST: number;
  31156. /** Explicit coordinates mode */
  31157. static readonly TEXTURE_EXPLICIT_MODE: number;
  31158. /** Spherical coordinates mode */
  31159. static readonly TEXTURE_SPHERICAL_MODE: number;
  31160. /** Planar coordinates mode */
  31161. static readonly TEXTURE_PLANAR_MODE: number;
  31162. /** Cubic coordinates mode */
  31163. static readonly TEXTURE_CUBIC_MODE: number;
  31164. /** Projection coordinates mode */
  31165. static readonly TEXTURE_PROJECTION_MODE: number;
  31166. /** Skybox coordinates mode */
  31167. static readonly TEXTURE_SKYBOX_MODE: number;
  31168. /** Inverse Cubic coordinates mode */
  31169. static readonly TEXTURE_INVCUBIC_MODE: number;
  31170. /** Equirectangular coordinates mode */
  31171. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31172. /** Equirectangular Fixed coordinates mode */
  31173. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31174. /** Equirectangular Fixed Mirrored coordinates mode */
  31175. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31176. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31177. static readonly SCALEMODE_FLOOR: number;
  31178. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31179. static readonly SCALEMODE_NEAREST: number;
  31180. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31181. static readonly SCALEMODE_CEILING: number;
  31182. /**
  31183. * Returns the current npm package of the sdk
  31184. */
  31185. static readonly NpmPackage: string;
  31186. /**
  31187. * Returns the current version of the framework
  31188. */
  31189. static readonly Version: string;
  31190. /** Gets the list of created engines */
  31191. static readonly Instances: Engine[];
  31192. /**
  31193. * Gets the latest created engine
  31194. */
  31195. static readonly LastCreatedEngine: Nullable<Engine>;
  31196. /**
  31197. * Gets the latest created scene
  31198. */
  31199. static readonly LastCreatedScene: Nullable<Scene>;
  31200. /**
  31201. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31202. * @param flag defines which part of the materials must be marked as dirty
  31203. * @param predicate defines a predicate used to filter which materials should be affected
  31204. */
  31205. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31206. /**
  31207. * Method called to create the default loading screen.
  31208. * This can be overriden in your own app.
  31209. * @param canvas The rendering canvas element
  31210. * @returns The loading screen
  31211. */
  31212. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31213. /**
  31214. * Method called to create the default rescale post process on each engine.
  31215. */
  31216. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31217. /**
  31218. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31219. **/
  31220. enableOfflineSupport: boolean;
  31221. /**
  31222. * 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)
  31223. **/
  31224. disableManifestCheck: boolean;
  31225. /**
  31226. * Gets the list of created scenes
  31227. */
  31228. scenes: Scene[];
  31229. /**
  31230. * Event raised when a new scene is created
  31231. */
  31232. onNewSceneAddedObservable: Observable<Scene>;
  31233. /**
  31234. * Gets the list of created postprocesses
  31235. */
  31236. postProcesses: PostProcess[];
  31237. /**
  31238. * Gets a boolean indicating if the pointer is currently locked
  31239. */
  31240. isPointerLock: boolean;
  31241. /**
  31242. * Observable event triggered each time the rendering canvas is resized
  31243. */
  31244. onResizeObservable: Observable<Engine>;
  31245. /**
  31246. * Observable event triggered each time the canvas loses focus
  31247. */
  31248. onCanvasBlurObservable: Observable<Engine>;
  31249. /**
  31250. * Observable event triggered each time the canvas gains focus
  31251. */
  31252. onCanvasFocusObservable: Observable<Engine>;
  31253. /**
  31254. * Observable event triggered each time the canvas receives pointerout event
  31255. */
  31256. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31257. /**
  31258. * Observable event triggered before each texture is initialized
  31259. */
  31260. onBeforeTextureInitObservable: Observable<Texture>;
  31261. /**
  31262. * Observable raised when the engine begins a new frame
  31263. */
  31264. onBeginFrameObservable: Observable<Engine>;
  31265. /**
  31266. * If set, will be used to request the next animation frame for the render loop
  31267. */
  31268. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31269. /**
  31270. * Observable raised when the engine ends the current frame
  31271. */
  31272. onEndFrameObservable: Observable<Engine>;
  31273. /**
  31274. * Observable raised when the engine is about to compile a shader
  31275. */
  31276. onBeforeShaderCompilationObservable: Observable<Engine>;
  31277. /**
  31278. * Observable raised when the engine has jsut compiled a shader
  31279. */
  31280. onAfterShaderCompilationObservable: Observable<Engine>;
  31281. /**
  31282. * Gets the audio engine
  31283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31284. * @ignorenaming
  31285. */
  31286. static audioEngine: IAudioEngine;
  31287. /**
  31288. * Default AudioEngine factory responsible of creating the Audio Engine.
  31289. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31290. */
  31291. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31292. /**
  31293. * Default offline support factory responsible of creating a tool used to store data locally.
  31294. * By default, this will create a Database object if the workload has been embedded.
  31295. */
  31296. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31297. private _loadingScreen;
  31298. private _pointerLockRequested;
  31299. private _dummyFramebuffer;
  31300. private _rescalePostProcess;
  31301. /** @hidden */
  31302. protected _alphaMode: number;
  31303. /** @hidden */
  31304. protected _alphaEquation: number;
  31305. private _deterministicLockstep;
  31306. private _lockstepMaxSteps;
  31307. protected readonly _supportsHardwareTextureRescaling: boolean;
  31308. private _fps;
  31309. private _deltaTime;
  31310. /**
  31311. * Turn this value on if you want to pause FPS computation when in background
  31312. */
  31313. disablePerformanceMonitorInBackground: boolean;
  31314. private _performanceMonitor;
  31315. /**
  31316. * Gets the performance monitor attached to this engine
  31317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31318. */
  31319. readonly performanceMonitor: PerformanceMonitor;
  31320. private _onFocus;
  31321. private _onBlur;
  31322. private _onCanvasPointerOut;
  31323. private _onCanvasBlur;
  31324. private _onCanvasFocus;
  31325. private _onFullscreenChange;
  31326. private _onPointerLockChange;
  31327. /**
  31328. * Creates a new engine
  31329. * @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
  31330. * @param antialias defines enable antialiasing (default: false)
  31331. * @param options defines further options to be sent to the getContext() function
  31332. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31333. */
  31334. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31335. /**
  31336. * Gets current aspect ratio
  31337. * @param viewportOwner defines the camera to use to get the aspect ratio
  31338. * @param useScreen defines if screen size must be used (or the current render target if any)
  31339. * @returns a number defining the aspect ratio
  31340. */
  31341. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31342. /**
  31343. * Gets current screen aspect ratio
  31344. * @returns a number defining the aspect ratio
  31345. */
  31346. getScreenAspectRatio(): number;
  31347. /**
  31348. * Gets host document
  31349. * @returns the host document object
  31350. */
  31351. getHostDocument(): Document;
  31352. /**
  31353. * Gets the client rect of the HTML canvas attached with the current webGL context
  31354. * @returns a client rectanglee
  31355. */
  31356. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31357. /**
  31358. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31360. * @returns true if engine is in deterministic lock step mode
  31361. */
  31362. isDeterministicLockStep(): boolean;
  31363. /**
  31364. * Gets the max steps when engine is running in deterministic lock step
  31365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31366. * @returns the max steps
  31367. */
  31368. getLockstepMaxSteps(): number;
  31369. /**
  31370. * Force the mipmap generation for the given render target texture
  31371. * @param texture defines the render target texture to use
  31372. */
  31373. generateMipMapsForCubemap(texture: InternalTexture): void;
  31374. /** States */
  31375. /**
  31376. * Set various states to the webGL context
  31377. * @param culling defines backface culling state
  31378. * @param zOffset defines the value to apply to zOffset (0 by default)
  31379. * @param force defines if states must be applied even if cache is up to date
  31380. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31381. */
  31382. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31383. /**
  31384. * Set the z offset to apply to current rendering
  31385. * @param value defines the offset to apply
  31386. */
  31387. setZOffset(value: number): void;
  31388. /**
  31389. * Gets the current value of the zOffset
  31390. * @returns the current zOffset state
  31391. */
  31392. getZOffset(): number;
  31393. /**
  31394. * Enable or disable depth buffering
  31395. * @param enable defines the state to set
  31396. */
  31397. setDepthBuffer(enable: boolean): void;
  31398. /**
  31399. * Gets a boolean indicating if depth writing is enabled
  31400. * @returns the current depth writing state
  31401. */
  31402. getDepthWrite(): boolean;
  31403. /**
  31404. * Enable or disable depth writing
  31405. * @param enable defines the state to set
  31406. */
  31407. setDepthWrite(enable: boolean): void;
  31408. /**
  31409. * Enable or disable color writing
  31410. * @param enable defines the state to set
  31411. */
  31412. setColorWrite(enable: boolean): void;
  31413. /**
  31414. * Gets a boolean indicating if color writing is enabled
  31415. * @returns the current color writing state
  31416. */
  31417. getColorWrite(): boolean;
  31418. /**
  31419. * Sets alpha constants used by some alpha blending modes
  31420. * @param r defines the red component
  31421. * @param g defines the green component
  31422. * @param b defines the blue component
  31423. * @param a defines the alpha component
  31424. */
  31425. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31426. /**
  31427. * Sets the current alpha mode
  31428. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31429. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31430. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31431. */
  31432. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31433. /**
  31434. * Gets the current alpha mode
  31435. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31436. * @returns the current alpha mode
  31437. */
  31438. getAlphaMode(): number;
  31439. /**
  31440. * Sets the current alpha equation
  31441. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31442. */
  31443. setAlphaEquation(equation: number): void;
  31444. /**
  31445. * Gets the current alpha equation.
  31446. * @returns the current alpha equation
  31447. */
  31448. getAlphaEquation(): number;
  31449. /**
  31450. * Gets a boolean indicating if stencil buffer is enabled
  31451. * @returns the current stencil buffer state
  31452. */
  31453. getStencilBuffer(): boolean;
  31454. /**
  31455. * Enable or disable the stencil buffer
  31456. * @param enable defines if the stencil buffer must be enabled or disabled
  31457. */
  31458. setStencilBuffer(enable: boolean): void;
  31459. /**
  31460. * Gets the current stencil mask
  31461. * @returns a number defining the new stencil mask to use
  31462. */
  31463. getStencilMask(): number;
  31464. /**
  31465. * Sets the current stencil mask
  31466. * @param mask defines the new stencil mask to use
  31467. */
  31468. setStencilMask(mask: number): void;
  31469. /**
  31470. * Gets the current stencil function
  31471. * @returns a number defining the stencil function to use
  31472. */
  31473. getStencilFunction(): number;
  31474. /**
  31475. * Gets the current stencil reference value
  31476. * @returns a number defining the stencil reference value to use
  31477. */
  31478. getStencilFunctionReference(): number;
  31479. /**
  31480. * Gets the current stencil mask
  31481. * @returns a number defining the stencil mask to use
  31482. */
  31483. getStencilFunctionMask(): number;
  31484. /**
  31485. * Sets the current stencil function
  31486. * @param stencilFunc defines the new stencil function to use
  31487. */
  31488. setStencilFunction(stencilFunc: number): void;
  31489. /**
  31490. * Sets the current stencil reference
  31491. * @param reference defines the new stencil reference to use
  31492. */
  31493. setStencilFunctionReference(reference: number): void;
  31494. /**
  31495. * Sets the current stencil mask
  31496. * @param mask defines the new stencil mask to use
  31497. */
  31498. setStencilFunctionMask(mask: number): void;
  31499. /**
  31500. * Gets the current stencil operation when stencil fails
  31501. * @returns a number defining stencil operation to use when stencil fails
  31502. */
  31503. getStencilOperationFail(): number;
  31504. /**
  31505. * Gets the current stencil operation when depth fails
  31506. * @returns a number defining stencil operation to use when depth fails
  31507. */
  31508. getStencilOperationDepthFail(): number;
  31509. /**
  31510. * Gets the current stencil operation when stencil passes
  31511. * @returns a number defining stencil operation to use when stencil passes
  31512. */
  31513. getStencilOperationPass(): number;
  31514. /**
  31515. * Sets the stencil operation to use when stencil fails
  31516. * @param operation defines the stencil operation to use when stencil fails
  31517. */
  31518. setStencilOperationFail(operation: number): void;
  31519. /**
  31520. * Sets the stencil operation to use when depth fails
  31521. * @param operation defines the stencil operation to use when depth fails
  31522. */
  31523. setStencilOperationDepthFail(operation: number): void;
  31524. /**
  31525. * Sets the stencil operation to use when stencil passes
  31526. * @param operation defines the stencil operation to use when stencil passes
  31527. */
  31528. setStencilOperationPass(operation: number): void;
  31529. /**
  31530. * Sets a boolean indicating if the dithering state is enabled or disabled
  31531. * @param value defines the dithering state
  31532. */
  31533. setDitheringState(value: boolean): void;
  31534. /**
  31535. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31536. * @param value defines the rasterizer state
  31537. */
  31538. setRasterizerState(value: boolean): void;
  31539. /**
  31540. * Gets the current depth function
  31541. * @returns a number defining the depth function
  31542. */
  31543. getDepthFunction(): Nullable<number>;
  31544. /**
  31545. * Sets the current depth function
  31546. * @param depthFunc defines the function to use
  31547. */
  31548. setDepthFunction(depthFunc: number): void;
  31549. /**
  31550. * Sets the current depth function to GREATER
  31551. */
  31552. setDepthFunctionToGreater(): void;
  31553. /**
  31554. * Sets the current depth function to GEQUAL
  31555. */
  31556. setDepthFunctionToGreaterOrEqual(): void;
  31557. /**
  31558. * Sets the current depth function to LESS
  31559. */
  31560. setDepthFunctionToLess(): void;
  31561. /**
  31562. * Sets the current depth function to LEQUAL
  31563. */
  31564. setDepthFunctionToLessOrEqual(): void;
  31565. private _cachedStencilBuffer;
  31566. private _cachedStencilFunction;
  31567. private _cachedStencilMask;
  31568. private _cachedStencilOperationPass;
  31569. private _cachedStencilOperationFail;
  31570. private _cachedStencilOperationDepthFail;
  31571. private _cachedStencilReference;
  31572. /**
  31573. * Caches the the state of the stencil buffer
  31574. */
  31575. cacheStencilState(): void;
  31576. /**
  31577. * Restores the state of the stencil buffer
  31578. */
  31579. restoreStencilState(): void;
  31580. /**
  31581. * Directly set the WebGL Viewport
  31582. * @param x defines the x coordinate of the viewport (in screen space)
  31583. * @param y defines the y coordinate of the viewport (in screen space)
  31584. * @param width defines the width of the viewport (in screen space)
  31585. * @param height defines the height of the viewport (in screen space)
  31586. * @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
  31587. */
  31588. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31589. /**
  31590. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31591. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31592. * @param y defines the y-coordinate of the corner of the clear rectangle
  31593. * @param width defines the width of the clear rectangle
  31594. * @param height defines the height of the clear rectangle
  31595. * @param clearColor defines the clear color
  31596. */
  31597. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31598. /**
  31599. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31600. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31601. * @param y defines the y-coordinate of the corner of the clear rectangle
  31602. * @param width defines the width of the clear rectangle
  31603. * @param height defines the height of the clear rectangle
  31604. */
  31605. enableScissor(x: number, y: number, width: number, height: number): void;
  31606. /**
  31607. * Disable previously set scissor test rectangle
  31608. */
  31609. disableScissor(): void;
  31610. /**
  31611. * Initializes a webVR display and starts listening to display change events
  31612. * The onVRDisplayChangedObservable will be notified upon these changes
  31613. * @returns The onVRDisplayChangedObservable
  31614. */
  31615. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31616. /** @hidden */
  31617. _prepareVRComponent(): void;
  31618. /** @hidden */
  31619. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31620. /** @hidden */
  31621. _submitVRFrame(): void;
  31622. /**
  31623. * Call this function to leave webVR mode
  31624. * Will do nothing if webVR is not supported or if there is no webVR device
  31625. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31626. */
  31627. disableVR(): void;
  31628. /**
  31629. * Gets a boolean indicating that the system is in VR mode and is presenting
  31630. * @returns true if VR mode is engaged
  31631. */
  31632. isVRPresenting(): boolean;
  31633. /** @hidden */
  31634. _requestVRFrame(): void;
  31635. /** @hidden */
  31636. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31637. /**
  31638. * Gets the source code of the vertex shader associated with a specific webGL program
  31639. * @param program defines the program to use
  31640. * @returns a string containing the source code of the vertex shader associated with the program
  31641. */
  31642. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31643. /**
  31644. * Gets the source code of the fragment shader associated with a specific webGL program
  31645. * @param program defines the program to use
  31646. * @returns a string containing the source code of the fragment shader associated with the program
  31647. */
  31648. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31649. /**
  31650. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31651. * @param x defines the x coordinate of the rectangle where pixels must be read
  31652. * @param y defines the y coordinate of the rectangle where pixels must be read
  31653. * @param width defines the width of the rectangle where pixels must be read
  31654. * @param height defines the height of the rectangle where pixels must be read
  31655. * @returns a Uint8Array containing RGBA colors
  31656. */
  31657. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31658. /**
  31659. * Sets a depth stencil texture from a render target to the according uniform.
  31660. * @param channel The texture channel
  31661. * @param uniform The uniform to set
  31662. * @param texture The render target texture containing the depth stencil texture to apply
  31663. */
  31664. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31665. /**
  31666. * Sets a texture to the webGL context from a postprocess
  31667. * @param channel defines the channel to use
  31668. * @param postProcess defines the source postprocess
  31669. */
  31670. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31671. /**
  31672. * Binds the output of the passed in post process to the texture channel specified
  31673. * @param channel The channel the texture should be bound to
  31674. * @param postProcess The post process which's output should be bound
  31675. */
  31676. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31677. /** @hidden */
  31678. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31679. protected _rebuildBuffers(): void;
  31680. _renderLoop(): void;
  31681. /**
  31682. * Toggle full screen mode
  31683. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31684. */
  31685. switchFullscreen(requestPointerLock: boolean): void;
  31686. /**
  31687. * Enters full screen mode
  31688. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31689. */
  31690. enterFullscreen(requestPointerLock: boolean): void;
  31691. /**
  31692. * Exits full screen mode
  31693. */
  31694. exitFullscreen(): void;
  31695. /**
  31696. * Enters Pointerlock mode
  31697. */
  31698. enterPointerlock(): void;
  31699. /**
  31700. * Exits Pointerlock mode
  31701. */
  31702. exitPointerlock(): void;
  31703. /**
  31704. * Begin a new frame
  31705. */
  31706. beginFrame(): void;
  31707. /**
  31708. * Enf the current frame
  31709. */
  31710. endFrame(): void;
  31711. resize(): void;
  31712. /**
  31713. * Set the compressed texture format to use, based on the formats you have, and the formats
  31714. * supported by the hardware / browser.
  31715. *
  31716. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31717. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31718. * to API arguments needed to compressed textures. This puts the burden on the container
  31719. * generator to house the arcane code for determining these for current & future formats.
  31720. *
  31721. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31722. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31723. *
  31724. * Note: The result of this call is not taken into account when a texture is base64.
  31725. *
  31726. * @param formatsAvailable defines the list of those format families you have created
  31727. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31728. *
  31729. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31730. * @returns The extension selected.
  31731. */
  31732. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31733. /**
  31734. * Force a specific size of the canvas
  31735. * @param width defines the new canvas' width
  31736. * @param height defines the new canvas' height
  31737. */
  31738. setSize(width: number, height: number): void;
  31739. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31740. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31741. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31742. _releaseTexture(texture: InternalTexture): void;
  31743. /**
  31744. * @hidden
  31745. * Rescales a texture
  31746. * @param source input texutre
  31747. * @param destination destination texture
  31748. * @param scene scene to use to render the resize
  31749. * @param internalFormat format to use when resizing
  31750. * @param onComplete callback to be called when resize has completed
  31751. */
  31752. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31753. /**
  31754. * Gets the current framerate
  31755. * @returns a number representing the framerate
  31756. */
  31757. getFps(): number;
  31758. /**
  31759. * Gets the time spent between current and previous frame
  31760. * @returns a number representing the delta time in ms
  31761. */
  31762. getDeltaTime(): number;
  31763. private _measureFps;
  31764. /**
  31765. * Creates a new render target texture
  31766. * @param size defines the size of the texture
  31767. * @param options defines the options used to create the texture
  31768. * @returns a new render target texture stored in an InternalTexture
  31769. */
  31770. createRenderTargetTexture(size: number | {
  31771. width: number;
  31772. height: number;
  31773. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31774. /**
  31775. * Updates the sample count of a render target texture
  31776. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31777. * @param texture defines the texture to update
  31778. * @param samples defines the sample count to set
  31779. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31780. */
  31781. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31782. /** @hidden */
  31783. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31784. dispose(): void;
  31785. private _disableTouchAction;
  31786. /**
  31787. * Display the loading screen
  31788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31789. */
  31790. displayLoadingUI(): void;
  31791. /**
  31792. * Hide the loading screen
  31793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31794. */
  31795. hideLoadingUI(): void;
  31796. /**
  31797. * Gets the current loading screen object
  31798. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31799. */
  31800. /**
  31801. * Sets the current loading screen object
  31802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31803. */
  31804. loadingScreen: ILoadingScreen;
  31805. /**
  31806. * Sets the current loading screen text
  31807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31808. */
  31809. loadingUIText: string;
  31810. /**
  31811. * Sets the current loading screen background color
  31812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31813. */
  31814. loadingUIBackgroundColor: string;
  31815. /** Pointerlock and fullscreen */
  31816. /**
  31817. * Ask the browser to promote the current element to pointerlock mode
  31818. * @param element defines the DOM element to promote
  31819. */
  31820. static _RequestPointerlock(element: HTMLElement): void;
  31821. /**
  31822. * Asks the browser to exit pointerlock mode
  31823. */
  31824. static _ExitPointerlock(): void;
  31825. /**
  31826. * Ask the browser to promote the current element to fullscreen rendering mode
  31827. * @param element defines the DOM element to promote
  31828. */
  31829. static _RequestFullscreen(element: HTMLElement): void;
  31830. /**
  31831. * Asks the browser to exit fullscreen mode
  31832. */
  31833. static _ExitFullscreen(): void;
  31834. }
  31835. }
  31836. declare module BABYLON {
  31837. /**
  31838. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31839. * during the life time of the application.
  31840. */
  31841. export class EngineStore {
  31842. /** Gets the list of created engines */
  31843. static Instances: Engine[];
  31844. /** @hidden */
  31845. static _LastCreatedScene: Nullable<Scene>;
  31846. /**
  31847. * Gets the latest created engine
  31848. */
  31849. static readonly LastCreatedEngine: Nullable<Engine>;
  31850. /**
  31851. * Gets the latest created scene
  31852. */
  31853. static readonly LastCreatedScene: Nullable<Scene>;
  31854. /**
  31855. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31856. * @ignorenaming
  31857. */
  31858. static UseFallbackTexture: boolean;
  31859. /**
  31860. * Texture content used if a texture cannot loaded
  31861. * @ignorenaming
  31862. */
  31863. static FallbackTexture: string;
  31864. }
  31865. }
  31866. declare module BABYLON {
  31867. /**
  31868. * Helper class that provides a small promise polyfill
  31869. */
  31870. export class PromisePolyfill {
  31871. /**
  31872. * Static function used to check if the polyfill is required
  31873. * If this is the case then the function will inject the polyfill to window.Promise
  31874. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31875. */
  31876. static Apply(force?: boolean): void;
  31877. }
  31878. }
  31879. declare module BABYLON {
  31880. /**
  31881. * Interface for screenshot methods with describe argument called `size` as object with options
  31882. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31883. */
  31884. export interface IScreenshotSize {
  31885. /**
  31886. * number in pixels for canvas height
  31887. */
  31888. height?: number;
  31889. /**
  31890. * multiplier allowing render at a higher or lower resolution
  31891. * If value is defined then height and width will be ignored and taken from camera
  31892. */
  31893. precision?: number;
  31894. /**
  31895. * number in pixels for canvas width
  31896. */
  31897. width?: number;
  31898. }
  31899. }
  31900. declare module BABYLON {
  31901. interface IColor4Like {
  31902. r: float;
  31903. g: float;
  31904. b: float;
  31905. a: float;
  31906. }
  31907. /**
  31908. * Class containing a set of static utilities functions
  31909. */
  31910. export class Tools {
  31911. /**
  31912. * Gets or sets the base URL to use to load assets
  31913. */
  31914. static BaseUrl: string;
  31915. /**
  31916. * Enable/Disable Custom HTTP Request Headers globally.
  31917. * default = false
  31918. * @see CustomRequestHeaders
  31919. */
  31920. static UseCustomRequestHeaders: boolean;
  31921. /**
  31922. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31923. * i.e. when loading files, where the server/service expects an Authorization header
  31924. */
  31925. static CustomRequestHeaders: {
  31926. [key: string]: string;
  31927. };
  31928. /**
  31929. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31930. */
  31931. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31932. /**
  31933. * Default behaviour for cors in the application.
  31934. * It can be a string if the expected behavior is identical in the entire app.
  31935. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31936. */
  31937. static CorsBehavior: string | ((url: string | string[]) => string);
  31938. /**
  31939. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31940. * @ignorenaming
  31941. */
  31942. static UseFallbackTexture: boolean;
  31943. /**
  31944. * Use this object to register external classes like custom textures or material
  31945. * to allow the laoders to instantiate them
  31946. */
  31947. static RegisteredExternalClasses: {
  31948. [key: string]: Object;
  31949. };
  31950. /**
  31951. * Texture content used if a texture cannot loaded
  31952. * @ignorenaming
  31953. */
  31954. static fallbackTexture: string;
  31955. /**
  31956. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31957. * @param u defines the coordinate on X axis
  31958. * @param v defines the coordinate on Y axis
  31959. * @param width defines the width of the source data
  31960. * @param height defines the height of the source data
  31961. * @param pixels defines the source byte array
  31962. * @param color defines the output color
  31963. */
  31964. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31965. /**
  31966. * Interpolates between a and b via alpha
  31967. * @param a The lower value (returned when alpha = 0)
  31968. * @param b The upper value (returned when alpha = 1)
  31969. * @param alpha The interpolation-factor
  31970. * @return The mixed value
  31971. */
  31972. static Mix(a: number, b: number, alpha: number): number;
  31973. /**
  31974. * Tries to instantiate a new object from a given class name
  31975. * @param className defines the class name to instantiate
  31976. * @returns the new object or null if the system was not able to do the instantiation
  31977. */
  31978. static Instantiate(className: string): any;
  31979. /**
  31980. * Provides a slice function that will work even on IE
  31981. * @param data defines the array to slice
  31982. * @param start defines the start of the data (optional)
  31983. * @param end defines the end of the data (optional)
  31984. * @returns the new sliced array
  31985. */
  31986. static Slice<T>(data: T, start?: number, end?: number): T;
  31987. /**
  31988. * Polyfill for setImmediate
  31989. * @param action defines the action to execute after the current execution block
  31990. */
  31991. static SetImmediate(action: () => void): void;
  31992. /**
  31993. * Function indicating if a number is an exponent of 2
  31994. * @param value defines the value to test
  31995. * @returns true if the value is an exponent of 2
  31996. */
  31997. static IsExponentOfTwo(value: number): boolean;
  31998. private static _tmpFloatArray;
  31999. /**
  32000. * Returns the nearest 32-bit single precision float representation of a Number
  32001. * @param value A Number. If the parameter is of a different type, it will get converted
  32002. * to a number or to NaN if it cannot be converted
  32003. * @returns number
  32004. */
  32005. static FloatRound(value: number): number;
  32006. /**
  32007. * Extracts the filename from a path
  32008. * @param path defines the path to use
  32009. * @returns the filename
  32010. */
  32011. static GetFilename(path: string): string;
  32012. /**
  32013. * Extracts the "folder" part of a path (everything before the filename).
  32014. * @param uri The URI to extract the info from
  32015. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32016. * @returns The "folder" part of the path
  32017. */
  32018. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32019. /**
  32020. * Extracts text content from a DOM element hierarchy
  32021. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32022. */
  32023. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32024. /**
  32025. * Convert an angle in radians to degrees
  32026. * @param angle defines the angle to convert
  32027. * @returns the angle in degrees
  32028. */
  32029. static ToDegrees(angle: number): number;
  32030. /**
  32031. * Convert an angle in degrees to radians
  32032. * @param angle defines the angle to convert
  32033. * @returns the angle in radians
  32034. */
  32035. static ToRadians(angle: number): number;
  32036. /**
  32037. * Encode a buffer to a base64 string
  32038. * @param buffer defines the buffer to encode
  32039. * @returns the encoded string
  32040. */
  32041. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32042. /**
  32043. * Returns an array if obj is not an array
  32044. * @param obj defines the object to evaluate as an array
  32045. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32046. * @returns either obj directly if obj is an array or a new array containing obj
  32047. */
  32048. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32049. /**
  32050. * Gets the pointer prefix to use
  32051. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32052. */
  32053. static GetPointerPrefix(): string;
  32054. /**
  32055. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32056. * @param url define the url we are trying
  32057. * @param element define the dom element where to configure the cors policy
  32058. */
  32059. static SetCorsBehavior(url: string | string[], element: {
  32060. crossOrigin: string | null;
  32061. }): void;
  32062. /**
  32063. * Removes unwanted characters from an url
  32064. * @param url defines the url to clean
  32065. * @returns the cleaned url
  32066. */
  32067. static CleanUrl(url: string): string;
  32068. /**
  32069. * Gets or sets a function used to pre-process url before using them to load assets
  32070. */
  32071. static PreprocessUrl: (url: string) => string;
  32072. /**
  32073. * Loads an image as an HTMLImageElement.
  32074. * @param input url string, ArrayBuffer, or Blob to load
  32075. * @param onLoad callback called when the image successfully loads
  32076. * @param onError callback called when the image fails to load
  32077. * @param offlineProvider offline provider for caching
  32078. * @returns the HTMLImageElement of the loaded image
  32079. */
  32080. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32081. /**
  32082. * Loads a file
  32083. * @param url url string, ArrayBuffer, or Blob to load
  32084. * @param onSuccess callback called when the file successfully loads
  32085. * @param onProgress callback called while file is loading (if the server supports this mode)
  32086. * @param offlineProvider defines the offline provider for caching
  32087. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32088. * @param onError callback called when the file fails to load
  32089. * @returns a file request object
  32090. */
  32091. 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;
  32092. /**
  32093. * Loads a file from a url
  32094. * @param url the file url to load
  32095. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32096. */
  32097. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32098. /**
  32099. * Load a script (identified by an url). When the url returns, the
  32100. * content of this file is added into a new script element, attached to the DOM (body element)
  32101. * @param scriptUrl defines the url of the script to laod
  32102. * @param onSuccess defines the callback called when the script is loaded
  32103. * @param onError defines the callback to call if an error occurs
  32104. * @param scriptId defines the id of the script element
  32105. */
  32106. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32107. /**
  32108. * Load an asynchronous script (identified by an url). When the url returns, the
  32109. * content of this file is added into a new script element, attached to the DOM (body element)
  32110. * @param scriptUrl defines the url of the script to laod
  32111. * @param scriptId defines the id of the script element
  32112. * @returns a promise request object
  32113. */
  32114. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32115. /**
  32116. * Loads a file from a blob
  32117. * @param fileToLoad defines the blob to use
  32118. * @param callback defines the callback to call when data is loaded
  32119. * @param progressCallback defines the callback to call during loading process
  32120. * @returns a file request object
  32121. */
  32122. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32123. /**
  32124. * Loads a file
  32125. * @param fileToLoad defines the file to load
  32126. * @param callback defines the callback to call when data is loaded
  32127. * @param progressCallBack defines the callback to call during loading process
  32128. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32129. * @returns a file request object
  32130. */
  32131. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32132. /**
  32133. * Creates a data url from a given string content
  32134. * @param content defines the content to convert
  32135. * @returns the new data url link
  32136. */
  32137. static FileAsURL(content: string): string;
  32138. /**
  32139. * Format the given number to a specific decimal format
  32140. * @param value defines the number to format
  32141. * @param decimals defines the number of decimals to use
  32142. * @returns the formatted string
  32143. */
  32144. static Format(value: number, decimals?: number): string;
  32145. /**
  32146. * Tries to copy an object by duplicating every property
  32147. * @param source defines the source object
  32148. * @param destination defines the target object
  32149. * @param doNotCopyList defines a list of properties to avoid
  32150. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32151. */
  32152. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32153. /**
  32154. * Gets a boolean indicating if the given object has no own property
  32155. * @param obj defines the object to test
  32156. * @returns true if object has no own property
  32157. */
  32158. static IsEmpty(obj: any): boolean;
  32159. /**
  32160. * Function used to register events at window level
  32161. * @param windowElement defines the Window object to use
  32162. * @param events defines the events to register
  32163. */
  32164. static RegisterTopRootEvents(windowElement: Window, events: {
  32165. name: string;
  32166. handler: Nullable<(e: FocusEvent) => any>;
  32167. }[]): void;
  32168. /**
  32169. * Function used to unregister events from window level
  32170. * @param windowElement defines the Window object to use
  32171. * @param events defines the events to unregister
  32172. */
  32173. static UnregisterTopRootEvents(windowElement: Window, events: {
  32174. name: string;
  32175. handler: Nullable<(e: FocusEvent) => any>;
  32176. }[]): void;
  32177. /**
  32178. * @ignore
  32179. */
  32180. static _ScreenshotCanvas: HTMLCanvasElement;
  32181. /**
  32182. * Dumps the current bound framebuffer
  32183. * @param width defines the rendering width
  32184. * @param height defines the rendering height
  32185. * @param engine defines the hosting engine
  32186. * @param successCallback defines the callback triggered once the data are available
  32187. * @param mimeType defines the mime type of the result
  32188. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32189. */
  32190. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32191. /**
  32192. * Converts the canvas data to blob.
  32193. * This acts as a polyfill for browsers not supporting the to blob function.
  32194. * @param canvas Defines the canvas to extract the data from
  32195. * @param successCallback Defines the callback triggered once the data are available
  32196. * @param mimeType Defines the mime type of the result
  32197. */
  32198. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32199. /**
  32200. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32201. * @param successCallback defines the callback triggered once the data are available
  32202. * @param mimeType defines the mime type of the result
  32203. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32204. */
  32205. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32206. /**
  32207. * Downloads a blob in the browser
  32208. * @param blob defines the blob to download
  32209. * @param fileName defines the name of the downloaded file
  32210. */
  32211. static Download(blob: Blob, fileName: string): void;
  32212. /**
  32213. * Captures a screenshot of the current rendering
  32214. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32215. * @param engine defines the rendering engine
  32216. * @param camera defines the source camera
  32217. * @param size This parameter can be set to a single number or to an object with the
  32218. * following (optional) properties: precision, width, height. If a single number is passed,
  32219. * it will be used for both width and height. If an object is passed, the screenshot size
  32220. * will be derived from the parameters. The precision property is a multiplier allowing
  32221. * rendering at a higher or lower resolution
  32222. * @param successCallback defines the callback receives a single parameter which contains the
  32223. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32224. * src parameter of an <img> to display it
  32225. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32226. * Check your browser for supported MIME types
  32227. */
  32228. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32229. /**
  32230. * Captures a screenshot of the current rendering
  32231. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32232. * @param engine defines the rendering engine
  32233. * @param camera defines the source camera
  32234. * @param size This parameter can be set to a single number or to an object with the
  32235. * following (optional) properties: precision, width, height. If a single number is passed,
  32236. * it will be used for both width and height. If an object is passed, the screenshot size
  32237. * will be derived from the parameters. The precision property is a multiplier allowing
  32238. * rendering at a higher or lower resolution
  32239. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32240. * Check your browser for supported MIME types
  32241. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32242. * to the src parameter of an <img> to display it
  32243. */
  32244. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32245. /**
  32246. * Generates an image screenshot from the specified camera.
  32247. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32248. * @param engine The engine to use for rendering
  32249. * @param camera The camera to use for rendering
  32250. * @param size This parameter can be set to a single number or to an object with the
  32251. * following (optional) properties: precision, width, height. If a single number is passed,
  32252. * it will be used for both width and height. If an object is passed, the screenshot size
  32253. * will be derived from the parameters. The precision property is a multiplier allowing
  32254. * rendering at a higher or lower resolution
  32255. * @param successCallback The callback receives a single parameter which contains the
  32256. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32257. * src parameter of an <img> to display it
  32258. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32259. * Check your browser for supported MIME types
  32260. * @param samples Texture samples (default: 1)
  32261. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32262. * @param fileName A name for for the downloaded file.
  32263. */
  32264. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32265. /**
  32266. * Generates an image screenshot from the specified camera.
  32267. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32268. * @param engine The engine to use for rendering
  32269. * @param camera The camera to use for rendering
  32270. * @param size This parameter can be set to a single number or to an object with the
  32271. * following (optional) properties: precision, width, height. If a single number is passed,
  32272. * it will be used for both width and height. If an object is passed, the screenshot size
  32273. * will be derived from the parameters. The precision property is a multiplier allowing
  32274. * rendering at a higher or lower resolution
  32275. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32276. * Check your browser for supported MIME types
  32277. * @param samples Texture samples (default: 1)
  32278. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32279. * @param fileName A name for for the downloaded file.
  32280. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32281. * to the src parameter of an <img> to display it
  32282. */
  32283. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32284. /**
  32285. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32286. * Be aware Math.random() could cause collisions, but:
  32287. * "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"
  32288. * @returns a pseudo random id
  32289. */
  32290. static RandomId(): string;
  32291. /**
  32292. * Test if the given uri is a base64 string
  32293. * @param uri The uri to test
  32294. * @return True if the uri is a base64 string or false otherwise
  32295. */
  32296. static IsBase64(uri: string): boolean;
  32297. /**
  32298. * Decode the given base64 uri.
  32299. * @param uri The uri to decode
  32300. * @return The decoded base64 data.
  32301. */
  32302. static DecodeBase64(uri: string): ArrayBuffer;
  32303. /**
  32304. * Gets the absolute url.
  32305. * @param url the input url
  32306. * @return the absolute url
  32307. */
  32308. static GetAbsoluteUrl(url: string): string;
  32309. /**
  32310. * No log
  32311. */
  32312. static readonly NoneLogLevel: number;
  32313. /**
  32314. * Only message logs
  32315. */
  32316. static readonly MessageLogLevel: number;
  32317. /**
  32318. * Only warning logs
  32319. */
  32320. static readonly WarningLogLevel: number;
  32321. /**
  32322. * Only error logs
  32323. */
  32324. static readonly ErrorLogLevel: number;
  32325. /**
  32326. * All logs
  32327. */
  32328. static readonly AllLogLevel: number;
  32329. /**
  32330. * Gets a value indicating the number of loading errors
  32331. * @ignorenaming
  32332. */
  32333. static readonly errorsCount: number;
  32334. /**
  32335. * Callback called when a new log is added
  32336. */
  32337. static OnNewCacheEntry: (entry: string) => void;
  32338. /**
  32339. * Log a message to the console
  32340. * @param message defines the message to log
  32341. */
  32342. static Log(message: string): void;
  32343. /**
  32344. * Write a warning message to the console
  32345. * @param message defines the message to log
  32346. */
  32347. static Warn(message: string): void;
  32348. /**
  32349. * Write an error message to the console
  32350. * @param message defines the message to log
  32351. */
  32352. static Error(message: string): void;
  32353. /**
  32354. * Gets current log cache (list of logs)
  32355. */
  32356. static readonly LogCache: string;
  32357. /**
  32358. * Clears the log cache
  32359. */
  32360. static ClearLogCache(): void;
  32361. /**
  32362. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32363. */
  32364. static LogLevels: number;
  32365. /**
  32366. * Checks if the window object exists
  32367. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32368. */
  32369. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32370. /**
  32371. * No performance log
  32372. */
  32373. static readonly PerformanceNoneLogLevel: number;
  32374. /**
  32375. * Use user marks to log performance
  32376. */
  32377. static readonly PerformanceUserMarkLogLevel: number;
  32378. /**
  32379. * Log performance to the console
  32380. */
  32381. static readonly PerformanceConsoleLogLevel: number;
  32382. private static _performance;
  32383. /**
  32384. * Sets the current performance log level
  32385. */
  32386. static PerformanceLogLevel: number;
  32387. private static _StartPerformanceCounterDisabled;
  32388. private static _EndPerformanceCounterDisabled;
  32389. private static _StartUserMark;
  32390. private static _EndUserMark;
  32391. private static _StartPerformanceConsole;
  32392. private static _EndPerformanceConsole;
  32393. /**
  32394. * Starts a performance counter
  32395. */
  32396. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32397. /**
  32398. * Ends a specific performance coutner
  32399. */
  32400. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32401. /**
  32402. * Gets either window.performance.now() if supported or Date.now() else
  32403. */
  32404. static readonly Now: number;
  32405. /**
  32406. * This method will return the name of the class used to create the instance of the given object.
  32407. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32408. * @param object the object to get the class name from
  32409. * @param isType defines if the object is actually a type
  32410. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32411. */
  32412. static GetClassName(object: any, isType?: boolean): string;
  32413. /**
  32414. * Gets the first element of an array satisfying a given predicate
  32415. * @param array defines the array to browse
  32416. * @param predicate defines the predicate to use
  32417. * @returns null if not found or the element
  32418. */
  32419. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32420. /**
  32421. * This method will return the name of the full name of the class, including its owning module (if any).
  32422. * 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).
  32423. * @param object the object to get the class name from
  32424. * @param isType defines if the object is actually a type
  32425. * @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.
  32426. * @ignorenaming
  32427. */
  32428. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32429. /**
  32430. * Returns a promise that resolves after the given amount of time.
  32431. * @param delay Number of milliseconds to delay
  32432. * @returns Promise that resolves after the given amount of time
  32433. */
  32434. static DelayAsync(delay: number): Promise<void>;
  32435. }
  32436. /**
  32437. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32438. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32439. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32440. * @param name The name of the class, case should be preserved
  32441. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32442. */
  32443. export function className(name: string, module?: string): (target: Object) => void;
  32444. /**
  32445. * An implementation of a loop for asynchronous functions.
  32446. */
  32447. export class AsyncLoop {
  32448. /**
  32449. * Defines the number of iterations for the loop
  32450. */
  32451. iterations: number;
  32452. /**
  32453. * Defines the current index of the loop.
  32454. */
  32455. index: number;
  32456. private _done;
  32457. private _fn;
  32458. private _successCallback;
  32459. /**
  32460. * Constructor.
  32461. * @param iterations the number of iterations.
  32462. * @param func the function to run each iteration
  32463. * @param successCallback the callback that will be called upon succesful execution
  32464. * @param offset starting offset.
  32465. */
  32466. constructor(
  32467. /**
  32468. * Defines the number of iterations for the loop
  32469. */
  32470. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32471. /**
  32472. * Execute the next iteration. Must be called after the last iteration was finished.
  32473. */
  32474. executeNext(): void;
  32475. /**
  32476. * Break the loop and run the success callback.
  32477. */
  32478. breakLoop(): void;
  32479. /**
  32480. * Create and run an async loop.
  32481. * @param iterations the number of iterations.
  32482. * @param fn the function to run each iteration
  32483. * @param successCallback the callback that will be called upon succesful execution
  32484. * @param offset starting offset.
  32485. * @returns the created async loop object
  32486. */
  32487. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32488. /**
  32489. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32490. * @param iterations total number of iterations
  32491. * @param syncedIterations number of synchronous iterations in each async iteration.
  32492. * @param fn the function to call each iteration.
  32493. * @param callback a success call back that will be called when iterating stops.
  32494. * @param breakFunction a break condition (optional)
  32495. * @param timeout timeout settings for the setTimeout function. default - 0.
  32496. * @returns the created async loop object
  32497. */
  32498. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32499. }
  32500. }
  32501. declare module BABYLON {
  32502. /**
  32503. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32504. * The underlying implementation relies on an associative array to ensure the best performances.
  32505. * The value can be anything including 'null' but except 'undefined'
  32506. */
  32507. export class StringDictionary<T> {
  32508. /**
  32509. * This will clear this dictionary and copy the content from the 'source' one.
  32510. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32511. * @param source the dictionary to take the content from and copy to this dictionary
  32512. */
  32513. copyFrom(source: StringDictionary<T>): void;
  32514. /**
  32515. * Get a value based from its key
  32516. * @param key the given key to get the matching value from
  32517. * @return the value if found, otherwise undefined is returned
  32518. */
  32519. get(key: string): T | undefined;
  32520. /**
  32521. * Get a value from its key or add it if it doesn't exist.
  32522. * This method will ensure you that a given key/data will be present in the dictionary.
  32523. * @param key the given key to get the matching value from
  32524. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32525. * The factory will only be invoked if there's no data for the given key.
  32526. * @return the value corresponding to the key.
  32527. */
  32528. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32529. /**
  32530. * Get a value from its key if present in the dictionary otherwise add it
  32531. * @param key the key to get the value from
  32532. * @param val if there's no such key/value pair in the dictionary add it with this value
  32533. * @return the value corresponding to the key
  32534. */
  32535. getOrAdd(key: string, val: T): T;
  32536. /**
  32537. * Check if there's a given key in the dictionary
  32538. * @param key the key to check for
  32539. * @return true if the key is present, false otherwise
  32540. */
  32541. contains(key: string): boolean;
  32542. /**
  32543. * Add a new key and its corresponding value
  32544. * @param key the key to add
  32545. * @param value the value corresponding to the key
  32546. * @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
  32547. */
  32548. add(key: string, value: T): boolean;
  32549. /**
  32550. * Update a specific value associated to a key
  32551. * @param key defines the key to use
  32552. * @param value defines the value to store
  32553. * @returns true if the value was updated (or false if the key was not found)
  32554. */
  32555. set(key: string, value: T): boolean;
  32556. /**
  32557. * Get the element of the given key and remove it from the dictionary
  32558. * @param key defines the key to search
  32559. * @returns the value associated with the key or null if not found
  32560. */
  32561. getAndRemove(key: string): Nullable<T>;
  32562. /**
  32563. * Remove a key/value from the dictionary.
  32564. * @param key the key to remove
  32565. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32566. */
  32567. remove(key: string): boolean;
  32568. /**
  32569. * Clear the whole content of the dictionary
  32570. */
  32571. clear(): void;
  32572. /**
  32573. * Gets the current count
  32574. */
  32575. readonly count: number;
  32576. /**
  32577. * Execute a callback on each key/val of the dictionary.
  32578. * Note that you can remove any element in this dictionary in the callback implementation
  32579. * @param callback the callback to execute on a given key/value pair
  32580. */
  32581. forEach(callback: (key: string, val: T) => void): void;
  32582. /**
  32583. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32584. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32585. * Note that you can remove any element in this dictionary in the callback implementation
  32586. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32587. * @returns the first item
  32588. */
  32589. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32590. private _count;
  32591. private _data;
  32592. }
  32593. }
  32594. declare module BABYLON {
  32595. /** @hidden */
  32596. export interface ICollisionCoordinator {
  32597. createCollider(): Collider;
  32598. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32599. init(scene: Scene): void;
  32600. }
  32601. /** @hidden */
  32602. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32603. private _scene;
  32604. private _scaledPosition;
  32605. private _scaledVelocity;
  32606. private _finalPosition;
  32607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32608. createCollider(): Collider;
  32609. init(scene: Scene): void;
  32610. private _collideWithWorld;
  32611. }
  32612. }
  32613. declare module BABYLON {
  32614. /**
  32615. * Class used to manage all inputs for the scene.
  32616. */
  32617. export class InputManager {
  32618. /** The distance in pixel that you have to move to prevent some events */
  32619. static DragMovementThreshold: number;
  32620. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32621. static LongPressDelay: number;
  32622. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32623. static DoubleClickDelay: number;
  32624. /** If you need to check double click without raising a single click at first click, enable this flag */
  32625. static ExclusiveDoubleClickMode: boolean;
  32626. private _wheelEventName;
  32627. private _onPointerMove;
  32628. private _onPointerDown;
  32629. private _onPointerUp;
  32630. private _initClickEvent;
  32631. private _initActionManager;
  32632. private _delayedSimpleClick;
  32633. private _delayedSimpleClickTimeout;
  32634. private _previousDelayedSimpleClickTimeout;
  32635. private _meshPickProceed;
  32636. private _previousButtonPressed;
  32637. private _currentPickResult;
  32638. private _previousPickResult;
  32639. private _totalPointersPressed;
  32640. private _doubleClickOccured;
  32641. private _pointerOverMesh;
  32642. private _pickedDownMesh;
  32643. private _pickedUpMesh;
  32644. private _pointerX;
  32645. private _pointerY;
  32646. private _unTranslatedPointerX;
  32647. private _unTranslatedPointerY;
  32648. private _startingPointerPosition;
  32649. private _previousStartingPointerPosition;
  32650. private _startingPointerTime;
  32651. private _previousStartingPointerTime;
  32652. private _pointerCaptures;
  32653. private _onKeyDown;
  32654. private _onKeyUp;
  32655. private _onCanvasFocusObserver;
  32656. private _onCanvasBlurObserver;
  32657. private _scene;
  32658. /**
  32659. * Creates a new InputManager
  32660. * @param scene defines the hosting scene
  32661. */
  32662. constructor(scene: Scene);
  32663. /**
  32664. * Gets the mesh that is currently under the pointer
  32665. */
  32666. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32667. /**
  32668. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32669. */
  32670. readonly unTranslatedPointer: Vector2;
  32671. /**
  32672. * Gets or sets the current on-screen X position of the pointer
  32673. */
  32674. pointerX: number;
  32675. /**
  32676. * Gets or sets the current on-screen Y position of the pointer
  32677. */
  32678. pointerY: number;
  32679. private _updatePointerPosition;
  32680. private _processPointerMove;
  32681. private _setRayOnPointerInfo;
  32682. private _checkPrePointerObservable;
  32683. /**
  32684. * Use this method to simulate a pointer move on a mesh
  32685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32688. */
  32689. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32690. /**
  32691. * Use this method to simulate a pointer down on a mesh
  32692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32695. */
  32696. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32697. private _processPointerDown;
  32698. /** @hidden */
  32699. _isPointerSwiping(): boolean;
  32700. /**
  32701. * Use this method to simulate a pointer up on a mesh
  32702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32705. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32706. */
  32707. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32708. private _processPointerUp;
  32709. /**
  32710. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32711. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32712. * @returns true if the pointer was captured
  32713. */
  32714. isPointerCaptured(pointerId?: number): boolean;
  32715. /**
  32716. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32717. * @param attachUp defines if you want to attach events to pointerup
  32718. * @param attachDown defines if you want to attach events to pointerdown
  32719. * @param attachMove defines if you want to attach events to pointermove
  32720. */
  32721. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32722. /**
  32723. * Detaches all event handlers
  32724. */
  32725. detachControl(): void;
  32726. /**
  32727. * Force the value of meshUnderPointer
  32728. * @param mesh defines the mesh to use
  32729. */
  32730. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32731. /**
  32732. * Gets the mesh under the pointer
  32733. * @returns a Mesh or null if no mesh is under the pointer
  32734. */
  32735. getPointerOverMesh(): Nullable<AbstractMesh>;
  32736. }
  32737. }
  32738. declare module BABYLON {
  32739. /**
  32740. * Helper class used to generate session unique ID
  32741. */
  32742. export class UniqueIdGenerator {
  32743. private static _UniqueIdCounter;
  32744. /**
  32745. * Gets an unique (relatively to the current scene) Id
  32746. */
  32747. static readonly UniqueId: number;
  32748. }
  32749. }
  32750. declare module BABYLON {
  32751. /**
  32752. * This class defines the direct association between an animation and a target
  32753. */
  32754. export class TargetedAnimation {
  32755. /**
  32756. * Animation to perform
  32757. */
  32758. animation: Animation;
  32759. /**
  32760. * Target to animate
  32761. */
  32762. target: any;
  32763. /**
  32764. * Serialize the object
  32765. * @returns the JSON object representing the current entity
  32766. */
  32767. serialize(): any;
  32768. }
  32769. /**
  32770. * Use this class to create coordinated animations on multiple targets
  32771. */
  32772. export class AnimationGroup implements IDisposable {
  32773. /** The name of the animation group */
  32774. name: string;
  32775. private _scene;
  32776. private _targetedAnimations;
  32777. private _animatables;
  32778. private _from;
  32779. private _to;
  32780. private _isStarted;
  32781. private _isPaused;
  32782. private _speedRatio;
  32783. private _loopAnimation;
  32784. /**
  32785. * Gets or sets the unique id of the node
  32786. */
  32787. uniqueId: number;
  32788. /**
  32789. * This observable will notify when one animation have ended
  32790. */
  32791. onAnimationEndObservable: Observable<TargetedAnimation>;
  32792. /**
  32793. * Observer raised when one animation loops
  32794. */
  32795. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32796. /**
  32797. * This observable will notify when all animations have ended.
  32798. */
  32799. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32800. /**
  32801. * This observable will notify when all animations have paused.
  32802. */
  32803. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32804. /**
  32805. * This observable will notify when all animations are playing.
  32806. */
  32807. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32808. /**
  32809. * Gets the first frame
  32810. */
  32811. readonly from: number;
  32812. /**
  32813. * Gets the last frame
  32814. */
  32815. readonly to: number;
  32816. /**
  32817. * Define if the animations are started
  32818. */
  32819. readonly isStarted: boolean;
  32820. /**
  32821. * Gets a value indicating that the current group is playing
  32822. */
  32823. readonly isPlaying: boolean;
  32824. /**
  32825. * Gets or sets the speed ratio to use for all animations
  32826. */
  32827. /**
  32828. * Gets or sets the speed ratio to use for all animations
  32829. */
  32830. speedRatio: number;
  32831. /**
  32832. * Gets or sets if all animations should loop or not
  32833. */
  32834. loopAnimation: boolean;
  32835. /**
  32836. * Gets the targeted animations for this animation group
  32837. */
  32838. readonly targetedAnimations: Array<TargetedAnimation>;
  32839. /**
  32840. * returning the list of animatables controlled by this animation group.
  32841. */
  32842. readonly animatables: Array<Animatable>;
  32843. /**
  32844. * Instantiates a new Animation Group.
  32845. * This helps managing several animations at once.
  32846. * @see http://doc.babylonjs.com/how_to/group
  32847. * @param name Defines the name of the group
  32848. * @param scene Defines the scene the group belongs to
  32849. */
  32850. constructor(
  32851. /** The name of the animation group */
  32852. name: string, scene?: Nullable<Scene>);
  32853. /**
  32854. * Add an animation (with its target) in the group
  32855. * @param animation defines the animation we want to add
  32856. * @param target defines the target of the animation
  32857. * @returns the TargetedAnimation object
  32858. */
  32859. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32860. /**
  32861. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32862. * It can add constant keys at begin or end
  32863. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32864. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32865. * @returns the animation group
  32866. */
  32867. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32868. /**
  32869. * Start all animations on given targets
  32870. * @param loop defines if animations must loop
  32871. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32872. * @param from defines the from key (optional)
  32873. * @param to defines the to key (optional)
  32874. * @returns the current animation group
  32875. */
  32876. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32877. /**
  32878. * Pause all animations
  32879. * @returns the animation group
  32880. */
  32881. pause(): AnimationGroup;
  32882. /**
  32883. * Play all animations to initial state
  32884. * This function will start() the animations if they were not started or will restart() them if they were paused
  32885. * @param loop defines if animations must loop
  32886. * @returns the animation group
  32887. */
  32888. play(loop?: boolean): AnimationGroup;
  32889. /**
  32890. * Reset all animations to initial state
  32891. * @returns the animation group
  32892. */
  32893. reset(): AnimationGroup;
  32894. /**
  32895. * Restart animations from key 0
  32896. * @returns the animation group
  32897. */
  32898. restart(): AnimationGroup;
  32899. /**
  32900. * Stop all animations
  32901. * @returns the animation group
  32902. */
  32903. stop(): AnimationGroup;
  32904. /**
  32905. * Set animation weight for all animatables
  32906. * @param weight defines the weight to use
  32907. * @return the animationGroup
  32908. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32909. */
  32910. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32911. /**
  32912. * Synchronize and normalize all animatables with a source animatable
  32913. * @param root defines the root animatable to synchronize with
  32914. * @return the animationGroup
  32915. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32916. */
  32917. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32918. /**
  32919. * Goes to a specific frame in this animation group
  32920. * @param frame the frame number to go to
  32921. * @return the animationGroup
  32922. */
  32923. goToFrame(frame: number): AnimationGroup;
  32924. /**
  32925. * Dispose all associated resources
  32926. */
  32927. dispose(): void;
  32928. private _checkAnimationGroupEnded;
  32929. /**
  32930. * Clone the current animation group and returns a copy
  32931. * @param newName defines the name of the new group
  32932. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32933. * @returns the new aniamtion group
  32934. */
  32935. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32936. /**
  32937. * Serializes the animationGroup to an object
  32938. * @returns Serialized object
  32939. */
  32940. serialize(): any;
  32941. /**
  32942. * Returns a new AnimationGroup object parsed from the source provided.
  32943. * @param parsedAnimationGroup defines the source
  32944. * @param scene defines the scene that will receive the animationGroup
  32945. * @returns a new AnimationGroup
  32946. */
  32947. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32948. /**
  32949. * Returns the string "AnimationGroup"
  32950. * @returns "AnimationGroup"
  32951. */
  32952. getClassName(): string;
  32953. /**
  32954. * Creates a detailled string about the object
  32955. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32956. * @returns a string representing the object
  32957. */
  32958. toString(fullDetails?: boolean): string;
  32959. }
  32960. }
  32961. declare module BABYLON {
  32962. /**
  32963. * Define an interface for all classes that will hold resources
  32964. */
  32965. export interface IDisposable {
  32966. /**
  32967. * Releases all held resources
  32968. */
  32969. dispose(): void;
  32970. }
  32971. /** Interface defining initialization parameters for Scene class */
  32972. export interface SceneOptions {
  32973. /**
  32974. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32975. * It will improve performance when the number of geometries becomes important.
  32976. */
  32977. useGeometryUniqueIdsMap?: boolean;
  32978. /**
  32979. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32980. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32981. */
  32982. useMaterialMeshMap?: boolean;
  32983. /**
  32984. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32985. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32986. */
  32987. useClonedMeshhMap?: boolean;
  32988. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32989. virtual?: boolean;
  32990. }
  32991. /**
  32992. * Represents a scene to be rendered by the engine.
  32993. * @see http://doc.babylonjs.com/features/scene
  32994. */
  32995. export class Scene extends AbstractScene implements IAnimatable {
  32996. /** The fog is deactivated */
  32997. static readonly FOGMODE_NONE: number;
  32998. /** The fog density is following an exponential function */
  32999. static readonly FOGMODE_EXP: number;
  33000. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33001. static readonly FOGMODE_EXP2: number;
  33002. /** The fog density is following a linear function. */
  33003. static readonly FOGMODE_LINEAR: number;
  33004. /**
  33005. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33007. */
  33008. static MinDeltaTime: number;
  33009. /**
  33010. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33012. */
  33013. static MaxDeltaTime: number;
  33014. /**
  33015. * Factory used to create the default material.
  33016. * @param name The name of the material to create
  33017. * @param scene The scene to create the material for
  33018. * @returns The default material
  33019. */
  33020. static DefaultMaterialFactory(scene: Scene): Material;
  33021. /**
  33022. * Factory used to create the a collision coordinator.
  33023. * @returns The collision coordinator
  33024. */
  33025. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33026. /** @hidden */
  33027. _inputManager: InputManager;
  33028. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33029. cameraToUseForPointers: Nullable<Camera>;
  33030. /** @hidden */
  33031. readonly _isScene: boolean;
  33032. /**
  33033. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33034. */
  33035. autoClear: boolean;
  33036. /**
  33037. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33038. */
  33039. autoClearDepthAndStencil: boolean;
  33040. /**
  33041. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33042. */
  33043. clearColor: Color4;
  33044. /**
  33045. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33046. */
  33047. ambientColor: Color3;
  33048. /**
  33049. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33050. * It should only be one of the following (if not the default embedded one):
  33051. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33052. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33053. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33054. * The material properties need to be setup according to the type of texture in use.
  33055. */
  33056. environmentBRDFTexture: BaseTexture;
  33057. /** @hidden */
  33058. protected _environmentTexture: Nullable<BaseTexture>;
  33059. /**
  33060. * Texture used in all pbr material as the reflection texture.
  33061. * As in the majority of the scene they are the same (exception for multi room and so on),
  33062. * this is easier to reference from here than from all the materials.
  33063. */
  33064. /**
  33065. * Texture used in all pbr material as the reflection texture.
  33066. * As in the majority of the scene they are the same (exception for multi room and so on),
  33067. * this is easier to set here than in all the materials.
  33068. */
  33069. environmentTexture: Nullable<BaseTexture>;
  33070. /** @hidden */
  33071. protected _environmentIntensity: number;
  33072. /**
  33073. * Intensity of the environment in all pbr material.
  33074. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33075. * As in the majority of the scene they are the same (exception for multi room and so on),
  33076. * this is easier to reference from here than from all the materials.
  33077. */
  33078. /**
  33079. * Intensity of the environment in all pbr material.
  33080. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33081. * As in the majority of the scene they are the same (exception for multi room and so on),
  33082. * this is easier to set here than in all the materials.
  33083. */
  33084. environmentIntensity: number;
  33085. /** @hidden */
  33086. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33087. /**
  33088. * Default image processing configuration used either in the rendering
  33089. * Forward main pass or through the imageProcessingPostProcess if present.
  33090. * As in the majority of the scene they are the same (exception for multi camera),
  33091. * this is easier to reference from here than from all the materials and post process.
  33092. *
  33093. * No setter as we it is a shared configuration, you can set the values instead.
  33094. */
  33095. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33096. private _forceWireframe;
  33097. /**
  33098. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33099. */
  33100. forceWireframe: boolean;
  33101. private _forcePointsCloud;
  33102. /**
  33103. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33104. */
  33105. forcePointsCloud: boolean;
  33106. /**
  33107. * Gets or sets the active clipplane 1
  33108. */
  33109. clipPlane: Nullable<Plane>;
  33110. /**
  33111. * Gets or sets the active clipplane 2
  33112. */
  33113. clipPlane2: Nullable<Plane>;
  33114. /**
  33115. * Gets or sets the active clipplane 3
  33116. */
  33117. clipPlane3: Nullable<Plane>;
  33118. /**
  33119. * Gets or sets the active clipplane 4
  33120. */
  33121. clipPlane4: Nullable<Plane>;
  33122. /**
  33123. * Gets or sets a boolean indicating if animations are enabled
  33124. */
  33125. animationsEnabled: boolean;
  33126. private _animationPropertiesOverride;
  33127. /**
  33128. * Gets or sets the animation properties override
  33129. */
  33130. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33131. /**
  33132. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33133. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33134. */
  33135. useConstantAnimationDeltaTime: boolean;
  33136. /**
  33137. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33138. * Please note that it requires to run a ray cast through the scene on every frame
  33139. */
  33140. constantlyUpdateMeshUnderPointer: boolean;
  33141. /**
  33142. * Defines the HTML cursor to use when hovering over interactive elements
  33143. */
  33144. hoverCursor: string;
  33145. /**
  33146. * Defines the HTML default cursor to use (empty by default)
  33147. */
  33148. defaultCursor: string;
  33149. /**
  33150. * This is used to call preventDefault() on pointer down
  33151. * in order to block unwanted artifacts like system double clicks
  33152. */
  33153. preventDefaultOnPointerDown: boolean;
  33154. /**
  33155. * This is used to call preventDefault() on pointer up
  33156. * in order to block unwanted artifacts like system double clicks
  33157. */
  33158. preventDefaultOnPointerUp: boolean;
  33159. /**
  33160. * Gets or sets user defined metadata
  33161. */
  33162. metadata: any;
  33163. /**
  33164. * For internal use only. Please do not use.
  33165. */
  33166. reservedDataStore: any;
  33167. /**
  33168. * Gets the name of the plugin used to load this scene (null by default)
  33169. */
  33170. loadingPluginName: string;
  33171. /**
  33172. * Use this array to add regular expressions used to disable offline support for specific urls
  33173. */
  33174. disableOfflineSupportExceptionRules: RegExp[];
  33175. /**
  33176. * An event triggered when the scene is disposed.
  33177. */
  33178. onDisposeObservable: Observable<Scene>;
  33179. private _onDisposeObserver;
  33180. /** Sets a function to be executed when this scene is disposed. */
  33181. onDispose: () => void;
  33182. /**
  33183. * An event triggered before rendering the scene (right after animations and physics)
  33184. */
  33185. onBeforeRenderObservable: Observable<Scene>;
  33186. private _onBeforeRenderObserver;
  33187. /** Sets a function to be executed before rendering this scene */
  33188. beforeRender: Nullable<() => void>;
  33189. /**
  33190. * An event triggered after rendering the scene
  33191. */
  33192. onAfterRenderObservable: Observable<Scene>;
  33193. /**
  33194. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33195. */
  33196. onAfterRenderCameraObservable: Observable<Camera>;
  33197. private _onAfterRenderObserver;
  33198. /** Sets a function to be executed after rendering this scene */
  33199. afterRender: Nullable<() => void>;
  33200. /**
  33201. * An event triggered before animating the scene
  33202. */
  33203. onBeforeAnimationsObservable: Observable<Scene>;
  33204. /**
  33205. * An event triggered after animations processing
  33206. */
  33207. onAfterAnimationsObservable: Observable<Scene>;
  33208. /**
  33209. * An event triggered before draw calls are ready to be sent
  33210. */
  33211. onBeforeDrawPhaseObservable: Observable<Scene>;
  33212. /**
  33213. * An event triggered after draw calls have been sent
  33214. */
  33215. onAfterDrawPhaseObservable: Observable<Scene>;
  33216. /**
  33217. * An event triggered when the scene is ready
  33218. */
  33219. onReadyObservable: Observable<Scene>;
  33220. /**
  33221. * An event triggered before rendering a camera
  33222. */
  33223. onBeforeCameraRenderObservable: Observable<Camera>;
  33224. private _onBeforeCameraRenderObserver;
  33225. /** Sets a function to be executed before rendering a camera*/
  33226. beforeCameraRender: () => void;
  33227. /**
  33228. * An event triggered after rendering a camera
  33229. */
  33230. onAfterCameraRenderObservable: Observable<Camera>;
  33231. private _onAfterCameraRenderObserver;
  33232. /** Sets a function to be executed after rendering a camera*/
  33233. afterCameraRender: () => void;
  33234. /**
  33235. * An event triggered when active meshes evaluation is about to start
  33236. */
  33237. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33238. /**
  33239. * An event triggered when active meshes evaluation is done
  33240. */
  33241. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33242. /**
  33243. * An event triggered when particles rendering is about to start
  33244. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33245. */
  33246. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33247. /**
  33248. * An event triggered when particles rendering is done
  33249. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33250. */
  33251. onAfterParticlesRenderingObservable: Observable<Scene>;
  33252. /**
  33253. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33254. */
  33255. onDataLoadedObservable: Observable<Scene>;
  33256. /**
  33257. * An event triggered when a camera is created
  33258. */
  33259. onNewCameraAddedObservable: Observable<Camera>;
  33260. /**
  33261. * An event triggered when a camera is removed
  33262. */
  33263. onCameraRemovedObservable: Observable<Camera>;
  33264. /**
  33265. * An event triggered when a light is created
  33266. */
  33267. onNewLightAddedObservable: Observable<Light>;
  33268. /**
  33269. * An event triggered when a light is removed
  33270. */
  33271. onLightRemovedObservable: Observable<Light>;
  33272. /**
  33273. * An event triggered when a geometry is created
  33274. */
  33275. onNewGeometryAddedObservable: Observable<Geometry>;
  33276. /**
  33277. * An event triggered when a geometry is removed
  33278. */
  33279. onGeometryRemovedObservable: Observable<Geometry>;
  33280. /**
  33281. * An event triggered when a transform node is created
  33282. */
  33283. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33284. /**
  33285. * An event triggered when a transform node is removed
  33286. */
  33287. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33288. /**
  33289. * An event triggered when a mesh is created
  33290. */
  33291. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33292. /**
  33293. * An event triggered when a mesh is removed
  33294. */
  33295. onMeshRemovedObservable: Observable<AbstractMesh>;
  33296. /**
  33297. * An event triggered when a skeleton is created
  33298. */
  33299. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33300. /**
  33301. * An event triggered when a skeleton is removed
  33302. */
  33303. onSkeletonRemovedObservable: Observable<Skeleton>;
  33304. /**
  33305. * An event triggered when a material is created
  33306. */
  33307. onNewMaterialAddedObservable: Observable<Material>;
  33308. /**
  33309. * An event triggered when a material is removed
  33310. */
  33311. onMaterialRemovedObservable: Observable<Material>;
  33312. /**
  33313. * An event triggered when a texture is created
  33314. */
  33315. onNewTextureAddedObservable: Observable<BaseTexture>;
  33316. /**
  33317. * An event triggered when a texture is removed
  33318. */
  33319. onTextureRemovedObservable: Observable<BaseTexture>;
  33320. /**
  33321. * An event triggered when render targets are about to be rendered
  33322. * Can happen multiple times per frame.
  33323. */
  33324. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33325. /**
  33326. * An event triggered when render targets were rendered.
  33327. * Can happen multiple times per frame.
  33328. */
  33329. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33330. /**
  33331. * An event triggered before calculating deterministic simulation step
  33332. */
  33333. onBeforeStepObservable: Observable<Scene>;
  33334. /**
  33335. * An event triggered after calculating deterministic simulation step
  33336. */
  33337. onAfterStepObservable: Observable<Scene>;
  33338. /**
  33339. * An event triggered when the activeCamera property is updated
  33340. */
  33341. onActiveCameraChanged: Observable<Scene>;
  33342. /**
  33343. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33344. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33345. * 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)
  33346. */
  33347. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33348. /**
  33349. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33350. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33351. * 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)
  33352. */
  33353. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33354. /**
  33355. * This Observable will when a mesh has been imported into the scene.
  33356. */
  33357. onMeshImportedObservable: Observable<AbstractMesh>;
  33358. /**
  33359. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33360. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33361. */
  33362. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33363. /** @hidden */
  33364. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33365. /**
  33366. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33367. */
  33368. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33369. /**
  33370. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33371. */
  33372. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33373. /**
  33374. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33375. */
  33376. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33377. /** Callback called when a pointer move is detected */
  33378. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33379. /** Callback called when a pointer down is detected */
  33380. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33381. /** Callback called when a pointer up is detected */
  33382. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33383. /** Callback called when a pointer pick is detected */
  33384. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33385. /**
  33386. * 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).
  33387. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33388. */
  33389. onPrePointerObservable: Observable<PointerInfoPre>;
  33390. /**
  33391. * Observable event triggered each time an input event is received from the rendering canvas
  33392. */
  33393. onPointerObservable: Observable<PointerInfo>;
  33394. /**
  33395. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33396. */
  33397. readonly unTranslatedPointer: Vector2;
  33398. /**
  33399. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33400. */
  33401. static DragMovementThreshold: number;
  33402. /**
  33403. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33404. */
  33405. static LongPressDelay: number;
  33406. /**
  33407. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33408. */
  33409. static DoubleClickDelay: number;
  33410. /** If you need to check double click without raising a single click at first click, enable this flag */
  33411. static ExclusiveDoubleClickMode: boolean;
  33412. /** @hidden */
  33413. _mirroredCameraPosition: Nullable<Vector3>;
  33414. /**
  33415. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33416. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33417. */
  33418. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33419. /**
  33420. * Observable event triggered each time an keyboard event is received from the hosting window
  33421. */
  33422. onKeyboardObservable: Observable<KeyboardInfo>;
  33423. private _useRightHandedSystem;
  33424. /**
  33425. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33426. */
  33427. useRightHandedSystem: boolean;
  33428. private _timeAccumulator;
  33429. private _currentStepId;
  33430. private _currentInternalStep;
  33431. /**
  33432. * Sets the step Id used by deterministic lock step
  33433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33434. * @param newStepId defines the step Id
  33435. */
  33436. setStepId(newStepId: number): void;
  33437. /**
  33438. * Gets the step Id used by deterministic lock step
  33439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33440. * @returns the step Id
  33441. */
  33442. getStepId(): number;
  33443. /**
  33444. * Gets the internal step used by deterministic lock step
  33445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33446. * @returns the internal step
  33447. */
  33448. getInternalStep(): number;
  33449. private _fogEnabled;
  33450. /**
  33451. * Gets or sets a boolean indicating if fog is enabled on this scene
  33452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33453. * (Default is true)
  33454. */
  33455. fogEnabled: boolean;
  33456. private _fogMode;
  33457. /**
  33458. * Gets or sets the fog mode to use
  33459. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33460. * | mode | value |
  33461. * | --- | --- |
  33462. * | FOGMODE_NONE | 0 |
  33463. * | FOGMODE_EXP | 1 |
  33464. * | FOGMODE_EXP2 | 2 |
  33465. * | FOGMODE_LINEAR | 3 |
  33466. */
  33467. fogMode: number;
  33468. /**
  33469. * Gets or sets the fog color to use
  33470. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33471. * (Default is Color3(0.2, 0.2, 0.3))
  33472. */
  33473. fogColor: Color3;
  33474. /**
  33475. * Gets or sets the fog density to use
  33476. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33477. * (Default is 0.1)
  33478. */
  33479. fogDensity: number;
  33480. /**
  33481. * Gets or sets the fog start distance to use
  33482. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33483. * (Default is 0)
  33484. */
  33485. fogStart: number;
  33486. /**
  33487. * Gets or sets the fog end distance to use
  33488. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33489. * (Default is 1000)
  33490. */
  33491. fogEnd: number;
  33492. private _shadowsEnabled;
  33493. /**
  33494. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33495. */
  33496. shadowsEnabled: boolean;
  33497. private _lightsEnabled;
  33498. /**
  33499. * Gets or sets a boolean indicating if lights are enabled on this scene
  33500. */
  33501. lightsEnabled: boolean;
  33502. /** All of the active cameras added to this scene. */
  33503. activeCameras: Camera[];
  33504. /** @hidden */
  33505. _activeCamera: Nullable<Camera>;
  33506. /** Gets or sets the current active camera */
  33507. activeCamera: Nullable<Camera>;
  33508. private _defaultMaterial;
  33509. /** The default material used on meshes when no material is affected */
  33510. /** The default material used on meshes when no material is affected */
  33511. defaultMaterial: Material;
  33512. private _texturesEnabled;
  33513. /**
  33514. * Gets or sets a boolean indicating if textures are enabled on this scene
  33515. */
  33516. texturesEnabled: boolean;
  33517. /**
  33518. * Gets or sets a boolean indicating if particles are enabled on this scene
  33519. */
  33520. particlesEnabled: boolean;
  33521. /**
  33522. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33523. */
  33524. spritesEnabled: boolean;
  33525. private _skeletonsEnabled;
  33526. /**
  33527. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33528. */
  33529. skeletonsEnabled: boolean;
  33530. /**
  33531. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33532. */
  33533. lensFlaresEnabled: boolean;
  33534. /**
  33535. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33536. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33537. */
  33538. collisionsEnabled: boolean;
  33539. private _collisionCoordinator;
  33540. /** @hidden */
  33541. readonly collisionCoordinator: ICollisionCoordinator;
  33542. /**
  33543. * Defines the gravity applied to this scene (used only for collisions)
  33544. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33545. */
  33546. gravity: Vector3;
  33547. /**
  33548. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33549. */
  33550. postProcessesEnabled: boolean;
  33551. /**
  33552. * The list of postprocesses added to the scene
  33553. */
  33554. postProcesses: PostProcess[];
  33555. /**
  33556. * Gets the current postprocess manager
  33557. */
  33558. postProcessManager: PostProcessManager;
  33559. /**
  33560. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33561. */
  33562. renderTargetsEnabled: boolean;
  33563. /**
  33564. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33565. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33566. */
  33567. dumpNextRenderTargets: boolean;
  33568. /**
  33569. * The list of user defined render targets added to the scene
  33570. */
  33571. customRenderTargets: RenderTargetTexture[];
  33572. /**
  33573. * Defines if texture loading must be delayed
  33574. * If true, textures will only be loaded when they need to be rendered
  33575. */
  33576. useDelayedTextureLoading: boolean;
  33577. /**
  33578. * Gets the list of meshes imported to the scene through SceneLoader
  33579. */
  33580. importedMeshesFiles: String[];
  33581. /**
  33582. * Gets or sets a boolean indicating if probes are enabled on this scene
  33583. */
  33584. probesEnabled: boolean;
  33585. /**
  33586. * Gets or sets the current offline provider to use to store scene data
  33587. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33588. */
  33589. offlineProvider: IOfflineProvider;
  33590. /**
  33591. * Gets or sets the action manager associated with the scene
  33592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33593. */
  33594. actionManager: AbstractActionManager;
  33595. private _meshesForIntersections;
  33596. /**
  33597. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33598. */
  33599. proceduralTexturesEnabled: boolean;
  33600. private _engine;
  33601. private _totalVertices;
  33602. /** @hidden */
  33603. _activeIndices: PerfCounter;
  33604. /** @hidden */
  33605. _activeParticles: PerfCounter;
  33606. /** @hidden */
  33607. _activeBones: PerfCounter;
  33608. private _animationRatio;
  33609. /** @hidden */
  33610. _animationTimeLast: number;
  33611. /** @hidden */
  33612. _animationTime: number;
  33613. /**
  33614. * Gets or sets a general scale for animation speed
  33615. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33616. */
  33617. animationTimeScale: number;
  33618. /** @hidden */
  33619. _cachedMaterial: Nullable<Material>;
  33620. /** @hidden */
  33621. _cachedEffect: Nullable<Effect>;
  33622. /** @hidden */
  33623. _cachedVisibility: Nullable<number>;
  33624. private _renderId;
  33625. private _frameId;
  33626. private _executeWhenReadyTimeoutId;
  33627. private _intermediateRendering;
  33628. private _viewUpdateFlag;
  33629. private _projectionUpdateFlag;
  33630. /** @hidden */
  33631. _toBeDisposed: Nullable<IDisposable>[];
  33632. private _activeRequests;
  33633. /** @hidden */
  33634. _pendingData: any[];
  33635. private _isDisposed;
  33636. /**
  33637. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33638. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33639. */
  33640. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33641. private _activeMeshes;
  33642. private _processedMaterials;
  33643. private _renderTargets;
  33644. /** @hidden */
  33645. _activeParticleSystems: SmartArray<IParticleSystem>;
  33646. private _activeSkeletons;
  33647. private _softwareSkinnedMeshes;
  33648. private _renderingManager;
  33649. /** @hidden */
  33650. _activeAnimatables: Animatable[];
  33651. private _transformMatrix;
  33652. private _sceneUbo;
  33653. /** @hidden */
  33654. _viewMatrix: Matrix;
  33655. private _projectionMatrix;
  33656. /** @hidden */
  33657. _forcedViewPosition: Nullable<Vector3>;
  33658. /** @hidden */
  33659. _frustumPlanes: Plane[];
  33660. /**
  33661. * Gets the list of frustum planes (built from the active camera)
  33662. */
  33663. readonly frustumPlanes: Plane[];
  33664. /**
  33665. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33666. * This is useful if there are more lights that the maximum simulteanous authorized
  33667. */
  33668. requireLightSorting: boolean;
  33669. /** @hidden */
  33670. readonly useMaterialMeshMap: boolean;
  33671. /** @hidden */
  33672. readonly useClonedMeshhMap: boolean;
  33673. private _externalData;
  33674. private _uid;
  33675. /**
  33676. * @hidden
  33677. * Backing store of defined scene components.
  33678. */
  33679. _components: ISceneComponent[];
  33680. /**
  33681. * @hidden
  33682. * Backing store of defined scene components.
  33683. */
  33684. _serializableComponents: ISceneSerializableComponent[];
  33685. /**
  33686. * List of components to register on the next registration step.
  33687. */
  33688. private _transientComponents;
  33689. /**
  33690. * Registers the transient components if needed.
  33691. */
  33692. private _registerTransientComponents;
  33693. /**
  33694. * @hidden
  33695. * Add a component to the scene.
  33696. * Note that the ccomponent could be registered on th next frame if this is called after
  33697. * the register component stage.
  33698. * @param component Defines the component to add to the scene
  33699. */
  33700. _addComponent(component: ISceneComponent): void;
  33701. /**
  33702. * @hidden
  33703. * Gets a component from the scene.
  33704. * @param name defines the name of the component to retrieve
  33705. * @returns the component or null if not present
  33706. */
  33707. _getComponent(name: string): Nullable<ISceneComponent>;
  33708. /**
  33709. * @hidden
  33710. * Defines the actions happening before camera updates.
  33711. */
  33712. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33713. /**
  33714. * @hidden
  33715. * Defines the actions happening before clear the canvas.
  33716. */
  33717. _beforeClearStage: Stage<SimpleStageAction>;
  33718. /**
  33719. * @hidden
  33720. * Defines the actions when collecting render targets for the frame.
  33721. */
  33722. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33723. /**
  33724. * @hidden
  33725. * Defines the actions happening for one camera in the frame.
  33726. */
  33727. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33728. /**
  33729. * @hidden
  33730. * Defines the actions happening during the per mesh ready checks.
  33731. */
  33732. _isReadyForMeshStage: Stage<MeshStageAction>;
  33733. /**
  33734. * @hidden
  33735. * Defines the actions happening before evaluate active mesh checks.
  33736. */
  33737. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33738. /**
  33739. * @hidden
  33740. * Defines the actions happening during the evaluate sub mesh checks.
  33741. */
  33742. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33743. /**
  33744. * @hidden
  33745. * Defines the actions happening during the active mesh stage.
  33746. */
  33747. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions happening during the per camera render target step.
  33751. */
  33752. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening just before the active camera is drawing.
  33756. */
  33757. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions happening just before a render target is drawing.
  33761. */
  33762. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening just before a rendering group is drawing.
  33766. */
  33767. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening just before a mesh is drawing.
  33771. */
  33772. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening just after a mesh has been drawn.
  33776. */
  33777. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening just after a rendering group has been drawn.
  33781. */
  33782. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening just after the active camera has been drawn.
  33786. */
  33787. _afterCameraDrawStage: Stage<CameraStageAction>;
  33788. /**
  33789. * @hidden
  33790. * Defines the actions happening just after a render target has been drawn.
  33791. */
  33792. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33793. /**
  33794. * @hidden
  33795. * Defines the actions happening just after rendering all cameras and computing intersections.
  33796. */
  33797. _afterRenderStage: Stage<SimpleStageAction>;
  33798. /**
  33799. * @hidden
  33800. * Defines the actions happening when a pointer move event happens.
  33801. */
  33802. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33803. /**
  33804. * @hidden
  33805. * Defines the actions happening when a pointer down event happens.
  33806. */
  33807. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33808. /**
  33809. * @hidden
  33810. * Defines the actions happening when a pointer up event happens.
  33811. */
  33812. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33813. /**
  33814. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33815. */
  33816. private geometriesByUniqueId;
  33817. /**
  33818. * Creates a new Scene
  33819. * @param engine defines the engine to use to render this scene
  33820. * @param options defines the scene options
  33821. */
  33822. constructor(engine: Engine, options?: SceneOptions);
  33823. /**
  33824. * Gets a string idenfifying the name of the class
  33825. * @returns "Scene" string
  33826. */
  33827. getClassName(): string;
  33828. private _defaultMeshCandidates;
  33829. /**
  33830. * @hidden
  33831. */
  33832. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33833. private _defaultSubMeshCandidates;
  33834. /**
  33835. * @hidden
  33836. */
  33837. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33838. /**
  33839. * Sets the default candidate providers for the scene.
  33840. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33841. * and getCollidingSubMeshCandidates to their default function
  33842. */
  33843. setDefaultCandidateProviders(): void;
  33844. /**
  33845. * Gets the mesh that is currently under the pointer
  33846. */
  33847. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33848. /**
  33849. * Gets or sets the current on-screen X position of the pointer
  33850. */
  33851. pointerX: number;
  33852. /**
  33853. * Gets or sets the current on-screen Y position of the pointer
  33854. */
  33855. pointerY: number;
  33856. /**
  33857. * Gets the cached material (ie. the latest rendered one)
  33858. * @returns the cached material
  33859. */
  33860. getCachedMaterial(): Nullable<Material>;
  33861. /**
  33862. * Gets the cached effect (ie. the latest rendered one)
  33863. * @returns the cached effect
  33864. */
  33865. getCachedEffect(): Nullable<Effect>;
  33866. /**
  33867. * Gets the cached visibility state (ie. the latest rendered one)
  33868. * @returns the cached visibility state
  33869. */
  33870. getCachedVisibility(): Nullable<number>;
  33871. /**
  33872. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33873. * @param material defines the current material
  33874. * @param effect defines the current effect
  33875. * @param visibility defines the current visibility state
  33876. * @returns true if one parameter is not cached
  33877. */
  33878. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33879. /**
  33880. * Gets the engine associated with the scene
  33881. * @returns an Engine
  33882. */
  33883. getEngine(): Engine;
  33884. /**
  33885. * Gets the total number of vertices rendered per frame
  33886. * @returns the total number of vertices rendered per frame
  33887. */
  33888. getTotalVertices(): number;
  33889. /**
  33890. * Gets the performance counter for total vertices
  33891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33892. */
  33893. readonly totalVerticesPerfCounter: PerfCounter;
  33894. /**
  33895. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33896. * @returns the total number of active indices rendered per frame
  33897. */
  33898. getActiveIndices(): number;
  33899. /**
  33900. * Gets the performance counter for active indices
  33901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33902. */
  33903. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33904. /**
  33905. * Gets the total number of active particles rendered per frame
  33906. * @returns the total number of active particles rendered per frame
  33907. */
  33908. getActiveParticles(): number;
  33909. /**
  33910. * Gets the performance counter for active particles
  33911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33912. */
  33913. readonly activeParticlesPerfCounter: PerfCounter;
  33914. /**
  33915. * Gets the total number of active bones rendered per frame
  33916. * @returns the total number of active bones rendered per frame
  33917. */
  33918. getActiveBones(): number;
  33919. /**
  33920. * Gets the performance counter for active bones
  33921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33922. */
  33923. readonly activeBonesPerfCounter: PerfCounter;
  33924. /**
  33925. * Gets the array of active meshes
  33926. * @returns an array of AbstractMesh
  33927. */
  33928. getActiveMeshes(): SmartArray<AbstractMesh>;
  33929. /**
  33930. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33931. * @returns a number
  33932. */
  33933. getAnimationRatio(): number;
  33934. /**
  33935. * Gets an unique Id for the current render phase
  33936. * @returns a number
  33937. */
  33938. getRenderId(): number;
  33939. /**
  33940. * Gets an unique Id for the current frame
  33941. * @returns a number
  33942. */
  33943. getFrameId(): number;
  33944. /** Call this function if you want to manually increment the render Id*/
  33945. incrementRenderId(): void;
  33946. private _createUbo;
  33947. /**
  33948. * Use this method to simulate a pointer move on a mesh
  33949. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33950. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33951. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33952. * @returns the current scene
  33953. */
  33954. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33955. /**
  33956. * Use this method to simulate a pointer down on a mesh
  33957. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33958. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33959. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33960. * @returns the current scene
  33961. */
  33962. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33963. /**
  33964. * Use this method to simulate a pointer up on a mesh
  33965. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33966. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33967. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33968. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33969. * @returns the current scene
  33970. */
  33971. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33972. /**
  33973. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33974. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33975. * @returns true if the pointer was captured
  33976. */
  33977. isPointerCaptured(pointerId?: number): boolean;
  33978. /**
  33979. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33980. * @param attachUp defines if you want to attach events to pointerup
  33981. * @param attachDown defines if you want to attach events to pointerdown
  33982. * @param attachMove defines if you want to attach events to pointermove
  33983. */
  33984. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33985. /** Detaches all event handlers*/
  33986. detachControl(): void;
  33987. /**
  33988. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33989. * Delay loaded resources are not taking in account
  33990. * @return true if all required resources are ready
  33991. */
  33992. isReady(): boolean;
  33993. /** Resets all cached information relative to material (including effect and visibility) */
  33994. resetCachedMaterial(): void;
  33995. /**
  33996. * Registers a function to be called before every frame render
  33997. * @param func defines the function to register
  33998. */
  33999. registerBeforeRender(func: () => void): void;
  34000. /**
  34001. * Unregisters a function called before every frame render
  34002. * @param func defines the function to unregister
  34003. */
  34004. unregisterBeforeRender(func: () => void): void;
  34005. /**
  34006. * Registers a function to be called after every frame render
  34007. * @param func defines the function to register
  34008. */
  34009. registerAfterRender(func: () => void): void;
  34010. /**
  34011. * Unregisters a function called after every frame render
  34012. * @param func defines the function to unregister
  34013. */
  34014. unregisterAfterRender(func: () => void): void;
  34015. private _executeOnceBeforeRender;
  34016. /**
  34017. * The provided function will run before render once and will be disposed afterwards.
  34018. * A timeout delay can be provided so that the function will be executed in N ms.
  34019. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34020. * @param func The function to be executed.
  34021. * @param timeout optional delay in ms
  34022. */
  34023. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34024. /** @hidden */
  34025. _addPendingData(data: any): void;
  34026. /** @hidden */
  34027. _removePendingData(data: any): void;
  34028. /**
  34029. * Returns the number of items waiting to be loaded
  34030. * @returns the number of items waiting to be loaded
  34031. */
  34032. getWaitingItemsCount(): number;
  34033. /**
  34034. * Returns a boolean indicating if the scene is still loading data
  34035. */
  34036. readonly isLoading: boolean;
  34037. /**
  34038. * Registers a function to be executed when the scene is ready
  34039. * @param {Function} func - the function to be executed
  34040. */
  34041. executeWhenReady(func: () => void): void;
  34042. /**
  34043. * Returns a promise that resolves when the scene is ready
  34044. * @returns A promise that resolves when the scene is ready
  34045. */
  34046. whenReadyAsync(): Promise<void>;
  34047. /** @hidden */
  34048. _checkIsReady(): void;
  34049. /**
  34050. * Gets all animatable attached to the scene
  34051. */
  34052. readonly animatables: Animatable[];
  34053. /**
  34054. * Resets the last animation time frame.
  34055. * Useful to override when animations start running when loading a scene for the first time.
  34056. */
  34057. resetLastAnimationTimeFrame(): void;
  34058. /**
  34059. * Gets the current view matrix
  34060. * @returns a Matrix
  34061. */
  34062. getViewMatrix(): Matrix;
  34063. /**
  34064. * Gets the current projection matrix
  34065. * @returns a Matrix
  34066. */
  34067. getProjectionMatrix(): Matrix;
  34068. /**
  34069. * Gets the current transform matrix
  34070. * @returns a Matrix made of View * Projection
  34071. */
  34072. getTransformMatrix(): Matrix;
  34073. /**
  34074. * Sets the current transform matrix
  34075. * @param viewL defines the View matrix to use
  34076. * @param projectionL defines the Projection matrix to use
  34077. * @param viewR defines the right View matrix to use (if provided)
  34078. * @param projectionR defines the right Projection matrix to use (if provided)
  34079. */
  34080. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34081. /**
  34082. * Gets the uniform buffer used to store scene data
  34083. * @returns a UniformBuffer
  34084. */
  34085. getSceneUniformBuffer(): UniformBuffer;
  34086. /**
  34087. * Gets an unique (relatively to the current scene) Id
  34088. * @returns an unique number for the scene
  34089. */
  34090. getUniqueId(): number;
  34091. /**
  34092. * Add a mesh to the list of scene's meshes
  34093. * @param newMesh defines the mesh to add
  34094. * @param recursive if all child meshes should also be added to the scene
  34095. */
  34096. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34097. /**
  34098. * Remove a mesh for the list of scene's meshes
  34099. * @param toRemove defines the mesh to remove
  34100. * @param recursive if all child meshes should also be removed from the scene
  34101. * @returns the index where the mesh was in the mesh list
  34102. */
  34103. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34104. /**
  34105. * Add a transform node to the list of scene's transform nodes
  34106. * @param newTransformNode defines the transform node to add
  34107. */
  34108. addTransformNode(newTransformNode: TransformNode): void;
  34109. /**
  34110. * Remove a transform node for the list of scene's transform nodes
  34111. * @param toRemove defines the transform node to remove
  34112. * @returns the index where the transform node was in the transform node list
  34113. */
  34114. removeTransformNode(toRemove: TransformNode): number;
  34115. /**
  34116. * Remove a skeleton for the list of scene's skeletons
  34117. * @param toRemove defines the skeleton to remove
  34118. * @returns the index where the skeleton was in the skeleton list
  34119. */
  34120. removeSkeleton(toRemove: Skeleton): number;
  34121. /**
  34122. * Remove a morph target for the list of scene's morph targets
  34123. * @param toRemove defines the morph target to remove
  34124. * @returns the index where the morph target was in the morph target list
  34125. */
  34126. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34127. /**
  34128. * Remove a light for the list of scene's lights
  34129. * @param toRemove defines the light to remove
  34130. * @returns the index where the light was in the light list
  34131. */
  34132. removeLight(toRemove: Light): number;
  34133. /**
  34134. * Remove a camera for the list of scene's cameras
  34135. * @param toRemove defines the camera to remove
  34136. * @returns the index where the camera was in the camera list
  34137. */
  34138. removeCamera(toRemove: Camera): number;
  34139. /**
  34140. * Remove a particle system for the list of scene's particle systems
  34141. * @param toRemove defines the particle system to remove
  34142. * @returns the index where the particle system was in the particle system list
  34143. */
  34144. removeParticleSystem(toRemove: IParticleSystem): number;
  34145. /**
  34146. * Remove a animation for the list of scene's animations
  34147. * @param toRemove defines the animation to remove
  34148. * @returns the index where the animation was in the animation list
  34149. */
  34150. removeAnimation(toRemove: Animation): number;
  34151. /**
  34152. * Will stop the animation of the given target
  34153. * @param target - the target
  34154. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34155. * @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)
  34156. */
  34157. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34158. /**
  34159. * Removes the given animation group from this scene.
  34160. * @param toRemove The animation group to remove
  34161. * @returns The index of the removed animation group
  34162. */
  34163. removeAnimationGroup(toRemove: AnimationGroup): number;
  34164. /**
  34165. * Removes the given multi-material from this scene.
  34166. * @param toRemove The multi-material to remove
  34167. * @returns The index of the removed multi-material
  34168. */
  34169. removeMultiMaterial(toRemove: MultiMaterial): number;
  34170. /**
  34171. * Removes the given material from this scene.
  34172. * @param toRemove The material to remove
  34173. * @returns The index of the removed material
  34174. */
  34175. removeMaterial(toRemove: Material): number;
  34176. /**
  34177. * Removes the given action manager from this scene.
  34178. * @param toRemove The action manager to remove
  34179. * @returns The index of the removed action manager
  34180. */
  34181. removeActionManager(toRemove: AbstractActionManager): number;
  34182. /**
  34183. * Removes the given texture from this scene.
  34184. * @param toRemove The texture to remove
  34185. * @returns The index of the removed texture
  34186. */
  34187. removeTexture(toRemove: BaseTexture): number;
  34188. /**
  34189. * Adds the given light to this scene
  34190. * @param newLight The light to add
  34191. */
  34192. addLight(newLight: Light): void;
  34193. /**
  34194. * Sorts the list list based on light priorities
  34195. */
  34196. sortLightsByPriority(): void;
  34197. /**
  34198. * Adds the given camera to this scene
  34199. * @param newCamera The camera to add
  34200. */
  34201. addCamera(newCamera: Camera): void;
  34202. /**
  34203. * Adds the given skeleton to this scene
  34204. * @param newSkeleton The skeleton to add
  34205. */
  34206. addSkeleton(newSkeleton: Skeleton): void;
  34207. /**
  34208. * Adds the given particle system to this scene
  34209. * @param newParticleSystem The particle system to add
  34210. */
  34211. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34212. /**
  34213. * Adds the given animation to this scene
  34214. * @param newAnimation The animation to add
  34215. */
  34216. addAnimation(newAnimation: Animation): void;
  34217. /**
  34218. * Adds the given animation group to this scene.
  34219. * @param newAnimationGroup The animation group to add
  34220. */
  34221. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34222. /**
  34223. * Adds the given multi-material to this scene
  34224. * @param newMultiMaterial The multi-material to add
  34225. */
  34226. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34227. /**
  34228. * Adds the given material to this scene
  34229. * @param newMaterial The material to add
  34230. */
  34231. addMaterial(newMaterial: Material): void;
  34232. /**
  34233. * Adds the given morph target to this scene
  34234. * @param newMorphTargetManager The morph target to add
  34235. */
  34236. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34237. /**
  34238. * Adds the given geometry to this scene
  34239. * @param newGeometry The geometry to add
  34240. */
  34241. addGeometry(newGeometry: Geometry): void;
  34242. /**
  34243. * Adds the given action manager to this scene
  34244. * @param newActionManager The action manager to add
  34245. */
  34246. addActionManager(newActionManager: AbstractActionManager): void;
  34247. /**
  34248. * Adds the given texture to this scene.
  34249. * @param newTexture The texture to add
  34250. */
  34251. addTexture(newTexture: BaseTexture): void;
  34252. /**
  34253. * Switch active camera
  34254. * @param newCamera defines the new active camera
  34255. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34256. */
  34257. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34258. /**
  34259. * sets the active camera of the scene using its ID
  34260. * @param id defines the camera's ID
  34261. * @return the new active camera or null if none found.
  34262. */
  34263. setActiveCameraByID(id: string): Nullable<Camera>;
  34264. /**
  34265. * sets the active camera of the scene using its name
  34266. * @param name defines the camera's name
  34267. * @returns the new active camera or null if none found.
  34268. */
  34269. setActiveCameraByName(name: string): Nullable<Camera>;
  34270. /**
  34271. * get an animation group using its name
  34272. * @param name defines the material's name
  34273. * @return the animation group or null if none found.
  34274. */
  34275. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34276. /**
  34277. * Get a material using its unique id
  34278. * @param uniqueId defines the material's unique id
  34279. * @return the material or null if none found.
  34280. */
  34281. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34282. /**
  34283. * get a material using its id
  34284. * @param id defines the material's ID
  34285. * @return the material or null if none found.
  34286. */
  34287. getMaterialByID(id: string): Nullable<Material>;
  34288. /**
  34289. * Gets a the last added material using a given id
  34290. * @param id defines the material's ID
  34291. * @return the last material with the given id or null if none found.
  34292. */
  34293. getLastMaterialByID(id: string): Nullable<Material>;
  34294. /**
  34295. * Gets a material using its name
  34296. * @param name defines the material's name
  34297. * @return the material or null if none found.
  34298. */
  34299. getMaterialByName(name: string): Nullable<Material>;
  34300. /**
  34301. * Get a texture using its unique id
  34302. * @param uniqueId defines the texture's unique id
  34303. * @return the texture or null if none found.
  34304. */
  34305. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34306. /**
  34307. * Gets a camera using its id
  34308. * @param id defines the id to look for
  34309. * @returns the camera or null if not found
  34310. */
  34311. getCameraByID(id: string): Nullable<Camera>;
  34312. /**
  34313. * Gets a camera using its unique id
  34314. * @param uniqueId defines the unique id to look for
  34315. * @returns the camera or null if not found
  34316. */
  34317. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34318. /**
  34319. * Gets a camera using its name
  34320. * @param name defines the camera's name
  34321. * @return the camera or null if none found.
  34322. */
  34323. getCameraByName(name: string): Nullable<Camera>;
  34324. /**
  34325. * Gets a bone using its id
  34326. * @param id defines the bone's id
  34327. * @return the bone or null if not found
  34328. */
  34329. getBoneByID(id: string): Nullable<Bone>;
  34330. /**
  34331. * Gets a bone using its id
  34332. * @param name defines the bone's name
  34333. * @return the bone or null if not found
  34334. */
  34335. getBoneByName(name: string): Nullable<Bone>;
  34336. /**
  34337. * Gets a light node using its name
  34338. * @param name defines the the light's name
  34339. * @return the light or null if none found.
  34340. */
  34341. getLightByName(name: string): Nullable<Light>;
  34342. /**
  34343. * Gets a light node using its id
  34344. * @param id defines the light's id
  34345. * @return the light or null if none found.
  34346. */
  34347. getLightByID(id: string): Nullable<Light>;
  34348. /**
  34349. * Gets a light node using its scene-generated unique ID
  34350. * @param uniqueId defines the light's unique id
  34351. * @return the light or null if none found.
  34352. */
  34353. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34354. /**
  34355. * Gets a particle system by id
  34356. * @param id defines the particle system id
  34357. * @return the corresponding system or null if none found
  34358. */
  34359. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34360. /**
  34361. * Gets a geometry using its ID
  34362. * @param id defines the geometry's id
  34363. * @return the geometry or null if none found.
  34364. */
  34365. getGeometryByID(id: string): Nullable<Geometry>;
  34366. private _getGeometryByUniqueID;
  34367. /**
  34368. * Add a new geometry to this scene
  34369. * @param geometry defines the geometry to be added to the scene.
  34370. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34371. * @return a boolean defining if the geometry was added or not
  34372. */
  34373. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34374. /**
  34375. * Removes an existing geometry
  34376. * @param geometry defines the geometry to be removed from the scene
  34377. * @return a boolean defining if the geometry was removed or not
  34378. */
  34379. removeGeometry(geometry: Geometry): boolean;
  34380. /**
  34381. * Gets the list of geometries attached to the scene
  34382. * @returns an array of Geometry
  34383. */
  34384. getGeometries(): Geometry[];
  34385. /**
  34386. * Gets the first added mesh found of a given ID
  34387. * @param id defines the id to search for
  34388. * @return the mesh found or null if not found at all
  34389. */
  34390. getMeshByID(id: string): Nullable<AbstractMesh>;
  34391. /**
  34392. * Gets a list of meshes using their id
  34393. * @param id defines the id to search for
  34394. * @returns a list of meshes
  34395. */
  34396. getMeshesByID(id: string): Array<AbstractMesh>;
  34397. /**
  34398. * Gets the first added transform node found of a given ID
  34399. * @param id defines the id to search for
  34400. * @return the found transform node or null if not found at all.
  34401. */
  34402. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34403. /**
  34404. * Gets a transform node with its auto-generated unique id
  34405. * @param uniqueId efines the unique id to search for
  34406. * @return the found transform node or null if not found at all.
  34407. */
  34408. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34409. /**
  34410. * Gets a list of transform nodes using their id
  34411. * @param id defines the id to search for
  34412. * @returns a list of transform nodes
  34413. */
  34414. getTransformNodesByID(id: string): Array<TransformNode>;
  34415. /**
  34416. * Gets a mesh with its auto-generated unique id
  34417. * @param uniqueId defines the unique id to search for
  34418. * @return the found mesh or null if not found at all.
  34419. */
  34420. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34421. /**
  34422. * Gets a the last added mesh using a given id
  34423. * @param id defines the id to search for
  34424. * @return the found mesh or null if not found at all.
  34425. */
  34426. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34427. /**
  34428. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34429. * @param id defines the id to search for
  34430. * @return the found node or null if not found at all
  34431. */
  34432. getLastEntryByID(id: string): Nullable<Node>;
  34433. /**
  34434. * Gets a node (Mesh, Camera, Light) using a given id
  34435. * @param id defines the id to search for
  34436. * @return the found node or null if not found at all
  34437. */
  34438. getNodeByID(id: string): Nullable<Node>;
  34439. /**
  34440. * Gets a node (Mesh, Camera, Light) using a given name
  34441. * @param name defines the name to search for
  34442. * @return the found node or null if not found at all.
  34443. */
  34444. getNodeByName(name: string): Nullable<Node>;
  34445. /**
  34446. * Gets a mesh using a given name
  34447. * @param name defines the name to search for
  34448. * @return the found mesh or null if not found at all.
  34449. */
  34450. getMeshByName(name: string): Nullable<AbstractMesh>;
  34451. /**
  34452. * Gets a transform node using a given name
  34453. * @param name defines the name to search for
  34454. * @return the found transform node or null if not found at all.
  34455. */
  34456. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34457. /**
  34458. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34459. * @param id defines the id to search for
  34460. * @return the found skeleton or null if not found at all.
  34461. */
  34462. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34463. /**
  34464. * Gets a skeleton using a given auto generated unique id
  34465. * @param uniqueId defines the unique id to search for
  34466. * @return the found skeleton or null if not found at all.
  34467. */
  34468. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34469. /**
  34470. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34471. * @param id defines the id to search for
  34472. * @return the found skeleton or null if not found at all.
  34473. */
  34474. getSkeletonById(id: string): Nullable<Skeleton>;
  34475. /**
  34476. * Gets a skeleton using a given name
  34477. * @param name defines the name to search for
  34478. * @return the found skeleton or null if not found at all.
  34479. */
  34480. getSkeletonByName(name: string): Nullable<Skeleton>;
  34481. /**
  34482. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34483. * @param id defines the id to search for
  34484. * @return the found morph target manager or null if not found at all.
  34485. */
  34486. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34487. /**
  34488. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34489. * @param id defines the id to search for
  34490. * @return the found morph target or null if not found at all.
  34491. */
  34492. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34493. /**
  34494. * Gets a boolean indicating if the given mesh is active
  34495. * @param mesh defines the mesh to look for
  34496. * @returns true if the mesh is in the active list
  34497. */
  34498. isActiveMesh(mesh: AbstractMesh): boolean;
  34499. /**
  34500. * Return a unique id as a string which can serve as an identifier for the scene
  34501. */
  34502. readonly uid: string;
  34503. /**
  34504. * Add an externaly attached data from its key.
  34505. * This method call will fail and return false, if such key already exists.
  34506. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34507. * @param key the unique key that identifies the data
  34508. * @param data the data object to associate to the key for this Engine instance
  34509. * @return true if no such key were already present and the data was added successfully, false otherwise
  34510. */
  34511. addExternalData<T>(key: string, data: T): boolean;
  34512. /**
  34513. * Get an externaly attached data from its key
  34514. * @param key the unique key that identifies the data
  34515. * @return the associated data, if present (can be null), or undefined if not present
  34516. */
  34517. getExternalData<T>(key: string): Nullable<T>;
  34518. /**
  34519. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34520. * @param key the unique key that identifies the data
  34521. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34522. * @return the associated data, can be null if the factory returned null.
  34523. */
  34524. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34525. /**
  34526. * Remove an externaly attached data from the Engine instance
  34527. * @param key the unique key that identifies the data
  34528. * @return true if the data was successfully removed, false if it doesn't exist
  34529. */
  34530. removeExternalData(key: string): boolean;
  34531. private _evaluateSubMesh;
  34532. /**
  34533. * Clear the processed materials smart array preventing retention point in material dispose.
  34534. */
  34535. freeProcessedMaterials(): void;
  34536. private _preventFreeActiveMeshesAndRenderingGroups;
  34537. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34538. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34539. * when disposing several meshes in a row or a hierarchy of meshes.
  34540. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34541. */
  34542. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34543. /**
  34544. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34545. */
  34546. freeActiveMeshes(): void;
  34547. /**
  34548. * Clear the info related to rendering groups preventing retention points during dispose.
  34549. */
  34550. freeRenderingGroups(): void;
  34551. /** @hidden */
  34552. _isInIntermediateRendering(): boolean;
  34553. /**
  34554. * Lambda returning the list of potentially active meshes.
  34555. */
  34556. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34557. /**
  34558. * Lambda returning the list of potentially active sub meshes.
  34559. */
  34560. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34561. /**
  34562. * Lambda returning the list of potentially intersecting sub meshes.
  34563. */
  34564. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34565. /**
  34566. * Lambda returning the list of potentially colliding sub meshes.
  34567. */
  34568. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34569. private _activeMeshesFrozen;
  34570. /**
  34571. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34572. * @returns the current scene
  34573. */
  34574. freezeActiveMeshes(): Scene;
  34575. /**
  34576. * Use this function to restart evaluating active meshes on every frame
  34577. * @returns the current scene
  34578. */
  34579. unfreezeActiveMeshes(): Scene;
  34580. private _evaluateActiveMeshes;
  34581. private _activeMesh;
  34582. /**
  34583. * Update the transform matrix to update from the current active camera
  34584. * @param force defines a boolean used to force the update even if cache is up to date
  34585. */
  34586. updateTransformMatrix(force?: boolean): void;
  34587. private _bindFrameBuffer;
  34588. /** @hidden */
  34589. _allowPostProcessClearColor: boolean;
  34590. /** @hidden */
  34591. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34592. private _processSubCameras;
  34593. private _checkIntersections;
  34594. /** @hidden */
  34595. _advancePhysicsEngineStep(step: number): void;
  34596. /**
  34597. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34598. */
  34599. getDeterministicFrameTime: () => number;
  34600. /** @hidden */
  34601. _animate(): void;
  34602. /** Execute all animations (for a frame) */
  34603. animate(): void;
  34604. /**
  34605. * Render the scene
  34606. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34607. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34608. */
  34609. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34610. /**
  34611. * Freeze all materials
  34612. * A frozen material will not be updatable but should be faster to render
  34613. */
  34614. freezeMaterials(): void;
  34615. /**
  34616. * Unfreeze all materials
  34617. * A frozen material will not be updatable but should be faster to render
  34618. */
  34619. unfreezeMaterials(): void;
  34620. /**
  34621. * Releases all held ressources
  34622. */
  34623. dispose(): void;
  34624. /**
  34625. * Gets if the scene is already disposed
  34626. */
  34627. readonly isDisposed: boolean;
  34628. /**
  34629. * Call this function to reduce memory footprint of the scene.
  34630. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34631. */
  34632. clearCachedVertexData(): void;
  34633. /**
  34634. * This function will remove the local cached buffer data from texture.
  34635. * It will save memory but will prevent the texture from being rebuilt
  34636. */
  34637. cleanCachedTextureBuffer(): void;
  34638. /**
  34639. * Get the world extend vectors with an optional filter
  34640. *
  34641. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34642. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34643. */
  34644. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34645. min: Vector3;
  34646. max: Vector3;
  34647. };
  34648. /**
  34649. * Creates a ray that can be used to pick in the scene
  34650. * @param x defines the x coordinate of the origin (on-screen)
  34651. * @param y defines the y coordinate of the origin (on-screen)
  34652. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34653. * @param camera defines the camera to use for the picking
  34654. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34655. * @returns a Ray
  34656. */
  34657. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34658. /**
  34659. * Creates a ray that can be used to pick in the scene
  34660. * @param x defines the x coordinate of the origin (on-screen)
  34661. * @param y defines the y coordinate of the origin (on-screen)
  34662. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34663. * @param result defines the ray where to store the picking ray
  34664. * @param camera defines the camera to use for the picking
  34665. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34666. * @returns the current scene
  34667. */
  34668. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34669. /**
  34670. * Creates a ray that can be used to pick in the scene
  34671. * @param x defines the x coordinate of the origin (on-screen)
  34672. * @param y defines the y coordinate of the origin (on-screen)
  34673. * @param camera defines the camera to use for the picking
  34674. * @returns a Ray
  34675. */
  34676. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34677. /**
  34678. * Creates a ray that can be used to pick in the scene
  34679. * @param x defines the x coordinate of the origin (on-screen)
  34680. * @param y defines the y coordinate of the origin (on-screen)
  34681. * @param result defines the ray where to store the picking ray
  34682. * @param camera defines the camera to use for the picking
  34683. * @returns the current scene
  34684. */
  34685. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34686. /** Launch a ray to try to pick a mesh in the scene
  34687. * @param x position on screen
  34688. * @param y position on screen
  34689. * @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
  34690. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34691. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34692. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34693. * @returns a PickingInfo
  34694. */
  34695. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34696. /** Use the given ray to pick a mesh in the scene
  34697. * @param ray The ray to use to pick meshes
  34698. * @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
  34699. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34700. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34701. * @returns a PickingInfo
  34702. */
  34703. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34704. /**
  34705. * Launch a ray to try to pick a mesh in the scene
  34706. * @param x X position on screen
  34707. * @param y Y position on screen
  34708. * @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
  34709. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34711. * @returns an array of PickingInfo
  34712. */
  34713. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34714. /**
  34715. * Launch a ray to try to pick a mesh in the scene
  34716. * @param ray Ray to use
  34717. * @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
  34718. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34719. * @returns an array of PickingInfo
  34720. */
  34721. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34722. /**
  34723. * Force the value of meshUnderPointer
  34724. * @param mesh defines the mesh to use
  34725. */
  34726. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34727. /**
  34728. * Gets the mesh under the pointer
  34729. * @returns a Mesh or null if no mesh is under the pointer
  34730. */
  34731. getPointerOverMesh(): Nullable<AbstractMesh>;
  34732. /** @hidden */
  34733. _rebuildGeometries(): void;
  34734. /** @hidden */
  34735. _rebuildTextures(): void;
  34736. private _getByTags;
  34737. /**
  34738. * Get a list of meshes by tags
  34739. * @param tagsQuery defines the tags query to use
  34740. * @param forEach defines a predicate used to filter results
  34741. * @returns an array of Mesh
  34742. */
  34743. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34744. /**
  34745. * Get a list of cameras by tags
  34746. * @param tagsQuery defines the tags query to use
  34747. * @param forEach defines a predicate used to filter results
  34748. * @returns an array of Camera
  34749. */
  34750. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34751. /**
  34752. * Get a list of lights by tags
  34753. * @param tagsQuery defines the tags query to use
  34754. * @param forEach defines a predicate used to filter results
  34755. * @returns an array of Light
  34756. */
  34757. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34758. /**
  34759. * Get a list of materials by tags
  34760. * @param tagsQuery defines the tags query to use
  34761. * @param forEach defines a predicate used to filter results
  34762. * @returns an array of Material
  34763. */
  34764. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34765. /**
  34766. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34767. * This allowed control for front to back rendering or reversly depending of the special needs.
  34768. *
  34769. * @param renderingGroupId The rendering group id corresponding to its index
  34770. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34771. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34772. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34773. */
  34774. 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;
  34775. /**
  34776. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34777. *
  34778. * @param renderingGroupId The rendering group id corresponding to its index
  34779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34780. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34781. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34782. */
  34783. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34784. /**
  34785. * Gets the current auto clear configuration for one rendering group of the rendering
  34786. * manager.
  34787. * @param index the rendering group index to get the information for
  34788. * @returns The auto clear setup for the requested rendering group
  34789. */
  34790. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34791. private _blockMaterialDirtyMechanism;
  34792. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34793. blockMaterialDirtyMechanism: boolean;
  34794. /**
  34795. * Will flag all materials as dirty to trigger new shader compilation
  34796. * @param flag defines the flag used to specify which material part must be marked as dirty
  34797. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34798. */
  34799. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34800. /** @hidden */
  34801. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34802. /** @hidden */
  34803. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. /**
  34808. * Set of assets to keep when moving a scene into an asset container.
  34809. */
  34810. export class KeepAssets extends AbstractScene {
  34811. }
  34812. /**
  34813. * Container with a set of assets that can be added or removed from a scene.
  34814. */
  34815. export class AssetContainer extends AbstractScene {
  34816. /**
  34817. * The scene the AssetContainer belongs to.
  34818. */
  34819. scene: Scene;
  34820. /**
  34821. * Instantiates an AssetContainer.
  34822. * @param scene The scene the AssetContainer belongs to.
  34823. */
  34824. constructor(scene: Scene);
  34825. /**
  34826. * Adds all the assets from the container to the scene.
  34827. */
  34828. addAllToScene(): void;
  34829. /**
  34830. * Removes all the assets in the container from the scene
  34831. */
  34832. removeAllFromScene(): void;
  34833. /**
  34834. * Disposes all the assets in the container
  34835. */
  34836. dispose(): void;
  34837. private _moveAssets;
  34838. /**
  34839. * Removes all the assets contained in the scene and adds them to the container.
  34840. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34841. */
  34842. moveAllFromScene(keepAssets?: KeepAssets): void;
  34843. /**
  34844. * 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.
  34845. * @returns the root mesh
  34846. */
  34847. createRootMesh(): Mesh;
  34848. }
  34849. }
  34850. declare module BABYLON {
  34851. /**
  34852. * Defines how the parser contract is defined.
  34853. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34854. */
  34855. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34856. /**
  34857. * Defines how the individual parser contract is defined.
  34858. * These parser can parse an individual asset
  34859. */
  34860. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34861. /**
  34862. * Base class of the scene acting as a container for the different elements composing a scene.
  34863. * This class is dynamically extended by the different components of the scene increasing
  34864. * flexibility and reducing coupling
  34865. */
  34866. export abstract class AbstractScene {
  34867. /**
  34868. * Stores the list of available parsers in the application.
  34869. */
  34870. private static _BabylonFileParsers;
  34871. /**
  34872. * Stores the list of available individual parsers in the application.
  34873. */
  34874. private static _IndividualBabylonFileParsers;
  34875. /**
  34876. * Adds a parser in the list of available ones
  34877. * @param name Defines the name of the parser
  34878. * @param parser Defines the parser to add
  34879. */
  34880. static AddParser(name: string, parser: BabylonFileParser): void;
  34881. /**
  34882. * Gets a general parser from the list of avaialble ones
  34883. * @param name Defines the name of the parser
  34884. * @returns the requested parser or null
  34885. */
  34886. static GetParser(name: string): Nullable<BabylonFileParser>;
  34887. /**
  34888. * Adds n individual parser in the list of available ones
  34889. * @param name Defines the name of the parser
  34890. * @param parser Defines the parser to add
  34891. */
  34892. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34893. /**
  34894. * Gets an individual parser from the list of avaialble ones
  34895. * @param name Defines the name of the parser
  34896. * @returns the requested parser or null
  34897. */
  34898. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34899. /**
  34900. * Parser json data and populate both a scene and its associated container object
  34901. * @param jsonData Defines the data to parse
  34902. * @param scene Defines the scene to parse the data for
  34903. * @param container Defines the container attached to the parsing sequence
  34904. * @param rootUrl Defines the root url of the data
  34905. */
  34906. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34907. /**
  34908. * Gets the list of root nodes (ie. nodes with no parent)
  34909. */
  34910. rootNodes: Node[];
  34911. /** All of the cameras added to this scene
  34912. * @see http://doc.babylonjs.com/babylon101/cameras
  34913. */
  34914. cameras: Camera[];
  34915. /**
  34916. * All of the lights added to this scene
  34917. * @see http://doc.babylonjs.com/babylon101/lights
  34918. */
  34919. lights: Light[];
  34920. /**
  34921. * All of the (abstract) meshes added to this scene
  34922. */
  34923. meshes: AbstractMesh[];
  34924. /**
  34925. * The list of skeletons added to the scene
  34926. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34927. */
  34928. skeletons: Skeleton[];
  34929. /**
  34930. * All of the particle systems added to this scene
  34931. * @see http://doc.babylonjs.com/babylon101/particles
  34932. */
  34933. particleSystems: IParticleSystem[];
  34934. /**
  34935. * Gets a list of Animations associated with the scene
  34936. */
  34937. animations: Animation[];
  34938. /**
  34939. * All of the animation groups added to this scene
  34940. * @see http://doc.babylonjs.com/how_to/group
  34941. */
  34942. animationGroups: AnimationGroup[];
  34943. /**
  34944. * All of the multi-materials added to this scene
  34945. * @see http://doc.babylonjs.com/how_to/multi_materials
  34946. */
  34947. multiMaterials: MultiMaterial[];
  34948. /**
  34949. * All of the materials added to this scene
  34950. * In the context of a Scene, it is not supposed to be modified manually.
  34951. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34952. * Note also that the order of the Material wihin the array is not significant and might change.
  34953. * @see http://doc.babylonjs.com/babylon101/materials
  34954. */
  34955. materials: Material[];
  34956. /**
  34957. * The list of morph target managers added to the scene
  34958. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34959. */
  34960. morphTargetManagers: MorphTargetManager[];
  34961. /**
  34962. * The list of geometries used in the scene.
  34963. */
  34964. geometries: Geometry[];
  34965. /**
  34966. * All of the tranform nodes added to this scene
  34967. * In the context of a Scene, it is not supposed to be modified manually.
  34968. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34969. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34970. * @see http://doc.babylonjs.com/how_to/transformnode
  34971. */
  34972. transformNodes: TransformNode[];
  34973. /**
  34974. * ActionManagers available on the scene.
  34975. */
  34976. actionManagers: AbstractActionManager[];
  34977. /**
  34978. * Textures to keep.
  34979. */
  34980. textures: BaseTexture[];
  34981. /**
  34982. * Environment texture for the scene
  34983. */
  34984. environmentTexture: Nullable<BaseTexture>;
  34985. }
  34986. }
  34987. declare module BABYLON {
  34988. /**
  34989. * Interface used to define options for Sound class
  34990. */
  34991. export interface ISoundOptions {
  34992. /**
  34993. * Does the sound autoplay once loaded.
  34994. */
  34995. autoplay?: boolean;
  34996. /**
  34997. * Does the sound loop after it finishes playing once.
  34998. */
  34999. loop?: boolean;
  35000. /**
  35001. * Sound's volume
  35002. */
  35003. volume?: number;
  35004. /**
  35005. * Is it a spatial sound?
  35006. */
  35007. spatialSound?: boolean;
  35008. /**
  35009. * Maximum distance to hear that sound
  35010. */
  35011. maxDistance?: number;
  35012. /**
  35013. * Uses user defined attenuation function
  35014. */
  35015. useCustomAttenuation?: boolean;
  35016. /**
  35017. * Define the roll off factor of spatial sounds.
  35018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35019. */
  35020. rolloffFactor?: number;
  35021. /**
  35022. * Define the reference distance the sound should be heard perfectly.
  35023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35024. */
  35025. refDistance?: number;
  35026. /**
  35027. * Define the distance attenuation model the sound will follow.
  35028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35029. */
  35030. distanceModel?: string;
  35031. /**
  35032. * Defines the playback speed (1 by default)
  35033. */
  35034. playbackRate?: number;
  35035. /**
  35036. * Defines if the sound is from a streaming source
  35037. */
  35038. streaming?: boolean;
  35039. /**
  35040. * Defines an optional length (in seconds) inside the sound file
  35041. */
  35042. length?: number;
  35043. /**
  35044. * Defines an optional offset (in seconds) inside the sound file
  35045. */
  35046. offset?: number;
  35047. /**
  35048. * If true, URLs will not be required to state the audio file codec to use.
  35049. */
  35050. skipCodecCheck?: boolean;
  35051. }
  35052. /**
  35053. * Defines a sound that can be played in the application.
  35054. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35056. */
  35057. export class Sound {
  35058. /**
  35059. * The name of the sound in the scene.
  35060. */
  35061. name: string;
  35062. /**
  35063. * Does the sound autoplay once loaded.
  35064. */
  35065. autoplay: boolean;
  35066. /**
  35067. * Does the sound loop after it finishes playing once.
  35068. */
  35069. loop: boolean;
  35070. /**
  35071. * Does the sound use a custom attenuation curve to simulate the falloff
  35072. * happening when the source gets further away from the camera.
  35073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35074. */
  35075. useCustomAttenuation: boolean;
  35076. /**
  35077. * The sound track id this sound belongs to.
  35078. */
  35079. soundTrackId: number;
  35080. /**
  35081. * Is this sound currently played.
  35082. */
  35083. isPlaying: boolean;
  35084. /**
  35085. * Is this sound currently paused.
  35086. */
  35087. isPaused: boolean;
  35088. /**
  35089. * Does this sound enables spatial sound.
  35090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35091. */
  35092. spatialSound: boolean;
  35093. /**
  35094. * Define the reference distance the sound should be heard perfectly.
  35095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35096. */
  35097. refDistance: number;
  35098. /**
  35099. * Define the roll off factor of spatial sounds.
  35100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35101. */
  35102. rolloffFactor: number;
  35103. /**
  35104. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35106. */
  35107. maxDistance: number;
  35108. /**
  35109. * Define the distance attenuation model the sound will follow.
  35110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35111. */
  35112. distanceModel: string;
  35113. /**
  35114. * @hidden
  35115. * Back Compat
  35116. **/
  35117. onended: () => any;
  35118. /**
  35119. * Observable event when the current playing sound finishes.
  35120. */
  35121. onEndedObservable: Observable<Sound>;
  35122. private _panningModel;
  35123. private _playbackRate;
  35124. private _streaming;
  35125. private _startTime;
  35126. private _startOffset;
  35127. private _position;
  35128. /** @hidden */
  35129. _positionInEmitterSpace: boolean;
  35130. private _localDirection;
  35131. private _volume;
  35132. private _isReadyToPlay;
  35133. private _isDirectional;
  35134. private _readyToPlayCallback;
  35135. private _audioBuffer;
  35136. private _soundSource;
  35137. private _streamingSource;
  35138. private _soundPanner;
  35139. private _soundGain;
  35140. private _inputAudioNode;
  35141. private _outputAudioNode;
  35142. private _coneInnerAngle;
  35143. private _coneOuterAngle;
  35144. private _coneOuterGain;
  35145. private _scene;
  35146. private _connectedTransformNode;
  35147. private _customAttenuationFunction;
  35148. private _registerFunc;
  35149. private _isOutputConnected;
  35150. private _htmlAudioElement;
  35151. private _urlType;
  35152. private _length?;
  35153. private _offset?;
  35154. /** @hidden */
  35155. static _SceneComponentInitialization: (scene: Scene) => void;
  35156. /**
  35157. * Create a sound and attach it to a scene
  35158. * @param name Name of your sound
  35159. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35160. * @param scene defines the scene the sound belongs to
  35161. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35162. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35163. */
  35164. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35165. /**
  35166. * Release the sound and its associated resources
  35167. */
  35168. dispose(): void;
  35169. /**
  35170. * Gets if the sounds is ready to be played or not.
  35171. * @returns true if ready, otherwise false
  35172. */
  35173. isReady(): boolean;
  35174. private _soundLoaded;
  35175. /**
  35176. * Sets the data of the sound from an audiobuffer
  35177. * @param audioBuffer The audioBuffer containing the data
  35178. */
  35179. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35180. /**
  35181. * Updates the current sounds options such as maxdistance, loop...
  35182. * @param options A JSON object containing values named as the object properties
  35183. */
  35184. updateOptions(options: ISoundOptions): void;
  35185. private _createSpatialParameters;
  35186. private _updateSpatialParameters;
  35187. /**
  35188. * Switch the panning model to HRTF:
  35189. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35191. */
  35192. switchPanningModelToHRTF(): void;
  35193. /**
  35194. * Switch the panning model to Equal Power:
  35195. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35197. */
  35198. switchPanningModelToEqualPower(): void;
  35199. private _switchPanningModel;
  35200. /**
  35201. * Connect this sound to a sound track audio node like gain...
  35202. * @param soundTrackAudioNode the sound track audio node to connect to
  35203. */
  35204. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35205. /**
  35206. * Transform this sound into a directional source
  35207. * @param coneInnerAngle Size of the inner cone in degree
  35208. * @param coneOuterAngle Size of the outer cone in degree
  35209. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35210. */
  35211. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35212. /**
  35213. * Gets or sets the inner angle for the directional cone.
  35214. */
  35215. /**
  35216. * Gets or sets the inner angle for the directional cone.
  35217. */
  35218. directionalConeInnerAngle: number;
  35219. /**
  35220. * Gets or sets the outer angle for the directional cone.
  35221. */
  35222. /**
  35223. * Gets or sets the outer angle for the directional cone.
  35224. */
  35225. directionalConeOuterAngle: number;
  35226. /**
  35227. * Sets the position of the emitter if spatial sound is enabled
  35228. * @param newPosition Defines the new posisiton
  35229. */
  35230. setPosition(newPosition: Vector3): void;
  35231. /**
  35232. * Sets the local direction of the emitter if spatial sound is enabled
  35233. * @param newLocalDirection Defines the new local direction
  35234. */
  35235. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35236. private _updateDirection;
  35237. /** @hidden */
  35238. updateDistanceFromListener(): void;
  35239. /**
  35240. * Sets a new custom attenuation function for the sound.
  35241. * @param callback Defines the function used for the attenuation
  35242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35243. */
  35244. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35245. /**
  35246. * Play the sound
  35247. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35248. * @param offset (optional) Start the sound at a specific time in seconds
  35249. * @param length (optional) Sound duration (in seconds)
  35250. */
  35251. play(time?: number, offset?: number, length?: number): void;
  35252. private _onended;
  35253. /**
  35254. * Stop the sound
  35255. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35256. */
  35257. stop(time?: number): void;
  35258. /**
  35259. * Put the sound in pause
  35260. */
  35261. pause(): void;
  35262. /**
  35263. * Sets a dedicated volume for this sounds
  35264. * @param newVolume Define the new volume of the sound
  35265. * @param time Define time for gradual change to new volume
  35266. */
  35267. setVolume(newVolume: number, time?: number): void;
  35268. /**
  35269. * Set the sound play back rate
  35270. * @param newPlaybackRate Define the playback rate the sound should be played at
  35271. */
  35272. setPlaybackRate(newPlaybackRate: number): void;
  35273. /**
  35274. * Gets the volume of the sound.
  35275. * @returns the volume of the sound
  35276. */
  35277. getVolume(): number;
  35278. /**
  35279. * Attach the sound to a dedicated mesh
  35280. * @param transformNode The transform node to connect the sound with
  35281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35282. */
  35283. attachToMesh(transformNode: TransformNode): void;
  35284. /**
  35285. * Detach the sound from the previously attached mesh
  35286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35287. */
  35288. detachFromMesh(): void;
  35289. private _onRegisterAfterWorldMatrixUpdate;
  35290. /**
  35291. * Clone the current sound in the scene.
  35292. * @returns the new sound clone
  35293. */
  35294. clone(): Nullable<Sound>;
  35295. /**
  35296. * Gets the current underlying audio buffer containing the data
  35297. * @returns the audio buffer
  35298. */
  35299. getAudioBuffer(): Nullable<AudioBuffer>;
  35300. /**
  35301. * Serializes the Sound in a JSON representation
  35302. * @returns the JSON representation of the sound
  35303. */
  35304. serialize(): any;
  35305. /**
  35306. * Parse a JSON representation of a sound to innstantiate in a given scene
  35307. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35308. * @param scene Define the scene the new parsed sound should be created in
  35309. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35310. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35311. * @returns the newly parsed sound
  35312. */
  35313. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35314. }
  35315. }
  35316. declare module BABYLON {
  35317. /**
  35318. * This defines an action helpful to play a defined sound on a triggered action.
  35319. */
  35320. export class PlaySoundAction extends Action {
  35321. private _sound;
  35322. /**
  35323. * Instantiate the action
  35324. * @param triggerOptions defines the trigger options
  35325. * @param sound defines the sound to play
  35326. * @param condition defines the trigger related conditions
  35327. */
  35328. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35329. /** @hidden */
  35330. _prepare(): void;
  35331. /**
  35332. * Execute the action and play the sound.
  35333. */
  35334. execute(): void;
  35335. /**
  35336. * Serializes the actions and its related information.
  35337. * @param parent defines the object to serialize in
  35338. * @returns the serialized object
  35339. */
  35340. serialize(parent: any): any;
  35341. }
  35342. /**
  35343. * This defines an action helpful to stop a defined sound on a triggered action.
  35344. */
  35345. export class StopSoundAction extends Action {
  35346. private _sound;
  35347. /**
  35348. * Instantiate the action
  35349. * @param triggerOptions defines the trigger options
  35350. * @param sound defines the sound to stop
  35351. * @param condition defines the trigger related conditions
  35352. */
  35353. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35354. /** @hidden */
  35355. _prepare(): void;
  35356. /**
  35357. * Execute the action and stop the sound.
  35358. */
  35359. execute(): void;
  35360. /**
  35361. * Serializes the actions and its related information.
  35362. * @param parent defines the object to serialize in
  35363. * @returns the serialized object
  35364. */
  35365. serialize(parent: any): any;
  35366. }
  35367. }
  35368. declare module BABYLON {
  35369. /**
  35370. * This defines an action responsible to change the value of a property
  35371. * by interpolating between its current value and the newly set one once triggered.
  35372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35373. */
  35374. export class InterpolateValueAction extends Action {
  35375. /**
  35376. * Defines the path of the property where the value should be interpolated
  35377. */
  35378. propertyPath: string;
  35379. /**
  35380. * Defines the target value at the end of the interpolation.
  35381. */
  35382. value: any;
  35383. /**
  35384. * Defines the time it will take for the property to interpolate to the value.
  35385. */
  35386. duration: number;
  35387. /**
  35388. * Defines if the other scene animations should be stopped when the action has been triggered
  35389. */
  35390. stopOtherAnimations?: boolean;
  35391. /**
  35392. * Defines a callback raised once the interpolation animation has been done.
  35393. */
  35394. onInterpolationDone?: () => void;
  35395. /**
  35396. * Observable triggered once the interpolation animation has been done.
  35397. */
  35398. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35399. private _target;
  35400. private _effectiveTarget;
  35401. private _property;
  35402. /**
  35403. * Instantiate the action
  35404. * @param triggerOptions defines the trigger options
  35405. * @param target defines the object containing the value to interpolate
  35406. * @param propertyPath defines the path to the property in the target object
  35407. * @param value defines the target value at the end of the interpolation
  35408. * @param duration deines the time it will take for the property to interpolate to the value.
  35409. * @param condition defines the trigger related conditions
  35410. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35411. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35412. */
  35413. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35414. /** @hidden */
  35415. _prepare(): void;
  35416. /**
  35417. * Execute the action starts the value interpolation.
  35418. */
  35419. execute(): void;
  35420. /**
  35421. * Serializes the actions and its related information.
  35422. * @param parent defines the object to serialize in
  35423. * @returns the serialized object
  35424. */
  35425. serialize(parent: any): any;
  35426. }
  35427. }
  35428. declare module BABYLON {
  35429. /**
  35430. * Options allowed during the creation of a sound track.
  35431. */
  35432. export interface ISoundTrackOptions {
  35433. /**
  35434. * The volume the sound track should take during creation
  35435. */
  35436. volume?: number;
  35437. /**
  35438. * Define if the sound track is the main sound track of the scene
  35439. */
  35440. mainTrack?: boolean;
  35441. }
  35442. /**
  35443. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35444. * It will be also used in a future release to apply effects on a specific track.
  35445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35446. */
  35447. export class SoundTrack {
  35448. /**
  35449. * The unique identifier of the sound track in the scene.
  35450. */
  35451. id: number;
  35452. /**
  35453. * The list of sounds included in the sound track.
  35454. */
  35455. soundCollection: Array<Sound>;
  35456. private _outputAudioNode;
  35457. private _scene;
  35458. private _isMainTrack;
  35459. private _connectedAnalyser;
  35460. private _options;
  35461. private _isInitialized;
  35462. /**
  35463. * Creates a new sound track.
  35464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35465. * @param scene Define the scene the sound track belongs to
  35466. * @param options
  35467. */
  35468. constructor(scene: Scene, options?: ISoundTrackOptions);
  35469. private _initializeSoundTrackAudioGraph;
  35470. /**
  35471. * Release the sound track and its associated resources
  35472. */
  35473. dispose(): void;
  35474. /**
  35475. * Adds a sound to this sound track
  35476. * @param sound define the cound to add
  35477. * @ignoreNaming
  35478. */
  35479. AddSound(sound: Sound): void;
  35480. /**
  35481. * Removes a sound to this sound track
  35482. * @param sound define the cound to remove
  35483. * @ignoreNaming
  35484. */
  35485. RemoveSound(sound: Sound): void;
  35486. /**
  35487. * Set a global volume for the full sound track.
  35488. * @param newVolume Define the new volume of the sound track
  35489. */
  35490. setVolume(newVolume: number): void;
  35491. /**
  35492. * Switch the panning model to HRTF:
  35493. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35495. */
  35496. switchPanningModelToHRTF(): void;
  35497. /**
  35498. * Switch the panning model to Equal Power:
  35499. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35501. */
  35502. switchPanningModelToEqualPower(): void;
  35503. /**
  35504. * Connect the sound track to an audio analyser allowing some amazing
  35505. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35507. * @param analyser The analyser to connect to the engine
  35508. */
  35509. connectToAnalyser(analyser: Analyser): void;
  35510. }
  35511. }
  35512. declare module BABYLON {
  35513. interface AbstractScene {
  35514. /**
  35515. * The list of sounds used in the scene.
  35516. */
  35517. sounds: Nullable<Array<Sound>>;
  35518. }
  35519. interface Scene {
  35520. /**
  35521. * @hidden
  35522. * Backing field
  35523. */
  35524. _mainSoundTrack: SoundTrack;
  35525. /**
  35526. * The main sound track played by the scene.
  35527. * It cotains your primary collection of sounds.
  35528. */
  35529. mainSoundTrack: SoundTrack;
  35530. /**
  35531. * The list of sound tracks added to the scene
  35532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35533. */
  35534. soundTracks: Nullable<Array<SoundTrack>>;
  35535. /**
  35536. * Gets a sound using a given name
  35537. * @param name defines the name to search for
  35538. * @return the found sound or null if not found at all.
  35539. */
  35540. getSoundByName(name: string): Nullable<Sound>;
  35541. /**
  35542. * Gets or sets if audio support is enabled
  35543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35544. */
  35545. audioEnabled: boolean;
  35546. /**
  35547. * Gets or sets if audio will be output to headphones
  35548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35549. */
  35550. headphone: boolean;
  35551. /**
  35552. * Gets or sets custom audio listener position provider
  35553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35554. */
  35555. audioListenerPositionProvider: Nullable<() => Vector3>;
  35556. }
  35557. /**
  35558. * Defines the sound scene component responsible to manage any sounds
  35559. * in a given scene.
  35560. */
  35561. export class AudioSceneComponent implements ISceneSerializableComponent {
  35562. /**
  35563. * The component name helpfull to identify the component in the list of scene components.
  35564. */
  35565. readonly name: string;
  35566. /**
  35567. * The scene the component belongs to.
  35568. */
  35569. scene: Scene;
  35570. private _audioEnabled;
  35571. /**
  35572. * Gets whether audio is enabled or not.
  35573. * Please use related enable/disable method to switch state.
  35574. */
  35575. readonly audioEnabled: boolean;
  35576. private _headphone;
  35577. /**
  35578. * Gets whether audio is outputing to headphone or not.
  35579. * Please use the according Switch methods to change output.
  35580. */
  35581. readonly headphone: boolean;
  35582. private _audioListenerPositionProvider;
  35583. /**
  35584. * Gets the current audio listener position provider
  35585. */
  35586. /**
  35587. * Sets a custom listener position for all sounds in the scene
  35588. * By default, this is the position of the first active camera
  35589. */
  35590. audioListenerPositionProvider: Nullable<() => Vector3>;
  35591. /**
  35592. * Creates a new instance of the component for the given scene
  35593. * @param scene Defines the scene to register the component in
  35594. */
  35595. constructor(scene: Scene);
  35596. /**
  35597. * Registers the component in a given scene
  35598. */
  35599. register(): void;
  35600. /**
  35601. * Rebuilds the elements related to this component in case of
  35602. * context lost for instance.
  35603. */
  35604. rebuild(): void;
  35605. /**
  35606. * Serializes the component data to the specified json object
  35607. * @param serializationObject The object to serialize to
  35608. */
  35609. serialize(serializationObject: any): void;
  35610. /**
  35611. * Adds all the elements from the container to the scene
  35612. * @param container the container holding the elements
  35613. */
  35614. addFromContainer(container: AbstractScene): void;
  35615. /**
  35616. * Removes all the elements in the container from the scene
  35617. * @param container contains the elements to remove
  35618. * @param dispose if the removed element should be disposed (default: false)
  35619. */
  35620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35621. /**
  35622. * Disposes the component and the associated ressources.
  35623. */
  35624. dispose(): void;
  35625. /**
  35626. * Disables audio in the associated scene.
  35627. */
  35628. disableAudio(): void;
  35629. /**
  35630. * Enables audio in the associated scene.
  35631. */
  35632. enableAudio(): void;
  35633. /**
  35634. * Switch audio to headphone output.
  35635. */
  35636. switchAudioModeForHeadphones(): void;
  35637. /**
  35638. * Switch audio to normal speakers.
  35639. */
  35640. switchAudioModeForNormalSpeakers(): void;
  35641. private _afterRender;
  35642. }
  35643. }
  35644. declare module BABYLON {
  35645. /**
  35646. * Wraps one or more Sound objects and selects one with random weight for playback.
  35647. */
  35648. export class WeightedSound {
  35649. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35650. loop: boolean;
  35651. private _coneInnerAngle;
  35652. private _coneOuterAngle;
  35653. private _volume;
  35654. /** A Sound is currently playing. */
  35655. isPlaying: boolean;
  35656. /** A Sound is currently paused. */
  35657. isPaused: boolean;
  35658. private _sounds;
  35659. private _weights;
  35660. private _currentIndex?;
  35661. /**
  35662. * Creates a new WeightedSound from the list of sounds given.
  35663. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35664. * @param sounds Array of Sounds that will be selected from.
  35665. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35666. */
  35667. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35668. /**
  35669. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35670. */
  35671. /**
  35672. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35673. */
  35674. directionalConeInnerAngle: number;
  35675. /**
  35676. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35677. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35678. */
  35679. /**
  35680. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35681. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35682. */
  35683. directionalConeOuterAngle: number;
  35684. /**
  35685. * Playback volume.
  35686. */
  35687. /**
  35688. * Playback volume.
  35689. */
  35690. volume: number;
  35691. private _onended;
  35692. /**
  35693. * Suspend playback
  35694. */
  35695. pause(): void;
  35696. /**
  35697. * Stop playback
  35698. */
  35699. stop(): void;
  35700. /**
  35701. * Start playback.
  35702. * @param startOffset Position the clip head at a specific time in seconds.
  35703. */
  35704. play(startOffset?: number): void;
  35705. }
  35706. }
  35707. declare module BABYLON {
  35708. /**
  35709. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35711. */
  35712. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35713. /**
  35714. * Gets the name of the behavior.
  35715. */
  35716. readonly name: string;
  35717. /**
  35718. * The easing function used by animations
  35719. */
  35720. static EasingFunction: BackEase;
  35721. /**
  35722. * The easing mode used by animations
  35723. */
  35724. static EasingMode: number;
  35725. /**
  35726. * The duration of the animation, in milliseconds
  35727. */
  35728. transitionDuration: number;
  35729. /**
  35730. * Length of the distance animated by the transition when lower radius is reached
  35731. */
  35732. lowerRadiusTransitionRange: number;
  35733. /**
  35734. * Length of the distance animated by the transition when upper radius is reached
  35735. */
  35736. upperRadiusTransitionRange: number;
  35737. private _autoTransitionRange;
  35738. /**
  35739. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35740. */
  35741. /**
  35742. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35743. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35744. */
  35745. autoTransitionRange: boolean;
  35746. private _attachedCamera;
  35747. private _onAfterCheckInputsObserver;
  35748. private _onMeshTargetChangedObserver;
  35749. /**
  35750. * Initializes the behavior.
  35751. */
  35752. init(): void;
  35753. /**
  35754. * Attaches the behavior to its arc rotate camera.
  35755. * @param camera Defines the camera to attach the behavior to
  35756. */
  35757. attach(camera: ArcRotateCamera): void;
  35758. /**
  35759. * Detaches the behavior from its current arc rotate camera.
  35760. */
  35761. detach(): void;
  35762. private _radiusIsAnimating;
  35763. private _radiusBounceTransition;
  35764. private _animatables;
  35765. private _cachedWheelPrecision;
  35766. /**
  35767. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35768. * @param radiusLimit The limit to check against.
  35769. * @return Bool to indicate if at limit.
  35770. */
  35771. private _isRadiusAtLimit;
  35772. /**
  35773. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35774. * @param radiusDelta The delta by which to animate to. Can be negative.
  35775. */
  35776. private _applyBoundRadiusAnimation;
  35777. /**
  35778. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35779. */
  35780. protected _clearAnimationLocks(): void;
  35781. /**
  35782. * Stops and removes all animations that have been applied to the camera
  35783. */
  35784. stopAllAnimations(): void;
  35785. }
  35786. }
  35787. declare module BABYLON {
  35788. /**
  35789. * 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.
  35790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35791. */
  35792. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35793. /**
  35794. * Gets the name of the behavior.
  35795. */
  35796. readonly name: string;
  35797. private _mode;
  35798. private _radiusScale;
  35799. private _positionScale;
  35800. private _defaultElevation;
  35801. private _elevationReturnTime;
  35802. private _elevationReturnWaitTime;
  35803. private _zoomStopsAnimation;
  35804. private _framingTime;
  35805. /**
  35806. * The easing function used by animations
  35807. */
  35808. static EasingFunction: ExponentialEase;
  35809. /**
  35810. * The easing mode used by animations
  35811. */
  35812. static EasingMode: number;
  35813. /**
  35814. * Sets the current mode used by the behavior
  35815. */
  35816. /**
  35817. * Gets current mode used by the behavior.
  35818. */
  35819. mode: number;
  35820. /**
  35821. * Sets the scale applied to the radius (1 by default)
  35822. */
  35823. /**
  35824. * Gets the scale applied to the radius
  35825. */
  35826. radiusScale: number;
  35827. /**
  35828. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35829. */
  35830. /**
  35831. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35832. */
  35833. positionScale: number;
  35834. /**
  35835. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35836. * behaviour is triggered, in radians.
  35837. */
  35838. /**
  35839. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35840. * behaviour is triggered, in radians.
  35841. */
  35842. defaultElevation: number;
  35843. /**
  35844. * Sets the time (in milliseconds) taken to return to the default beta position.
  35845. * Negative value indicates camera should not return to default.
  35846. */
  35847. /**
  35848. * Gets the time (in milliseconds) taken to return to the default beta position.
  35849. * Negative value indicates camera should not return to default.
  35850. */
  35851. elevationReturnTime: number;
  35852. /**
  35853. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35854. */
  35855. /**
  35856. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35857. */
  35858. elevationReturnWaitTime: number;
  35859. /**
  35860. * Sets the flag that indicates if user zooming should stop animation.
  35861. */
  35862. /**
  35863. * Gets the flag that indicates if user zooming should stop animation.
  35864. */
  35865. zoomStopsAnimation: boolean;
  35866. /**
  35867. * Sets the transition time when framing the mesh, in milliseconds
  35868. */
  35869. /**
  35870. * Gets the transition time when framing the mesh, in milliseconds
  35871. */
  35872. framingTime: number;
  35873. /**
  35874. * Define if the behavior should automatically change the configured
  35875. * camera limits and sensibilities.
  35876. */
  35877. autoCorrectCameraLimitsAndSensibility: boolean;
  35878. private _onPrePointerObservableObserver;
  35879. private _onAfterCheckInputsObserver;
  35880. private _onMeshTargetChangedObserver;
  35881. private _attachedCamera;
  35882. private _isPointerDown;
  35883. private _lastInteractionTime;
  35884. /**
  35885. * Initializes the behavior.
  35886. */
  35887. init(): void;
  35888. /**
  35889. * Attaches the behavior to its arc rotate camera.
  35890. * @param camera Defines the camera to attach the behavior to
  35891. */
  35892. attach(camera: ArcRotateCamera): void;
  35893. /**
  35894. * Detaches the behavior from its current arc rotate camera.
  35895. */
  35896. detach(): void;
  35897. private _animatables;
  35898. private _betaIsAnimating;
  35899. private _betaTransition;
  35900. private _radiusTransition;
  35901. private _vectorTransition;
  35902. /**
  35903. * Targets the given mesh and updates zoom level accordingly.
  35904. * @param mesh The mesh to target.
  35905. * @param radius Optional. If a cached radius position already exists, overrides default.
  35906. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35907. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35908. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35909. */
  35910. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35911. /**
  35912. * Targets the given mesh with its children and updates zoom level accordingly.
  35913. * @param mesh The mesh to target.
  35914. * @param radius Optional. If a cached radius position already exists, overrides default.
  35915. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35916. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35917. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35918. */
  35919. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35920. /**
  35921. * Targets the given meshes with their children and updates zoom level accordingly.
  35922. * @param meshes The mesh to target.
  35923. * @param radius Optional. If a cached radius position already exists, overrides default.
  35924. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35925. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35926. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35927. */
  35928. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35929. /**
  35930. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35931. * @param minimumWorld Determines the smaller position of the bounding box extend
  35932. * @param maximumWorld Determines the bigger position of the bounding box extend
  35933. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35934. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35935. */
  35936. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35937. /**
  35938. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35939. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35940. * frustum width.
  35941. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35942. * to fully enclose the mesh in the viewing frustum.
  35943. */
  35944. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35945. /**
  35946. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35947. * is automatically returned to its default position (expected to be above ground plane).
  35948. */
  35949. private _maintainCameraAboveGround;
  35950. /**
  35951. * Returns the frustum slope based on the canvas ratio and camera FOV
  35952. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35953. */
  35954. private _getFrustumSlope;
  35955. /**
  35956. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35957. */
  35958. private _clearAnimationLocks;
  35959. /**
  35960. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35961. */
  35962. private _applyUserInteraction;
  35963. /**
  35964. * Stops and removes all animations that have been applied to the camera
  35965. */
  35966. stopAllAnimations(): void;
  35967. /**
  35968. * Gets a value indicating if the user is moving the camera
  35969. */
  35970. readonly isUserIsMoving: boolean;
  35971. /**
  35972. * The camera can move all the way towards the mesh.
  35973. */
  35974. static IgnoreBoundsSizeMode: number;
  35975. /**
  35976. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35977. */
  35978. static FitFrustumSidesMode: number;
  35979. }
  35980. }
  35981. declare module BABYLON {
  35982. /**
  35983. * Base class for Camera Pointer Inputs.
  35984. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35985. * for example usage.
  35986. */
  35987. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35988. /**
  35989. * Defines the camera the input is attached to.
  35990. */
  35991. abstract camera: Camera;
  35992. /**
  35993. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35994. */
  35995. protected _altKey: boolean;
  35996. protected _ctrlKey: boolean;
  35997. protected _metaKey: boolean;
  35998. protected _shiftKey: boolean;
  35999. /**
  36000. * Which mouse buttons were pressed at time of last mouse event.
  36001. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36002. */
  36003. protected _buttonsPressed: number;
  36004. /**
  36005. * Defines the buttons associated with the input to handle camera move.
  36006. */
  36007. buttons: number[];
  36008. /**
  36009. * Attach the input controls to a specific dom element to get the input from.
  36010. * @param element Defines the element the controls should be listened from
  36011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36012. */
  36013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36014. /**
  36015. * Detach the current controls from the specified dom element.
  36016. * @param element Defines the element to stop listening the inputs from
  36017. */
  36018. detachControl(element: Nullable<HTMLElement>): void;
  36019. /**
  36020. * Gets the class name of the current input.
  36021. * @returns the class name
  36022. */
  36023. getClassName(): string;
  36024. /**
  36025. * Get the friendly name associated with the input class.
  36026. * @returns the input friendly name
  36027. */
  36028. getSimpleName(): string;
  36029. /**
  36030. * Called on pointer POINTERDOUBLETAP event.
  36031. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36032. */
  36033. protected onDoubleTap(type: string): void;
  36034. /**
  36035. * Called on pointer POINTERMOVE event if only a single touch is active.
  36036. * Override this method to provide functionality.
  36037. */
  36038. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36039. /**
  36040. * Called on pointer POINTERMOVE event if multiple touches are active.
  36041. * Override this method to provide functionality.
  36042. */
  36043. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36044. /**
  36045. * Called on JS contextmenu event.
  36046. * Override this method to provide functionality.
  36047. */
  36048. protected onContextMenu(evt: PointerEvent): void;
  36049. /**
  36050. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36051. * press.
  36052. * Override this method to provide functionality.
  36053. */
  36054. protected onButtonDown(evt: PointerEvent): void;
  36055. /**
  36056. * Called each time a new POINTERUP event occurs. Ie, for each button
  36057. * release.
  36058. * Override this method to provide functionality.
  36059. */
  36060. protected onButtonUp(evt: PointerEvent): void;
  36061. /**
  36062. * Called when window becomes inactive.
  36063. * Override this method to provide functionality.
  36064. */
  36065. protected onLostFocus(): void;
  36066. private _pointerInput;
  36067. private _observer;
  36068. private _onLostFocus;
  36069. private pointA;
  36070. private pointB;
  36071. }
  36072. }
  36073. declare module BABYLON {
  36074. /**
  36075. * Manage the pointers inputs to control an arc rotate camera.
  36076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36077. */
  36078. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36079. /**
  36080. * Defines the camera the input is attached to.
  36081. */
  36082. camera: ArcRotateCamera;
  36083. /**
  36084. * Gets the class name of the current input.
  36085. * @returns the class name
  36086. */
  36087. getClassName(): string;
  36088. /**
  36089. * Defines the buttons associated with the input to handle camera move.
  36090. */
  36091. buttons: number[];
  36092. /**
  36093. * Defines the pointer angular sensibility along the X axis or how fast is
  36094. * the camera rotating.
  36095. */
  36096. angularSensibilityX: number;
  36097. /**
  36098. * Defines the pointer angular sensibility along the Y axis or how fast is
  36099. * the camera rotating.
  36100. */
  36101. angularSensibilityY: number;
  36102. /**
  36103. * Defines the pointer pinch precision or how fast is the camera zooming.
  36104. */
  36105. pinchPrecision: number;
  36106. /**
  36107. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36108. * from 0.
  36109. * It defines the percentage of current camera.radius to use as delta when
  36110. * pinch zoom is used.
  36111. */
  36112. pinchDeltaPercentage: number;
  36113. /**
  36114. * Defines the pointer panning sensibility or how fast is the camera moving.
  36115. */
  36116. panningSensibility: number;
  36117. /**
  36118. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36119. */
  36120. multiTouchPanning: boolean;
  36121. /**
  36122. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36123. * zoom (pinch) through multitouch.
  36124. */
  36125. multiTouchPanAndZoom: boolean;
  36126. /**
  36127. * Revers pinch action direction.
  36128. */
  36129. pinchInwards: boolean;
  36130. private _isPanClick;
  36131. private _twoFingerActivityCount;
  36132. private _isPinching;
  36133. /**
  36134. * Called on pointer POINTERMOVE event if only a single touch is active.
  36135. */
  36136. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36137. /**
  36138. * Called on pointer POINTERDOUBLETAP event.
  36139. */
  36140. protected onDoubleTap(type: string): void;
  36141. /**
  36142. * Called on pointer POINTERMOVE event if multiple touches are active.
  36143. */
  36144. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36145. /**
  36146. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36147. * press.
  36148. */
  36149. protected onButtonDown(evt: PointerEvent): void;
  36150. /**
  36151. * Called each time a new POINTERUP event occurs. Ie, for each button
  36152. * release.
  36153. */
  36154. protected onButtonUp(evt: PointerEvent): void;
  36155. /**
  36156. * Called when window becomes inactive.
  36157. */
  36158. protected onLostFocus(): void;
  36159. }
  36160. }
  36161. declare module BABYLON {
  36162. /**
  36163. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36165. */
  36166. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36167. /**
  36168. * Defines the camera the input is attached to.
  36169. */
  36170. camera: ArcRotateCamera;
  36171. /**
  36172. * Defines the list of key codes associated with the up action (increase alpha)
  36173. */
  36174. keysUp: number[];
  36175. /**
  36176. * Defines the list of key codes associated with the down action (decrease alpha)
  36177. */
  36178. keysDown: number[];
  36179. /**
  36180. * Defines the list of key codes associated with the left action (increase beta)
  36181. */
  36182. keysLeft: number[];
  36183. /**
  36184. * Defines the list of key codes associated with the right action (decrease beta)
  36185. */
  36186. keysRight: number[];
  36187. /**
  36188. * Defines the list of key codes associated with the reset action.
  36189. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36190. */
  36191. keysReset: number[];
  36192. /**
  36193. * Defines the panning sensibility of the inputs.
  36194. * (How fast is the camera paning)
  36195. */
  36196. panningSensibility: number;
  36197. /**
  36198. * Defines the zooming sensibility of the inputs.
  36199. * (How fast is the camera zooming)
  36200. */
  36201. zoomingSensibility: number;
  36202. /**
  36203. * Defines wether maintaining the alt key down switch the movement mode from
  36204. * orientation to zoom.
  36205. */
  36206. useAltToZoom: boolean;
  36207. /**
  36208. * Rotation speed of the camera
  36209. */
  36210. angularSpeed: number;
  36211. private _keys;
  36212. private _ctrlPressed;
  36213. private _altPressed;
  36214. private _onCanvasBlurObserver;
  36215. private _onKeyboardObserver;
  36216. private _engine;
  36217. private _scene;
  36218. /**
  36219. * Attach the input controls to a specific dom element to get the input from.
  36220. * @param element Defines the element the controls should be listened from
  36221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36222. */
  36223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36224. /**
  36225. * Detach the current controls from the specified dom element.
  36226. * @param element Defines the element to stop listening the inputs from
  36227. */
  36228. detachControl(element: Nullable<HTMLElement>): void;
  36229. /**
  36230. * Update the current camera state depending on the inputs that have been used this frame.
  36231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36232. */
  36233. checkInputs(): void;
  36234. /**
  36235. * Gets the class name of the current intput.
  36236. * @returns the class name
  36237. */
  36238. getClassName(): string;
  36239. /**
  36240. * Get the friendly name associated with the input class.
  36241. * @returns the input friendly name
  36242. */
  36243. getSimpleName(): string;
  36244. }
  36245. }
  36246. declare module BABYLON {
  36247. /**
  36248. * Manage the mouse wheel inputs to control an arc rotate camera.
  36249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36250. */
  36251. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36252. /**
  36253. * Defines the camera the input is attached to.
  36254. */
  36255. camera: ArcRotateCamera;
  36256. /**
  36257. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36258. */
  36259. wheelPrecision: number;
  36260. /**
  36261. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36262. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36263. */
  36264. wheelDeltaPercentage: number;
  36265. private _wheel;
  36266. private _observer;
  36267. private computeDeltaFromMouseWheelLegacyEvent;
  36268. /**
  36269. * Attach the input controls to a specific dom element to get the input from.
  36270. * @param element Defines the element the controls should be listened from
  36271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36272. */
  36273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36274. /**
  36275. * Detach the current controls from the specified dom element.
  36276. * @param element Defines the element to stop listening the inputs from
  36277. */
  36278. detachControl(element: Nullable<HTMLElement>): void;
  36279. /**
  36280. * Gets the class name of the current intput.
  36281. * @returns the class name
  36282. */
  36283. getClassName(): string;
  36284. /**
  36285. * Get the friendly name associated with the input class.
  36286. * @returns the input friendly name
  36287. */
  36288. getSimpleName(): string;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * Default Inputs manager for the ArcRotateCamera.
  36294. * It groups all the default supported inputs for ease of use.
  36295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36296. */
  36297. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36298. /**
  36299. * Instantiates a new ArcRotateCameraInputsManager.
  36300. * @param camera Defines the camera the inputs belong to
  36301. */
  36302. constructor(camera: ArcRotateCamera);
  36303. /**
  36304. * Add mouse wheel input support to the input manager.
  36305. * @returns the current input manager
  36306. */
  36307. addMouseWheel(): ArcRotateCameraInputsManager;
  36308. /**
  36309. * Add pointers input support to the input manager.
  36310. * @returns the current input manager
  36311. */
  36312. addPointers(): ArcRotateCameraInputsManager;
  36313. /**
  36314. * Add keyboard input support to the input manager.
  36315. * @returns the current input manager
  36316. */
  36317. addKeyboard(): ArcRotateCameraInputsManager;
  36318. }
  36319. }
  36320. declare module BABYLON {
  36321. /**
  36322. * This represents an orbital type of camera.
  36323. *
  36324. * 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.
  36325. * 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.
  36326. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36327. */
  36328. export class ArcRotateCamera extends TargetCamera {
  36329. /**
  36330. * Defines the rotation angle of the camera along the longitudinal axis.
  36331. */
  36332. alpha: number;
  36333. /**
  36334. * Defines the rotation angle of the camera along the latitudinal axis.
  36335. */
  36336. beta: number;
  36337. /**
  36338. * Defines the radius of the camera from it s target point.
  36339. */
  36340. radius: number;
  36341. protected _target: Vector3;
  36342. protected _targetHost: Nullable<AbstractMesh>;
  36343. /**
  36344. * Defines the target point of the camera.
  36345. * The camera looks towards it form the radius distance.
  36346. */
  36347. target: Vector3;
  36348. /**
  36349. * Define the current local position of the camera in the scene
  36350. */
  36351. position: Vector3;
  36352. protected _upVector: Vector3;
  36353. protected _upToYMatrix: Matrix;
  36354. protected _YToUpMatrix: Matrix;
  36355. /**
  36356. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36357. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36358. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36359. */
  36360. upVector: Vector3;
  36361. /**
  36362. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36363. */
  36364. setMatUp(): void;
  36365. /**
  36366. * Current inertia value on the longitudinal axis.
  36367. * The bigger this number the longer it will take for the camera to stop.
  36368. */
  36369. inertialAlphaOffset: number;
  36370. /**
  36371. * Current inertia value on the latitudinal axis.
  36372. * The bigger this number the longer it will take for the camera to stop.
  36373. */
  36374. inertialBetaOffset: number;
  36375. /**
  36376. * Current inertia value on the radius axis.
  36377. * The bigger this number the longer it will take for the camera to stop.
  36378. */
  36379. inertialRadiusOffset: number;
  36380. /**
  36381. * Minimum allowed angle on the longitudinal axis.
  36382. * This can help limiting how the Camera is able to move in the scene.
  36383. */
  36384. lowerAlphaLimit: Nullable<number>;
  36385. /**
  36386. * Maximum allowed angle on the longitudinal axis.
  36387. * This can help limiting how the Camera is able to move in the scene.
  36388. */
  36389. upperAlphaLimit: Nullable<number>;
  36390. /**
  36391. * Minimum allowed angle on the latitudinal axis.
  36392. * This can help limiting how the Camera is able to move in the scene.
  36393. */
  36394. lowerBetaLimit: number;
  36395. /**
  36396. * Maximum allowed angle on the latitudinal axis.
  36397. * This can help limiting how the Camera is able to move in the scene.
  36398. */
  36399. upperBetaLimit: number;
  36400. /**
  36401. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36402. * This can help limiting how the Camera is able to move in the scene.
  36403. */
  36404. lowerRadiusLimit: Nullable<number>;
  36405. /**
  36406. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36407. * This can help limiting how the Camera is able to move in the scene.
  36408. */
  36409. upperRadiusLimit: Nullable<number>;
  36410. /**
  36411. * Defines the current inertia value used during panning of the camera along the X axis.
  36412. */
  36413. inertialPanningX: number;
  36414. /**
  36415. * Defines the current inertia value used during panning of the camera along the Y axis.
  36416. */
  36417. inertialPanningY: number;
  36418. /**
  36419. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36420. * Basically if your fingers moves away from more than this distance you will be considered
  36421. * in pinch mode.
  36422. */
  36423. pinchToPanMaxDistance: number;
  36424. /**
  36425. * Defines the maximum distance the camera can pan.
  36426. * This could help keeping the cammera always in your scene.
  36427. */
  36428. panningDistanceLimit: Nullable<number>;
  36429. /**
  36430. * Defines the target of the camera before paning.
  36431. */
  36432. panningOriginTarget: Vector3;
  36433. /**
  36434. * Defines the value of the inertia used during panning.
  36435. * 0 would mean stop inertia and one would mean no decelleration at all.
  36436. */
  36437. panningInertia: number;
  36438. /**
  36439. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36440. */
  36441. angularSensibilityX: number;
  36442. /**
  36443. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36444. */
  36445. angularSensibilityY: number;
  36446. /**
  36447. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36448. */
  36449. pinchPrecision: number;
  36450. /**
  36451. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36452. * It will be used instead of pinchDeltaPrecision if different from 0.
  36453. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36454. */
  36455. pinchDeltaPercentage: number;
  36456. /**
  36457. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36458. */
  36459. panningSensibility: number;
  36460. /**
  36461. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36462. */
  36463. keysUp: number[];
  36464. /**
  36465. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36466. */
  36467. keysDown: number[];
  36468. /**
  36469. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36470. */
  36471. keysLeft: number[];
  36472. /**
  36473. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36474. */
  36475. keysRight: number[];
  36476. /**
  36477. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36478. */
  36479. wheelPrecision: number;
  36480. /**
  36481. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36482. * It will be used instead of pinchDeltaPrecision if different from 0.
  36483. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36484. */
  36485. wheelDeltaPercentage: number;
  36486. /**
  36487. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36488. */
  36489. zoomOnFactor: number;
  36490. /**
  36491. * Defines a screen offset for the camera position.
  36492. */
  36493. targetScreenOffset: Vector2;
  36494. /**
  36495. * Allows the camera to be completely reversed.
  36496. * If false the camera can not arrive upside down.
  36497. */
  36498. allowUpsideDown: boolean;
  36499. /**
  36500. * Define if double tap/click is used to restore the previously saved state of the camera.
  36501. */
  36502. useInputToRestoreState: boolean;
  36503. /** @hidden */
  36504. _viewMatrix: Matrix;
  36505. /** @hidden */
  36506. _useCtrlForPanning: boolean;
  36507. /** @hidden */
  36508. _panningMouseButton: number;
  36509. /**
  36510. * Defines the input associated to the camera.
  36511. */
  36512. inputs: ArcRotateCameraInputsManager;
  36513. /** @hidden */
  36514. _reset: () => void;
  36515. /**
  36516. * Defines the allowed panning axis.
  36517. */
  36518. panningAxis: Vector3;
  36519. protected _localDirection: Vector3;
  36520. protected _transformedDirection: Vector3;
  36521. private _bouncingBehavior;
  36522. /**
  36523. * Gets the bouncing behavior of the camera if it has been enabled.
  36524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36525. */
  36526. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36527. /**
  36528. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36530. */
  36531. useBouncingBehavior: boolean;
  36532. private _framingBehavior;
  36533. /**
  36534. * Gets the framing behavior of the camera if it has been enabled.
  36535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36536. */
  36537. readonly framingBehavior: Nullable<FramingBehavior>;
  36538. /**
  36539. * Defines if the framing behavior of the camera is enabled on the camera.
  36540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36541. */
  36542. useFramingBehavior: boolean;
  36543. private _autoRotationBehavior;
  36544. /**
  36545. * Gets the auto rotation behavior of the camera if it has been enabled.
  36546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36547. */
  36548. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36549. /**
  36550. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36552. */
  36553. useAutoRotationBehavior: boolean;
  36554. /**
  36555. * Observable triggered when the mesh target has been changed on the camera.
  36556. */
  36557. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36558. /**
  36559. * Event raised when the camera is colliding with a mesh.
  36560. */
  36561. onCollide: (collidedMesh: AbstractMesh) => void;
  36562. /**
  36563. * Defines whether the camera should check collision with the objects oh the scene.
  36564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36565. */
  36566. checkCollisions: boolean;
  36567. /**
  36568. * Defines the collision radius of the camera.
  36569. * This simulates a sphere around the camera.
  36570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36571. */
  36572. collisionRadius: Vector3;
  36573. protected _collider: Collider;
  36574. protected _previousPosition: Vector3;
  36575. protected _collisionVelocity: Vector3;
  36576. protected _newPosition: Vector3;
  36577. protected _previousAlpha: number;
  36578. protected _previousBeta: number;
  36579. protected _previousRadius: number;
  36580. protected _collisionTriggered: boolean;
  36581. protected _targetBoundingCenter: Nullable<Vector3>;
  36582. private _computationVector;
  36583. /**
  36584. * Instantiates a new ArcRotateCamera in a given scene
  36585. * @param name Defines the name of the camera
  36586. * @param alpha Defines the camera rotation along the logitudinal axis
  36587. * @param beta Defines the camera rotation along the latitudinal axis
  36588. * @param radius Defines the camera distance from its target
  36589. * @param target Defines the camera target
  36590. * @param scene Defines the scene the camera belongs to
  36591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36592. */
  36593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36594. /** @hidden */
  36595. _initCache(): void;
  36596. /** @hidden */
  36597. _updateCache(ignoreParentClass?: boolean): void;
  36598. protected _getTargetPosition(): Vector3;
  36599. private _storedAlpha;
  36600. private _storedBeta;
  36601. private _storedRadius;
  36602. private _storedTarget;
  36603. private _storedTargetScreenOffset;
  36604. /**
  36605. * Stores the current state of the camera (alpha, beta, radius and target)
  36606. * @returns the camera itself
  36607. */
  36608. storeState(): Camera;
  36609. /**
  36610. * @hidden
  36611. * Restored camera state. You must call storeState() first
  36612. */
  36613. _restoreStateValues(): boolean;
  36614. /** @hidden */
  36615. _isSynchronizedViewMatrix(): boolean;
  36616. /**
  36617. * Attached controls to the current camera.
  36618. * @param element Defines the element the controls should be listened from
  36619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36620. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36621. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36622. */
  36623. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36624. /**
  36625. * Detach the current controls from the camera.
  36626. * The camera will stop reacting to inputs.
  36627. * @param element Defines the element to stop listening the inputs from
  36628. */
  36629. detachControl(element: HTMLElement): void;
  36630. /** @hidden */
  36631. _checkInputs(): void;
  36632. protected _checkLimits(): void;
  36633. /**
  36634. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36635. */
  36636. rebuildAnglesAndRadius(): void;
  36637. /**
  36638. * Use a position to define the current camera related information like aplha, beta and radius
  36639. * @param position Defines the position to set the camera at
  36640. */
  36641. setPosition(position: Vector3): void;
  36642. /**
  36643. * Defines the target the camera should look at.
  36644. * This will automatically adapt alpha beta and radius to fit within the new target.
  36645. * @param target Defines the new target as a Vector or a mesh
  36646. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36647. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36648. */
  36649. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36650. /** @hidden */
  36651. _getViewMatrix(): Matrix;
  36652. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36653. /**
  36654. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36655. * @param meshes Defines the mesh to zoom on
  36656. * @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)
  36657. */
  36658. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36659. /**
  36660. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36661. * The target will be changed but the radius
  36662. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36663. * @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)
  36664. */
  36665. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36666. min: Vector3;
  36667. max: Vector3;
  36668. distance: number;
  36669. }, doNotUpdateMaxZ?: boolean): void;
  36670. /**
  36671. * @override
  36672. * Override Camera.createRigCamera
  36673. */
  36674. createRigCamera(name: string, cameraIndex: number): Camera;
  36675. /**
  36676. * @hidden
  36677. * @override
  36678. * Override Camera._updateRigCameras
  36679. */
  36680. _updateRigCameras(): void;
  36681. /**
  36682. * Destroy the camera and release the current resources hold by it.
  36683. */
  36684. dispose(): void;
  36685. /**
  36686. * Gets the current object class name.
  36687. * @return the class name
  36688. */
  36689. getClassName(): string;
  36690. }
  36691. }
  36692. declare module BABYLON {
  36693. /**
  36694. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36696. */
  36697. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36698. /**
  36699. * Gets the name of the behavior.
  36700. */
  36701. readonly name: string;
  36702. private _zoomStopsAnimation;
  36703. private _idleRotationSpeed;
  36704. private _idleRotationWaitTime;
  36705. private _idleRotationSpinupTime;
  36706. /**
  36707. * Sets the flag that indicates if user zooming should stop animation.
  36708. */
  36709. /**
  36710. * Gets the flag that indicates if user zooming should stop animation.
  36711. */
  36712. zoomStopsAnimation: boolean;
  36713. /**
  36714. * Sets the default speed at which the camera rotates around the model.
  36715. */
  36716. /**
  36717. * Gets the default speed at which the camera rotates around the model.
  36718. */
  36719. idleRotationSpeed: number;
  36720. /**
  36721. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36722. */
  36723. /**
  36724. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36725. */
  36726. idleRotationWaitTime: number;
  36727. /**
  36728. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36729. */
  36730. /**
  36731. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36732. */
  36733. idleRotationSpinupTime: number;
  36734. /**
  36735. * Gets a value indicating if the camera is currently rotating because of this behavior
  36736. */
  36737. readonly rotationInProgress: boolean;
  36738. private _onPrePointerObservableObserver;
  36739. private _onAfterCheckInputsObserver;
  36740. private _attachedCamera;
  36741. private _isPointerDown;
  36742. private _lastFrameTime;
  36743. private _lastInteractionTime;
  36744. private _cameraRotationSpeed;
  36745. /**
  36746. * Initializes the behavior.
  36747. */
  36748. init(): void;
  36749. /**
  36750. * Attaches the behavior to its arc rotate camera.
  36751. * @param camera Defines the camera to attach the behavior to
  36752. */
  36753. attach(camera: ArcRotateCamera): void;
  36754. /**
  36755. * Detaches the behavior from its current arc rotate camera.
  36756. */
  36757. detach(): void;
  36758. /**
  36759. * Returns true if user is scrolling.
  36760. * @return true if user is scrolling.
  36761. */
  36762. private _userIsZooming;
  36763. private _lastFrameRadius;
  36764. private _shouldAnimationStopForInteraction;
  36765. /**
  36766. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36767. */
  36768. private _applyUserInteraction;
  36769. private _userIsMoving;
  36770. }
  36771. }
  36772. declare module BABYLON {
  36773. /**
  36774. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36775. */
  36776. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36777. private ui;
  36778. /**
  36779. * The name of the behavior
  36780. */
  36781. name: string;
  36782. /**
  36783. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36784. */
  36785. distanceAwayFromFace: number;
  36786. /**
  36787. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36788. */
  36789. distanceAwayFromBottomOfFace: number;
  36790. private _faceVectors;
  36791. private _target;
  36792. private _scene;
  36793. private _onRenderObserver;
  36794. private _tmpMatrix;
  36795. private _tmpVector;
  36796. /**
  36797. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36798. * @param ui The transform node that should be attched to the mesh
  36799. */
  36800. constructor(ui: TransformNode);
  36801. /**
  36802. * Initializes the behavior
  36803. */
  36804. init(): void;
  36805. private _closestFace;
  36806. private _zeroVector;
  36807. private _lookAtTmpMatrix;
  36808. private _lookAtToRef;
  36809. /**
  36810. * Attaches the AttachToBoxBehavior to the passed in mesh
  36811. * @param target The mesh that the specified node will be attached to
  36812. */
  36813. attach(target: Mesh): void;
  36814. /**
  36815. * Detaches the behavior from the mesh
  36816. */
  36817. detach(): void;
  36818. }
  36819. }
  36820. declare module BABYLON {
  36821. /**
  36822. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36823. */
  36824. export class FadeInOutBehavior implements Behavior<Mesh> {
  36825. /**
  36826. * Time in milliseconds to delay before fading in (Default: 0)
  36827. */
  36828. delay: number;
  36829. /**
  36830. * Time in milliseconds for the mesh to fade in (Default: 300)
  36831. */
  36832. fadeInTime: number;
  36833. private _millisecondsPerFrame;
  36834. private _hovered;
  36835. private _hoverValue;
  36836. private _ownerNode;
  36837. /**
  36838. * Instatiates the FadeInOutBehavior
  36839. */
  36840. constructor();
  36841. /**
  36842. * The name of the behavior
  36843. */
  36844. readonly name: string;
  36845. /**
  36846. * Initializes the behavior
  36847. */
  36848. init(): void;
  36849. /**
  36850. * Attaches the fade behavior on the passed in mesh
  36851. * @param ownerNode The mesh that will be faded in/out once attached
  36852. */
  36853. attach(ownerNode: Mesh): void;
  36854. /**
  36855. * Detaches the behavior from the mesh
  36856. */
  36857. detach(): void;
  36858. /**
  36859. * Triggers the mesh to begin fading in or out
  36860. * @param value if the object should fade in or out (true to fade in)
  36861. */
  36862. fadeIn(value: boolean): void;
  36863. private _update;
  36864. private _setAllVisibility;
  36865. }
  36866. }
  36867. declare module BABYLON {
  36868. /**
  36869. * Class containing a set of static utilities functions for managing Pivots
  36870. * @hidden
  36871. */
  36872. export class PivotTools {
  36873. private static _PivotCached;
  36874. private static _OldPivotPoint;
  36875. private static _PivotTranslation;
  36876. private static _PivotTmpVector;
  36877. /** @hidden */
  36878. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36879. /** @hidden */
  36880. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36881. }
  36882. }
  36883. declare module BABYLON {
  36884. /**
  36885. * Class containing static functions to help procedurally build meshes
  36886. */
  36887. export class PlaneBuilder {
  36888. /**
  36889. * Creates a plane mesh
  36890. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36891. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36892. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36894. * * 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
  36895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36896. * @param name defines the name of the mesh
  36897. * @param options defines the options used to create the mesh
  36898. * @param scene defines the hosting scene
  36899. * @returns the plane mesh
  36900. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36901. */
  36902. static CreatePlane(name: string, options: {
  36903. size?: number;
  36904. width?: number;
  36905. height?: number;
  36906. sideOrientation?: number;
  36907. frontUVs?: Vector4;
  36908. backUVs?: Vector4;
  36909. updatable?: boolean;
  36910. sourcePlane?: Plane;
  36911. }, scene?: Nullable<Scene>): Mesh;
  36912. }
  36913. }
  36914. declare module BABYLON {
  36915. /**
  36916. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36917. */
  36918. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36919. private static _AnyMouseID;
  36920. /**
  36921. * Abstract mesh the behavior is set on
  36922. */
  36923. attachedNode: AbstractMesh;
  36924. private _dragPlane;
  36925. private _scene;
  36926. private _pointerObserver;
  36927. private _beforeRenderObserver;
  36928. private static _planeScene;
  36929. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36930. /**
  36931. * 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)
  36932. */
  36933. maxDragAngle: number;
  36934. /**
  36935. * @hidden
  36936. */
  36937. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36938. /**
  36939. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36940. */
  36941. currentDraggingPointerID: number;
  36942. /**
  36943. * The last position where the pointer hit the drag plane in world space
  36944. */
  36945. lastDragPosition: Vector3;
  36946. /**
  36947. * If the behavior is currently in a dragging state
  36948. */
  36949. dragging: boolean;
  36950. /**
  36951. * 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)
  36952. */
  36953. dragDeltaRatio: number;
  36954. /**
  36955. * If the drag plane orientation should be updated during the dragging (Default: true)
  36956. */
  36957. updateDragPlane: boolean;
  36958. private _debugMode;
  36959. private _moving;
  36960. /**
  36961. * Fires each time the attached mesh is dragged with the pointer
  36962. * * delta between last drag position and current drag position in world space
  36963. * * dragDistance along the drag axis
  36964. * * dragPlaneNormal normal of the current drag plane used during the drag
  36965. * * dragPlanePoint in world space where the drag intersects the drag plane
  36966. */
  36967. onDragObservable: Observable<{
  36968. delta: Vector3;
  36969. dragPlanePoint: Vector3;
  36970. dragPlaneNormal: Vector3;
  36971. dragDistance: number;
  36972. pointerId: number;
  36973. }>;
  36974. /**
  36975. * Fires each time a drag begins (eg. mouse down on mesh)
  36976. */
  36977. onDragStartObservable: Observable<{
  36978. dragPlanePoint: Vector3;
  36979. pointerId: number;
  36980. }>;
  36981. /**
  36982. * Fires each time a drag ends (eg. mouse release after drag)
  36983. */
  36984. onDragEndObservable: Observable<{
  36985. dragPlanePoint: Vector3;
  36986. pointerId: number;
  36987. }>;
  36988. /**
  36989. * If the attached mesh should be moved when dragged
  36990. */
  36991. moveAttached: boolean;
  36992. /**
  36993. * If the drag behavior will react to drag events (Default: true)
  36994. */
  36995. enabled: boolean;
  36996. /**
  36997. * If pointer events should start and release the drag (Default: true)
  36998. */
  36999. startAndReleaseDragOnPointerEvents: boolean;
  37000. /**
  37001. * If camera controls should be detached during the drag
  37002. */
  37003. detachCameraControls: boolean;
  37004. /**
  37005. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37006. */
  37007. useObjectOrienationForDragging: boolean;
  37008. private _options;
  37009. /**
  37010. * Creates a pointer drag behavior that can be attached to a mesh
  37011. * @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)
  37012. */
  37013. constructor(options?: {
  37014. dragAxis?: Vector3;
  37015. dragPlaneNormal?: Vector3;
  37016. });
  37017. /**
  37018. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37019. */
  37020. validateDrag: (targetPosition: Vector3) => boolean;
  37021. /**
  37022. * The name of the behavior
  37023. */
  37024. readonly name: string;
  37025. /**
  37026. * Initializes the behavior
  37027. */
  37028. init(): void;
  37029. private _tmpVector;
  37030. private _alternatePickedPoint;
  37031. private _worldDragAxis;
  37032. private _targetPosition;
  37033. private _attachedElement;
  37034. /**
  37035. * Attaches the drag behavior the passed in mesh
  37036. * @param ownerNode The mesh that will be dragged around once attached
  37037. * @param predicate Predicate to use for pick filtering
  37038. */
  37039. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37040. /**
  37041. * Force relase the drag action by code.
  37042. */
  37043. releaseDrag(): void;
  37044. private _startDragRay;
  37045. private _lastPointerRay;
  37046. /**
  37047. * Simulates the start of a pointer drag event on the behavior
  37048. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37049. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37050. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37051. */
  37052. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37053. private _startDrag;
  37054. private _dragDelta;
  37055. private _moveDrag;
  37056. private _pickWithRayOnDragPlane;
  37057. private _pointA;
  37058. private _pointB;
  37059. private _pointC;
  37060. private _lineA;
  37061. private _lineB;
  37062. private _localAxis;
  37063. private _lookAt;
  37064. private _updateDragPlanePosition;
  37065. /**
  37066. * Detaches the behavior from the mesh
  37067. */
  37068. detach(): void;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37074. */
  37075. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37076. private _dragBehaviorA;
  37077. private _dragBehaviorB;
  37078. private _startDistance;
  37079. private _initialScale;
  37080. private _targetScale;
  37081. private _ownerNode;
  37082. private _sceneRenderObserver;
  37083. /**
  37084. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37085. */
  37086. constructor();
  37087. /**
  37088. * The name of the behavior
  37089. */
  37090. readonly name: string;
  37091. /**
  37092. * Initializes the behavior
  37093. */
  37094. init(): void;
  37095. private _getCurrentDistance;
  37096. /**
  37097. * Attaches the scale behavior the passed in mesh
  37098. * @param ownerNode The mesh that will be scaled around once attached
  37099. */
  37100. attach(ownerNode: Mesh): void;
  37101. /**
  37102. * Detaches the behavior from the mesh
  37103. */
  37104. detach(): void;
  37105. }
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * 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
  37110. */
  37111. export class SixDofDragBehavior implements Behavior<Mesh> {
  37112. private static _virtualScene;
  37113. private _ownerNode;
  37114. private _sceneRenderObserver;
  37115. private _scene;
  37116. private _targetPosition;
  37117. private _virtualOriginMesh;
  37118. private _virtualDragMesh;
  37119. private _pointerObserver;
  37120. private _moving;
  37121. private _startingOrientation;
  37122. /**
  37123. * 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)
  37124. */
  37125. private zDragFactor;
  37126. /**
  37127. * If the object should rotate to face the drag origin
  37128. */
  37129. rotateDraggedObject: boolean;
  37130. /**
  37131. * If the behavior is currently in a dragging state
  37132. */
  37133. dragging: boolean;
  37134. /**
  37135. * 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)
  37136. */
  37137. dragDeltaRatio: number;
  37138. /**
  37139. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37140. */
  37141. currentDraggingPointerID: number;
  37142. /**
  37143. * If camera controls should be detached during the drag
  37144. */
  37145. detachCameraControls: boolean;
  37146. /**
  37147. * Fires each time a drag starts
  37148. */
  37149. onDragStartObservable: Observable<{}>;
  37150. /**
  37151. * Fires each time a drag ends (eg. mouse release after drag)
  37152. */
  37153. onDragEndObservable: Observable<{}>;
  37154. /**
  37155. * 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
  37156. */
  37157. constructor();
  37158. /**
  37159. * The name of the behavior
  37160. */
  37161. readonly name: string;
  37162. /**
  37163. * Initializes the behavior
  37164. */
  37165. init(): void;
  37166. /**
  37167. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37168. */
  37169. private readonly _pointerCamera;
  37170. /**
  37171. * Attaches the scale behavior the passed in mesh
  37172. * @param ownerNode The mesh that will be scaled around once attached
  37173. */
  37174. attach(ownerNode: Mesh): void;
  37175. /**
  37176. * Detaches the behavior from the mesh
  37177. */
  37178. detach(): void;
  37179. }
  37180. }
  37181. declare module BABYLON {
  37182. /**
  37183. * Class used to apply inverse kinematics to bones
  37184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37185. */
  37186. export class BoneIKController {
  37187. private static _tmpVecs;
  37188. private static _tmpQuat;
  37189. private static _tmpMats;
  37190. /**
  37191. * Gets or sets the target mesh
  37192. */
  37193. targetMesh: AbstractMesh;
  37194. /** Gets or sets the mesh used as pole */
  37195. poleTargetMesh: AbstractMesh;
  37196. /**
  37197. * Gets or sets the bone used as pole
  37198. */
  37199. poleTargetBone: Nullable<Bone>;
  37200. /**
  37201. * Gets or sets the target position
  37202. */
  37203. targetPosition: Vector3;
  37204. /**
  37205. * Gets or sets the pole target position
  37206. */
  37207. poleTargetPosition: Vector3;
  37208. /**
  37209. * Gets or sets the pole target local offset
  37210. */
  37211. poleTargetLocalOffset: Vector3;
  37212. /**
  37213. * Gets or sets the pole angle
  37214. */
  37215. poleAngle: number;
  37216. /**
  37217. * Gets or sets the mesh associated with the controller
  37218. */
  37219. mesh: AbstractMesh;
  37220. /**
  37221. * 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)
  37222. */
  37223. slerpAmount: number;
  37224. private _bone1Quat;
  37225. private _bone1Mat;
  37226. private _bone2Ang;
  37227. private _bone1;
  37228. private _bone2;
  37229. private _bone1Length;
  37230. private _bone2Length;
  37231. private _maxAngle;
  37232. private _maxReach;
  37233. private _rightHandedSystem;
  37234. private _bendAxis;
  37235. private _slerping;
  37236. private _adjustRoll;
  37237. /**
  37238. * Gets or sets maximum allowed angle
  37239. */
  37240. maxAngle: number;
  37241. /**
  37242. * Creates a new BoneIKController
  37243. * @param mesh defines the mesh to control
  37244. * @param bone defines the bone to control
  37245. * @param options defines options to set up the controller
  37246. */
  37247. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37248. targetMesh?: AbstractMesh;
  37249. poleTargetMesh?: AbstractMesh;
  37250. poleTargetBone?: Bone;
  37251. poleTargetLocalOffset?: Vector3;
  37252. poleAngle?: number;
  37253. bendAxis?: Vector3;
  37254. maxAngle?: number;
  37255. slerpAmount?: number;
  37256. });
  37257. private _setMaxAngle;
  37258. /**
  37259. * Force the controller to update the bones
  37260. */
  37261. update(): void;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * Class used to make a bone look toward a point in space
  37267. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37268. */
  37269. export class BoneLookController {
  37270. private static _tmpVecs;
  37271. private static _tmpQuat;
  37272. private static _tmpMats;
  37273. /**
  37274. * The target Vector3 that the bone will look at
  37275. */
  37276. target: Vector3;
  37277. /**
  37278. * The mesh that the bone is attached to
  37279. */
  37280. mesh: AbstractMesh;
  37281. /**
  37282. * The bone that will be looking to the target
  37283. */
  37284. bone: Bone;
  37285. /**
  37286. * The up axis of the coordinate system that is used when the bone is rotated
  37287. */
  37288. upAxis: Vector3;
  37289. /**
  37290. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37291. */
  37292. upAxisSpace: Space;
  37293. /**
  37294. * Used to make an adjustment to the yaw of the bone
  37295. */
  37296. adjustYaw: number;
  37297. /**
  37298. * Used to make an adjustment to the pitch of the bone
  37299. */
  37300. adjustPitch: number;
  37301. /**
  37302. * Used to make an adjustment to the roll of the bone
  37303. */
  37304. adjustRoll: number;
  37305. /**
  37306. * 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)
  37307. */
  37308. slerpAmount: number;
  37309. private _minYaw;
  37310. private _maxYaw;
  37311. private _minPitch;
  37312. private _maxPitch;
  37313. private _minYawSin;
  37314. private _minYawCos;
  37315. private _maxYawSin;
  37316. private _maxYawCos;
  37317. private _midYawConstraint;
  37318. private _minPitchTan;
  37319. private _maxPitchTan;
  37320. private _boneQuat;
  37321. private _slerping;
  37322. private _transformYawPitch;
  37323. private _transformYawPitchInv;
  37324. private _firstFrameSkipped;
  37325. private _yawRange;
  37326. private _fowardAxis;
  37327. /**
  37328. * Gets or sets the minimum yaw angle that the bone can look to
  37329. */
  37330. minYaw: number;
  37331. /**
  37332. * Gets or sets the maximum yaw angle that the bone can look to
  37333. */
  37334. maxYaw: number;
  37335. /**
  37336. * Gets or sets the minimum pitch angle that the bone can look to
  37337. */
  37338. minPitch: number;
  37339. /**
  37340. * Gets or sets the maximum pitch angle that the bone can look to
  37341. */
  37342. maxPitch: number;
  37343. /**
  37344. * Create a BoneLookController
  37345. * @param mesh the mesh that the bone belongs to
  37346. * @param bone the bone that will be looking to the target
  37347. * @param target the target Vector3 to look at
  37348. * @param options optional settings:
  37349. * * maxYaw: the maximum angle the bone will yaw to
  37350. * * minYaw: the minimum angle the bone will yaw to
  37351. * * maxPitch: the maximum angle the bone will pitch to
  37352. * * minPitch: the minimum angle the bone will yaw to
  37353. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37354. * * upAxis: the up axis of the coordinate system
  37355. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37356. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37357. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37358. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37359. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37360. * * adjustRoll: used to make an adjustment to the roll of the bone
  37361. **/
  37362. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37363. maxYaw?: number;
  37364. minYaw?: number;
  37365. maxPitch?: number;
  37366. minPitch?: number;
  37367. slerpAmount?: number;
  37368. upAxis?: Vector3;
  37369. upAxisSpace?: Space;
  37370. yawAxis?: Vector3;
  37371. pitchAxis?: Vector3;
  37372. adjustYaw?: number;
  37373. adjustPitch?: number;
  37374. adjustRoll?: number;
  37375. });
  37376. /**
  37377. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37378. */
  37379. update(): void;
  37380. private _getAngleDiff;
  37381. private _getAngleBetween;
  37382. private _isAngleBetween;
  37383. }
  37384. }
  37385. declare module BABYLON {
  37386. /**
  37387. * Manage the gamepad inputs to control an arc rotate camera.
  37388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37389. */
  37390. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37391. /**
  37392. * Defines the camera the input is attached to.
  37393. */
  37394. camera: ArcRotateCamera;
  37395. /**
  37396. * Defines the gamepad the input is gathering event from.
  37397. */
  37398. gamepad: Nullable<Gamepad>;
  37399. /**
  37400. * Defines the gamepad rotation sensiblity.
  37401. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37402. */
  37403. gamepadRotationSensibility: number;
  37404. /**
  37405. * Defines the gamepad move sensiblity.
  37406. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37407. */
  37408. gamepadMoveSensibility: number;
  37409. private _onGamepadConnectedObserver;
  37410. private _onGamepadDisconnectedObserver;
  37411. /**
  37412. * Attach the input controls to a specific dom element to get the input from.
  37413. * @param element Defines the element the controls should be listened from
  37414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37415. */
  37416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37417. /**
  37418. * Detach the current controls from the specified dom element.
  37419. * @param element Defines the element to stop listening the inputs from
  37420. */
  37421. detachControl(element: Nullable<HTMLElement>): void;
  37422. /**
  37423. * Update the current camera state depending on the inputs that have been used this frame.
  37424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37425. */
  37426. checkInputs(): void;
  37427. /**
  37428. * Gets the class name of the current intput.
  37429. * @returns the class name
  37430. */
  37431. getClassName(): string;
  37432. /**
  37433. * Get the friendly name associated with the input class.
  37434. * @returns the input friendly name
  37435. */
  37436. getSimpleName(): string;
  37437. }
  37438. }
  37439. declare module BABYLON {
  37440. interface ArcRotateCameraInputsManager {
  37441. /**
  37442. * Add orientation input support to the input manager.
  37443. * @returns the current input manager
  37444. */
  37445. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37446. }
  37447. /**
  37448. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37450. */
  37451. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37452. /**
  37453. * Defines the camera the input is attached to.
  37454. */
  37455. camera: ArcRotateCamera;
  37456. /**
  37457. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37458. */
  37459. alphaCorrection: number;
  37460. /**
  37461. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37462. */
  37463. gammaCorrection: number;
  37464. private _alpha;
  37465. private _gamma;
  37466. private _dirty;
  37467. private _deviceOrientationHandler;
  37468. /**
  37469. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37470. */
  37471. constructor();
  37472. /**
  37473. * Attach the input controls to a specific dom element to get the input from.
  37474. * @param element Defines the element the controls should be listened from
  37475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37476. */
  37477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37478. /** @hidden */
  37479. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37480. /**
  37481. * Update the current camera state depending on the inputs that have been used this frame.
  37482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37483. */
  37484. checkInputs(): void;
  37485. /**
  37486. * Detach the current controls from the specified dom element.
  37487. * @param element Defines the element to stop listening the inputs from
  37488. */
  37489. detachControl(element: Nullable<HTMLElement>): void;
  37490. /**
  37491. * Gets the class name of the current intput.
  37492. * @returns the class name
  37493. */
  37494. getClassName(): string;
  37495. /**
  37496. * Get the friendly name associated with the input class.
  37497. * @returns the input friendly name
  37498. */
  37499. getSimpleName(): string;
  37500. }
  37501. }
  37502. declare module BABYLON {
  37503. /**
  37504. * Listen to mouse events to control the camera.
  37505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37506. */
  37507. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37508. /**
  37509. * Defines the camera the input is attached to.
  37510. */
  37511. camera: FlyCamera;
  37512. /**
  37513. * Defines if touch is enabled. (Default is true.)
  37514. */
  37515. touchEnabled: boolean;
  37516. /**
  37517. * Defines the buttons associated with the input to handle camera rotation.
  37518. */
  37519. buttons: number[];
  37520. /**
  37521. * Assign buttons for Yaw control.
  37522. */
  37523. buttonsYaw: number[];
  37524. /**
  37525. * Assign buttons for Pitch control.
  37526. */
  37527. buttonsPitch: number[];
  37528. /**
  37529. * Assign buttons for Roll control.
  37530. */
  37531. buttonsRoll: number[];
  37532. /**
  37533. * Detect if any button is being pressed while mouse is moved.
  37534. * -1 = Mouse locked.
  37535. * 0 = Left button.
  37536. * 1 = Middle Button.
  37537. * 2 = Right Button.
  37538. */
  37539. activeButton: number;
  37540. /**
  37541. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37542. * Higher values reduce its sensitivity.
  37543. */
  37544. angularSensibility: number;
  37545. private _mousemoveCallback;
  37546. private _observer;
  37547. private _rollObserver;
  37548. private previousPosition;
  37549. private noPreventDefault;
  37550. private element;
  37551. /**
  37552. * Listen to mouse events to control the camera.
  37553. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37555. */
  37556. constructor(touchEnabled?: boolean);
  37557. /**
  37558. * Attach the mouse control to the HTML DOM element.
  37559. * @param element Defines the element that listens to the input events.
  37560. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37561. */
  37562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37563. /**
  37564. * Detach the current controls from the specified dom element.
  37565. * @param element Defines the element to stop listening the inputs from
  37566. */
  37567. detachControl(element: Nullable<HTMLElement>): void;
  37568. /**
  37569. * Gets the class name of the current input.
  37570. * @returns the class name.
  37571. */
  37572. getClassName(): string;
  37573. /**
  37574. * Get the friendly name associated with the input class.
  37575. * @returns the input's friendly name.
  37576. */
  37577. getSimpleName(): string;
  37578. private _pointerInput;
  37579. private _onMouseMove;
  37580. /**
  37581. * Rotate camera by mouse offset.
  37582. */
  37583. private rotateCamera;
  37584. }
  37585. }
  37586. declare module BABYLON {
  37587. /**
  37588. * Default Inputs manager for the FlyCamera.
  37589. * It groups all the default supported inputs for ease of use.
  37590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37591. */
  37592. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37593. /**
  37594. * Instantiates a new FlyCameraInputsManager.
  37595. * @param camera Defines the camera the inputs belong to.
  37596. */
  37597. constructor(camera: FlyCamera);
  37598. /**
  37599. * Add keyboard input support to the input manager.
  37600. * @returns the new FlyCameraKeyboardMoveInput().
  37601. */
  37602. addKeyboard(): FlyCameraInputsManager;
  37603. /**
  37604. * Add mouse input support to the input manager.
  37605. * @param touchEnabled Enable touch screen support.
  37606. * @returns the new FlyCameraMouseInput().
  37607. */
  37608. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37609. }
  37610. }
  37611. declare module BABYLON {
  37612. /**
  37613. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37614. * such as in a 3D Space Shooter or a Flight Simulator.
  37615. */
  37616. export class FlyCamera extends TargetCamera {
  37617. /**
  37618. * Define the collision ellipsoid of the camera.
  37619. * This is helpful for simulating a camera body, like a player's body.
  37620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37621. */
  37622. ellipsoid: Vector3;
  37623. /**
  37624. * Define an offset for the position of the ellipsoid around the camera.
  37625. * This can be helpful if the camera is attached away from the player's body center,
  37626. * such as at its head.
  37627. */
  37628. ellipsoidOffset: Vector3;
  37629. /**
  37630. * Enable or disable collisions of the camera with the rest of the scene objects.
  37631. */
  37632. checkCollisions: boolean;
  37633. /**
  37634. * Enable or disable gravity on the camera.
  37635. */
  37636. applyGravity: boolean;
  37637. /**
  37638. * Define the current direction the camera is moving to.
  37639. */
  37640. cameraDirection: Vector3;
  37641. /**
  37642. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37643. * This overrides and empties cameraRotation.
  37644. */
  37645. rotationQuaternion: Quaternion;
  37646. /**
  37647. * Track Roll to maintain the wanted Rolling when looking around.
  37648. */
  37649. _trackRoll: number;
  37650. /**
  37651. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37652. */
  37653. rollCorrect: number;
  37654. /**
  37655. * Mimic a banked turn, Rolling the camera when Yawing.
  37656. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37657. */
  37658. bankedTurn: boolean;
  37659. /**
  37660. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37661. */
  37662. bankedTurnLimit: number;
  37663. /**
  37664. * Value of 0 disables the banked Roll.
  37665. * Value of 1 is equal to the Yaw angle in radians.
  37666. */
  37667. bankedTurnMultiplier: number;
  37668. /**
  37669. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37670. */
  37671. inputs: FlyCameraInputsManager;
  37672. /**
  37673. * Gets the input sensibility for mouse input.
  37674. * Higher values reduce sensitivity.
  37675. */
  37676. /**
  37677. * Sets the input sensibility for a mouse input.
  37678. * Higher values reduce sensitivity.
  37679. */
  37680. angularSensibility: number;
  37681. /**
  37682. * Get the keys for camera movement forward.
  37683. */
  37684. /**
  37685. * Set the keys for camera movement forward.
  37686. */
  37687. keysForward: number[];
  37688. /**
  37689. * Get the keys for camera movement backward.
  37690. */
  37691. keysBackward: number[];
  37692. /**
  37693. * Get the keys for camera movement up.
  37694. */
  37695. /**
  37696. * Set the keys for camera movement up.
  37697. */
  37698. keysUp: number[];
  37699. /**
  37700. * Get the keys for camera movement down.
  37701. */
  37702. /**
  37703. * Set the keys for camera movement down.
  37704. */
  37705. keysDown: number[];
  37706. /**
  37707. * Get the keys for camera movement left.
  37708. */
  37709. /**
  37710. * Set the keys for camera movement left.
  37711. */
  37712. keysLeft: number[];
  37713. /**
  37714. * Set the keys for camera movement right.
  37715. */
  37716. /**
  37717. * Set the keys for camera movement right.
  37718. */
  37719. keysRight: number[];
  37720. /**
  37721. * Event raised when the camera collides with a mesh in the scene.
  37722. */
  37723. onCollide: (collidedMesh: AbstractMesh) => void;
  37724. private _collider;
  37725. private _needMoveForGravity;
  37726. private _oldPosition;
  37727. private _diffPosition;
  37728. private _newPosition;
  37729. /** @hidden */
  37730. _localDirection: Vector3;
  37731. /** @hidden */
  37732. _transformedDirection: Vector3;
  37733. /**
  37734. * Instantiates a FlyCamera.
  37735. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37736. * such as in a 3D Space Shooter or a Flight Simulator.
  37737. * @param name Define the name of the camera in the scene.
  37738. * @param position Define the starting position of the camera in the scene.
  37739. * @param scene Define the scene the camera belongs to.
  37740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37741. */
  37742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37743. /**
  37744. * Attach a control to the HTML DOM element.
  37745. * @param element Defines the element that listens to the input events.
  37746. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37747. */
  37748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37749. /**
  37750. * Detach a control from the HTML DOM element.
  37751. * The camera will stop reacting to that input.
  37752. * @param element Defines the element that listens to the input events.
  37753. */
  37754. detachControl(element: HTMLElement): void;
  37755. private _collisionMask;
  37756. /**
  37757. * Get the mask that the camera ignores in collision events.
  37758. */
  37759. /**
  37760. * Set the mask that the camera ignores in collision events.
  37761. */
  37762. collisionMask: number;
  37763. /** @hidden */
  37764. _collideWithWorld(displacement: Vector3): void;
  37765. /** @hidden */
  37766. private _onCollisionPositionChange;
  37767. /** @hidden */
  37768. _checkInputs(): void;
  37769. /** @hidden */
  37770. _decideIfNeedsToMove(): boolean;
  37771. /** @hidden */
  37772. _updatePosition(): void;
  37773. /**
  37774. * Restore the Roll to its target value at the rate specified.
  37775. * @param rate - Higher means slower restoring.
  37776. * @hidden
  37777. */
  37778. restoreRoll(rate: number): void;
  37779. /**
  37780. * Destroy the camera and release the current resources held by it.
  37781. */
  37782. dispose(): void;
  37783. /**
  37784. * Get the current object class name.
  37785. * @returns the class name.
  37786. */
  37787. getClassName(): string;
  37788. }
  37789. }
  37790. declare module BABYLON {
  37791. /**
  37792. * Listen to keyboard events to control the camera.
  37793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37794. */
  37795. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37796. /**
  37797. * Defines the camera the input is attached to.
  37798. */
  37799. camera: FlyCamera;
  37800. /**
  37801. * The list of keyboard keys used to control the forward move of the camera.
  37802. */
  37803. keysForward: number[];
  37804. /**
  37805. * The list of keyboard keys used to control the backward move of the camera.
  37806. */
  37807. keysBackward: number[];
  37808. /**
  37809. * The list of keyboard keys used to control the forward move of the camera.
  37810. */
  37811. keysUp: number[];
  37812. /**
  37813. * The list of keyboard keys used to control the backward move of the camera.
  37814. */
  37815. keysDown: number[];
  37816. /**
  37817. * The list of keyboard keys used to control the right strafe move of the camera.
  37818. */
  37819. keysRight: number[];
  37820. /**
  37821. * The list of keyboard keys used to control the left strafe move of the camera.
  37822. */
  37823. keysLeft: number[];
  37824. private _keys;
  37825. private _onCanvasBlurObserver;
  37826. private _onKeyboardObserver;
  37827. private _engine;
  37828. private _scene;
  37829. /**
  37830. * Attach the input controls to a specific dom element to get the input from.
  37831. * @param element Defines the element the controls should be listened from
  37832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37833. */
  37834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37835. /**
  37836. * Detach the current controls from the specified dom element.
  37837. * @param element Defines the element to stop listening the inputs from
  37838. */
  37839. detachControl(element: Nullable<HTMLElement>): void;
  37840. /**
  37841. * Gets the class name of the current intput.
  37842. * @returns the class name
  37843. */
  37844. getClassName(): string;
  37845. /** @hidden */
  37846. _onLostFocus(e: FocusEvent): void;
  37847. /**
  37848. * Get the friendly name associated with the input class.
  37849. * @returns the input friendly name
  37850. */
  37851. getSimpleName(): string;
  37852. /**
  37853. * Update the current camera state depending on the inputs that have been used this frame.
  37854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37855. */
  37856. checkInputs(): void;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /**
  37861. * Manage the mouse wheel inputs to control a follow camera.
  37862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37863. */
  37864. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37865. /**
  37866. * Defines the camera the input is attached to.
  37867. */
  37868. camera: FollowCamera;
  37869. /**
  37870. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37871. */
  37872. axisControlRadius: boolean;
  37873. /**
  37874. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37875. */
  37876. axisControlHeight: boolean;
  37877. /**
  37878. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37879. */
  37880. axisControlRotation: boolean;
  37881. /**
  37882. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37883. * relation to mouseWheel events.
  37884. */
  37885. wheelPrecision: number;
  37886. /**
  37887. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37888. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37889. */
  37890. wheelDeltaPercentage: number;
  37891. private _wheel;
  37892. private _observer;
  37893. /**
  37894. * Attach the input controls to a specific dom element to get the input from.
  37895. * @param element Defines the element the controls should be listened from
  37896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37897. */
  37898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37899. /**
  37900. * Detach the current controls from the specified dom element.
  37901. * @param element Defines the element to stop listening the inputs from
  37902. */
  37903. detachControl(element: Nullable<HTMLElement>): void;
  37904. /**
  37905. * Gets the class name of the current intput.
  37906. * @returns the class name
  37907. */
  37908. getClassName(): string;
  37909. /**
  37910. * Get the friendly name associated with the input class.
  37911. * @returns the input friendly name
  37912. */
  37913. getSimpleName(): string;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /**
  37918. * Manage the pointers inputs to control an follow camera.
  37919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37920. */
  37921. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37922. /**
  37923. * Defines the camera the input is attached to.
  37924. */
  37925. camera: FollowCamera;
  37926. /**
  37927. * Gets the class name of the current input.
  37928. * @returns the class name
  37929. */
  37930. getClassName(): string;
  37931. /**
  37932. * Defines the pointer angular sensibility along the X axis or how fast is
  37933. * the camera rotating.
  37934. * A negative number will reverse the axis direction.
  37935. */
  37936. angularSensibilityX: number;
  37937. /**
  37938. * Defines the pointer angular sensibility along the Y axis or how fast is
  37939. * the camera rotating.
  37940. * A negative number will reverse the axis direction.
  37941. */
  37942. angularSensibilityY: number;
  37943. /**
  37944. * Defines the pointer pinch precision or how fast is the camera zooming.
  37945. * A negative number will reverse the axis direction.
  37946. */
  37947. pinchPrecision: number;
  37948. /**
  37949. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37950. * from 0.
  37951. * It defines the percentage of current camera.radius to use as delta when
  37952. * pinch zoom is used.
  37953. */
  37954. pinchDeltaPercentage: number;
  37955. /**
  37956. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37957. */
  37958. axisXControlRadius: boolean;
  37959. /**
  37960. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37961. */
  37962. axisXControlHeight: boolean;
  37963. /**
  37964. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37965. */
  37966. axisXControlRotation: boolean;
  37967. /**
  37968. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37969. */
  37970. axisYControlRadius: boolean;
  37971. /**
  37972. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37973. */
  37974. axisYControlHeight: boolean;
  37975. /**
  37976. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37977. */
  37978. axisYControlRotation: boolean;
  37979. /**
  37980. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37981. */
  37982. axisPinchControlRadius: boolean;
  37983. /**
  37984. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37985. */
  37986. axisPinchControlHeight: boolean;
  37987. /**
  37988. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37989. */
  37990. axisPinchControlRotation: boolean;
  37991. /**
  37992. * Log error messages if basic misconfiguration has occurred.
  37993. */
  37994. warningEnable: boolean;
  37995. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37996. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37997. private _warningCounter;
  37998. private _warning;
  37999. }
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * Default Inputs manager for the FollowCamera.
  38004. * It groups all the default supported inputs for ease of use.
  38005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38006. */
  38007. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38008. /**
  38009. * Instantiates a new FollowCameraInputsManager.
  38010. * @param camera Defines the camera the inputs belong to
  38011. */
  38012. constructor(camera: FollowCamera);
  38013. /**
  38014. * Add keyboard input support to the input manager.
  38015. * @returns the current input manager
  38016. */
  38017. addKeyboard(): FollowCameraInputsManager;
  38018. /**
  38019. * Add mouse wheel input support to the input manager.
  38020. * @returns the current input manager
  38021. */
  38022. addMouseWheel(): FollowCameraInputsManager;
  38023. /**
  38024. * Add pointers input support to the input manager.
  38025. * @returns the current input manager
  38026. */
  38027. addPointers(): FollowCameraInputsManager;
  38028. /**
  38029. * Add orientation input support to the input manager.
  38030. * @returns the current input manager
  38031. */
  38032. addVRDeviceOrientation(): FollowCameraInputsManager;
  38033. }
  38034. }
  38035. declare module BABYLON {
  38036. /**
  38037. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38038. * an arc rotate version arcFollowCamera are available.
  38039. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38040. */
  38041. export class FollowCamera extends TargetCamera {
  38042. /**
  38043. * Distance the follow camera should follow an object at
  38044. */
  38045. radius: number;
  38046. /**
  38047. * Minimum allowed distance of the camera to the axis of rotation
  38048. * (The camera can not get closer).
  38049. * This can help limiting how the Camera is able to move in the scene.
  38050. */
  38051. lowerRadiusLimit: Nullable<number>;
  38052. /**
  38053. * Maximum allowed distance of the camera to the axis of rotation
  38054. * (The camera can not get further).
  38055. * This can help limiting how the Camera is able to move in the scene.
  38056. */
  38057. upperRadiusLimit: Nullable<number>;
  38058. /**
  38059. * Define a rotation offset between the camera and the object it follows
  38060. */
  38061. rotationOffset: number;
  38062. /**
  38063. * Minimum allowed angle to camera position relative to target object.
  38064. * This can help limiting how the Camera is able to move in the scene.
  38065. */
  38066. lowerRotationOffsetLimit: Nullable<number>;
  38067. /**
  38068. * Maximum allowed angle to camera position relative to target object.
  38069. * This can help limiting how the Camera is able to move in the scene.
  38070. */
  38071. upperRotationOffsetLimit: Nullable<number>;
  38072. /**
  38073. * Define a height offset between the camera and the object it follows.
  38074. * It can help following an object from the top (like a car chaing a plane)
  38075. */
  38076. heightOffset: number;
  38077. /**
  38078. * Minimum allowed height of camera position relative to target object.
  38079. * This can help limiting how the Camera is able to move in the scene.
  38080. */
  38081. lowerHeightOffsetLimit: Nullable<number>;
  38082. /**
  38083. * Maximum allowed height of camera position relative to target object.
  38084. * This can help limiting how the Camera is able to move in the scene.
  38085. */
  38086. upperHeightOffsetLimit: Nullable<number>;
  38087. /**
  38088. * Define how fast the camera can accelerate to follow it s target.
  38089. */
  38090. cameraAcceleration: number;
  38091. /**
  38092. * Define the speed limit of the camera following an object.
  38093. */
  38094. maxCameraSpeed: number;
  38095. /**
  38096. * Define the target of the camera.
  38097. */
  38098. lockedTarget: Nullable<AbstractMesh>;
  38099. /**
  38100. * Defines the input associated with the camera.
  38101. */
  38102. inputs: FollowCameraInputsManager;
  38103. /**
  38104. * Instantiates the follow camera.
  38105. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38106. * @param name Define the name of the camera in the scene
  38107. * @param position Define the position of the camera
  38108. * @param scene Define the scene the camera belong to
  38109. * @param lockedTarget Define the target of the camera
  38110. */
  38111. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38112. private _follow;
  38113. /**
  38114. * Attached controls to the current camera.
  38115. * @param element Defines the element the controls should be listened from
  38116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38117. */
  38118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38119. /**
  38120. * Detach the current controls from the camera.
  38121. * The camera will stop reacting to inputs.
  38122. * @param element Defines the element to stop listening the inputs from
  38123. */
  38124. detachControl(element: HTMLElement): void;
  38125. /** @hidden */
  38126. _checkInputs(): void;
  38127. private _checkLimits;
  38128. /**
  38129. * Gets the camera class name.
  38130. * @returns the class name
  38131. */
  38132. getClassName(): string;
  38133. }
  38134. /**
  38135. * Arc Rotate version of the follow camera.
  38136. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38137. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38138. */
  38139. export class ArcFollowCamera extends TargetCamera {
  38140. /** The longitudinal angle of the camera */
  38141. alpha: number;
  38142. /** The latitudinal angle of the camera */
  38143. beta: number;
  38144. /** The radius of the camera from its target */
  38145. radius: number;
  38146. /** Define the camera target (the messh it should follow) */
  38147. target: Nullable<AbstractMesh>;
  38148. private _cartesianCoordinates;
  38149. /**
  38150. * Instantiates a new ArcFollowCamera
  38151. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38152. * @param name Define the name of the camera
  38153. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38154. * @param beta Define the rotation angle of the camera around the elevation axis
  38155. * @param radius Define the radius of the camera from its target point
  38156. * @param target Define the target of the camera
  38157. * @param scene Define the scene the camera belongs to
  38158. */
  38159. constructor(name: string,
  38160. /** The longitudinal angle of the camera */
  38161. alpha: number,
  38162. /** The latitudinal angle of the camera */
  38163. beta: number,
  38164. /** The radius of the camera from its target */
  38165. radius: number,
  38166. /** Define the camera target (the messh it should follow) */
  38167. target: Nullable<AbstractMesh>, scene: Scene);
  38168. private _follow;
  38169. /** @hidden */
  38170. _checkInputs(): void;
  38171. /**
  38172. * Returns the class name of the object.
  38173. * It is mostly used internally for serialization purposes.
  38174. */
  38175. getClassName(): string;
  38176. }
  38177. }
  38178. declare module BABYLON {
  38179. /**
  38180. * Manage the keyboard inputs to control the movement of a follow camera.
  38181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38182. */
  38183. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38184. /**
  38185. * Defines the camera the input is attached to.
  38186. */
  38187. camera: FollowCamera;
  38188. /**
  38189. * Defines the list of key codes associated with the up action (increase heightOffset)
  38190. */
  38191. keysHeightOffsetIncr: number[];
  38192. /**
  38193. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38194. */
  38195. keysHeightOffsetDecr: number[];
  38196. /**
  38197. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38198. */
  38199. keysHeightOffsetModifierAlt: boolean;
  38200. /**
  38201. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38202. */
  38203. keysHeightOffsetModifierCtrl: boolean;
  38204. /**
  38205. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38206. */
  38207. keysHeightOffsetModifierShift: boolean;
  38208. /**
  38209. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38210. */
  38211. keysRotationOffsetIncr: number[];
  38212. /**
  38213. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38214. */
  38215. keysRotationOffsetDecr: number[];
  38216. /**
  38217. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38218. */
  38219. keysRotationOffsetModifierAlt: boolean;
  38220. /**
  38221. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38222. */
  38223. keysRotationOffsetModifierCtrl: boolean;
  38224. /**
  38225. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38226. */
  38227. keysRotationOffsetModifierShift: boolean;
  38228. /**
  38229. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38230. */
  38231. keysRadiusIncr: number[];
  38232. /**
  38233. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38234. */
  38235. keysRadiusDecr: number[];
  38236. /**
  38237. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38238. */
  38239. keysRadiusModifierAlt: boolean;
  38240. /**
  38241. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38242. */
  38243. keysRadiusModifierCtrl: boolean;
  38244. /**
  38245. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38246. */
  38247. keysRadiusModifierShift: boolean;
  38248. /**
  38249. * Defines the rate of change of heightOffset.
  38250. */
  38251. heightSensibility: number;
  38252. /**
  38253. * Defines the rate of change of rotationOffset.
  38254. */
  38255. rotationSensibility: number;
  38256. /**
  38257. * Defines the rate of change of radius.
  38258. */
  38259. radiusSensibility: number;
  38260. private _keys;
  38261. private _ctrlPressed;
  38262. private _altPressed;
  38263. private _shiftPressed;
  38264. private _onCanvasBlurObserver;
  38265. private _onKeyboardObserver;
  38266. private _engine;
  38267. private _scene;
  38268. /**
  38269. * Attach the input controls to a specific dom element to get the input from.
  38270. * @param element Defines the element the controls should be listened from
  38271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38272. */
  38273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38274. /**
  38275. * Detach the current controls from the specified dom element.
  38276. * @param element Defines the element to stop listening the inputs from
  38277. */
  38278. detachControl(element: Nullable<HTMLElement>): void;
  38279. /**
  38280. * Update the current camera state depending on the inputs that have been used this frame.
  38281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38282. */
  38283. checkInputs(): void;
  38284. /**
  38285. * Gets the class name of the current input.
  38286. * @returns the class name
  38287. */
  38288. getClassName(): string;
  38289. /**
  38290. * Get the friendly name associated with the input class.
  38291. * @returns the input friendly name
  38292. */
  38293. getSimpleName(): string;
  38294. /**
  38295. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38296. * allow modification of the heightOffset value.
  38297. */
  38298. private _modifierHeightOffset;
  38299. /**
  38300. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38301. * allow modification of the rotationOffset value.
  38302. */
  38303. private _modifierRotationOffset;
  38304. /**
  38305. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38306. * allow modification of the radius value.
  38307. */
  38308. private _modifierRadius;
  38309. }
  38310. }
  38311. declare module BABYLON {
  38312. interface FreeCameraInputsManager {
  38313. /**
  38314. * @hidden
  38315. */
  38316. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38317. /**
  38318. * Add orientation input support to the input manager.
  38319. * @returns the current input manager
  38320. */
  38321. addDeviceOrientation(): FreeCameraInputsManager;
  38322. }
  38323. /**
  38324. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38325. * Screen rotation is taken into account.
  38326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38327. */
  38328. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38329. private _camera;
  38330. private _screenOrientationAngle;
  38331. private _constantTranform;
  38332. private _screenQuaternion;
  38333. private _alpha;
  38334. private _beta;
  38335. private _gamma;
  38336. /**
  38337. * Can be used to detect if a device orientation sensor is availible on a device
  38338. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38339. * @returns a promise that will resolve on orientation change
  38340. */
  38341. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38342. /**
  38343. * @hidden
  38344. */
  38345. _onDeviceOrientationChangedObservable: Observable<void>;
  38346. /**
  38347. * Instantiates a new input
  38348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38349. */
  38350. constructor();
  38351. /**
  38352. * Define the camera controlled by the input.
  38353. */
  38354. camera: FreeCamera;
  38355. /**
  38356. * Attach the input controls to a specific dom element to get the input from.
  38357. * @param element Defines the element the controls should be listened from
  38358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38359. */
  38360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38361. private _orientationChanged;
  38362. private _deviceOrientation;
  38363. /**
  38364. * Detach the current controls from the specified dom element.
  38365. * @param element Defines the element to stop listening the inputs from
  38366. */
  38367. detachControl(element: Nullable<HTMLElement>): void;
  38368. /**
  38369. * Update the current camera state depending on the inputs that have been used this frame.
  38370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38371. */
  38372. checkInputs(): void;
  38373. /**
  38374. * Gets the class name of the current intput.
  38375. * @returns the class name
  38376. */
  38377. getClassName(): string;
  38378. /**
  38379. * Get the friendly name associated with the input class.
  38380. * @returns the input friendly name
  38381. */
  38382. getSimpleName(): string;
  38383. }
  38384. }
  38385. declare module BABYLON {
  38386. /**
  38387. * Manage the gamepad inputs to control a free camera.
  38388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38389. */
  38390. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38391. /**
  38392. * Define the camera the input is attached to.
  38393. */
  38394. camera: FreeCamera;
  38395. /**
  38396. * Define the Gamepad controlling the input
  38397. */
  38398. gamepad: Nullable<Gamepad>;
  38399. /**
  38400. * Defines the gamepad rotation sensiblity.
  38401. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38402. */
  38403. gamepadAngularSensibility: number;
  38404. /**
  38405. * Defines the gamepad move sensiblity.
  38406. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38407. */
  38408. gamepadMoveSensibility: number;
  38409. private _onGamepadConnectedObserver;
  38410. private _onGamepadDisconnectedObserver;
  38411. private _cameraTransform;
  38412. private _deltaTransform;
  38413. private _vector3;
  38414. private _vector2;
  38415. /**
  38416. * Attach the input controls to a specific dom element to get the input from.
  38417. * @param element Defines the element the controls should be listened from
  38418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38419. */
  38420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38421. /**
  38422. * Detach the current controls from the specified dom element.
  38423. * @param element Defines the element to stop listening the inputs from
  38424. */
  38425. detachControl(element: Nullable<HTMLElement>): void;
  38426. /**
  38427. * Update the current camera state depending on the inputs that have been used this frame.
  38428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38429. */
  38430. checkInputs(): void;
  38431. /**
  38432. * Gets the class name of the current intput.
  38433. * @returns the class name
  38434. */
  38435. getClassName(): string;
  38436. /**
  38437. * Get the friendly name associated with the input class.
  38438. * @returns the input friendly name
  38439. */
  38440. getSimpleName(): string;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Defines the potential axis of a Joystick
  38446. */
  38447. export enum JoystickAxis {
  38448. /** X axis */
  38449. X = 0,
  38450. /** Y axis */
  38451. Y = 1,
  38452. /** Z axis */
  38453. Z = 2
  38454. }
  38455. /**
  38456. * Class used to define virtual joystick (used in touch mode)
  38457. */
  38458. export class VirtualJoystick {
  38459. /**
  38460. * Gets or sets a boolean indicating that left and right values must be inverted
  38461. */
  38462. reverseLeftRight: boolean;
  38463. /**
  38464. * Gets or sets a boolean indicating that up and down values must be inverted
  38465. */
  38466. reverseUpDown: boolean;
  38467. /**
  38468. * Gets the offset value for the position (ie. the change of the position value)
  38469. */
  38470. deltaPosition: Vector3;
  38471. /**
  38472. * Gets a boolean indicating if the virtual joystick was pressed
  38473. */
  38474. pressed: boolean;
  38475. /**
  38476. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38477. */
  38478. static Canvas: Nullable<HTMLCanvasElement>;
  38479. private static _globalJoystickIndex;
  38480. private static vjCanvasContext;
  38481. private static vjCanvasWidth;
  38482. private static vjCanvasHeight;
  38483. private static halfWidth;
  38484. private _action;
  38485. private _axisTargetedByLeftAndRight;
  38486. private _axisTargetedByUpAndDown;
  38487. private _joystickSensibility;
  38488. private _inversedSensibility;
  38489. private _joystickPointerID;
  38490. private _joystickColor;
  38491. private _joystickPointerPos;
  38492. private _joystickPreviousPointerPos;
  38493. private _joystickPointerStartPos;
  38494. private _deltaJoystickVector;
  38495. private _leftJoystick;
  38496. private _touches;
  38497. private _onPointerDownHandlerRef;
  38498. private _onPointerMoveHandlerRef;
  38499. private _onPointerUpHandlerRef;
  38500. private _onResize;
  38501. /**
  38502. * Creates a new virtual joystick
  38503. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38504. */
  38505. constructor(leftJoystick?: boolean);
  38506. /**
  38507. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38508. * @param newJoystickSensibility defines the new sensibility
  38509. */
  38510. setJoystickSensibility(newJoystickSensibility: number): void;
  38511. private _onPointerDown;
  38512. private _onPointerMove;
  38513. private _onPointerUp;
  38514. /**
  38515. * Change the color of the virtual joystick
  38516. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38517. */
  38518. setJoystickColor(newColor: string): void;
  38519. /**
  38520. * Defines a callback to call when the joystick is touched
  38521. * @param action defines the callback
  38522. */
  38523. setActionOnTouch(action: () => any): void;
  38524. /**
  38525. * Defines which axis you'd like to control for left & right
  38526. * @param axis defines the axis to use
  38527. */
  38528. setAxisForLeftRight(axis: JoystickAxis): void;
  38529. /**
  38530. * Defines which axis you'd like to control for up & down
  38531. * @param axis defines the axis to use
  38532. */
  38533. setAxisForUpDown(axis: JoystickAxis): void;
  38534. private _drawVirtualJoystick;
  38535. /**
  38536. * Release internal HTML canvas
  38537. */
  38538. releaseCanvas(): void;
  38539. }
  38540. }
  38541. declare module BABYLON {
  38542. interface FreeCameraInputsManager {
  38543. /**
  38544. * Add virtual joystick input support to the input manager.
  38545. * @returns the current input manager
  38546. */
  38547. addVirtualJoystick(): FreeCameraInputsManager;
  38548. }
  38549. /**
  38550. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38552. */
  38553. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38554. /**
  38555. * Defines the camera the input is attached to.
  38556. */
  38557. camera: FreeCamera;
  38558. private _leftjoystick;
  38559. private _rightjoystick;
  38560. /**
  38561. * Gets the left stick of the virtual joystick.
  38562. * @returns The virtual Joystick
  38563. */
  38564. getLeftJoystick(): VirtualJoystick;
  38565. /**
  38566. * Gets the right stick of the virtual joystick.
  38567. * @returns The virtual Joystick
  38568. */
  38569. getRightJoystick(): VirtualJoystick;
  38570. /**
  38571. * Update the current camera state depending on the inputs that have been used this frame.
  38572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38573. */
  38574. checkInputs(): void;
  38575. /**
  38576. * Attach the input controls to a specific dom element to get the input from.
  38577. * @param element Defines the element the controls should be listened from
  38578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38579. */
  38580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38581. /**
  38582. * Detach the current controls from the specified dom element.
  38583. * @param element Defines the element to stop listening the inputs from
  38584. */
  38585. detachControl(element: Nullable<HTMLElement>): void;
  38586. /**
  38587. * Gets the class name of the current intput.
  38588. * @returns the class name
  38589. */
  38590. getClassName(): string;
  38591. /**
  38592. * Get the friendly name associated with the input class.
  38593. * @returns the input friendly name
  38594. */
  38595. getSimpleName(): string;
  38596. }
  38597. }
  38598. declare module BABYLON {
  38599. /**
  38600. * This represents a FPS type of camera controlled by touch.
  38601. * This is like a universal camera minus the Gamepad controls.
  38602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38603. */
  38604. export class TouchCamera extends FreeCamera {
  38605. /**
  38606. * Defines the touch sensibility for rotation.
  38607. * The higher the faster.
  38608. */
  38609. touchAngularSensibility: number;
  38610. /**
  38611. * Defines the touch sensibility for move.
  38612. * The higher the faster.
  38613. */
  38614. touchMoveSensibility: number;
  38615. /**
  38616. * Instantiates a new touch camera.
  38617. * This represents a FPS type of camera controlled by touch.
  38618. * This is like a universal camera minus the Gamepad controls.
  38619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38620. * @param name Define the name of the camera in the scene
  38621. * @param position Define the start position of the camera in the scene
  38622. * @param scene Define the scene the camera belongs to
  38623. */
  38624. constructor(name: string, position: Vector3, scene: Scene);
  38625. /**
  38626. * Gets the current object class name.
  38627. * @return the class name
  38628. */
  38629. getClassName(): string;
  38630. /** @hidden */
  38631. _setupInputs(): void;
  38632. }
  38633. }
  38634. declare module BABYLON {
  38635. /**
  38636. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38637. * being tilted forward or back and left or right.
  38638. */
  38639. export class DeviceOrientationCamera extends FreeCamera {
  38640. private _initialQuaternion;
  38641. private _quaternionCache;
  38642. private _tmpDragQuaternion;
  38643. private _disablePointerInputWhenUsingDeviceOrientation;
  38644. /**
  38645. * Creates a new device orientation camera
  38646. * @param name The name of the camera
  38647. * @param position The start position camera
  38648. * @param scene The scene the camera belongs to
  38649. */
  38650. constructor(name: string, position: Vector3, scene: Scene);
  38651. /**
  38652. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38653. */
  38654. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38655. private _dragFactor;
  38656. /**
  38657. * Enabled turning on the y axis when the orientation sensor is active
  38658. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38659. */
  38660. enableHorizontalDragging(dragFactor?: number): void;
  38661. /**
  38662. * Gets the current instance class name ("DeviceOrientationCamera").
  38663. * This helps avoiding instanceof at run time.
  38664. * @returns the class name
  38665. */
  38666. getClassName(): string;
  38667. /**
  38668. * @hidden
  38669. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38670. */
  38671. _checkInputs(): void;
  38672. /**
  38673. * Reset the camera to its default orientation on the specified axis only.
  38674. * @param axis The axis to reset
  38675. */
  38676. resetToCurrentRotation(axis?: Axis): void;
  38677. }
  38678. }
  38679. declare module BABYLON {
  38680. /**
  38681. * Defines supported buttons for XBox360 compatible gamepads
  38682. */
  38683. export enum Xbox360Button {
  38684. /** A */
  38685. A = 0,
  38686. /** B */
  38687. B = 1,
  38688. /** X */
  38689. X = 2,
  38690. /** Y */
  38691. Y = 3,
  38692. /** Start */
  38693. Start = 4,
  38694. /** Back */
  38695. Back = 5,
  38696. /** Left button */
  38697. LB = 6,
  38698. /** Right button */
  38699. RB = 7,
  38700. /** Left stick */
  38701. LeftStick = 8,
  38702. /** Right stick */
  38703. RightStick = 9
  38704. }
  38705. /** Defines values for XBox360 DPad */
  38706. export enum Xbox360Dpad {
  38707. /** Up */
  38708. Up = 0,
  38709. /** Down */
  38710. Down = 1,
  38711. /** Left */
  38712. Left = 2,
  38713. /** Right */
  38714. Right = 3
  38715. }
  38716. /**
  38717. * Defines a XBox360 gamepad
  38718. */
  38719. export class Xbox360Pad extends Gamepad {
  38720. private _leftTrigger;
  38721. private _rightTrigger;
  38722. private _onlefttriggerchanged;
  38723. private _onrighttriggerchanged;
  38724. private _onbuttondown;
  38725. private _onbuttonup;
  38726. private _ondpaddown;
  38727. private _ondpadup;
  38728. /** Observable raised when a button is pressed */
  38729. onButtonDownObservable: Observable<Xbox360Button>;
  38730. /** Observable raised when a button is released */
  38731. onButtonUpObservable: Observable<Xbox360Button>;
  38732. /** Observable raised when a pad is pressed */
  38733. onPadDownObservable: Observable<Xbox360Dpad>;
  38734. /** Observable raised when a pad is released */
  38735. onPadUpObservable: Observable<Xbox360Dpad>;
  38736. private _buttonA;
  38737. private _buttonB;
  38738. private _buttonX;
  38739. private _buttonY;
  38740. private _buttonBack;
  38741. private _buttonStart;
  38742. private _buttonLB;
  38743. private _buttonRB;
  38744. private _buttonLeftStick;
  38745. private _buttonRightStick;
  38746. private _dPadUp;
  38747. private _dPadDown;
  38748. private _dPadLeft;
  38749. private _dPadRight;
  38750. private _isXboxOnePad;
  38751. /**
  38752. * Creates a new XBox360 gamepad object
  38753. * @param id defines the id of this gamepad
  38754. * @param index defines its index
  38755. * @param gamepad defines the internal HTML gamepad object
  38756. * @param xboxOne defines if it is a XBox One gamepad
  38757. */
  38758. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38759. /**
  38760. * Defines the callback to call when left trigger is pressed
  38761. * @param callback defines the callback to use
  38762. */
  38763. onlefttriggerchanged(callback: (value: number) => void): void;
  38764. /**
  38765. * Defines the callback to call when right trigger is pressed
  38766. * @param callback defines the callback to use
  38767. */
  38768. onrighttriggerchanged(callback: (value: number) => void): void;
  38769. /**
  38770. * Gets the left trigger value
  38771. */
  38772. /**
  38773. * Sets the left trigger value
  38774. */
  38775. leftTrigger: number;
  38776. /**
  38777. * Gets the right trigger value
  38778. */
  38779. /**
  38780. * Sets the right trigger value
  38781. */
  38782. rightTrigger: number;
  38783. /**
  38784. * Defines the callback to call when a button is pressed
  38785. * @param callback defines the callback to use
  38786. */
  38787. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38788. /**
  38789. * Defines the callback to call when a button is released
  38790. * @param callback defines the callback to use
  38791. */
  38792. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38793. /**
  38794. * Defines the callback to call when a pad is pressed
  38795. * @param callback defines the callback to use
  38796. */
  38797. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38798. /**
  38799. * Defines the callback to call when a pad is released
  38800. * @param callback defines the callback to use
  38801. */
  38802. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38803. private _setButtonValue;
  38804. private _setDPadValue;
  38805. /**
  38806. * Gets the value of the `A` button
  38807. */
  38808. /**
  38809. * Sets the value of the `A` button
  38810. */
  38811. buttonA: number;
  38812. /**
  38813. * Gets the value of the `B` button
  38814. */
  38815. /**
  38816. * Sets the value of the `B` button
  38817. */
  38818. buttonB: number;
  38819. /**
  38820. * Gets the value of the `X` button
  38821. */
  38822. /**
  38823. * Sets the value of the `X` button
  38824. */
  38825. buttonX: number;
  38826. /**
  38827. * Gets the value of the `Y` button
  38828. */
  38829. /**
  38830. * Sets the value of the `Y` button
  38831. */
  38832. buttonY: number;
  38833. /**
  38834. * Gets the value of the `Start` button
  38835. */
  38836. /**
  38837. * Sets the value of the `Start` button
  38838. */
  38839. buttonStart: number;
  38840. /**
  38841. * Gets the value of the `Back` button
  38842. */
  38843. /**
  38844. * Sets the value of the `Back` button
  38845. */
  38846. buttonBack: number;
  38847. /**
  38848. * Gets the value of the `Left` button
  38849. */
  38850. /**
  38851. * Sets the value of the `Left` button
  38852. */
  38853. buttonLB: number;
  38854. /**
  38855. * Gets the value of the `Right` button
  38856. */
  38857. /**
  38858. * Sets the value of the `Right` button
  38859. */
  38860. buttonRB: number;
  38861. /**
  38862. * Gets the value of the Left joystick
  38863. */
  38864. /**
  38865. * Sets the value of the Left joystick
  38866. */
  38867. buttonLeftStick: number;
  38868. /**
  38869. * Gets the value of the Right joystick
  38870. */
  38871. /**
  38872. * Sets the value of the Right joystick
  38873. */
  38874. buttonRightStick: number;
  38875. /**
  38876. * Gets the value of D-pad up
  38877. */
  38878. /**
  38879. * Sets the value of D-pad up
  38880. */
  38881. dPadUp: number;
  38882. /**
  38883. * Gets the value of D-pad down
  38884. */
  38885. /**
  38886. * Sets the value of D-pad down
  38887. */
  38888. dPadDown: number;
  38889. /**
  38890. * Gets the value of D-pad left
  38891. */
  38892. /**
  38893. * Sets the value of D-pad left
  38894. */
  38895. dPadLeft: number;
  38896. /**
  38897. * Gets the value of D-pad right
  38898. */
  38899. /**
  38900. * Sets the value of D-pad right
  38901. */
  38902. dPadRight: number;
  38903. /**
  38904. * Force the gamepad to synchronize with device values
  38905. */
  38906. update(): void;
  38907. /**
  38908. * Disposes the gamepad
  38909. */
  38910. dispose(): void;
  38911. }
  38912. }
  38913. declare module BABYLON {
  38914. /**
  38915. * Defines supported buttons for DualShock compatible gamepads
  38916. */
  38917. export enum DualShockButton {
  38918. /** Cross */
  38919. Cross = 0,
  38920. /** Circle */
  38921. Circle = 1,
  38922. /** Square */
  38923. Square = 2,
  38924. /** Triangle */
  38925. Triangle = 3,
  38926. /** Options */
  38927. Options = 4,
  38928. /** Share */
  38929. Share = 5,
  38930. /** L1 */
  38931. L1 = 6,
  38932. /** R1 */
  38933. R1 = 7,
  38934. /** Left stick */
  38935. LeftStick = 8,
  38936. /** Right stick */
  38937. RightStick = 9
  38938. }
  38939. /** Defines values for DualShock DPad */
  38940. export enum DualShockDpad {
  38941. /** Up */
  38942. Up = 0,
  38943. /** Down */
  38944. Down = 1,
  38945. /** Left */
  38946. Left = 2,
  38947. /** Right */
  38948. Right = 3
  38949. }
  38950. /**
  38951. * Defines a DualShock gamepad
  38952. */
  38953. export class DualShockPad extends Gamepad {
  38954. private _leftTrigger;
  38955. private _rightTrigger;
  38956. private _onlefttriggerchanged;
  38957. private _onrighttriggerchanged;
  38958. private _onbuttondown;
  38959. private _onbuttonup;
  38960. private _ondpaddown;
  38961. private _ondpadup;
  38962. /** Observable raised when a button is pressed */
  38963. onButtonDownObservable: Observable<DualShockButton>;
  38964. /** Observable raised when a button is released */
  38965. onButtonUpObservable: Observable<DualShockButton>;
  38966. /** Observable raised when a pad is pressed */
  38967. onPadDownObservable: Observable<DualShockDpad>;
  38968. /** Observable raised when a pad is released */
  38969. onPadUpObservable: Observable<DualShockDpad>;
  38970. private _buttonCross;
  38971. private _buttonCircle;
  38972. private _buttonSquare;
  38973. private _buttonTriangle;
  38974. private _buttonShare;
  38975. private _buttonOptions;
  38976. private _buttonL1;
  38977. private _buttonR1;
  38978. private _buttonLeftStick;
  38979. private _buttonRightStick;
  38980. private _dPadUp;
  38981. private _dPadDown;
  38982. private _dPadLeft;
  38983. private _dPadRight;
  38984. /**
  38985. * Creates a new DualShock gamepad object
  38986. * @param id defines the id of this gamepad
  38987. * @param index defines its index
  38988. * @param gamepad defines the internal HTML gamepad object
  38989. */
  38990. constructor(id: string, index: number, gamepad: any);
  38991. /**
  38992. * Defines the callback to call when left trigger is pressed
  38993. * @param callback defines the callback to use
  38994. */
  38995. onlefttriggerchanged(callback: (value: number) => void): void;
  38996. /**
  38997. * Defines the callback to call when right trigger is pressed
  38998. * @param callback defines the callback to use
  38999. */
  39000. onrighttriggerchanged(callback: (value: number) => void): void;
  39001. /**
  39002. * Gets the left trigger value
  39003. */
  39004. /**
  39005. * Sets the left trigger value
  39006. */
  39007. leftTrigger: number;
  39008. /**
  39009. * Gets the right trigger value
  39010. */
  39011. /**
  39012. * Sets the right trigger value
  39013. */
  39014. rightTrigger: number;
  39015. /**
  39016. * Defines the callback to call when a button is pressed
  39017. * @param callback defines the callback to use
  39018. */
  39019. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39020. /**
  39021. * Defines the callback to call when a button is released
  39022. * @param callback defines the callback to use
  39023. */
  39024. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39025. /**
  39026. * Defines the callback to call when a pad is pressed
  39027. * @param callback defines the callback to use
  39028. */
  39029. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39030. /**
  39031. * Defines the callback to call when a pad is released
  39032. * @param callback defines the callback to use
  39033. */
  39034. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39035. private _setButtonValue;
  39036. private _setDPadValue;
  39037. /**
  39038. * Gets the value of the `Cross` button
  39039. */
  39040. /**
  39041. * Sets the value of the `Cross` button
  39042. */
  39043. buttonCross: number;
  39044. /**
  39045. * Gets the value of the `Circle` button
  39046. */
  39047. /**
  39048. * Sets the value of the `Circle` button
  39049. */
  39050. buttonCircle: number;
  39051. /**
  39052. * Gets the value of the `Square` button
  39053. */
  39054. /**
  39055. * Sets the value of the `Square` button
  39056. */
  39057. buttonSquare: number;
  39058. /**
  39059. * Gets the value of the `Triangle` button
  39060. */
  39061. /**
  39062. * Sets the value of the `Triangle` button
  39063. */
  39064. buttonTriangle: number;
  39065. /**
  39066. * Gets the value of the `Options` button
  39067. */
  39068. /**
  39069. * Sets the value of the `Options` button
  39070. */
  39071. buttonOptions: number;
  39072. /**
  39073. * Gets the value of the `Share` button
  39074. */
  39075. /**
  39076. * Sets the value of the `Share` button
  39077. */
  39078. buttonShare: number;
  39079. /**
  39080. * Gets the value of the `L1` button
  39081. */
  39082. /**
  39083. * Sets the value of the `L1` button
  39084. */
  39085. buttonL1: number;
  39086. /**
  39087. * Gets the value of the `R1` button
  39088. */
  39089. /**
  39090. * Sets the value of the `R1` button
  39091. */
  39092. buttonR1: number;
  39093. /**
  39094. * Gets the value of the Left joystick
  39095. */
  39096. /**
  39097. * Sets the value of the Left joystick
  39098. */
  39099. buttonLeftStick: number;
  39100. /**
  39101. * Gets the value of the Right joystick
  39102. */
  39103. /**
  39104. * Sets the value of the Right joystick
  39105. */
  39106. buttonRightStick: number;
  39107. /**
  39108. * Gets the value of D-pad up
  39109. */
  39110. /**
  39111. * Sets the value of D-pad up
  39112. */
  39113. dPadUp: number;
  39114. /**
  39115. * Gets the value of D-pad down
  39116. */
  39117. /**
  39118. * Sets the value of D-pad down
  39119. */
  39120. dPadDown: number;
  39121. /**
  39122. * Gets the value of D-pad left
  39123. */
  39124. /**
  39125. * Sets the value of D-pad left
  39126. */
  39127. dPadLeft: number;
  39128. /**
  39129. * Gets the value of D-pad right
  39130. */
  39131. /**
  39132. * Sets the value of D-pad right
  39133. */
  39134. dPadRight: number;
  39135. /**
  39136. * Force the gamepad to synchronize with device values
  39137. */
  39138. update(): void;
  39139. /**
  39140. * Disposes the gamepad
  39141. */
  39142. dispose(): void;
  39143. }
  39144. }
  39145. declare module BABYLON {
  39146. /**
  39147. * Manager for handling gamepads
  39148. */
  39149. export class GamepadManager {
  39150. private _scene?;
  39151. private _babylonGamepads;
  39152. private _oneGamepadConnected;
  39153. /** @hidden */
  39154. _isMonitoring: boolean;
  39155. private _gamepadEventSupported;
  39156. private _gamepadSupport;
  39157. /**
  39158. * observable to be triggered when the gamepad controller has been connected
  39159. */
  39160. onGamepadConnectedObservable: Observable<Gamepad>;
  39161. /**
  39162. * observable to be triggered when the gamepad controller has been disconnected
  39163. */
  39164. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39165. private _onGamepadConnectedEvent;
  39166. private _onGamepadDisconnectedEvent;
  39167. /**
  39168. * Initializes the gamepad manager
  39169. * @param _scene BabylonJS scene
  39170. */
  39171. constructor(_scene?: Scene | undefined);
  39172. /**
  39173. * The gamepads in the game pad manager
  39174. */
  39175. readonly gamepads: Gamepad[];
  39176. /**
  39177. * Get the gamepad controllers based on type
  39178. * @param type The type of gamepad controller
  39179. * @returns Nullable gamepad
  39180. */
  39181. getGamepadByType(type?: number): Nullable<Gamepad>;
  39182. /**
  39183. * Disposes the gamepad manager
  39184. */
  39185. dispose(): void;
  39186. private _addNewGamepad;
  39187. private _startMonitoringGamepads;
  39188. private _stopMonitoringGamepads;
  39189. /** @hidden */
  39190. _checkGamepadsStatus(): void;
  39191. private _updateGamepadObjects;
  39192. }
  39193. }
  39194. declare module BABYLON {
  39195. interface Scene {
  39196. /** @hidden */
  39197. _gamepadManager: Nullable<GamepadManager>;
  39198. /**
  39199. * Gets the gamepad manager associated with the scene
  39200. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39201. */
  39202. gamepadManager: GamepadManager;
  39203. }
  39204. /**
  39205. * Interface representing a free camera inputs manager
  39206. */
  39207. interface FreeCameraInputsManager {
  39208. /**
  39209. * Adds gamepad input support to the FreeCameraInputsManager.
  39210. * @returns the FreeCameraInputsManager
  39211. */
  39212. addGamepad(): FreeCameraInputsManager;
  39213. }
  39214. /**
  39215. * Interface representing an arc rotate camera inputs manager
  39216. */
  39217. interface ArcRotateCameraInputsManager {
  39218. /**
  39219. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39220. * @returns the camera inputs manager
  39221. */
  39222. addGamepad(): ArcRotateCameraInputsManager;
  39223. }
  39224. /**
  39225. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39226. */
  39227. export class GamepadSystemSceneComponent implements ISceneComponent {
  39228. /**
  39229. * The component name helpfull to identify the component in the list of scene components.
  39230. */
  39231. readonly name: string;
  39232. /**
  39233. * The scene the component belongs to.
  39234. */
  39235. scene: Scene;
  39236. /**
  39237. * Creates a new instance of the component for the given scene
  39238. * @param scene Defines the scene to register the component in
  39239. */
  39240. constructor(scene: Scene);
  39241. /**
  39242. * Registers the component in a given scene
  39243. */
  39244. register(): void;
  39245. /**
  39246. * Rebuilds the elements related to this component in case of
  39247. * context lost for instance.
  39248. */
  39249. rebuild(): void;
  39250. /**
  39251. * Disposes the component and the associated ressources
  39252. */
  39253. dispose(): void;
  39254. private _beforeCameraUpdate;
  39255. }
  39256. }
  39257. declare module BABYLON {
  39258. /**
  39259. * 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,
  39260. * which still works and will still be found in many Playgrounds.
  39261. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39262. */
  39263. export class UniversalCamera extends TouchCamera {
  39264. /**
  39265. * Defines the gamepad rotation sensiblity.
  39266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39267. */
  39268. gamepadAngularSensibility: number;
  39269. /**
  39270. * Defines the gamepad move sensiblity.
  39271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39272. */
  39273. gamepadMoveSensibility: number;
  39274. /**
  39275. * 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,
  39276. * which still works and will still be found in many Playgrounds.
  39277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39278. * @param name Define the name of the camera in the scene
  39279. * @param position Define the start position of the camera in the scene
  39280. * @param scene Define the scene the camera belongs to
  39281. */
  39282. constructor(name: string, position: Vector3, scene: Scene);
  39283. /**
  39284. * Gets the current object class name.
  39285. * @return the class name
  39286. */
  39287. getClassName(): string;
  39288. }
  39289. }
  39290. declare module BABYLON {
  39291. /**
  39292. * This represents a FPS type of camera. This is only here for back compat purpose.
  39293. * Please use the UniversalCamera instead as both are identical.
  39294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39295. */
  39296. export class GamepadCamera extends UniversalCamera {
  39297. /**
  39298. * Instantiates a new Gamepad Camera
  39299. * This represents a FPS type of camera. This is only here for back compat purpose.
  39300. * Please use the UniversalCamera instead as both are identical.
  39301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39302. * @param name Define the name of the camera in the scene
  39303. * @param position Define the start position of the camera in the scene
  39304. * @param scene Define the scene the camera belongs to
  39305. */
  39306. constructor(name: string, position: Vector3, scene: Scene);
  39307. /**
  39308. * Gets the current object class name.
  39309. * @return the class name
  39310. */
  39311. getClassName(): string;
  39312. }
  39313. }
  39314. declare module BABYLON {
  39315. /** @hidden */
  39316. export var passPixelShader: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module BABYLON {
  39322. /** @hidden */
  39323. export var passCubePixelShader: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module BABYLON {
  39329. /**
  39330. * PassPostProcess which produces an output the same as it's input
  39331. */
  39332. export class PassPostProcess extends PostProcess {
  39333. /**
  39334. * Creates the PassPostProcess
  39335. * @param name The name of the effect.
  39336. * @param options The required width/height ratio to downsize to before computing the render pass.
  39337. * @param camera The camera to apply the render pass to.
  39338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39339. * @param engine The engine which the post process will be applied. (default: current engine)
  39340. * @param reusable If the post process can be reused on the same frame. (default: false)
  39341. * @param textureType The type of texture to be used when performing the post processing.
  39342. * @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)
  39343. */
  39344. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39345. }
  39346. /**
  39347. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39348. */
  39349. export class PassCubePostProcess extends PostProcess {
  39350. private _face;
  39351. /**
  39352. * Gets or sets the cube face to display.
  39353. * * 0 is +X
  39354. * * 1 is -X
  39355. * * 2 is +Y
  39356. * * 3 is -Y
  39357. * * 4 is +Z
  39358. * * 5 is -Z
  39359. */
  39360. face: number;
  39361. /**
  39362. * Creates the PassCubePostProcess
  39363. * @param name The name of the effect.
  39364. * @param options The required width/height ratio to downsize to before computing the render pass.
  39365. * @param camera The camera to apply the render pass to.
  39366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39367. * @param engine The engine which the post process will be applied. (default: current engine)
  39368. * @param reusable If the post process can be reused on the same frame. (default: false)
  39369. * @param textureType The type of texture to be used when performing the post processing.
  39370. * @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)
  39371. */
  39372. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39373. }
  39374. }
  39375. declare module BABYLON {
  39376. /** @hidden */
  39377. export var anaglyphPixelShader: {
  39378. name: string;
  39379. shader: string;
  39380. };
  39381. }
  39382. declare module BABYLON {
  39383. /**
  39384. * Postprocess used to generate anaglyphic rendering
  39385. */
  39386. export class AnaglyphPostProcess extends PostProcess {
  39387. private _passedProcess;
  39388. /**
  39389. * Creates a new AnaglyphPostProcess
  39390. * @param name defines postprocess name
  39391. * @param options defines creation options or target ratio scale
  39392. * @param rigCameras defines cameras using this postprocess
  39393. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39394. * @param engine defines hosting engine
  39395. * @param reusable defines if the postprocess will be reused multiple times per frame
  39396. */
  39397. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39398. }
  39399. }
  39400. declare module BABYLON {
  39401. /**
  39402. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39404. */
  39405. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39406. /**
  39407. * Creates a new AnaglyphArcRotateCamera
  39408. * @param name defines camera name
  39409. * @param alpha defines alpha angle (in radians)
  39410. * @param beta defines beta angle (in radians)
  39411. * @param radius defines radius
  39412. * @param target defines camera target
  39413. * @param interaxialDistance defines distance between each color axis
  39414. * @param scene defines the hosting scene
  39415. */
  39416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39417. /**
  39418. * Gets camera class name
  39419. * @returns AnaglyphArcRotateCamera
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39428. */
  39429. export class AnaglyphFreeCamera extends FreeCamera {
  39430. /**
  39431. * Creates a new AnaglyphFreeCamera
  39432. * @param name defines camera name
  39433. * @param position defines initial position
  39434. * @param interaxialDistance defines distance between each color axis
  39435. * @param scene defines the hosting scene
  39436. */
  39437. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39438. /**
  39439. * Gets camera class name
  39440. * @returns AnaglyphFreeCamera
  39441. */
  39442. getClassName(): string;
  39443. }
  39444. }
  39445. declare module BABYLON {
  39446. /**
  39447. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39449. */
  39450. export class AnaglyphGamepadCamera extends GamepadCamera {
  39451. /**
  39452. * Creates a new AnaglyphGamepadCamera
  39453. * @param name defines camera name
  39454. * @param position defines initial position
  39455. * @param interaxialDistance defines distance between each color axis
  39456. * @param scene defines the hosting scene
  39457. */
  39458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39459. /**
  39460. * Gets camera class name
  39461. * @returns AnaglyphGamepadCamera
  39462. */
  39463. getClassName(): string;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39469. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39470. */
  39471. export class AnaglyphUniversalCamera extends UniversalCamera {
  39472. /**
  39473. * Creates a new AnaglyphUniversalCamera
  39474. * @param name defines camera name
  39475. * @param position defines initial position
  39476. * @param interaxialDistance defines distance between each color axis
  39477. * @param scene defines the hosting scene
  39478. */
  39479. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39480. /**
  39481. * Gets camera class name
  39482. * @returns AnaglyphUniversalCamera
  39483. */
  39484. getClassName(): string;
  39485. }
  39486. }
  39487. declare module BABYLON {
  39488. /** @hidden */
  39489. export var stereoscopicInterlacePixelShader: {
  39490. name: string;
  39491. shader: string;
  39492. };
  39493. }
  39494. declare module BABYLON {
  39495. /**
  39496. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39497. */
  39498. export class StereoscopicInterlacePostProcess extends PostProcess {
  39499. private _stepSize;
  39500. private _passedProcess;
  39501. /**
  39502. * Initializes a StereoscopicInterlacePostProcess
  39503. * @param name The name of the effect.
  39504. * @param rigCameras The rig cameras to be appled to the post process
  39505. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39507. * @param engine The engine which the post process will be applied. (default: current engine)
  39508. * @param reusable If the post process can be reused on the same frame. (default: false)
  39509. */
  39510. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39511. }
  39512. }
  39513. declare module BABYLON {
  39514. /**
  39515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39516. * @see http://doc.babylonjs.com/features/cameras
  39517. */
  39518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39519. /**
  39520. * Creates a new StereoscopicArcRotateCamera
  39521. * @param name defines camera name
  39522. * @param alpha defines alpha angle (in radians)
  39523. * @param beta defines beta angle (in radians)
  39524. * @param radius defines radius
  39525. * @param target defines camera target
  39526. * @param interaxialDistance defines distance between each color axis
  39527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39528. * @param scene defines the hosting scene
  39529. */
  39530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39531. /**
  39532. * Gets camera class name
  39533. * @returns StereoscopicArcRotateCamera
  39534. */
  39535. getClassName(): string;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /**
  39540. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39541. * @see http://doc.babylonjs.com/features/cameras
  39542. */
  39543. export class StereoscopicFreeCamera extends FreeCamera {
  39544. /**
  39545. * Creates a new StereoscopicFreeCamera
  39546. * @param name defines camera name
  39547. * @param position defines initial position
  39548. * @param interaxialDistance defines distance between each color axis
  39549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39550. * @param scene defines the hosting scene
  39551. */
  39552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39553. /**
  39554. * Gets camera class name
  39555. * @returns StereoscopicFreeCamera
  39556. */
  39557. getClassName(): string;
  39558. }
  39559. }
  39560. declare module BABYLON {
  39561. /**
  39562. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39563. * @see http://doc.babylonjs.com/features/cameras
  39564. */
  39565. export class StereoscopicGamepadCamera extends GamepadCamera {
  39566. /**
  39567. * Creates a new StereoscopicGamepadCamera
  39568. * @param name defines camera name
  39569. * @param position defines initial position
  39570. * @param interaxialDistance defines distance between each color axis
  39571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39572. * @param scene defines the hosting scene
  39573. */
  39574. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39575. /**
  39576. * Gets camera class name
  39577. * @returns StereoscopicGamepadCamera
  39578. */
  39579. getClassName(): string;
  39580. }
  39581. }
  39582. declare module BABYLON {
  39583. /**
  39584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39585. * @see http://doc.babylonjs.com/features/cameras
  39586. */
  39587. export class StereoscopicUniversalCamera extends UniversalCamera {
  39588. /**
  39589. * Creates a new StereoscopicUniversalCamera
  39590. * @param name defines camera name
  39591. * @param position defines initial position
  39592. * @param interaxialDistance defines distance between each color axis
  39593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39594. * @param scene defines the hosting scene
  39595. */
  39596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39597. /**
  39598. * Gets camera class name
  39599. * @returns StereoscopicUniversalCamera
  39600. */
  39601. getClassName(): string;
  39602. }
  39603. }
  39604. declare module BABYLON {
  39605. /**
  39606. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39610. */
  39611. export class VirtualJoysticksCamera extends FreeCamera {
  39612. /**
  39613. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39617. * @param name Define the name of the camera in the scene
  39618. * @param position Define the start position of the camera in the scene
  39619. * @param scene Define the scene the camera belongs to
  39620. */
  39621. constructor(name: string, position: Vector3, scene: Scene);
  39622. /**
  39623. * Gets the current object class name.
  39624. * @return the class name
  39625. */
  39626. getClassName(): string;
  39627. }
  39628. }
  39629. declare module BABYLON {
  39630. /**
  39631. * This represents all the required metrics to create a VR camera.
  39632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39633. */
  39634. export class VRCameraMetrics {
  39635. /**
  39636. * Define the horizontal resolution off the screen.
  39637. */
  39638. hResolution: number;
  39639. /**
  39640. * Define the vertical resolution off the screen.
  39641. */
  39642. vResolution: number;
  39643. /**
  39644. * Define the horizontal screen size.
  39645. */
  39646. hScreenSize: number;
  39647. /**
  39648. * Define the vertical screen size.
  39649. */
  39650. vScreenSize: number;
  39651. /**
  39652. * Define the vertical screen center position.
  39653. */
  39654. vScreenCenter: number;
  39655. /**
  39656. * Define the distance of the eyes to the screen.
  39657. */
  39658. eyeToScreenDistance: number;
  39659. /**
  39660. * Define the distance between both lenses
  39661. */
  39662. lensSeparationDistance: number;
  39663. /**
  39664. * Define the distance between both viewer's eyes.
  39665. */
  39666. interpupillaryDistance: number;
  39667. /**
  39668. * Define the distortion factor of the VR postprocess.
  39669. * Please, touch with care.
  39670. */
  39671. distortionK: number[];
  39672. /**
  39673. * Define the chromatic aberration correction factors for the VR post process.
  39674. */
  39675. chromaAbCorrection: number[];
  39676. /**
  39677. * Define the scale factor of the post process.
  39678. * The smaller the better but the slower.
  39679. */
  39680. postProcessScaleFactor: number;
  39681. /**
  39682. * Define an offset for the lens center.
  39683. */
  39684. lensCenterOffset: number;
  39685. /**
  39686. * Define if the current vr camera should compensate the distortion of the lense or not.
  39687. */
  39688. compensateDistortion: boolean;
  39689. /**
  39690. * Defines if multiview should be enabled when rendering (Default: false)
  39691. */
  39692. multiviewEnabled: boolean;
  39693. /**
  39694. * Gets the rendering aspect ratio based on the provided resolutions.
  39695. */
  39696. readonly aspectRatio: number;
  39697. /**
  39698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39699. */
  39700. readonly aspectRatioFov: number;
  39701. /**
  39702. * @hidden
  39703. */
  39704. readonly leftHMatrix: Matrix;
  39705. /**
  39706. * @hidden
  39707. */
  39708. readonly rightHMatrix: Matrix;
  39709. /**
  39710. * @hidden
  39711. */
  39712. readonly leftPreViewMatrix: Matrix;
  39713. /**
  39714. * @hidden
  39715. */
  39716. readonly rightPreViewMatrix: Matrix;
  39717. /**
  39718. * Get the default VRMetrics based on the most generic setup.
  39719. * @returns the default vr metrics
  39720. */
  39721. static GetDefault(): VRCameraMetrics;
  39722. }
  39723. }
  39724. declare module BABYLON {
  39725. /** @hidden */
  39726. export var vrDistortionCorrectionPixelShader: {
  39727. name: string;
  39728. shader: string;
  39729. };
  39730. }
  39731. declare module BABYLON {
  39732. /**
  39733. * VRDistortionCorrectionPostProcess used for mobile VR
  39734. */
  39735. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39736. private _isRightEye;
  39737. private _distortionFactors;
  39738. private _postProcessScaleFactor;
  39739. private _lensCenterOffset;
  39740. private _scaleIn;
  39741. private _scaleFactor;
  39742. private _lensCenter;
  39743. /**
  39744. * Initializes the VRDistortionCorrectionPostProcess
  39745. * @param name The name of the effect.
  39746. * @param camera The camera to apply the render pass to.
  39747. * @param isRightEye If this is for the right eye distortion
  39748. * @param vrMetrics All the required metrics for the VR camera
  39749. */
  39750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39751. }
  39752. }
  39753. declare module BABYLON {
  39754. /**
  39755. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39757. */
  39758. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39759. /**
  39760. * Creates a new VRDeviceOrientationArcRotateCamera
  39761. * @param name defines camera name
  39762. * @param alpha defines the camera rotation along the logitudinal axis
  39763. * @param beta defines the camera rotation along the latitudinal axis
  39764. * @param radius defines the camera distance from its target
  39765. * @param target defines the camera target
  39766. * @param scene defines the scene the camera belongs to
  39767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39769. */
  39770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39771. /**
  39772. * Gets camera class name
  39773. * @returns VRDeviceOrientationArcRotateCamera
  39774. */
  39775. getClassName(): string;
  39776. }
  39777. }
  39778. declare module BABYLON {
  39779. /**
  39780. * Camera used to simulate VR rendering (based on FreeCamera)
  39781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39782. */
  39783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39784. /**
  39785. * Creates a new VRDeviceOrientationFreeCamera
  39786. * @param name defines camera name
  39787. * @param position defines the start position of the camera
  39788. * @param scene defines the scene the camera belongs to
  39789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39791. */
  39792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39793. /**
  39794. * Gets camera class name
  39795. * @returns VRDeviceOrientationFreeCamera
  39796. */
  39797. getClassName(): string;
  39798. }
  39799. }
  39800. declare module BABYLON {
  39801. /**
  39802. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39804. */
  39805. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39806. /**
  39807. * Creates a new VRDeviceOrientationGamepadCamera
  39808. * @param name defines camera name
  39809. * @param position defines the start position of the camera
  39810. * @param scene defines the scene the camera belongs to
  39811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39813. */
  39814. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39815. /**
  39816. * Gets camera class name
  39817. * @returns VRDeviceOrientationGamepadCamera
  39818. */
  39819. getClassName(): string;
  39820. }
  39821. }
  39822. declare module BABYLON {
  39823. /**
  39824. * Base class of materials working in push mode in babylon JS
  39825. * @hidden
  39826. */
  39827. export class PushMaterial extends Material {
  39828. protected _activeEffect: Effect;
  39829. protected _normalMatrix: Matrix;
  39830. /**
  39831. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39832. * This means that the material can keep using a previous shader while a new one is being compiled.
  39833. * This is mostly used when shader parallel compilation is supported (true by default)
  39834. */
  39835. allowShaderHotSwapping: boolean;
  39836. constructor(name: string, scene: Scene);
  39837. getEffect(): Effect;
  39838. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39839. /**
  39840. * Binds the given world matrix to the active effect
  39841. *
  39842. * @param world the matrix to bind
  39843. */
  39844. bindOnlyWorldMatrix(world: Matrix): void;
  39845. /**
  39846. * Binds the given normal matrix to the active effect
  39847. *
  39848. * @param normalMatrix the matrix to bind
  39849. */
  39850. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39851. bind(world: Matrix, mesh?: Mesh): void;
  39852. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39853. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39854. }
  39855. }
  39856. declare module BABYLON {
  39857. /**
  39858. * This groups all the flags used to control the materials channel.
  39859. */
  39860. export class MaterialFlags {
  39861. private static _DiffuseTextureEnabled;
  39862. /**
  39863. * Are diffuse textures enabled in the application.
  39864. */
  39865. static DiffuseTextureEnabled: boolean;
  39866. private static _AmbientTextureEnabled;
  39867. /**
  39868. * Are ambient textures enabled in the application.
  39869. */
  39870. static AmbientTextureEnabled: boolean;
  39871. private static _OpacityTextureEnabled;
  39872. /**
  39873. * Are opacity textures enabled in the application.
  39874. */
  39875. static OpacityTextureEnabled: boolean;
  39876. private static _ReflectionTextureEnabled;
  39877. /**
  39878. * Are reflection textures enabled in the application.
  39879. */
  39880. static ReflectionTextureEnabled: boolean;
  39881. private static _EmissiveTextureEnabled;
  39882. /**
  39883. * Are emissive textures enabled in the application.
  39884. */
  39885. static EmissiveTextureEnabled: boolean;
  39886. private static _SpecularTextureEnabled;
  39887. /**
  39888. * Are specular textures enabled in the application.
  39889. */
  39890. static SpecularTextureEnabled: boolean;
  39891. private static _BumpTextureEnabled;
  39892. /**
  39893. * Are bump textures enabled in the application.
  39894. */
  39895. static BumpTextureEnabled: boolean;
  39896. private static _LightmapTextureEnabled;
  39897. /**
  39898. * Are lightmap textures enabled in the application.
  39899. */
  39900. static LightmapTextureEnabled: boolean;
  39901. private static _RefractionTextureEnabled;
  39902. /**
  39903. * Are refraction textures enabled in the application.
  39904. */
  39905. static RefractionTextureEnabled: boolean;
  39906. private static _ColorGradingTextureEnabled;
  39907. /**
  39908. * Are color grading textures enabled in the application.
  39909. */
  39910. static ColorGradingTextureEnabled: boolean;
  39911. private static _FresnelEnabled;
  39912. /**
  39913. * Are fresnels enabled in the application.
  39914. */
  39915. static FresnelEnabled: boolean;
  39916. private static _ClearCoatTextureEnabled;
  39917. /**
  39918. * Are clear coat textures enabled in the application.
  39919. */
  39920. static ClearCoatTextureEnabled: boolean;
  39921. private static _ClearCoatBumpTextureEnabled;
  39922. /**
  39923. * Are clear coat bump textures enabled in the application.
  39924. */
  39925. static ClearCoatBumpTextureEnabled: boolean;
  39926. private static _ClearCoatTintTextureEnabled;
  39927. /**
  39928. * Are clear coat tint textures enabled in the application.
  39929. */
  39930. static ClearCoatTintTextureEnabled: boolean;
  39931. private static _SheenTextureEnabled;
  39932. /**
  39933. * Are sheen textures enabled in the application.
  39934. */
  39935. static SheenTextureEnabled: boolean;
  39936. private static _AnisotropicTextureEnabled;
  39937. /**
  39938. * Are anisotropic textures enabled in the application.
  39939. */
  39940. static AnisotropicTextureEnabled: boolean;
  39941. private static _ThicknessTextureEnabled;
  39942. /**
  39943. * Are thickness textures enabled in the application.
  39944. */
  39945. static ThicknessTextureEnabled: boolean;
  39946. }
  39947. }
  39948. declare module BABYLON {
  39949. /** @hidden */
  39950. export var defaultFragmentDeclaration: {
  39951. name: string;
  39952. shader: string;
  39953. };
  39954. }
  39955. declare module BABYLON {
  39956. /** @hidden */
  39957. export var defaultUboDeclaration: {
  39958. name: string;
  39959. shader: string;
  39960. };
  39961. }
  39962. declare module BABYLON {
  39963. /** @hidden */
  39964. export var lightFragmentDeclaration: {
  39965. name: string;
  39966. shader: string;
  39967. };
  39968. }
  39969. declare module BABYLON {
  39970. /** @hidden */
  39971. export var lightUboDeclaration: {
  39972. name: string;
  39973. shader: string;
  39974. };
  39975. }
  39976. declare module BABYLON {
  39977. /** @hidden */
  39978. export var lightsFragmentFunctions: {
  39979. name: string;
  39980. shader: string;
  39981. };
  39982. }
  39983. declare module BABYLON {
  39984. /** @hidden */
  39985. export var shadowsFragmentFunctions: {
  39986. name: string;
  39987. shader: string;
  39988. };
  39989. }
  39990. declare module BABYLON {
  39991. /** @hidden */
  39992. export var fresnelFunction: {
  39993. name: string;
  39994. shader: string;
  39995. };
  39996. }
  39997. declare module BABYLON {
  39998. /** @hidden */
  39999. export var reflectionFunction: {
  40000. name: string;
  40001. shader: string;
  40002. };
  40003. }
  40004. declare module BABYLON {
  40005. /** @hidden */
  40006. export var bumpFragmentFunctions: {
  40007. name: string;
  40008. shader: string;
  40009. };
  40010. }
  40011. declare module BABYLON {
  40012. /** @hidden */
  40013. export var logDepthDeclaration: {
  40014. name: string;
  40015. shader: string;
  40016. };
  40017. }
  40018. declare module BABYLON {
  40019. /** @hidden */
  40020. export var bumpFragment: {
  40021. name: string;
  40022. shader: string;
  40023. };
  40024. }
  40025. declare module BABYLON {
  40026. /** @hidden */
  40027. export var depthPrePass: {
  40028. name: string;
  40029. shader: string;
  40030. };
  40031. }
  40032. declare module BABYLON {
  40033. /** @hidden */
  40034. export var lightFragment: {
  40035. name: string;
  40036. shader: string;
  40037. };
  40038. }
  40039. declare module BABYLON {
  40040. /** @hidden */
  40041. export var logDepthFragment: {
  40042. name: string;
  40043. shader: string;
  40044. };
  40045. }
  40046. declare module BABYLON {
  40047. /** @hidden */
  40048. export var defaultPixelShader: {
  40049. name: string;
  40050. shader: string;
  40051. };
  40052. }
  40053. declare module BABYLON {
  40054. /** @hidden */
  40055. export var defaultVertexDeclaration: {
  40056. name: string;
  40057. shader: string;
  40058. };
  40059. }
  40060. declare module BABYLON {
  40061. /** @hidden */
  40062. export var bumpVertexDeclaration: {
  40063. name: string;
  40064. shader: string;
  40065. };
  40066. }
  40067. declare module BABYLON {
  40068. /** @hidden */
  40069. export var bumpVertex: {
  40070. name: string;
  40071. shader: string;
  40072. };
  40073. }
  40074. declare module BABYLON {
  40075. /** @hidden */
  40076. export var fogVertex: {
  40077. name: string;
  40078. shader: string;
  40079. };
  40080. }
  40081. declare module BABYLON {
  40082. /** @hidden */
  40083. export var shadowsVertex: {
  40084. name: string;
  40085. shader: string;
  40086. };
  40087. }
  40088. declare module BABYLON {
  40089. /** @hidden */
  40090. export var pointCloudVertex: {
  40091. name: string;
  40092. shader: string;
  40093. };
  40094. }
  40095. declare module BABYLON {
  40096. /** @hidden */
  40097. export var logDepthVertex: {
  40098. name: string;
  40099. shader: string;
  40100. };
  40101. }
  40102. declare module BABYLON {
  40103. /** @hidden */
  40104. export var defaultVertexShader: {
  40105. name: string;
  40106. shader: string;
  40107. };
  40108. }
  40109. declare module BABYLON {
  40110. /** @hidden */
  40111. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40112. MAINUV1: boolean;
  40113. MAINUV2: boolean;
  40114. DIFFUSE: boolean;
  40115. DIFFUSEDIRECTUV: number;
  40116. AMBIENT: boolean;
  40117. AMBIENTDIRECTUV: number;
  40118. OPACITY: boolean;
  40119. OPACITYDIRECTUV: number;
  40120. OPACITYRGB: boolean;
  40121. REFLECTION: boolean;
  40122. EMISSIVE: boolean;
  40123. EMISSIVEDIRECTUV: number;
  40124. SPECULAR: boolean;
  40125. SPECULARDIRECTUV: number;
  40126. BUMP: boolean;
  40127. BUMPDIRECTUV: number;
  40128. PARALLAX: boolean;
  40129. PARALLAXOCCLUSION: boolean;
  40130. SPECULAROVERALPHA: boolean;
  40131. CLIPPLANE: boolean;
  40132. CLIPPLANE2: boolean;
  40133. CLIPPLANE3: boolean;
  40134. CLIPPLANE4: boolean;
  40135. ALPHATEST: boolean;
  40136. DEPTHPREPASS: boolean;
  40137. ALPHAFROMDIFFUSE: boolean;
  40138. POINTSIZE: boolean;
  40139. FOG: boolean;
  40140. SPECULARTERM: boolean;
  40141. DIFFUSEFRESNEL: boolean;
  40142. OPACITYFRESNEL: boolean;
  40143. REFLECTIONFRESNEL: boolean;
  40144. REFRACTIONFRESNEL: boolean;
  40145. EMISSIVEFRESNEL: boolean;
  40146. FRESNEL: boolean;
  40147. NORMAL: boolean;
  40148. UV1: boolean;
  40149. UV2: boolean;
  40150. VERTEXCOLOR: boolean;
  40151. VERTEXALPHA: boolean;
  40152. NUM_BONE_INFLUENCERS: number;
  40153. BonesPerMesh: number;
  40154. BONETEXTURE: boolean;
  40155. INSTANCES: boolean;
  40156. GLOSSINESS: boolean;
  40157. ROUGHNESS: boolean;
  40158. EMISSIVEASILLUMINATION: boolean;
  40159. LINKEMISSIVEWITHDIFFUSE: boolean;
  40160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40161. LIGHTMAP: boolean;
  40162. LIGHTMAPDIRECTUV: number;
  40163. OBJECTSPACE_NORMALMAP: boolean;
  40164. USELIGHTMAPASSHADOWMAP: boolean;
  40165. REFLECTIONMAP_3D: boolean;
  40166. REFLECTIONMAP_SPHERICAL: boolean;
  40167. REFLECTIONMAP_PLANAR: boolean;
  40168. REFLECTIONMAP_CUBIC: boolean;
  40169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40170. REFLECTIONMAP_PROJECTION: boolean;
  40171. REFLECTIONMAP_SKYBOX: boolean;
  40172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40173. REFLECTIONMAP_EXPLICIT: boolean;
  40174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40177. INVERTCUBICMAP: boolean;
  40178. LOGARITHMICDEPTH: boolean;
  40179. REFRACTION: boolean;
  40180. REFRACTIONMAP_3D: boolean;
  40181. REFLECTIONOVERALPHA: boolean;
  40182. TWOSIDEDLIGHTING: boolean;
  40183. SHADOWFLOAT: boolean;
  40184. MORPHTARGETS: boolean;
  40185. MORPHTARGETS_NORMAL: boolean;
  40186. MORPHTARGETS_TANGENT: boolean;
  40187. MORPHTARGETS_UV: boolean;
  40188. NUM_MORPH_INFLUENCERS: number;
  40189. NONUNIFORMSCALING: boolean;
  40190. PREMULTIPLYALPHA: boolean;
  40191. IMAGEPROCESSING: boolean;
  40192. VIGNETTE: boolean;
  40193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40194. VIGNETTEBLENDMODEOPAQUE: boolean;
  40195. TONEMAPPING: boolean;
  40196. TONEMAPPING_ACES: boolean;
  40197. CONTRAST: boolean;
  40198. COLORCURVES: boolean;
  40199. COLORGRADING: boolean;
  40200. COLORGRADING3D: boolean;
  40201. SAMPLER3DGREENDEPTH: boolean;
  40202. SAMPLER3DBGRMAP: boolean;
  40203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40204. MULTIVIEW: boolean;
  40205. /**
  40206. * If the reflection texture on this material is in linear color space
  40207. * @hidden
  40208. */
  40209. IS_REFLECTION_LINEAR: boolean;
  40210. /**
  40211. * If the refraction texture on this material is in linear color space
  40212. * @hidden
  40213. */
  40214. IS_REFRACTION_LINEAR: boolean;
  40215. EXPOSURE: boolean;
  40216. constructor();
  40217. setReflectionMode(modeToEnable: string): void;
  40218. }
  40219. /**
  40220. * This is the default material used in Babylon. It is the best trade off between quality
  40221. * and performances.
  40222. * @see http://doc.babylonjs.com/babylon101/materials
  40223. */
  40224. export class StandardMaterial extends PushMaterial {
  40225. private _diffuseTexture;
  40226. /**
  40227. * The basic texture of the material as viewed under a light.
  40228. */
  40229. diffuseTexture: Nullable<BaseTexture>;
  40230. private _ambientTexture;
  40231. /**
  40232. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40233. */
  40234. ambientTexture: Nullable<BaseTexture>;
  40235. private _opacityTexture;
  40236. /**
  40237. * Define the transparency of the material from a texture.
  40238. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40239. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40240. */
  40241. opacityTexture: Nullable<BaseTexture>;
  40242. private _reflectionTexture;
  40243. /**
  40244. * Define the texture used to display the reflection.
  40245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40246. */
  40247. reflectionTexture: Nullable<BaseTexture>;
  40248. private _emissiveTexture;
  40249. /**
  40250. * Define texture of the material as if self lit.
  40251. * This will be mixed in the final result even in the absence of light.
  40252. */
  40253. emissiveTexture: Nullable<BaseTexture>;
  40254. private _specularTexture;
  40255. /**
  40256. * Define how the color and intensity of the highlight given by the light in the material.
  40257. */
  40258. specularTexture: Nullable<BaseTexture>;
  40259. private _bumpTexture;
  40260. /**
  40261. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40262. * 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.
  40263. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40264. */
  40265. bumpTexture: Nullable<BaseTexture>;
  40266. private _lightmapTexture;
  40267. /**
  40268. * Complex lighting can be computationally expensive to compute at runtime.
  40269. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40270. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40271. */
  40272. lightmapTexture: Nullable<BaseTexture>;
  40273. private _refractionTexture;
  40274. /**
  40275. * Define the texture used to display the refraction.
  40276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40277. */
  40278. refractionTexture: Nullable<BaseTexture>;
  40279. /**
  40280. * The color of the material lit by the environmental background lighting.
  40281. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40282. */
  40283. ambientColor: Color3;
  40284. /**
  40285. * The basic color of the material as viewed under a light.
  40286. */
  40287. diffuseColor: Color3;
  40288. /**
  40289. * Define how the color and intensity of the highlight given by the light in the material.
  40290. */
  40291. specularColor: Color3;
  40292. /**
  40293. * Define the color of the material as if self lit.
  40294. * This will be mixed in the final result even in the absence of light.
  40295. */
  40296. emissiveColor: Color3;
  40297. /**
  40298. * Defines how sharp are the highlights in the material.
  40299. * The bigger the value the sharper giving a more glossy feeling to the result.
  40300. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40301. */
  40302. specularPower: number;
  40303. private _useAlphaFromDiffuseTexture;
  40304. /**
  40305. * Does the transparency come from the diffuse texture alpha channel.
  40306. */
  40307. useAlphaFromDiffuseTexture: boolean;
  40308. private _useEmissiveAsIllumination;
  40309. /**
  40310. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40311. */
  40312. useEmissiveAsIllumination: boolean;
  40313. private _linkEmissiveWithDiffuse;
  40314. /**
  40315. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40316. * the emissive level when the final color is close to one.
  40317. */
  40318. linkEmissiveWithDiffuse: boolean;
  40319. private _useSpecularOverAlpha;
  40320. /**
  40321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40323. */
  40324. useSpecularOverAlpha: boolean;
  40325. private _useReflectionOverAlpha;
  40326. /**
  40327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40329. */
  40330. useReflectionOverAlpha: boolean;
  40331. private _disableLighting;
  40332. /**
  40333. * Does lights from the scene impacts this material.
  40334. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40335. */
  40336. disableLighting: boolean;
  40337. private _useObjectSpaceNormalMap;
  40338. /**
  40339. * Allows using an object space normal map (instead of tangent space).
  40340. */
  40341. useObjectSpaceNormalMap: boolean;
  40342. private _useParallax;
  40343. /**
  40344. * Is parallax enabled or not.
  40345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40346. */
  40347. useParallax: boolean;
  40348. private _useParallaxOcclusion;
  40349. /**
  40350. * Is parallax occlusion enabled or not.
  40351. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40353. */
  40354. useParallaxOcclusion: boolean;
  40355. /**
  40356. * 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.
  40357. */
  40358. parallaxScaleBias: number;
  40359. private _roughness;
  40360. /**
  40361. * Helps to define how blurry the reflections should appears in the material.
  40362. */
  40363. roughness: number;
  40364. /**
  40365. * In case of refraction, define the value of the index of refraction.
  40366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40367. */
  40368. indexOfRefraction: number;
  40369. /**
  40370. * Invert the refraction texture alongside the y axis.
  40371. * It can be useful with procedural textures or probe for instance.
  40372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40373. */
  40374. invertRefractionY: boolean;
  40375. /**
  40376. * Defines the alpha limits in alpha test mode.
  40377. */
  40378. alphaCutOff: number;
  40379. private _useLightmapAsShadowmap;
  40380. /**
  40381. * In case of light mapping, define whether the map contains light or shadow informations.
  40382. */
  40383. useLightmapAsShadowmap: boolean;
  40384. private _diffuseFresnelParameters;
  40385. /**
  40386. * Define the diffuse fresnel parameters of the material.
  40387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40388. */
  40389. diffuseFresnelParameters: FresnelParameters;
  40390. private _opacityFresnelParameters;
  40391. /**
  40392. * Define the opacity fresnel parameters of the material.
  40393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40394. */
  40395. opacityFresnelParameters: FresnelParameters;
  40396. private _reflectionFresnelParameters;
  40397. /**
  40398. * Define the reflection fresnel parameters of the material.
  40399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40400. */
  40401. reflectionFresnelParameters: FresnelParameters;
  40402. private _refractionFresnelParameters;
  40403. /**
  40404. * Define the refraction fresnel parameters of the material.
  40405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40406. */
  40407. refractionFresnelParameters: FresnelParameters;
  40408. private _emissiveFresnelParameters;
  40409. /**
  40410. * Define the emissive fresnel parameters of the material.
  40411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40412. */
  40413. emissiveFresnelParameters: FresnelParameters;
  40414. private _useReflectionFresnelFromSpecular;
  40415. /**
  40416. * If true automatically deducts the fresnels values from the material specularity.
  40417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40418. */
  40419. useReflectionFresnelFromSpecular: boolean;
  40420. private _useGlossinessFromSpecularMapAlpha;
  40421. /**
  40422. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40423. */
  40424. useGlossinessFromSpecularMapAlpha: boolean;
  40425. private _maxSimultaneousLights;
  40426. /**
  40427. * Defines the maximum number of lights that can be used in the material
  40428. */
  40429. maxSimultaneousLights: number;
  40430. private _invertNormalMapX;
  40431. /**
  40432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40433. */
  40434. invertNormalMapX: boolean;
  40435. private _invertNormalMapY;
  40436. /**
  40437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40438. */
  40439. invertNormalMapY: boolean;
  40440. private _twoSidedLighting;
  40441. /**
  40442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40443. */
  40444. twoSidedLighting: boolean;
  40445. /**
  40446. * Default configuration related to image processing available in the standard Material.
  40447. */
  40448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40449. /**
  40450. * Gets the image processing configuration used either in this material.
  40451. */
  40452. /**
  40453. * Sets the Default image processing configuration used either in the this material.
  40454. *
  40455. * If sets to null, the scene one is in use.
  40456. */
  40457. imageProcessingConfiguration: ImageProcessingConfiguration;
  40458. /**
  40459. * Keep track of the image processing observer to allow dispose and replace.
  40460. */
  40461. private _imageProcessingObserver;
  40462. /**
  40463. * Attaches a new image processing configuration to the Standard Material.
  40464. * @param configuration
  40465. */
  40466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40467. /**
  40468. * Gets wether the color curves effect is enabled.
  40469. */
  40470. /**
  40471. * Sets wether the color curves effect is enabled.
  40472. */
  40473. cameraColorCurvesEnabled: boolean;
  40474. /**
  40475. * Gets wether the color grading effect is enabled.
  40476. */
  40477. /**
  40478. * Gets wether the color grading effect is enabled.
  40479. */
  40480. cameraColorGradingEnabled: boolean;
  40481. /**
  40482. * Gets wether tonemapping is enabled or not.
  40483. */
  40484. /**
  40485. * Sets wether tonemapping is enabled or not
  40486. */
  40487. cameraToneMappingEnabled: boolean;
  40488. /**
  40489. * The camera exposure used on this material.
  40490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40491. * This corresponds to a photographic exposure.
  40492. */
  40493. /**
  40494. * The camera exposure used on this material.
  40495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40496. * This corresponds to a photographic exposure.
  40497. */
  40498. cameraExposure: number;
  40499. /**
  40500. * Gets The camera contrast used on this material.
  40501. */
  40502. /**
  40503. * Sets The camera contrast used on this material.
  40504. */
  40505. cameraContrast: number;
  40506. /**
  40507. * Gets the Color Grading 2D Lookup Texture.
  40508. */
  40509. /**
  40510. * Sets the Color Grading 2D Lookup Texture.
  40511. */
  40512. cameraColorGradingTexture: Nullable<BaseTexture>;
  40513. /**
  40514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40516. * 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;
  40517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40518. */
  40519. /**
  40520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40522. * 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;
  40523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40524. */
  40525. cameraColorCurves: Nullable<ColorCurves>;
  40526. /**
  40527. * Custom callback helping to override the default shader used in the material.
  40528. */
  40529. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40530. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40531. protected _worldViewProjectionMatrix: Matrix;
  40532. protected _globalAmbientColor: Color3;
  40533. protected _useLogarithmicDepth: boolean;
  40534. protected _rebuildInParallel: boolean;
  40535. /**
  40536. * Instantiates a new standard material.
  40537. * This is the default material used in Babylon. It is the best trade off between quality
  40538. * and performances.
  40539. * @see http://doc.babylonjs.com/babylon101/materials
  40540. * @param name Define the name of the material in the scene
  40541. * @param scene Define the scene the material belong to
  40542. */
  40543. constructor(name: string, scene: Scene);
  40544. /**
  40545. * Gets a boolean indicating that current material needs to register RTT
  40546. */
  40547. readonly hasRenderTargetTextures: boolean;
  40548. /**
  40549. * Gets the current class name of the material e.g. "StandardMaterial"
  40550. * Mainly use in serialization.
  40551. * @returns the class name
  40552. */
  40553. getClassName(): string;
  40554. /**
  40555. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40556. * You can try switching to logarithmic depth.
  40557. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40558. */
  40559. useLogarithmicDepth: boolean;
  40560. /**
  40561. * Specifies if the material will require alpha blending
  40562. * @returns a boolean specifying if alpha blending is needed
  40563. */
  40564. needAlphaBlending(): boolean;
  40565. /**
  40566. * Specifies if this material should be rendered in alpha test mode
  40567. * @returns a boolean specifying if an alpha test is needed.
  40568. */
  40569. needAlphaTesting(): boolean;
  40570. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40571. /**
  40572. * Get the texture used for alpha test purpose.
  40573. * @returns the diffuse texture in case of the standard material.
  40574. */
  40575. getAlphaTestTexture(): Nullable<BaseTexture>;
  40576. /**
  40577. * Get if the submesh is ready to be used and all its information available.
  40578. * Child classes can use it to update shaders
  40579. * @param mesh defines the mesh to check
  40580. * @param subMesh defines which submesh to check
  40581. * @param useInstances specifies that instances should be used
  40582. * @returns a boolean indicating that the submesh is ready or not
  40583. */
  40584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40585. /**
  40586. * Builds the material UBO layouts.
  40587. * Used internally during the effect preparation.
  40588. */
  40589. buildUniformLayout(): void;
  40590. /**
  40591. * Unbinds the material from the mesh
  40592. */
  40593. unbind(): void;
  40594. /**
  40595. * Binds the submesh to this material by preparing the effect and shader to draw
  40596. * @param world defines the world transformation matrix
  40597. * @param mesh defines the mesh containing the submesh
  40598. * @param subMesh defines the submesh to bind the material to
  40599. */
  40600. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40601. /**
  40602. * Get the list of animatables in the material.
  40603. * @returns the list of animatables object used in the material
  40604. */
  40605. getAnimatables(): IAnimatable[];
  40606. /**
  40607. * Gets the active textures from the material
  40608. * @returns an array of textures
  40609. */
  40610. getActiveTextures(): BaseTexture[];
  40611. /**
  40612. * Specifies if the material uses a texture
  40613. * @param texture defines the texture to check against the material
  40614. * @returns a boolean specifying if the material uses the texture
  40615. */
  40616. hasTexture(texture: BaseTexture): boolean;
  40617. /**
  40618. * Disposes the material
  40619. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40620. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40621. */
  40622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40623. /**
  40624. * Makes a duplicate of the material, and gives it a new name
  40625. * @param name defines the new name for the duplicated material
  40626. * @returns the cloned material
  40627. */
  40628. clone(name: string): StandardMaterial;
  40629. /**
  40630. * Serializes this material in a JSON representation
  40631. * @returns the serialized material object
  40632. */
  40633. serialize(): any;
  40634. /**
  40635. * Creates a standard material from parsed material data
  40636. * @param source defines the JSON representation of the material
  40637. * @param scene defines the hosting scene
  40638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40639. * @returns a new standard material
  40640. */
  40641. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40642. /**
  40643. * Are diffuse textures enabled in the application.
  40644. */
  40645. static DiffuseTextureEnabled: boolean;
  40646. /**
  40647. * Are ambient textures enabled in the application.
  40648. */
  40649. static AmbientTextureEnabled: boolean;
  40650. /**
  40651. * Are opacity textures enabled in the application.
  40652. */
  40653. static OpacityTextureEnabled: boolean;
  40654. /**
  40655. * Are reflection textures enabled in the application.
  40656. */
  40657. static ReflectionTextureEnabled: boolean;
  40658. /**
  40659. * Are emissive textures enabled in the application.
  40660. */
  40661. static EmissiveTextureEnabled: boolean;
  40662. /**
  40663. * Are specular textures enabled in the application.
  40664. */
  40665. static SpecularTextureEnabled: boolean;
  40666. /**
  40667. * Are bump textures enabled in the application.
  40668. */
  40669. static BumpTextureEnabled: boolean;
  40670. /**
  40671. * Are lightmap textures enabled in the application.
  40672. */
  40673. static LightmapTextureEnabled: boolean;
  40674. /**
  40675. * Are refraction textures enabled in the application.
  40676. */
  40677. static RefractionTextureEnabled: boolean;
  40678. /**
  40679. * Are color grading textures enabled in the application.
  40680. */
  40681. static ColorGradingTextureEnabled: boolean;
  40682. /**
  40683. * Are fresnels enabled in the application.
  40684. */
  40685. static FresnelEnabled: boolean;
  40686. }
  40687. }
  40688. declare module BABYLON {
  40689. /** @hidden */
  40690. export var imageProcessingPixelShader: {
  40691. name: string;
  40692. shader: string;
  40693. };
  40694. }
  40695. declare module BABYLON {
  40696. /**
  40697. * ImageProcessingPostProcess
  40698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40699. */
  40700. export class ImageProcessingPostProcess extends PostProcess {
  40701. /**
  40702. * Default configuration related to image processing available in the PBR Material.
  40703. */
  40704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40705. /**
  40706. * Gets the image processing configuration used either in this material.
  40707. */
  40708. /**
  40709. * Sets the Default image processing configuration used either in the this material.
  40710. *
  40711. * If sets to null, the scene one is in use.
  40712. */
  40713. imageProcessingConfiguration: ImageProcessingConfiguration;
  40714. /**
  40715. * Keep track of the image processing observer to allow dispose and replace.
  40716. */
  40717. private _imageProcessingObserver;
  40718. /**
  40719. * Attaches a new image processing configuration to the PBR Material.
  40720. * @param configuration
  40721. */
  40722. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40723. /**
  40724. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40725. */
  40726. /**
  40727. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40728. */
  40729. colorCurves: Nullable<ColorCurves>;
  40730. /**
  40731. * Gets wether the color curves effect is enabled.
  40732. */
  40733. /**
  40734. * Sets wether the color curves effect is enabled.
  40735. */
  40736. colorCurvesEnabled: boolean;
  40737. /**
  40738. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40739. */
  40740. /**
  40741. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40742. */
  40743. colorGradingTexture: Nullable<BaseTexture>;
  40744. /**
  40745. * Gets wether the color grading effect is enabled.
  40746. */
  40747. /**
  40748. * Gets wether the color grading effect is enabled.
  40749. */
  40750. colorGradingEnabled: boolean;
  40751. /**
  40752. * Gets exposure used in the effect.
  40753. */
  40754. /**
  40755. * Sets exposure used in the effect.
  40756. */
  40757. exposure: number;
  40758. /**
  40759. * Gets wether tonemapping is enabled or not.
  40760. */
  40761. /**
  40762. * Sets wether tonemapping is enabled or not
  40763. */
  40764. toneMappingEnabled: boolean;
  40765. /**
  40766. * Gets the type of tone mapping effect.
  40767. */
  40768. /**
  40769. * Sets the type of tone mapping effect.
  40770. */
  40771. toneMappingType: number;
  40772. /**
  40773. * Gets contrast used in the effect.
  40774. */
  40775. /**
  40776. * Sets contrast used in the effect.
  40777. */
  40778. contrast: number;
  40779. /**
  40780. * Gets Vignette stretch size.
  40781. */
  40782. /**
  40783. * Sets Vignette stretch size.
  40784. */
  40785. vignetteStretch: number;
  40786. /**
  40787. * Gets Vignette centre X Offset.
  40788. */
  40789. /**
  40790. * Sets Vignette centre X Offset.
  40791. */
  40792. vignetteCentreX: number;
  40793. /**
  40794. * Gets Vignette centre Y Offset.
  40795. */
  40796. /**
  40797. * Sets Vignette centre Y Offset.
  40798. */
  40799. vignetteCentreY: number;
  40800. /**
  40801. * Gets Vignette weight or intensity of the vignette effect.
  40802. */
  40803. /**
  40804. * Sets Vignette weight or intensity of the vignette effect.
  40805. */
  40806. vignetteWeight: number;
  40807. /**
  40808. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40809. * if vignetteEnabled is set to true.
  40810. */
  40811. /**
  40812. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40813. * if vignetteEnabled is set to true.
  40814. */
  40815. vignetteColor: Color4;
  40816. /**
  40817. * Gets Camera field of view used by the Vignette effect.
  40818. */
  40819. /**
  40820. * Sets Camera field of view used by the Vignette effect.
  40821. */
  40822. vignetteCameraFov: number;
  40823. /**
  40824. * Gets the vignette blend mode allowing different kind of effect.
  40825. */
  40826. /**
  40827. * Sets the vignette blend mode allowing different kind of effect.
  40828. */
  40829. vignetteBlendMode: number;
  40830. /**
  40831. * Gets wether the vignette effect is enabled.
  40832. */
  40833. /**
  40834. * Sets wether the vignette effect is enabled.
  40835. */
  40836. vignetteEnabled: boolean;
  40837. private _fromLinearSpace;
  40838. /**
  40839. * Gets wether the input of the processing is in Gamma or Linear Space.
  40840. */
  40841. /**
  40842. * Sets wether the input of the processing is in Gamma or Linear Space.
  40843. */
  40844. fromLinearSpace: boolean;
  40845. /**
  40846. * Defines cache preventing GC.
  40847. */
  40848. private _defines;
  40849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40850. /**
  40851. * "ImageProcessingPostProcess"
  40852. * @returns "ImageProcessingPostProcess"
  40853. */
  40854. getClassName(): string;
  40855. protected _updateParameters(): void;
  40856. dispose(camera?: Camera): void;
  40857. }
  40858. }
  40859. declare module BABYLON {
  40860. /**
  40861. * Class containing static functions to help procedurally build meshes
  40862. */
  40863. export class GroundBuilder {
  40864. /**
  40865. * Creates a ground mesh
  40866. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40867. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40869. * @param name defines the name of the mesh
  40870. * @param options defines the options used to create the mesh
  40871. * @param scene defines the hosting scene
  40872. * @returns the ground mesh
  40873. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40874. */
  40875. static CreateGround(name: string, options: {
  40876. width?: number;
  40877. height?: number;
  40878. subdivisions?: number;
  40879. subdivisionsX?: number;
  40880. subdivisionsY?: number;
  40881. updatable?: boolean;
  40882. }, scene: any): Mesh;
  40883. /**
  40884. * Creates a tiled ground mesh
  40885. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40886. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40887. * * 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
  40888. * * 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
  40889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40890. * @param name defines the name of the mesh
  40891. * @param options defines the options used to create the mesh
  40892. * @param scene defines the hosting scene
  40893. * @returns the tiled ground mesh
  40894. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40895. */
  40896. static CreateTiledGround(name: string, options: {
  40897. xmin: number;
  40898. zmin: number;
  40899. xmax: number;
  40900. zmax: number;
  40901. subdivisions?: {
  40902. w: number;
  40903. h: number;
  40904. };
  40905. precision?: {
  40906. w: number;
  40907. h: number;
  40908. };
  40909. updatable?: boolean;
  40910. }, scene?: Nullable<Scene>): Mesh;
  40911. /**
  40912. * Creates a ground mesh from a height map
  40913. * * The parameter `url` sets the URL of the height map image resource.
  40914. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40915. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40916. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40917. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40918. * * 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.
  40919. * * 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).
  40920. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40922. * @param name defines the name of the mesh
  40923. * @param url defines the url to the height map
  40924. * @param options defines the options used to create the mesh
  40925. * @param scene defines the hosting scene
  40926. * @returns the ground mesh
  40927. * @see https://doc.babylonjs.com/babylon101/height_map
  40928. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40929. */
  40930. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40931. width?: number;
  40932. height?: number;
  40933. subdivisions?: number;
  40934. minHeight?: number;
  40935. maxHeight?: number;
  40936. colorFilter?: Color3;
  40937. alphaFilter?: number;
  40938. updatable?: boolean;
  40939. onReady?: (mesh: GroundMesh) => void;
  40940. }, scene?: Nullable<Scene>): GroundMesh;
  40941. }
  40942. }
  40943. declare module BABYLON {
  40944. /**
  40945. * Class containing static functions to help procedurally build meshes
  40946. */
  40947. export class TorusBuilder {
  40948. /**
  40949. * Creates a torus mesh
  40950. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40951. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40952. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40954. * * 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
  40955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40956. * @param name defines the name of the mesh
  40957. * @param options defines the options used to create the mesh
  40958. * @param scene defines the hosting scene
  40959. * @returns the torus mesh
  40960. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40961. */
  40962. static CreateTorus(name: string, options: {
  40963. diameter?: number;
  40964. thickness?: number;
  40965. tessellation?: number;
  40966. updatable?: boolean;
  40967. sideOrientation?: number;
  40968. frontUVs?: Vector4;
  40969. backUVs?: Vector4;
  40970. }, scene: any): Mesh;
  40971. }
  40972. }
  40973. declare module BABYLON {
  40974. /**
  40975. * Class containing static functions to help procedurally build meshes
  40976. */
  40977. export class CylinderBuilder {
  40978. /**
  40979. * Creates a cylinder or a cone mesh
  40980. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40981. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40982. * * 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.
  40983. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40984. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40985. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40986. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40987. * * 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).
  40988. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40989. * * 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).
  40990. * * 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
  40991. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40992. * * 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
  40993. * * 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.
  40994. * * If `enclose` is false, a ring surface is one element.
  40995. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40996. * * 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
  40997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40998. * * 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
  40999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41000. * @param name defines the name of the mesh
  41001. * @param options defines the options used to create the mesh
  41002. * @param scene defines the hosting scene
  41003. * @returns the cylinder mesh
  41004. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41005. */
  41006. static CreateCylinder(name: string, options: {
  41007. height?: number;
  41008. diameterTop?: number;
  41009. diameterBottom?: number;
  41010. diameter?: number;
  41011. tessellation?: number;
  41012. subdivisions?: number;
  41013. arc?: number;
  41014. faceColors?: Color4[];
  41015. faceUV?: Vector4[];
  41016. updatable?: boolean;
  41017. hasRings?: boolean;
  41018. enclose?: boolean;
  41019. cap?: number;
  41020. sideOrientation?: number;
  41021. frontUVs?: Vector4;
  41022. backUVs?: Vector4;
  41023. }, scene: any): Mesh;
  41024. }
  41025. }
  41026. declare module BABYLON {
  41027. /**
  41028. * Options to modify the vr teleportation behavior.
  41029. */
  41030. export interface VRTeleportationOptions {
  41031. /**
  41032. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41033. */
  41034. floorMeshName?: string;
  41035. /**
  41036. * A list of meshes to be used as the teleportation floor. (default: empty)
  41037. */
  41038. floorMeshes?: Mesh[];
  41039. }
  41040. /**
  41041. * Options to modify the vr experience helper's behavior.
  41042. */
  41043. export interface VRExperienceHelperOptions extends WebVROptions {
  41044. /**
  41045. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41046. */
  41047. createDeviceOrientationCamera?: boolean;
  41048. /**
  41049. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41050. */
  41051. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41052. /**
  41053. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41054. */
  41055. laserToggle?: boolean;
  41056. /**
  41057. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41058. */
  41059. floorMeshes?: Mesh[];
  41060. /**
  41061. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41062. */
  41063. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41064. }
  41065. /**
  41066. * Event containing information after VR has been entered
  41067. */
  41068. export class OnAfterEnteringVRObservableEvent {
  41069. /**
  41070. * If entering vr was successful
  41071. */
  41072. success: boolean;
  41073. }
  41074. /**
  41075. * Helps to quickly add VR support to an existing scene.
  41076. * See http://doc.babylonjs.com/how_to/webvr_helper
  41077. */
  41078. export class VRExperienceHelper {
  41079. /** Options to modify the vr experience helper's behavior. */
  41080. webVROptions: VRExperienceHelperOptions;
  41081. private _scene;
  41082. private _position;
  41083. private _btnVR;
  41084. private _btnVRDisplayed;
  41085. private _webVRsupported;
  41086. private _webVRready;
  41087. private _webVRrequesting;
  41088. private _webVRpresenting;
  41089. private _hasEnteredVR;
  41090. private _fullscreenVRpresenting;
  41091. private _canvas;
  41092. private _webVRCamera;
  41093. private _vrDeviceOrientationCamera;
  41094. private _deviceOrientationCamera;
  41095. private _existingCamera;
  41096. private _onKeyDown;
  41097. private _onVrDisplayPresentChange;
  41098. private _onVRDisplayChanged;
  41099. private _onVRRequestPresentStart;
  41100. private _onVRRequestPresentComplete;
  41101. /**
  41102. * 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)
  41103. */
  41104. enableGazeEvenWhenNoPointerLock: boolean;
  41105. /**
  41106. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41107. */
  41108. exitVROnDoubleTap: boolean;
  41109. /**
  41110. * Observable raised right before entering VR.
  41111. */
  41112. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41113. /**
  41114. * Observable raised when entering VR has completed.
  41115. */
  41116. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41117. /**
  41118. * Observable raised when exiting VR.
  41119. */
  41120. onExitingVRObservable: Observable<VRExperienceHelper>;
  41121. /**
  41122. * Observable raised when controller mesh is loaded.
  41123. */
  41124. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41125. /** Return this.onEnteringVRObservable
  41126. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41127. */
  41128. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41129. /** Return this.onExitingVRObservable
  41130. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41131. */
  41132. readonly onExitingVR: Observable<VRExperienceHelper>;
  41133. /** Return this.onControllerMeshLoadedObservable
  41134. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41135. */
  41136. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41137. private _rayLength;
  41138. private _useCustomVRButton;
  41139. private _teleportationRequested;
  41140. private _teleportActive;
  41141. private _floorMeshName;
  41142. private _floorMeshesCollection;
  41143. private _rotationAllowed;
  41144. private _teleportBackwardsVector;
  41145. private _teleportationTarget;
  41146. private _isDefaultTeleportationTarget;
  41147. private _postProcessMove;
  41148. private _teleportationFillColor;
  41149. private _teleportationBorderColor;
  41150. private _rotationAngle;
  41151. private _haloCenter;
  41152. private _cameraGazer;
  41153. private _padSensibilityUp;
  41154. private _padSensibilityDown;
  41155. private _leftController;
  41156. private _rightController;
  41157. /**
  41158. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41159. */
  41160. onNewMeshSelected: Observable<AbstractMesh>;
  41161. /**
  41162. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41163. * This observable will provide the mesh and the controller used to select the mesh
  41164. */
  41165. onMeshSelectedWithController: Observable<{
  41166. mesh: AbstractMesh;
  41167. controller: WebVRController;
  41168. }>;
  41169. /**
  41170. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41171. */
  41172. onNewMeshPicked: Observable<PickingInfo>;
  41173. private _circleEase;
  41174. /**
  41175. * Observable raised before camera teleportation
  41176. */
  41177. onBeforeCameraTeleport: Observable<Vector3>;
  41178. /**
  41179. * Observable raised after camera teleportation
  41180. */
  41181. onAfterCameraTeleport: Observable<Vector3>;
  41182. /**
  41183. * Observable raised when current selected mesh gets unselected
  41184. */
  41185. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41186. private _raySelectionPredicate;
  41187. /**
  41188. * To be optionaly changed by user to define custom ray selection
  41189. */
  41190. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41191. /**
  41192. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41193. */
  41194. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41195. /**
  41196. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41197. */
  41198. teleportationEnabled: boolean;
  41199. private _defaultHeight;
  41200. private _teleportationInitialized;
  41201. private _interactionsEnabled;
  41202. private _interactionsRequested;
  41203. private _displayGaze;
  41204. private _displayLaserPointer;
  41205. /**
  41206. * The mesh used to display where the user is going to teleport.
  41207. */
  41208. /**
  41209. * Sets the mesh to be used to display where the user is going to teleport.
  41210. */
  41211. teleportationTarget: Mesh;
  41212. /**
  41213. * 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
  41214. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41215. * See http://doc.babylonjs.com/resources/baking_transformations
  41216. */
  41217. gazeTrackerMesh: Mesh;
  41218. /**
  41219. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41220. */
  41221. updateGazeTrackerScale: boolean;
  41222. /**
  41223. * If the gaze trackers color should be updated when selecting meshes
  41224. */
  41225. updateGazeTrackerColor: boolean;
  41226. /**
  41227. * If the controller laser color should be updated when selecting meshes
  41228. */
  41229. updateControllerLaserColor: boolean;
  41230. /**
  41231. * The gaze tracking mesh corresponding to the left controller
  41232. */
  41233. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41234. /**
  41235. * The gaze tracking mesh corresponding to the right controller
  41236. */
  41237. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41238. /**
  41239. * If the ray of the gaze should be displayed.
  41240. */
  41241. /**
  41242. * Sets if the ray of the gaze should be displayed.
  41243. */
  41244. displayGaze: boolean;
  41245. /**
  41246. * If the ray of the LaserPointer should be displayed.
  41247. */
  41248. /**
  41249. * Sets if the ray of the LaserPointer should be displayed.
  41250. */
  41251. displayLaserPointer: boolean;
  41252. /**
  41253. * The deviceOrientationCamera used as the camera when not in VR.
  41254. */
  41255. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41256. /**
  41257. * Based on the current WebVR support, returns the current VR camera used.
  41258. */
  41259. readonly currentVRCamera: Nullable<Camera>;
  41260. /**
  41261. * The webVRCamera which is used when in VR.
  41262. */
  41263. readonly webVRCamera: WebVRFreeCamera;
  41264. /**
  41265. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41266. */
  41267. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41268. /**
  41269. * The html button that is used to trigger entering into VR.
  41270. */
  41271. readonly vrButton: Nullable<HTMLButtonElement>;
  41272. private readonly _teleportationRequestInitiated;
  41273. /**
  41274. * Defines wether or not Pointer lock should be requested when switching to
  41275. * full screen.
  41276. */
  41277. requestPointerLockOnFullScreen: boolean;
  41278. /**
  41279. * Instantiates a VRExperienceHelper.
  41280. * Helps to quickly add VR support to an existing scene.
  41281. * @param scene The scene the VRExperienceHelper belongs to.
  41282. * @param webVROptions Options to modify the vr experience helper's behavior.
  41283. */
  41284. constructor(scene: Scene,
  41285. /** Options to modify the vr experience helper's behavior. */
  41286. webVROptions?: VRExperienceHelperOptions);
  41287. private _onDefaultMeshLoaded;
  41288. private _onResize;
  41289. private _onFullscreenChange;
  41290. /**
  41291. * Gets a value indicating if we are currently in VR mode.
  41292. */
  41293. readonly isInVRMode: boolean;
  41294. private onVrDisplayPresentChange;
  41295. private onVRDisplayChanged;
  41296. private moveButtonToBottomRight;
  41297. private displayVRButton;
  41298. private updateButtonVisibility;
  41299. private _cachedAngularSensibility;
  41300. /**
  41301. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41302. * Otherwise, will use the fullscreen API.
  41303. */
  41304. enterVR(): void;
  41305. /**
  41306. * Attempt to exit VR, or fullscreen.
  41307. */
  41308. exitVR(): void;
  41309. /**
  41310. * The position of the vr experience helper.
  41311. */
  41312. /**
  41313. * Sets the position of the vr experience helper.
  41314. */
  41315. position: Vector3;
  41316. /**
  41317. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41318. */
  41319. enableInteractions(): void;
  41320. private readonly _noControllerIsActive;
  41321. private beforeRender;
  41322. private _isTeleportationFloor;
  41323. /**
  41324. * Adds a floor mesh to be used for teleportation.
  41325. * @param floorMesh the mesh to be used for teleportation.
  41326. */
  41327. addFloorMesh(floorMesh: Mesh): void;
  41328. /**
  41329. * Removes a floor mesh from being used for teleportation.
  41330. * @param floorMesh the mesh to be removed.
  41331. */
  41332. removeFloorMesh(floorMesh: Mesh): void;
  41333. /**
  41334. * Enables interactions and teleportation using the VR controllers and gaze.
  41335. * @param vrTeleportationOptions options to modify teleportation behavior.
  41336. */
  41337. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41338. private _onNewGamepadConnected;
  41339. private _tryEnableInteractionOnController;
  41340. private _onNewGamepadDisconnected;
  41341. private _enableInteractionOnController;
  41342. private _checkTeleportWithRay;
  41343. private _checkRotate;
  41344. private _checkTeleportBackwards;
  41345. private _enableTeleportationOnController;
  41346. private _createTeleportationCircles;
  41347. private _displayTeleportationTarget;
  41348. private _hideTeleportationTarget;
  41349. private _rotateCamera;
  41350. private _moveTeleportationSelectorTo;
  41351. private _workingVector;
  41352. private _workingQuaternion;
  41353. private _workingMatrix;
  41354. /**
  41355. * Teleports the users feet to the desired location
  41356. * @param location The location where the user's feet should be placed
  41357. */
  41358. teleportCamera(location: Vector3): void;
  41359. private _convertNormalToDirectionOfRay;
  41360. private _castRayAndSelectObject;
  41361. private _notifySelectedMeshUnselected;
  41362. /**
  41363. * Sets the color of the laser ray from the vr controllers.
  41364. * @param color new color for the ray.
  41365. */
  41366. changeLaserColor(color: Color3): void;
  41367. /**
  41368. * Sets the color of the ray from the vr headsets gaze.
  41369. * @param color new color for the ray.
  41370. */
  41371. changeGazeColor(color: Color3): void;
  41372. /**
  41373. * Exits VR and disposes of the vr experience helper
  41374. */
  41375. dispose(): void;
  41376. /**
  41377. * Gets the name of the VRExperienceHelper class
  41378. * @returns "VRExperienceHelper"
  41379. */
  41380. getClassName(): string;
  41381. }
  41382. }
  41383. declare module BABYLON {
  41384. /**
  41385. * Manages an XRSession to work with Babylon's engine
  41386. * @see https://doc.babylonjs.com/how_to/webxr
  41387. */
  41388. export class WebXRSessionManager implements IDisposable {
  41389. private scene;
  41390. /**
  41391. * Fires every time a new xrFrame arrives which can be used to update the camera
  41392. */
  41393. onXRFrameObservable: Observable<any>;
  41394. /**
  41395. * Fires when the xr session is ended either by the device or manually done
  41396. */
  41397. onXRSessionEnded: Observable<any>;
  41398. /**
  41399. * Underlying xr session
  41400. */
  41401. session: XRSession;
  41402. /**
  41403. * Type of reference space used when creating the session
  41404. */
  41405. referenceSpace: XRReferenceSpace;
  41406. /** @hidden */
  41407. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41408. /**
  41409. * Current XR frame
  41410. */
  41411. currentFrame: Nullable<XRFrame>;
  41412. private _xrNavigator;
  41413. private baseLayer;
  41414. /**
  41415. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41416. * @param scene The scene which the session should be created for
  41417. */
  41418. constructor(scene: Scene);
  41419. /**
  41420. * Initializes the manager
  41421. * After initialization enterXR can be called to start an XR session
  41422. * @returns Promise which resolves after it is initialized
  41423. */
  41424. initializeAsync(): Promise<void>;
  41425. /**
  41426. * Initializes an xr session
  41427. * @param xrSessionMode mode to initialize
  41428. * @returns a promise which will resolve once the session has been initialized
  41429. */
  41430. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41431. /**
  41432. * Sets the reference space on the xr session
  41433. * @param referenceSpace space to set
  41434. * @returns a promise that will resolve once the reference space has been set
  41435. */
  41436. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41437. /**
  41438. * Updates the render state of the session
  41439. * @param state state to set
  41440. * @returns a promise that resolves once the render state has been updated
  41441. */
  41442. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41443. /**
  41444. * Starts rendering to the xr layer
  41445. * @returns a promise that will resolve once rendering has started
  41446. */
  41447. startRenderingToXRAsync(): Promise<void>;
  41448. /**
  41449. * Stops the xrSession and restores the renderloop
  41450. * @returns Promise which resolves after it exits XR
  41451. */
  41452. exitXRAsync(): Promise<unknown>;
  41453. /**
  41454. * Checks if a session would be supported for the creation options specified
  41455. * @param sessionMode session mode to check if supported eg. immersive-vr
  41456. * @returns true if supported
  41457. */
  41458. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41459. /**
  41460. * @hidden
  41461. * Converts the render layer of xrSession to a render target
  41462. * @param session session to create render target for
  41463. * @param scene scene the new render target should be created for
  41464. */
  41465. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41466. /**
  41467. * Disposes of the session manager
  41468. */
  41469. dispose(): void;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /**
  41474. * WebXR Camera which holds the views for the xrSession
  41475. * @see https://doc.babylonjs.com/how_to/webxr
  41476. */
  41477. export class WebXRCamera extends FreeCamera {
  41478. private static _TmpMatrix;
  41479. /**
  41480. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41481. * @param name the name of the camera
  41482. * @param scene the scene to add the camera to
  41483. */
  41484. constructor(name: string, scene: Scene);
  41485. private _updateNumberOfRigCameras;
  41486. /** @hidden */
  41487. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41488. /**
  41489. * Updates the cameras position from the current pose information of the XR session
  41490. * @param xrSessionManager the session containing pose information
  41491. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41492. */
  41493. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /**
  41498. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41499. */
  41500. export class WebXRManagedOutputCanvas implements IDisposable {
  41501. private helper;
  41502. private _canvas;
  41503. /**
  41504. * xrpresent context of the canvas which can be used to display/mirror xr content
  41505. */
  41506. canvasContext: WebGLRenderingContext;
  41507. /**
  41508. * xr layer for the canvas
  41509. */
  41510. xrLayer: Nullable<XRWebGLLayer>;
  41511. /**
  41512. * Initializes the xr layer for the session
  41513. * @param xrSession xr session
  41514. * @returns a promise that will resolve once the XR Layer has been created
  41515. */
  41516. initializeXRLayerAsync(xrSession: any): any;
  41517. /**
  41518. * Initializes the canvas to be added/removed upon entering/exiting xr
  41519. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41520. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41521. */
  41522. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41523. /**
  41524. * Disposes of the object
  41525. */
  41526. dispose(): void;
  41527. private _setManagedOutputCanvas;
  41528. private _addCanvas;
  41529. private _removeCanvas;
  41530. }
  41531. }
  41532. declare module BABYLON {
  41533. /**
  41534. * States of the webXR experience
  41535. */
  41536. export enum WebXRState {
  41537. /**
  41538. * Transitioning to being in XR mode
  41539. */
  41540. ENTERING_XR = 0,
  41541. /**
  41542. * Transitioning to non XR mode
  41543. */
  41544. EXITING_XR = 1,
  41545. /**
  41546. * In XR mode and presenting
  41547. */
  41548. IN_XR = 2,
  41549. /**
  41550. * Not entered XR mode
  41551. */
  41552. NOT_IN_XR = 3
  41553. }
  41554. /**
  41555. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41556. * @see https://doc.babylonjs.com/how_to/webxr
  41557. */
  41558. export class WebXRExperienceHelper implements IDisposable {
  41559. private scene;
  41560. /**
  41561. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41562. */
  41563. container: AbstractMesh;
  41564. /**
  41565. * Camera used to render xr content
  41566. */
  41567. camera: WebXRCamera;
  41568. /**
  41569. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41570. */
  41571. state: WebXRState;
  41572. private _setState;
  41573. private static _TmpVector;
  41574. /**
  41575. * Fires when the state of the experience helper has changed
  41576. */
  41577. onStateChangedObservable: Observable<WebXRState>;
  41578. /** Session manager used to keep track of xr session */
  41579. sessionManager: WebXRSessionManager;
  41580. private _nonVRCamera;
  41581. private _originalSceneAutoClear;
  41582. private _supported;
  41583. /**
  41584. * Creates the experience helper
  41585. * @param scene the scene to attach the experience helper to
  41586. * @returns a promise for the experience helper
  41587. */
  41588. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41589. /**
  41590. * Creates a WebXRExperienceHelper
  41591. * @param scene The scene the helper should be created in
  41592. */
  41593. private constructor();
  41594. /**
  41595. * Exits XR mode and returns the scene to its original state
  41596. * @returns promise that resolves after xr mode has exited
  41597. */
  41598. exitXRAsync(): Promise<unknown>;
  41599. /**
  41600. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41601. * @param sessionCreationOptions options for the XR session
  41602. * @param referenceSpaceType frame of reference of the XR session
  41603. * @param outputCanvas the output canvas that will be used to enter XR mode
  41604. * @returns promise that resolves after xr mode has entered
  41605. */
  41606. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41607. /**
  41608. * Updates the global position of the camera by moving the camera's container
  41609. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41610. * @param position The desired global position of the camera
  41611. */
  41612. setPositionOfCameraUsingContainer(position: Vector3): void;
  41613. /**
  41614. * Rotates the xr camera by rotating the camera's container around the camera's position
  41615. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41616. * @param rotation the desired quaternion rotation to apply to the camera
  41617. */
  41618. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41619. /**
  41620. * Disposes of the experience helper
  41621. */
  41622. dispose(): void;
  41623. }
  41624. }
  41625. declare module BABYLON {
  41626. /**
  41627. * Button which can be used to enter a different mode of XR
  41628. */
  41629. export class WebXREnterExitUIButton {
  41630. /** button element */
  41631. element: HTMLElement;
  41632. /** XR initialization options for the button */
  41633. sessionMode: XRSessionMode;
  41634. /** Reference space type */
  41635. referenceSpaceType: XRReferenceSpaceType;
  41636. /**
  41637. * Creates a WebXREnterExitUIButton
  41638. * @param element button element
  41639. * @param sessionMode XR initialization session mode
  41640. * @param referenceSpaceType the type of reference space to be used
  41641. */
  41642. constructor(
  41643. /** button element */
  41644. element: HTMLElement,
  41645. /** XR initialization options for the button */
  41646. sessionMode: XRSessionMode,
  41647. /** Reference space type */
  41648. referenceSpaceType: XRReferenceSpaceType);
  41649. /**
  41650. * Overwritable function which can be used to update the button's visuals when the state changes
  41651. * @param activeButton the current active button in the UI
  41652. */
  41653. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41654. }
  41655. /**
  41656. * Options to create the webXR UI
  41657. */
  41658. export class WebXREnterExitUIOptions {
  41659. /**
  41660. * Context to enter xr with
  41661. */
  41662. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41663. /**
  41664. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41665. */
  41666. customButtons?: Array<WebXREnterExitUIButton>;
  41667. }
  41668. /**
  41669. * UI to allow the user to enter/exit XR mode
  41670. */
  41671. export class WebXREnterExitUI implements IDisposable {
  41672. private scene;
  41673. private _overlay;
  41674. private _buttons;
  41675. private _activeButton;
  41676. /**
  41677. * Fired every time the active button is changed.
  41678. *
  41679. * When xr is entered via a button that launches xr that button will be the callback parameter
  41680. *
  41681. * When exiting xr the callback parameter will be null)
  41682. */
  41683. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41684. /**
  41685. * Creates UI to allow the user to enter/exit XR mode
  41686. * @param scene the scene to add the ui to
  41687. * @param helper the xr experience helper to enter/exit xr with
  41688. * @param options options to configure the UI
  41689. * @returns the created ui
  41690. */
  41691. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41692. private constructor();
  41693. private _updateButtons;
  41694. /**
  41695. * Disposes of the object
  41696. */
  41697. dispose(): void;
  41698. }
  41699. }
  41700. declare module BABYLON {
  41701. /**
  41702. * Represents an XR input
  41703. */
  41704. export class WebXRController {
  41705. private scene;
  41706. /** The underlying input source for the controller */
  41707. inputSource: XRInputSource;
  41708. private parentContainer;
  41709. /**
  41710. * 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
  41711. */
  41712. grip?: AbstractMesh;
  41713. /**
  41714. * Pointer which can be used to select objects or attach a visible laser to
  41715. */
  41716. pointer: AbstractMesh;
  41717. /**
  41718. * Event that fires when the controller is removed/disposed
  41719. */
  41720. onDisposeObservable: Observable<{}>;
  41721. private _tmpMatrix;
  41722. private _tmpQuaternion;
  41723. private _tmpVector;
  41724. /**
  41725. * Creates the controller
  41726. * @see https://doc.babylonjs.com/how_to/webxr
  41727. * @param scene the scene which the controller should be associated to
  41728. * @param inputSource the underlying input source for the controller
  41729. * @param parentContainer parent that the controller meshes should be children of
  41730. */
  41731. constructor(scene: Scene,
  41732. /** The underlying input source for the controller */
  41733. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41734. /**
  41735. * Updates the controller pose based on the given XRFrame
  41736. * @param xrFrame xr frame to update the pose with
  41737. * @param referenceSpace reference space to use
  41738. */
  41739. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41740. /**
  41741. * Gets a world space ray coming from the controller
  41742. * @param result the resulting ray
  41743. */
  41744. getWorldPointerRayToRef(result: Ray): void;
  41745. /**
  41746. * Disposes of the object
  41747. */
  41748. dispose(): void;
  41749. }
  41750. }
  41751. declare module BABYLON {
  41752. /**
  41753. * XR input used to track XR inputs such as controllers/rays
  41754. */
  41755. export class WebXRInput implements IDisposable {
  41756. /**
  41757. * Base experience the input listens to
  41758. */
  41759. baseExperience: WebXRExperienceHelper;
  41760. /**
  41761. * XR controllers being tracked
  41762. */
  41763. controllers: Array<WebXRController>;
  41764. private _frameObserver;
  41765. private _stateObserver;
  41766. /**
  41767. * Event when a controller has been connected/added
  41768. */
  41769. onControllerAddedObservable: Observable<WebXRController>;
  41770. /**
  41771. * Event when a controller has been removed/disconnected
  41772. */
  41773. onControllerRemovedObservable: Observable<WebXRController>;
  41774. /**
  41775. * Initializes the WebXRInput
  41776. * @param baseExperience experience helper which the input should be created for
  41777. */
  41778. constructor(
  41779. /**
  41780. * Base experience the input listens to
  41781. */
  41782. baseExperience: WebXRExperienceHelper);
  41783. private _onInputSourcesChange;
  41784. private _addAndRemoveControllers;
  41785. /**
  41786. * Disposes of the object
  41787. */
  41788. dispose(): void;
  41789. }
  41790. }
  41791. declare module BABYLON {
  41792. /**
  41793. * Enables teleportation
  41794. */
  41795. export class WebXRControllerTeleportation {
  41796. private _teleportationFillColor;
  41797. private _teleportationBorderColor;
  41798. private _tmpRay;
  41799. private _tmpVector;
  41800. /**
  41801. * Creates a WebXRControllerTeleportation
  41802. * @param input input manager to add teleportation to
  41803. * @param floorMeshes floormeshes which can be teleported to
  41804. */
  41805. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41806. }
  41807. }
  41808. declare module BABYLON {
  41809. /**
  41810. * Handles pointer input automatically for the pointer of XR controllers
  41811. */
  41812. export class WebXRControllerPointerSelection {
  41813. private static _idCounter;
  41814. private _tmpRay;
  41815. /**
  41816. * Creates a WebXRControllerPointerSelection
  41817. * @param input input manager to setup pointer selection
  41818. */
  41819. constructor(input: WebXRInput);
  41820. private _convertNormalToDirectionOfRay;
  41821. private _updatePointerDistance;
  41822. }
  41823. }
  41824. declare module BABYLON {
  41825. /**
  41826. * Class used to represent data loading progression
  41827. */
  41828. export class SceneLoaderProgressEvent {
  41829. /** defines if data length to load can be evaluated */
  41830. readonly lengthComputable: boolean;
  41831. /** defines the loaded data length */
  41832. readonly loaded: number;
  41833. /** defines the data length to load */
  41834. readonly total: number;
  41835. /**
  41836. * Create a new progress event
  41837. * @param lengthComputable defines if data length to load can be evaluated
  41838. * @param loaded defines the loaded data length
  41839. * @param total defines the data length to load
  41840. */
  41841. constructor(
  41842. /** defines if data length to load can be evaluated */
  41843. lengthComputable: boolean,
  41844. /** defines the loaded data length */
  41845. loaded: number,
  41846. /** defines the data length to load */
  41847. total: number);
  41848. /**
  41849. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41850. * @param event defines the source event
  41851. * @returns a new SceneLoaderProgressEvent
  41852. */
  41853. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41854. }
  41855. /**
  41856. * Interface used by SceneLoader plugins to define supported file extensions
  41857. */
  41858. export interface ISceneLoaderPluginExtensions {
  41859. /**
  41860. * Defines the list of supported extensions
  41861. */
  41862. [extension: string]: {
  41863. isBinary: boolean;
  41864. };
  41865. }
  41866. /**
  41867. * Interface used by SceneLoader plugin factory
  41868. */
  41869. export interface ISceneLoaderPluginFactory {
  41870. /**
  41871. * Defines the name of the factory
  41872. */
  41873. name: string;
  41874. /**
  41875. * Function called to create a new plugin
  41876. * @return the new plugin
  41877. */
  41878. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41879. /**
  41880. * Boolean indicating if the plugin can direct load specific data
  41881. */
  41882. canDirectLoad?: (data: string) => boolean;
  41883. }
  41884. /**
  41885. * Interface used to define a SceneLoader plugin
  41886. */
  41887. export interface ISceneLoaderPlugin {
  41888. /**
  41889. * The friendly name of this plugin.
  41890. */
  41891. name: string;
  41892. /**
  41893. * The file extensions supported by this plugin.
  41894. */
  41895. extensions: string | ISceneLoaderPluginExtensions;
  41896. /**
  41897. * Import meshes into a scene.
  41898. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41899. * @param scene The scene to import into
  41900. * @param data The data to import
  41901. * @param rootUrl The root url for scene and resources
  41902. * @param meshes The meshes array to import into
  41903. * @param particleSystems The particle systems array to import into
  41904. * @param skeletons The skeletons array to import into
  41905. * @param onError The callback when import fails
  41906. * @returns True if successful or false otherwise
  41907. */
  41908. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41909. /**
  41910. * Load into a scene.
  41911. * @param scene The scene to load into
  41912. * @param data The data to import
  41913. * @param rootUrl The root url for scene and resources
  41914. * @param onError The callback when import fails
  41915. * @returns true if successful or false otherwise
  41916. */
  41917. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41918. /**
  41919. * The callback that returns true if the data can be directly loaded.
  41920. */
  41921. canDirectLoad?: (data: string) => boolean;
  41922. /**
  41923. * The callback that allows custom handling of the root url based on the response url.
  41924. */
  41925. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41926. /**
  41927. * Load into an asset container.
  41928. * @param scene The scene to load into
  41929. * @param data The data to import
  41930. * @param rootUrl The root url for scene and resources
  41931. * @param onError The callback when import fails
  41932. * @returns The loaded asset container
  41933. */
  41934. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41935. }
  41936. /**
  41937. * Interface used to define an async SceneLoader plugin
  41938. */
  41939. export interface ISceneLoaderPluginAsync {
  41940. /**
  41941. * The friendly name of this plugin.
  41942. */
  41943. name: string;
  41944. /**
  41945. * The file extensions supported by this plugin.
  41946. */
  41947. extensions: string | ISceneLoaderPluginExtensions;
  41948. /**
  41949. * Import meshes into a scene.
  41950. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41951. * @param scene The scene to import into
  41952. * @param data The data to import
  41953. * @param rootUrl The root url for scene and resources
  41954. * @param onProgress The callback when the load progresses
  41955. * @param fileName Defines the name of the file to load
  41956. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41957. */
  41958. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41959. meshes: AbstractMesh[];
  41960. particleSystems: IParticleSystem[];
  41961. skeletons: Skeleton[];
  41962. animationGroups: AnimationGroup[];
  41963. }>;
  41964. /**
  41965. * Load into a scene.
  41966. * @param scene The scene to load into
  41967. * @param data The data to import
  41968. * @param rootUrl The root url for scene and resources
  41969. * @param onProgress The callback when the load progresses
  41970. * @param fileName Defines the name of the file to load
  41971. * @returns Nothing
  41972. */
  41973. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41974. /**
  41975. * The callback that returns true if the data can be directly loaded.
  41976. */
  41977. canDirectLoad?: (data: string) => boolean;
  41978. /**
  41979. * The callback that allows custom handling of the root url based on the response url.
  41980. */
  41981. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41982. /**
  41983. * Load into an asset container.
  41984. * @param scene The scene to load into
  41985. * @param data The data to import
  41986. * @param rootUrl The root url for scene and resources
  41987. * @param onProgress The callback when the load progresses
  41988. * @param fileName Defines the name of the file to load
  41989. * @returns The loaded asset container
  41990. */
  41991. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41992. }
  41993. /**
  41994. * Class used to load scene from various file formats using registered plugins
  41995. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41996. */
  41997. export class SceneLoader {
  41998. /**
  41999. * No logging while loading
  42000. */
  42001. static readonly NO_LOGGING: number;
  42002. /**
  42003. * Minimal logging while loading
  42004. */
  42005. static readonly MINIMAL_LOGGING: number;
  42006. /**
  42007. * Summary logging while loading
  42008. */
  42009. static readonly SUMMARY_LOGGING: number;
  42010. /**
  42011. * Detailled logging while loading
  42012. */
  42013. static readonly DETAILED_LOGGING: number;
  42014. /**
  42015. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42016. */
  42017. static ForceFullSceneLoadingForIncremental: boolean;
  42018. /**
  42019. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42020. */
  42021. static ShowLoadingScreen: boolean;
  42022. /**
  42023. * Defines the current logging level (while loading the scene)
  42024. * @ignorenaming
  42025. */
  42026. static loggingLevel: number;
  42027. /**
  42028. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42029. */
  42030. static CleanBoneMatrixWeights: boolean;
  42031. /**
  42032. * Event raised when a plugin is used to load a scene
  42033. */
  42034. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42035. private static _registeredPlugins;
  42036. private static _getDefaultPlugin;
  42037. private static _getPluginForExtension;
  42038. private static _getPluginForDirectLoad;
  42039. private static _getPluginForFilename;
  42040. private static _getDirectLoad;
  42041. private static _loadData;
  42042. private static _getFileInfo;
  42043. /**
  42044. * Gets a plugin that can load the given extension
  42045. * @param extension defines the extension to load
  42046. * @returns a plugin or null if none works
  42047. */
  42048. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42049. /**
  42050. * Gets a boolean indicating that the given extension can be loaded
  42051. * @param extension defines the extension to load
  42052. * @returns true if the extension is supported
  42053. */
  42054. static IsPluginForExtensionAvailable(extension: string): boolean;
  42055. /**
  42056. * Adds a new plugin to the list of registered plugins
  42057. * @param plugin defines the plugin to add
  42058. */
  42059. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42060. /**
  42061. * Import meshes into a scene
  42062. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42063. * @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)
  42064. * @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)
  42065. * @param scene the instance of BABYLON.Scene to append to
  42066. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42067. * @param onProgress a callback with a progress event for each file being loaded
  42068. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42069. * @param pluginExtension the extension used to determine the plugin
  42070. * @returns The loaded plugin
  42071. */
  42072. 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>;
  42073. /**
  42074. * Import meshes into a scene
  42075. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42076. * @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)
  42077. * @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)
  42078. * @param scene the instance of BABYLON.Scene to append to
  42079. * @param onProgress a callback with a progress event for each file being loaded
  42080. * @param pluginExtension the extension used to determine the plugin
  42081. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42082. */
  42083. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42084. meshes: AbstractMesh[];
  42085. particleSystems: IParticleSystem[];
  42086. skeletons: Skeleton[];
  42087. animationGroups: AnimationGroup[];
  42088. }>;
  42089. /**
  42090. * Load a scene
  42091. * @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)
  42092. * @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)
  42093. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42094. * @param onSuccess a callback with the scene when import succeeds
  42095. * @param onProgress a callback with a progress event for each file being loaded
  42096. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42097. * @param pluginExtension the extension used to determine the plugin
  42098. * @returns The loaded plugin
  42099. */
  42100. 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>;
  42101. /**
  42102. * Load a scene
  42103. * @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)
  42104. * @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)
  42105. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42106. * @param onProgress a callback with a progress event for each file being loaded
  42107. * @param pluginExtension the extension used to determine the plugin
  42108. * @returns The loaded scene
  42109. */
  42110. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42111. /**
  42112. * Append a scene
  42113. * @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)
  42114. * @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)
  42115. * @param scene is the instance of BABYLON.Scene to append to
  42116. * @param onSuccess a callback with the scene when import succeeds
  42117. * @param onProgress a callback with a progress event for each file being loaded
  42118. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42119. * @param pluginExtension the extension used to determine the plugin
  42120. * @returns The loaded plugin
  42121. */
  42122. 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>;
  42123. /**
  42124. * Append a scene
  42125. * @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)
  42126. * @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)
  42127. * @param scene is the instance of BABYLON.Scene to append to
  42128. * @param onProgress a callback with a progress event for each file being loaded
  42129. * @param pluginExtension the extension used to determine the plugin
  42130. * @returns The given scene
  42131. */
  42132. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42133. /**
  42134. * Load a scene into an asset container
  42135. * @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)
  42136. * @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)
  42137. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42138. * @param onSuccess a callback with the scene when import succeeds
  42139. * @param onProgress a callback with a progress event for each file being loaded
  42140. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42141. * @param pluginExtension the extension used to determine the plugin
  42142. * @returns The loaded plugin
  42143. */
  42144. 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>;
  42145. /**
  42146. * Load a scene into an asset container
  42147. * @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)
  42148. * @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)
  42149. * @param scene is the instance of Scene to append to
  42150. * @param onProgress a callback with a progress event for each file being loaded
  42151. * @param pluginExtension the extension used to determine the plugin
  42152. * @returns The loaded asset container
  42153. */
  42154. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /**
  42159. * Generic Controller
  42160. */
  42161. export class GenericController extends WebVRController {
  42162. /**
  42163. * Base Url for the controller model.
  42164. */
  42165. static readonly MODEL_BASE_URL: string;
  42166. /**
  42167. * File name for the controller model.
  42168. */
  42169. static readonly MODEL_FILENAME: string;
  42170. /**
  42171. * Creates a new GenericController from a gamepad
  42172. * @param vrGamepad the gamepad that the controller should be created from
  42173. */
  42174. constructor(vrGamepad: any);
  42175. /**
  42176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42177. * @param scene scene in which to add meshes
  42178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42179. */
  42180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42181. /**
  42182. * Called once for each button that changed state since the last frame
  42183. * @param buttonIdx Which button index changed
  42184. * @param state New state of the button
  42185. * @param changes Which properties on the state changed since last frame
  42186. */
  42187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42188. }
  42189. }
  42190. declare module BABYLON {
  42191. /**
  42192. * Defines the WindowsMotionController object that the state of the windows motion controller
  42193. */
  42194. export class WindowsMotionController extends WebVRController {
  42195. /**
  42196. * The base url used to load the left and right controller models
  42197. */
  42198. static MODEL_BASE_URL: string;
  42199. /**
  42200. * The name of the left controller model file
  42201. */
  42202. static MODEL_LEFT_FILENAME: string;
  42203. /**
  42204. * The name of the right controller model file
  42205. */
  42206. static MODEL_RIGHT_FILENAME: string;
  42207. /**
  42208. * The controller name prefix for this controller type
  42209. */
  42210. static readonly GAMEPAD_ID_PREFIX: string;
  42211. /**
  42212. * The controller id pattern for this controller type
  42213. */
  42214. private static readonly GAMEPAD_ID_PATTERN;
  42215. private _loadedMeshInfo;
  42216. private readonly _mapping;
  42217. /**
  42218. * Fired when the trackpad on this controller is clicked
  42219. */
  42220. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42221. /**
  42222. * Fired when the trackpad on this controller is modified
  42223. */
  42224. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42225. /**
  42226. * The current x and y values of this controller's trackpad
  42227. */
  42228. trackpad: StickValues;
  42229. /**
  42230. * Creates a new WindowsMotionController from a gamepad
  42231. * @param vrGamepad the gamepad that the controller should be created from
  42232. */
  42233. constructor(vrGamepad: any);
  42234. /**
  42235. * Fired when the trigger on this controller is modified
  42236. */
  42237. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42238. /**
  42239. * Fired when the menu button on this controller is modified
  42240. */
  42241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42242. /**
  42243. * Fired when the grip button on this controller is modified
  42244. */
  42245. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42246. /**
  42247. * Fired when the thumbstick button on this controller is modified
  42248. */
  42249. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42250. /**
  42251. * Fired when the touchpad button on this controller is modified
  42252. */
  42253. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42254. /**
  42255. * Fired when the touchpad values on this controller are modified
  42256. */
  42257. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42258. private _updateTrackpad;
  42259. /**
  42260. * Called once per frame by the engine.
  42261. */
  42262. update(): void;
  42263. /**
  42264. * Called once for each button that changed state since the last frame
  42265. * @param buttonIdx Which button index changed
  42266. * @param state New state of the button
  42267. * @param changes Which properties on the state changed since last frame
  42268. */
  42269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42270. /**
  42271. * Moves the buttons on the controller mesh based on their current state
  42272. * @param buttonName the name of the button to move
  42273. * @param buttonValue the value of the button which determines the buttons new position
  42274. */
  42275. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42276. /**
  42277. * Moves the axis on the controller mesh based on its current state
  42278. * @param axis the index of the axis
  42279. * @param axisValue the value of the axis which determines the meshes new position
  42280. * @hidden
  42281. */
  42282. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42283. /**
  42284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42285. * @param scene scene in which to add meshes
  42286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42287. */
  42288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42289. /**
  42290. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42291. * can be transformed by button presses and axes values, based on this._mapping.
  42292. *
  42293. * @param scene scene in which the meshes exist
  42294. * @param meshes list of meshes that make up the controller model to process
  42295. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42296. */
  42297. private processModel;
  42298. private createMeshInfo;
  42299. /**
  42300. * Gets the ray of the controller in the direction the controller is pointing
  42301. * @param length the length the resulting ray should be
  42302. * @returns a ray in the direction the controller is pointing
  42303. */
  42304. getForwardRay(length?: number): Ray;
  42305. /**
  42306. * Disposes of the controller
  42307. */
  42308. dispose(): void;
  42309. }
  42310. }
  42311. declare module BABYLON {
  42312. /**
  42313. * Oculus Touch Controller
  42314. */
  42315. export class OculusTouchController extends WebVRController {
  42316. /**
  42317. * Base Url for the controller model.
  42318. */
  42319. static MODEL_BASE_URL: string;
  42320. /**
  42321. * File name for the left controller model.
  42322. */
  42323. static MODEL_LEFT_FILENAME: string;
  42324. /**
  42325. * File name for the right controller model.
  42326. */
  42327. static MODEL_RIGHT_FILENAME: string;
  42328. /**
  42329. * Base Url for the Quest controller model.
  42330. */
  42331. static QUEST_MODEL_BASE_URL: string;
  42332. /**
  42333. * @hidden
  42334. * If the controllers are running on a device that needs the updated Quest controller models
  42335. */
  42336. static _IsQuest: boolean;
  42337. /**
  42338. * Fired when the secondary trigger on this controller is modified
  42339. */
  42340. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42341. /**
  42342. * Fired when the thumb rest on this controller is modified
  42343. */
  42344. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42345. /**
  42346. * Creates a new OculusTouchController from a gamepad
  42347. * @param vrGamepad the gamepad that the controller should be created from
  42348. */
  42349. constructor(vrGamepad: any);
  42350. /**
  42351. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42352. * @param scene scene in which to add meshes
  42353. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42354. */
  42355. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42356. /**
  42357. * Fired when the A button on this controller is modified
  42358. */
  42359. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42360. /**
  42361. * Fired when the B button on this controller is modified
  42362. */
  42363. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42364. /**
  42365. * Fired when the X button on this controller is modified
  42366. */
  42367. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42368. /**
  42369. * Fired when the Y button on this controller is modified
  42370. */
  42371. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42372. /**
  42373. * Called once for each button that changed state since the last frame
  42374. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42375. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42376. * 2) secondary trigger (same)
  42377. * 3) A (right) X (left), touch, pressed = value
  42378. * 4) B / Y
  42379. * 5) thumb rest
  42380. * @param buttonIdx Which button index changed
  42381. * @param state New state of the button
  42382. * @param changes Which properties on the state changed since last frame
  42383. */
  42384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42385. }
  42386. }
  42387. declare module BABYLON {
  42388. /**
  42389. * Vive Controller
  42390. */
  42391. export class ViveController extends WebVRController {
  42392. /**
  42393. * Base Url for the controller model.
  42394. */
  42395. static MODEL_BASE_URL: string;
  42396. /**
  42397. * File name for the controller model.
  42398. */
  42399. static MODEL_FILENAME: string;
  42400. /**
  42401. * Creates a new ViveController from a gamepad
  42402. * @param vrGamepad the gamepad that the controller should be created from
  42403. */
  42404. constructor(vrGamepad: any);
  42405. /**
  42406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42407. * @param scene scene in which to add meshes
  42408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42409. */
  42410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42411. /**
  42412. * Fired when the left button on this controller is modified
  42413. */
  42414. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42415. /**
  42416. * Fired when the right button on this controller is modified
  42417. */
  42418. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42419. /**
  42420. * Fired when the menu button on this controller is modified
  42421. */
  42422. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42423. /**
  42424. * Called once for each button that changed state since the last frame
  42425. * Vive mapping:
  42426. * 0: touchpad
  42427. * 1: trigger
  42428. * 2: left AND right buttons
  42429. * 3: menu button
  42430. * @param buttonIdx Which button index changed
  42431. * @param state New state of the button
  42432. * @param changes Which properties on the state changed since last frame
  42433. */
  42434. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42435. }
  42436. }
  42437. declare module BABYLON {
  42438. /**
  42439. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42440. */
  42441. export class WebXRControllerModelLoader {
  42442. /**
  42443. * Creates the WebXRControllerModelLoader
  42444. * @param input xr input that creates the controllers
  42445. */
  42446. constructor(input: WebXRInput);
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * Contains an array of blocks representing the octree
  42452. */
  42453. export interface IOctreeContainer<T> {
  42454. /**
  42455. * Blocks within the octree
  42456. */
  42457. blocks: Array<OctreeBlock<T>>;
  42458. }
  42459. /**
  42460. * Class used to store a cell in an octree
  42461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42462. */
  42463. export class OctreeBlock<T> {
  42464. /**
  42465. * Gets the content of the current block
  42466. */
  42467. entries: T[];
  42468. /**
  42469. * Gets the list of block children
  42470. */
  42471. blocks: Array<OctreeBlock<T>>;
  42472. private _depth;
  42473. private _maxDepth;
  42474. private _capacity;
  42475. private _minPoint;
  42476. private _maxPoint;
  42477. private _boundingVectors;
  42478. private _creationFunc;
  42479. /**
  42480. * Creates a new block
  42481. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42482. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42483. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42484. * @param depth defines the current depth of this block in the octree
  42485. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42486. * @param creationFunc defines a callback to call when an element is added to the block
  42487. */
  42488. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42489. /**
  42490. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42491. */
  42492. readonly capacity: number;
  42493. /**
  42494. * Gets the minimum vector (in world space) of the block's bounding box
  42495. */
  42496. readonly minPoint: Vector3;
  42497. /**
  42498. * Gets the maximum vector (in world space) of the block's bounding box
  42499. */
  42500. readonly maxPoint: Vector3;
  42501. /**
  42502. * Add a new element to this block
  42503. * @param entry defines the element to add
  42504. */
  42505. addEntry(entry: T): void;
  42506. /**
  42507. * Remove an element from this block
  42508. * @param entry defines the element to remove
  42509. */
  42510. removeEntry(entry: T): void;
  42511. /**
  42512. * Add an array of elements to this block
  42513. * @param entries defines the array of elements to add
  42514. */
  42515. addEntries(entries: T[]): void;
  42516. /**
  42517. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42518. * @param frustumPlanes defines the frustum planes to test
  42519. * @param selection defines the array to store current content if selection is positive
  42520. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42521. */
  42522. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42523. /**
  42524. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42525. * @param sphereCenter defines the bounding sphere center
  42526. * @param sphereRadius defines the bounding sphere radius
  42527. * @param selection defines the array to store current content if selection is positive
  42528. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42529. */
  42530. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42531. /**
  42532. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42533. * @param ray defines the ray to test with
  42534. * @param selection defines the array to store current content if selection is positive
  42535. */
  42536. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42537. /**
  42538. * Subdivide the content into child blocks (this block will then be empty)
  42539. */
  42540. createInnerBlocks(): void;
  42541. /**
  42542. * @hidden
  42543. */
  42544. 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;
  42545. }
  42546. }
  42547. declare module BABYLON {
  42548. /**
  42549. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42550. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42551. */
  42552. export class Octree<T> {
  42553. /** 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.) */
  42554. maxDepth: number;
  42555. /**
  42556. * Blocks within the octree containing objects
  42557. */
  42558. blocks: Array<OctreeBlock<T>>;
  42559. /**
  42560. * Content stored in the octree
  42561. */
  42562. dynamicContent: T[];
  42563. private _maxBlockCapacity;
  42564. private _selectionContent;
  42565. private _creationFunc;
  42566. /**
  42567. * Creates a octree
  42568. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42569. * @param creationFunc function to be used to instatiate the octree
  42570. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42571. * @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.)
  42572. */
  42573. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42574. /** 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.) */
  42575. maxDepth?: number);
  42576. /**
  42577. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42578. * @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);
  42579. * @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);
  42580. * @param entries meshes to be added to the octree blocks
  42581. */
  42582. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42583. /**
  42584. * Adds a mesh to the octree
  42585. * @param entry Mesh to add to the octree
  42586. */
  42587. addMesh(entry: T): void;
  42588. /**
  42589. * Remove an element from the octree
  42590. * @param entry defines the element to remove
  42591. */
  42592. removeMesh(entry: T): void;
  42593. /**
  42594. * Selects an array of meshes within the frustum
  42595. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42596. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42597. * @returns array of meshes within the frustum
  42598. */
  42599. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42600. /**
  42601. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42602. * @param sphereCenter defines the bounding sphere center
  42603. * @param sphereRadius defines the bounding sphere radius
  42604. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42605. * @returns an array of objects that intersect the sphere
  42606. */
  42607. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42608. /**
  42609. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42610. * @param ray defines the ray to test with
  42611. * @returns array of intersected objects
  42612. */
  42613. intersectsRay(ray: Ray): SmartArray<T>;
  42614. /**
  42615. * Adds a mesh into the octree block if it intersects the block
  42616. */
  42617. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42618. /**
  42619. * Adds a submesh into the octree block if it intersects the block
  42620. */
  42621. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42622. }
  42623. }
  42624. declare module BABYLON {
  42625. interface Scene {
  42626. /**
  42627. * @hidden
  42628. * Backing Filed
  42629. */
  42630. _selectionOctree: Octree<AbstractMesh>;
  42631. /**
  42632. * Gets the octree used to boost mesh selection (picking)
  42633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42634. */
  42635. selectionOctree: Octree<AbstractMesh>;
  42636. /**
  42637. * Creates or updates the octree used to boost selection (picking)
  42638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42639. * @param maxCapacity defines the maximum capacity per leaf
  42640. * @param maxDepth defines the maximum depth of the octree
  42641. * @returns an octree of AbstractMesh
  42642. */
  42643. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42644. }
  42645. interface AbstractMesh {
  42646. /**
  42647. * @hidden
  42648. * Backing Field
  42649. */
  42650. _submeshesOctree: Octree<SubMesh>;
  42651. /**
  42652. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42653. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42654. * @param maxCapacity defines the maximum size of each block (64 by default)
  42655. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42656. * @returns the new octree
  42657. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42659. */
  42660. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42661. }
  42662. /**
  42663. * Defines the octree scene component responsible to manage any octrees
  42664. * in a given scene.
  42665. */
  42666. export class OctreeSceneComponent {
  42667. /**
  42668. * The component name help to identify the component in the list of scene components.
  42669. */
  42670. readonly name: string;
  42671. /**
  42672. * The scene the component belongs to.
  42673. */
  42674. scene: Scene;
  42675. /**
  42676. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42677. */
  42678. readonly checksIsEnabled: boolean;
  42679. /**
  42680. * Creates a new instance of the component for the given scene
  42681. * @param scene Defines the scene to register the component in
  42682. */
  42683. constructor(scene: Scene);
  42684. /**
  42685. * Registers the component in a given scene
  42686. */
  42687. register(): void;
  42688. /**
  42689. * Return the list of active meshes
  42690. * @returns the list of active meshes
  42691. */
  42692. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42693. /**
  42694. * Return the list of active sub meshes
  42695. * @param mesh The mesh to get the candidates sub meshes from
  42696. * @returns the list of active sub meshes
  42697. */
  42698. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42699. private _tempRay;
  42700. /**
  42701. * Return the list of sub meshes intersecting with a given local ray
  42702. * @param mesh defines the mesh to find the submesh for
  42703. * @param localRay defines the ray in local space
  42704. * @returns the list of intersecting sub meshes
  42705. */
  42706. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42707. /**
  42708. * Return the list of sub meshes colliding with a collider
  42709. * @param mesh defines the mesh to find the submesh for
  42710. * @param collider defines the collider to evaluate the collision against
  42711. * @returns the list of colliding sub meshes
  42712. */
  42713. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42714. /**
  42715. * Rebuilds the elements related to this component in case of
  42716. * context lost for instance.
  42717. */
  42718. rebuild(): void;
  42719. /**
  42720. * Disposes the component and the associated ressources.
  42721. */
  42722. dispose(): void;
  42723. }
  42724. }
  42725. declare module BABYLON {
  42726. /**
  42727. * Renders a layer on top of an existing scene
  42728. */
  42729. export class UtilityLayerRenderer implements IDisposable {
  42730. /** the original scene that will be rendered on top of */
  42731. originalScene: Scene;
  42732. private _pointerCaptures;
  42733. private _lastPointerEvents;
  42734. private static _DefaultUtilityLayer;
  42735. private static _DefaultKeepDepthUtilityLayer;
  42736. private _sharedGizmoLight;
  42737. private _renderCamera;
  42738. /**
  42739. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42740. * @returns the camera that is used when rendering the utility layer
  42741. */
  42742. getRenderCamera(): Nullable<Camera>;
  42743. /**
  42744. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42745. * @param cam the camera that should be used when rendering the utility layer
  42746. */
  42747. setRenderCamera(cam: Nullable<Camera>): void;
  42748. /**
  42749. * @hidden
  42750. * Light which used by gizmos to get light shading
  42751. */
  42752. _getSharedGizmoLight(): HemisphericLight;
  42753. /**
  42754. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42755. */
  42756. pickUtilitySceneFirst: boolean;
  42757. /**
  42758. * 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)
  42759. */
  42760. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42761. /**
  42762. * 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)
  42763. */
  42764. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42765. /**
  42766. * The scene that is rendered on top of the original scene
  42767. */
  42768. utilityLayerScene: Scene;
  42769. /**
  42770. * If the utility layer should automatically be rendered on top of existing scene
  42771. */
  42772. shouldRender: boolean;
  42773. /**
  42774. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42775. */
  42776. onlyCheckPointerDownEvents: boolean;
  42777. /**
  42778. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42779. */
  42780. processAllEvents: boolean;
  42781. /**
  42782. * Observable raised when the pointer move from the utility layer scene to the main scene
  42783. */
  42784. onPointerOutObservable: Observable<number>;
  42785. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42786. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42787. private _afterRenderObserver;
  42788. private _sceneDisposeObserver;
  42789. private _originalPointerObserver;
  42790. /**
  42791. * Instantiates a UtilityLayerRenderer
  42792. * @param originalScene the original scene that will be rendered on top of
  42793. * @param handleEvents boolean indicating if the utility layer should handle events
  42794. */
  42795. constructor(
  42796. /** the original scene that will be rendered on top of */
  42797. originalScene: Scene, handleEvents?: boolean);
  42798. private _notifyObservers;
  42799. /**
  42800. * Renders the utility layers scene on top of the original scene
  42801. */
  42802. render(): void;
  42803. /**
  42804. * Disposes of the renderer
  42805. */
  42806. dispose(): void;
  42807. private _updateCamera;
  42808. }
  42809. }
  42810. declare module BABYLON {
  42811. /**
  42812. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42813. */
  42814. export class Gizmo implements IDisposable {
  42815. /** The utility layer the gizmo will be added to */
  42816. gizmoLayer: UtilityLayerRenderer;
  42817. /**
  42818. * The root mesh of the gizmo
  42819. */
  42820. _rootMesh: Mesh;
  42821. private _attachedMesh;
  42822. /**
  42823. * Ratio for the scale of the gizmo (Default: 1)
  42824. */
  42825. scaleRatio: number;
  42826. /**
  42827. * If a custom mesh has been set (Default: false)
  42828. */
  42829. protected _customMeshSet: boolean;
  42830. /**
  42831. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42832. * * When set, interactions will be enabled
  42833. */
  42834. attachedMesh: Nullable<AbstractMesh>;
  42835. /**
  42836. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42837. * @param mesh The mesh to replace the default mesh of the gizmo
  42838. */
  42839. setCustomMesh(mesh: Mesh): void;
  42840. /**
  42841. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42842. */
  42843. updateGizmoRotationToMatchAttachedMesh: boolean;
  42844. /**
  42845. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42846. */
  42847. updateGizmoPositionToMatchAttachedMesh: boolean;
  42848. /**
  42849. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42850. */
  42851. updateScale: boolean;
  42852. protected _interactionsEnabled: boolean;
  42853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42854. private _beforeRenderObserver;
  42855. private _tempVector;
  42856. /**
  42857. * Creates a gizmo
  42858. * @param gizmoLayer The utility layer the gizmo will be added to
  42859. */
  42860. constructor(
  42861. /** The utility layer the gizmo will be added to */
  42862. gizmoLayer?: UtilityLayerRenderer);
  42863. /**
  42864. * Updates the gizmo to match the attached mesh's position/rotation
  42865. */
  42866. protected _update(): void;
  42867. /**
  42868. * Disposes of the gizmo
  42869. */
  42870. dispose(): void;
  42871. }
  42872. }
  42873. declare module BABYLON {
  42874. /**
  42875. * Single plane drag gizmo
  42876. */
  42877. export class PlaneDragGizmo extends Gizmo {
  42878. /**
  42879. * Drag behavior responsible for the gizmos dragging interactions
  42880. */
  42881. dragBehavior: PointerDragBehavior;
  42882. private _pointerObserver;
  42883. /**
  42884. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42885. */
  42886. snapDistance: number;
  42887. /**
  42888. * Event that fires each time the gizmo snaps to a new location.
  42889. * * snapDistance is the the change in distance
  42890. */
  42891. onSnapObservable: Observable<{
  42892. snapDistance: number;
  42893. }>;
  42894. private _plane;
  42895. private _coloredMaterial;
  42896. private _hoverMaterial;
  42897. private _isEnabled;
  42898. private _parent;
  42899. /** @hidden */
  42900. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42901. /** @hidden */
  42902. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42903. /**
  42904. * Creates a PlaneDragGizmo
  42905. * @param gizmoLayer The utility layer the gizmo will be added to
  42906. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42907. * @param color The color of the gizmo
  42908. */
  42909. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42910. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42911. /**
  42912. * If the gizmo is enabled
  42913. */
  42914. isEnabled: boolean;
  42915. /**
  42916. * Disposes of the gizmo
  42917. */
  42918. dispose(): void;
  42919. }
  42920. }
  42921. declare module BABYLON {
  42922. /**
  42923. * Gizmo that enables dragging a mesh along 3 axis
  42924. */
  42925. export class PositionGizmo extends Gizmo {
  42926. /**
  42927. * Internal gizmo used for interactions on the x axis
  42928. */
  42929. xGizmo: AxisDragGizmo;
  42930. /**
  42931. * Internal gizmo used for interactions on the y axis
  42932. */
  42933. yGizmo: AxisDragGizmo;
  42934. /**
  42935. * Internal gizmo used for interactions on the z axis
  42936. */
  42937. zGizmo: AxisDragGizmo;
  42938. /**
  42939. * Internal gizmo used for interactions on the yz plane
  42940. */
  42941. xPlaneGizmo: PlaneDragGizmo;
  42942. /**
  42943. * Internal gizmo used for interactions on the xz plane
  42944. */
  42945. yPlaneGizmo: PlaneDragGizmo;
  42946. /**
  42947. * Internal gizmo used for interactions on the xy plane
  42948. */
  42949. zPlaneGizmo: PlaneDragGizmo;
  42950. /**
  42951. * private variables
  42952. */
  42953. private _meshAttached;
  42954. private _updateGizmoRotationToMatchAttachedMesh;
  42955. private _snapDistance;
  42956. private _scaleRatio;
  42957. /** Fires an event when any of it's sub gizmos are dragged */
  42958. onDragStartObservable: Observable<unknown>;
  42959. /** Fires an event when any of it's sub gizmos are released from dragging */
  42960. onDragEndObservable: Observable<unknown>;
  42961. /**
  42962. * If set to true, planar drag is enabled
  42963. */
  42964. private _planarGizmoEnabled;
  42965. attachedMesh: Nullable<AbstractMesh>;
  42966. /**
  42967. * Creates a PositionGizmo
  42968. * @param gizmoLayer The utility layer the gizmo will be added to
  42969. */
  42970. constructor(gizmoLayer?: UtilityLayerRenderer);
  42971. /**
  42972. * If the planar drag gizmo is enabled
  42973. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42974. */
  42975. planarGizmoEnabled: boolean;
  42976. updateGizmoRotationToMatchAttachedMesh: boolean;
  42977. /**
  42978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42979. */
  42980. snapDistance: number;
  42981. /**
  42982. * Ratio for the scale of the gizmo (Default: 1)
  42983. */
  42984. scaleRatio: number;
  42985. /**
  42986. * Disposes of the gizmo
  42987. */
  42988. dispose(): void;
  42989. /**
  42990. * CustomMeshes are not supported by this gizmo
  42991. * @param mesh The mesh to replace the default mesh of the gizmo
  42992. */
  42993. setCustomMesh(mesh: Mesh): void;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Single axis drag gizmo
  42999. */
  43000. export class AxisDragGizmo extends Gizmo {
  43001. /**
  43002. * Drag behavior responsible for the gizmos dragging interactions
  43003. */
  43004. dragBehavior: PointerDragBehavior;
  43005. private _pointerObserver;
  43006. /**
  43007. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43008. */
  43009. snapDistance: number;
  43010. /**
  43011. * Event that fires each time the gizmo snaps to a new location.
  43012. * * snapDistance is the the change in distance
  43013. */
  43014. onSnapObservable: Observable<{
  43015. snapDistance: number;
  43016. }>;
  43017. private _isEnabled;
  43018. private _parent;
  43019. private _arrow;
  43020. private _coloredMaterial;
  43021. private _hoverMaterial;
  43022. /** @hidden */
  43023. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43024. /** @hidden */
  43025. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43026. /**
  43027. * Creates an AxisDragGizmo
  43028. * @param gizmoLayer The utility layer the gizmo will be added to
  43029. * @param dragAxis The axis which the gizmo will be able to drag on
  43030. * @param color The color of the gizmo
  43031. */
  43032. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43033. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43034. /**
  43035. * If the gizmo is enabled
  43036. */
  43037. isEnabled: boolean;
  43038. /**
  43039. * Disposes of the gizmo
  43040. */
  43041. dispose(): void;
  43042. }
  43043. }
  43044. declare module BABYLON.Debug {
  43045. /**
  43046. * The Axes viewer will show 3 axes in a specific point in space
  43047. */
  43048. export class AxesViewer {
  43049. private _xAxis;
  43050. private _yAxis;
  43051. private _zAxis;
  43052. private _scaleLinesFactor;
  43053. private _instanced;
  43054. /**
  43055. * Gets the hosting scene
  43056. */
  43057. scene: Scene;
  43058. /**
  43059. * Gets or sets a number used to scale line length
  43060. */
  43061. scaleLines: number;
  43062. /** Gets the node hierarchy used to render x-axis */
  43063. readonly xAxis: TransformNode;
  43064. /** Gets the node hierarchy used to render y-axis */
  43065. readonly yAxis: TransformNode;
  43066. /** Gets the node hierarchy used to render z-axis */
  43067. readonly zAxis: TransformNode;
  43068. /**
  43069. * Creates a new AxesViewer
  43070. * @param scene defines the hosting scene
  43071. * @param scaleLines defines a number used to scale line length (1 by default)
  43072. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43073. * @param xAxis defines the node hierarchy used to render the x-axis
  43074. * @param yAxis defines the node hierarchy used to render the y-axis
  43075. * @param zAxis defines the node hierarchy used to render the z-axis
  43076. */
  43077. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43078. /**
  43079. * Force the viewer to update
  43080. * @param position defines the position of the viewer
  43081. * @param xaxis defines the x axis of the viewer
  43082. * @param yaxis defines the y axis of the viewer
  43083. * @param zaxis defines the z axis of the viewer
  43084. */
  43085. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43086. /**
  43087. * Creates an instance of this axes viewer.
  43088. * @returns a new axes viewer with instanced meshes
  43089. */
  43090. createInstance(): AxesViewer;
  43091. /** Releases resources */
  43092. dispose(): void;
  43093. private static _SetRenderingGroupId;
  43094. }
  43095. }
  43096. declare module BABYLON.Debug {
  43097. /**
  43098. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43099. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43100. */
  43101. export class BoneAxesViewer extends AxesViewer {
  43102. /**
  43103. * Gets or sets the target mesh where to display the axes viewer
  43104. */
  43105. mesh: Nullable<Mesh>;
  43106. /**
  43107. * Gets or sets the target bone where to display the axes viewer
  43108. */
  43109. bone: Nullable<Bone>;
  43110. /** Gets current position */
  43111. pos: Vector3;
  43112. /** Gets direction of X axis */
  43113. xaxis: Vector3;
  43114. /** Gets direction of Y axis */
  43115. yaxis: Vector3;
  43116. /** Gets direction of Z axis */
  43117. zaxis: Vector3;
  43118. /**
  43119. * Creates a new BoneAxesViewer
  43120. * @param scene defines the hosting scene
  43121. * @param bone defines the target bone
  43122. * @param mesh defines the target mesh
  43123. * @param scaleLines defines a scaling factor for line length (1 by default)
  43124. */
  43125. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43126. /**
  43127. * Force the viewer to update
  43128. */
  43129. update(): void;
  43130. /** Releases resources */
  43131. dispose(): void;
  43132. }
  43133. }
  43134. declare module BABYLON {
  43135. /**
  43136. * Interface used to define scene explorer extensibility option
  43137. */
  43138. export interface IExplorerExtensibilityOption {
  43139. /**
  43140. * Define the option label
  43141. */
  43142. label: string;
  43143. /**
  43144. * Defines the action to execute on click
  43145. */
  43146. action: (entity: any) => void;
  43147. }
  43148. /**
  43149. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43150. */
  43151. export interface IExplorerExtensibilityGroup {
  43152. /**
  43153. * Defines a predicate to test if a given type mut be extended
  43154. */
  43155. predicate: (entity: any) => boolean;
  43156. /**
  43157. * Gets the list of options added to a type
  43158. */
  43159. entries: IExplorerExtensibilityOption[];
  43160. }
  43161. /**
  43162. * Interface used to define the options to use to create the Inspector
  43163. */
  43164. export interface IInspectorOptions {
  43165. /**
  43166. * Display in overlay mode (default: false)
  43167. */
  43168. overlay?: boolean;
  43169. /**
  43170. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43171. */
  43172. globalRoot?: HTMLElement;
  43173. /**
  43174. * Display the Scene explorer
  43175. */
  43176. showExplorer?: boolean;
  43177. /**
  43178. * Display the property inspector
  43179. */
  43180. showInspector?: boolean;
  43181. /**
  43182. * Display in embed mode (both panes on the right)
  43183. */
  43184. embedMode?: boolean;
  43185. /**
  43186. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43187. */
  43188. handleResize?: boolean;
  43189. /**
  43190. * Allow the panes to popup (default: true)
  43191. */
  43192. enablePopup?: boolean;
  43193. /**
  43194. * Allow the panes to be closed by users (default: true)
  43195. */
  43196. enableClose?: boolean;
  43197. /**
  43198. * Optional list of extensibility entries
  43199. */
  43200. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43201. /**
  43202. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43203. */
  43204. inspectorURL?: string;
  43205. }
  43206. interface Scene {
  43207. /**
  43208. * @hidden
  43209. * Backing field
  43210. */
  43211. _debugLayer: DebugLayer;
  43212. /**
  43213. * Gets the debug layer (aka Inspector) associated with the scene
  43214. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43215. */
  43216. debugLayer: DebugLayer;
  43217. }
  43218. /**
  43219. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43220. * what is happening in your scene
  43221. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43222. */
  43223. export class DebugLayer {
  43224. /**
  43225. * Define the url to get the inspector script from.
  43226. * By default it uses the babylonjs CDN.
  43227. * @ignoreNaming
  43228. */
  43229. static InspectorURL: string;
  43230. private _scene;
  43231. private BJSINSPECTOR;
  43232. private _onPropertyChangedObservable?;
  43233. /**
  43234. * Observable triggered when a property is changed through the inspector.
  43235. */
  43236. readonly onPropertyChangedObservable: any;
  43237. /**
  43238. * Instantiates a new debug layer.
  43239. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43240. * what is happening in your scene
  43241. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43242. * @param scene Defines the scene to inspect
  43243. */
  43244. constructor(scene: Scene);
  43245. /** Creates the inspector window. */
  43246. private _createInspector;
  43247. /**
  43248. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43249. * @param entity defines the entity to select
  43250. * @param lineContainerTitle defines the specific block to highlight
  43251. */
  43252. select(entity: any, lineContainerTitle?: string): void;
  43253. /** Get the inspector from bundle or global */
  43254. private _getGlobalInspector;
  43255. /**
  43256. * Get if the inspector is visible or not.
  43257. * @returns true if visible otherwise, false
  43258. */
  43259. isVisible(): boolean;
  43260. /**
  43261. * Hide the inspector and close its window.
  43262. */
  43263. hide(): void;
  43264. /**
  43265. * Launch the debugLayer.
  43266. * @param config Define the configuration of the inspector
  43267. * @return a promise fulfilled when the debug layer is visible
  43268. */
  43269. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43270. }
  43271. }
  43272. declare module BABYLON {
  43273. /**
  43274. * Class containing static functions to help procedurally build meshes
  43275. */
  43276. export class BoxBuilder {
  43277. /**
  43278. * Creates a box mesh
  43279. * * The parameter `size` sets the size (float) of each box side (default 1)
  43280. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43281. * * 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)
  43282. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43284. * * 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
  43285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43286. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43287. * @param name defines the name of the mesh
  43288. * @param options defines the options used to create the mesh
  43289. * @param scene defines the hosting scene
  43290. * @returns the box mesh
  43291. */
  43292. static CreateBox(name: string, options: {
  43293. size?: number;
  43294. width?: number;
  43295. height?: number;
  43296. depth?: number;
  43297. faceUV?: Vector4[];
  43298. faceColors?: Color4[];
  43299. sideOrientation?: number;
  43300. frontUVs?: Vector4;
  43301. backUVs?: Vector4;
  43302. wrap?: boolean;
  43303. topBaseAt?: number;
  43304. bottomBaseAt?: number;
  43305. updatable?: boolean;
  43306. }, scene?: Nullable<Scene>): Mesh;
  43307. }
  43308. }
  43309. declare module BABYLON {
  43310. /**
  43311. * Class containing static functions to help procedurally build meshes
  43312. */
  43313. export class SphereBuilder {
  43314. /**
  43315. * Creates a sphere mesh
  43316. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43317. * * 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`)
  43318. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43319. * * 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
  43320. * * 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)
  43321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43322. * * 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
  43323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43324. * @param name defines the name of the mesh
  43325. * @param options defines the options used to create the mesh
  43326. * @param scene defines the hosting scene
  43327. * @returns the sphere mesh
  43328. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43329. */
  43330. static CreateSphere(name: string, options: {
  43331. segments?: number;
  43332. diameter?: number;
  43333. diameterX?: number;
  43334. diameterY?: number;
  43335. diameterZ?: number;
  43336. arc?: number;
  43337. slice?: number;
  43338. sideOrientation?: number;
  43339. frontUVs?: Vector4;
  43340. backUVs?: Vector4;
  43341. updatable?: boolean;
  43342. }, scene?: Nullable<Scene>): Mesh;
  43343. }
  43344. }
  43345. declare module BABYLON.Debug {
  43346. /**
  43347. * Used to show the physics impostor around the specific mesh
  43348. */
  43349. export class PhysicsViewer {
  43350. /** @hidden */
  43351. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43352. /** @hidden */
  43353. protected _meshes: Array<Nullable<AbstractMesh>>;
  43354. /** @hidden */
  43355. protected _scene: Nullable<Scene>;
  43356. /** @hidden */
  43357. protected _numMeshes: number;
  43358. /** @hidden */
  43359. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43360. private _renderFunction;
  43361. private _utilityLayer;
  43362. private _debugBoxMesh;
  43363. private _debugSphereMesh;
  43364. private _debugCylinderMesh;
  43365. private _debugMaterial;
  43366. private _debugMeshMeshes;
  43367. /**
  43368. * Creates a new PhysicsViewer
  43369. * @param scene defines the hosting scene
  43370. */
  43371. constructor(scene: Scene);
  43372. /** @hidden */
  43373. protected _updateDebugMeshes(): void;
  43374. /**
  43375. * Renders a specified physic impostor
  43376. * @param impostor defines the impostor to render
  43377. * @param targetMesh defines the mesh represented by the impostor
  43378. * @returns the new debug mesh used to render the impostor
  43379. */
  43380. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43381. /**
  43382. * Hides a specified physic impostor
  43383. * @param impostor defines the impostor to hide
  43384. */
  43385. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43386. private _getDebugMaterial;
  43387. private _getDebugBoxMesh;
  43388. private _getDebugSphereMesh;
  43389. private _getDebugCylinderMesh;
  43390. private _getDebugMeshMesh;
  43391. private _getDebugMesh;
  43392. /** Releases all resources */
  43393. dispose(): void;
  43394. }
  43395. }
  43396. declare module BABYLON {
  43397. /**
  43398. * Class containing static functions to help procedurally build meshes
  43399. */
  43400. export class LinesBuilder {
  43401. /**
  43402. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43403. * * 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
  43404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43405. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43406. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43407. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43408. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43409. * * 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
  43410. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43413. * @param name defines the name of the new line system
  43414. * @param options defines the options used to create the line system
  43415. * @param scene defines the hosting scene
  43416. * @returns a new line system mesh
  43417. */
  43418. static CreateLineSystem(name: string, options: {
  43419. lines: Vector3[][];
  43420. updatable?: boolean;
  43421. instance?: Nullable<LinesMesh>;
  43422. colors?: Nullable<Color4[][]>;
  43423. useVertexAlpha?: boolean;
  43424. }, scene: Nullable<Scene>): LinesMesh;
  43425. /**
  43426. * Creates a line mesh
  43427. * 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
  43428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43429. * * The parameter `points` is an array successive Vector3
  43430. * * 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
  43431. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43432. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43433. * * When updating an instance, remember that only point positions can change, not the number of points
  43434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43436. * @param name defines the name of the new line system
  43437. * @param options defines the options used to create the line system
  43438. * @param scene defines the hosting scene
  43439. * @returns a new line mesh
  43440. */
  43441. static CreateLines(name: string, options: {
  43442. points: Vector3[];
  43443. updatable?: boolean;
  43444. instance?: Nullable<LinesMesh>;
  43445. colors?: Color4[];
  43446. useVertexAlpha?: boolean;
  43447. }, scene?: Nullable<Scene>): LinesMesh;
  43448. /**
  43449. * Creates a dashed line mesh
  43450. * * 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
  43451. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43452. * * The parameter `points` is an array successive Vector3
  43453. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43454. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43455. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43456. * * 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
  43457. * * When updating an instance, remember that only point positions can change, not the number of points
  43458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43459. * @param name defines the name of the mesh
  43460. * @param options defines the options used to create the mesh
  43461. * @param scene defines the hosting scene
  43462. * @returns the dashed line mesh
  43463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43464. */
  43465. static CreateDashedLines(name: string, options: {
  43466. points: Vector3[];
  43467. dashSize?: number;
  43468. gapSize?: number;
  43469. dashNb?: number;
  43470. updatable?: boolean;
  43471. instance?: LinesMesh;
  43472. }, scene?: Nullable<Scene>): LinesMesh;
  43473. }
  43474. }
  43475. declare module BABYLON {
  43476. /**
  43477. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43478. * in order to better appreciate the issue one might have.
  43479. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43480. */
  43481. export class RayHelper {
  43482. /**
  43483. * Defines the ray we are currently tryin to visualize.
  43484. */
  43485. ray: Nullable<Ray>;
  43486. private _renderPoints;
  43487. private _renderLine;
  43488. private _renderFunction;
  43489. private _scene;
  43490. private _updateToMeshFunction;
  43491. private _attachedToMesh;
  43492. private _meshSpaceDirection;
  43493. private _meshSpaceOrigin;
  43494. /**
  43495. * Helper function to create a colored helper in a scene in one line.
  43496. * @param ray Defines the ray we are currently tryin to visualize
  43497. * @param scene Defines the scene the ray is used in
  43498. * @param color Defines the color we want to see the ray in
  43499. * @returns The newly created ray helper.
  43500. */
  43501. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43502. /**
  43503. * Instantiate a new ray helper.
  43504. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43505. * in order to better appreciate the issue one might have.
  43506. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43507. * @param ray Defines the ray we are currently tryin to visualize
  43508. */
  43509. constructor(ray: Ray);
  43510. /**
  43511. * Shows the ray we are willing to debug.
  43512. * @param scene Defines the scene the ray needs to be rendered in
  43513. * @param color Defines the color the ray needs to be rendered in
  43514. */
  43515. show(scene: Scene, color?: Color3): void;
  43516. /**
  43517. * Hides the ray we are debugging.
  43518. */
  43519. hide(): void;
  43520. private _render;
  43521. /**
  43522. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43523. * @param mesh Defines the mesh we want the helper attached to
  43524. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43525. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43526. * @param length Defines the length of the ray
  43527. */
  43528. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43529. /**
  43530. * Detach the ray helper from the mesh it has previously been attached to.
  43531. */
  43532. detachFromMesh(): void;
  43533. private _updateToMesh;
  43534. /**
  43535. * Dispose the helper and release its associated resources.
  43536. */
  43537. dispose(): void;
  43538. }
  43539. }
  43540. declare module BABYLON.Debug {
  43541. /**
  43542. * Class used to render a debug view of a given skeleton
  43543. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43544. */
  43545. export class SkeletonViewer {
  43546. /** defines the skeleton to render */
  43547. skeleton: Skeleton;
  43548. /** defines the mesh attached to the skeleton */
  43549. mesh: AbstractMesh;
  43550. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43551. autoUpdateBonesMatrices: boolean;
  43552. /** defines the rendering group id to use with the viewer */
  43553. renderingGroupId: number;
  43554. /** Gets or sets the color used to render the skeleton */
  43555. color: Color3;
  43556. private _scene;
  43557. private _debugLines;
  43558. private _debugMesh;
  43559. private _isEnabled;
  43560. private _renderFunction;
  43561. private _utilityLayer;
  43562. /**
  43563. * Returns the mesh used to render the bones
  43564. */
  43565. readonly debugMesh: Nullable<LinesMesh>;
  43566. /**
  43567. * Creates a new SkeletonViewer
  43568. * @param skeleton defines the skeleton to render
  43569. * @param mesh defines the mesh attached to the skeleton
  43570. * @param scene defines the hosting scene
  43571. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43572. * @param renderingGroupId defines the rendering group id to use with the viewer
  43573. */
  43574. constructor(
  43575. /** defines the skeleton to render */
  43576. skeleton: Skeleton,
  43577. /** defines the mesh attached to the skeleton */
  43578. mesh: AbstractMesh, scene: Scene,
  43579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43580. autoUpdateBonesMatrices?: boolean,
  43581. /** defines the rendering group id to use with the viewer */
  43582. renderingGroupId?: number);
  43583. /** Gets or sets a boolean indicating if the viewer is enabled */
  43584. isEnabled: boolean;
  43585. private _getBonePosition;
  43586. private _getLinesForBonesWithLength;
  43587. private _getLinesForBonesNoLength;
  43588. /** Update the viewer to sync with current skeleton state */
  43589. update(): void;
  43590. /** Release associated resources */
  43591. dispose(): void;
  43592. }
  43593. }
  43594. declare module BABYLON {
  43595. /**
  43596. * Options to create the null engine
  43597. */
  43598. export class NullEngineOptions {
  43599. /**
  43600. * Render width (Default: 512)
  43601. */
  43602. renderWidth: number;
  43603. /**
  43604. * Render height (Default: 256)
  43605. */
  43606. renderHeight: number;
  43607. /**
  43608. * Texture size (Default: 512)
  43609. */
  43610. textureSize: number;
  43611. /**
  43612. * If delta time between frames should be constant
  43613. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43614. */
  43615. deterministicLockstep: boolean;
  43616. /**
  43617. * Maximum about of steps between frames (Default: 4)
  43618. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43619. */
  43620. lockstepMaxSteps: number;
  43621. }
  43622. /**
  43623. * The null engine class provides support for headless version of babylon.js.
  43624. * This can be used in server side scenario or for testing purposes
  43625. */
  43626. export class NullEngine extends Engine {
  43627. private _options;
  43628. /**
  43629. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43630. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43631. * @returns true if engine is in deterministic lock step mode
  43632. */
  43633. isDeterministicLockStep(): boolean;
  43634. /**
  43635. * Gets the max steps when engine is running in deterministic lock step
  43636. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43637. * @returns the max steps
  43638. */
  43639. getLockstepMaxSteps(): number;
  43640. /**
  43641. * Gets the current hardware scaling level.
  43642. * By default the hardware scaling level is computed from the window device ratio.
  43643. * 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.
  43644. * @returns a number indicating the current hardware scaling level
  43645. */
  43646. getHardwareScalingLevel(): number;
  43647. constructor(options?: NullEngineOptions);
  43648. /**
  43649. * Creates a vertex buffer
  43650. * @param vertices the data for the vertex buffer
  43651. * @returns the new WebGL static buffer
  43652. */
  43653. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43654. /**
  43655. * Creates a new index buffer
  43656. * @param indices defines the content of the index buffer
  43657. * @param updatable defines if the index buffer must be updatable
  43658. * @returns a new webGL buffer
  43659. */
  43660. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43661. /**
  43662. * Clear the current render buffer or the current render target (if any is set up)
  43663. * @param color defines the color to use
  43664. * @param backBuffer defines if the back buffer must be cleared
  43665. * @param depth defines if the depth buffer must be cleared
  43666. * @param stencil defines if the stencil buffer must be cleared
  43667. */
  43668. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43669. /**
  43670. * Gets the current render width
  43671. * @param useScreen defines if screen size must be used (or the current render target if any)
  43672. * @returns a number defining the current render width
  43673. */
  43674. getRenderWidth(useScreen?: boolean): number;
  43675. /**
  43676. * Gets the current render height
  43677. * @param useScreen defines if screen size must be used (or the current render target if any)
  43678. * @returns a number defining the current render height
  43679. */
  43680. getRenderHeight(useScreen?: boolean): number;
  43681. /**
  43682. * Set the WebGL's viewport
  43683. * @param viewport defines the viewport element to be used
  43684. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43685. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43686. */
  43687. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43688. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43689. /**
  43690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43691. * @param pipelineContext defines the pipeline context to use
  43692. * @param uniformsNames defines the list of uniform names
  43693. * @returns an array of webGL uniform locations
  43694. */
  43695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43696. /**
  43697. * Gets the lsit of active attributes for a given webGL program
  43698. * @param pipelineContext defines the pipeline context to use
  43699. * @param attributesNames defines the list of attribute names to get
  43700. * @returns an array of indices indicating the offset of each attribute
  43701. */
  43702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43703. /**
  43704. * Binds an effect to the webGL context
  43705. * @param effect defines the effect to bind
  43706. */
  43707. bindSamplers(effect: Effect): void;
  43708. /**
  43709. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43710. * @param effect defines the effect to activate
  43711. */
  43712. enableEffect(effect: Effect): void;
  43713. /**
  43714. * Set various states to the webGL context
  43715. * @param culling defines backface culling state
  43716. * @param zOffset defines the value to apply to zOffset (0 by default)
  43717. * @param force defines if states must be applied even if cache is up to date
  43718. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43719. */
  43720. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43721. /**
  43722. * Set the value of an uniform to an array of int32
  43723. * @param uniform defines the webGL uniform location where to store the value
  43724. * @param array defines the array of int32 to store
  43725. */
  43726. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43727. /**
  43728. * Set the value of an uniform to an array of int32 (stored as vec2)
  43729. * @param uniform defines the webGL uniform location where to store the value
  43730. * @param array defines the array of int32 to store
  43731. */
  43732. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43733. /**
  43734. * Set the value of an uniform to an array of int32 (stored as vec3)
  43735. * @param uniform defines the webGL uniform location where to store the value
  43736. * @param array defines the array of int32 to store
  43737. */
  43738. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43739. /**
  43740. * Set the value of an uniform to an array of int32 (stored as vec4)
  43741. * @param uniform defines the webGL uniform location where to store the value
  43742. * @param array defines the array of int32 to store
  43743. */
  43744. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43745. /**
  43746. * Set the value of an uniform to an array of float32
  43747. * @param uniform defines the webGL uniform location where to store the value
  43748. * @param array defines the array of float32 to store
  43749. */
  43750. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43751. /**
  43752. * Set the value of an uniform to an array of float32 (stored as vec2)
  43753. * @param uniform defines the webGL uniform location where to store the value
  43754. * @param array defines the array of float32 to store
  43755. */
  43756. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43757. /**
  43758. * Set the value of an uniform to an array of float32 (stored as vec3)
  43759. * @param uniform defines the webGL uniform location where to store the value
  43760. * @param array defines the array of float32 to store
  43761. */
  43762. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43763. /**
  43764. * Set the value of an uniform to an array of float32 (stored as vec4)
  43765. * @param uniform defines the webGL uniform location where to store the value
  43766. * @param array defines the array of float32 to store
  43767. */
  43768. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43769. /**
  43770. * Set the value of an uniform to an array of number
  43771. * @param uniform defines the webGL uniform location where to store the value
  43772. * @param array defines the array of number to store
  43773. */
  43774. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43775. /**
  43776. * Set the value of an uniform to an array of number (stored as vec2)
  43777. * @param uniform defines the webGL uniform location where to store the value
  43778. * @param array defines the array of number to store
  43779. */
  43780. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43781. /**
  43782. * Set the value of an uniform to an array of number (stored as vec3)
  43783. * @param uniform defines the webGL uniform location where to store the value
  43784. * @param array defines the array of number to store
  43785. */
  43786. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43787. /**
  43788. * Set the value of an uniform to an array of number (stored as vec4)
  43789. * @param uniform defines the webGL uniform location where to store the value
  43790. * @param array defines the array of number to store
  43791. */
  43792. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43793. /**
  43794. * Set the value of an uniform to an array of float32 (stored as matrices)
  43795. * @param uniform defines the webGL uniform location where to store the value
  43796. * @param matrices defines the array of float32 to store
  43797. */
  43798. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43799. /**
  43800. * Set the value of an uniform to a matrix (3x3)
  43801. * @param uniform defines the webGL uniform location where to store the value
  43802. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43803. */
  43804. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43805. /**
  43806. * Set the value of an uniform to a matrix (2x2)
  43807. * @param uniform defines the webGL uniform location where to store the value
  43808. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43809. */
  43810. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43811. /**
  43812. * Set the value of an uniform to a number (float)
  43813. * @param uniform defines the webGL uniform location where to store the value
  43814. * @param value defines the float number to store
  43815. */
  43816. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43817. /**
  43818. * Set the value of an uniform to a vec2
  43819. * @param uniform defines the webGL uniform location where to store the value
  43820. * @param x defines the 1st component of the value
  43821. * @param y defines the 2nd component of the value
  43822. */
  43823. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43824. /**
  43825. * Set the value of an uniform to a vec3
  43826. * @param uniform defines the webGL uniform location where to store the value
  43827. * @param x defines the 1st component of the value
  43828. * @param y defines the 2nd component of the value
  43829. * @param z defines the 3rd component of the value
  43830. */
  43831. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43832. /**
  43833. * Set the value of an uniform to a boolean
  43834. * @param uniform defines the webGL uniform location where to store the value
  43835. * @param bool defines the boolean to store
  43836. */
  43837. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43838. /**
  43839. * Set the value of an uniform to a vec4
  43840. * @param uniform defines the webGL uniform location where to store the value
  43841. * @param x defines the 1st component of the value
  43842. * @param y defines the 2nd component of the value
  43843. * @param z defines the 3rd component of the value
  43844. * @param w defines the 4th component of the value
  43845. */
  43846. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43847. /**
  43848. * Sets the current alpha mode
  43849. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43850. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43851. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43852. */
  43853. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43854. /**
  43855. * Bind webGl buffers directly to the webGL context
  43856. * @param vertexBuffers defines the vertex buffer to bind
  43857. * @param indexBuffer defines the index buffer to bind
  43858. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43859. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43860. * @param effect defines the effect associated with the vertex buffer
  43861. */
  43862. bindBuffers(vertexBuffers: {
  43863. [key: string]: VertexBuffer;
  43864. }, indexBuffer: DataBuffer, effect: Effect): void;
  43865. /**
  43866. * Force the entire cache to be cleared
  43867. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43868. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43869. */
  43870. wipeCaches(bruteForce?: boolean): void;
  43871. /**
  43872. * Send a draw order
  43873. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43874. * @param indexStart defines the starting index
  43875. * @param indexCount defines the number of index to draw
  43876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43877. */
  43878. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43879. /**
  43880. * Draw a list of indexed primitives
  43881. * @param fillMode defines the primitive to use
  43882. * @param indexStart defines the starting index
  43883. * @param indexCount defines the number of index to draw
  43884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43885. */
  43886. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43887. /**
  43888. * Draw a list of unindexed primitives
  43889. * @param fillMode defines the primitive to use
  43890. * @param verticesStart defines the index of first vertex to draw
  43891. * @param verticesCount defines the count of vertices to draw
  43892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43893. */
  43894. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43895. /** @hidden */
  43896. _createTexture(): WebGLTexture;
  43897. /** @hidden */
  43898. _releaseTexture(texture: InternalTexture): void;
  43899. /**
  43900. * Usually called from Texture.ts.
  43901. * Passed information to create a WebGLTexture
  43902. * @param urlArg defines a value which contains one of the following:
  43903. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43904. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43905. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43907. * @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)
  43908. * @param scene needed for loading to the correct scene
  43909. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43910. * @param onLoad optional callback to be called upon successful completion
  43911. * @param onError optional callback to be called upon failure
  43912. * @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
  43913. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43914. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43915. * @param forcedExtension defines the extension to use to pick the right loader
  43916. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43917. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43918. */
  43919. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  43920. /**
  43921. * Creates a new render target texture
  43922. * @param size defines the size of the texture
  43923. * @param options defines the options used to create the texture
  43924. * @returns a new render target texture stored in an InternalTexture
  43925. */
  43926. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43927. /**
  43928. * Update the sampling mode of a given texture
  43929. * @param samplingMode defines the required sampling mode
  43930. * @param texture defines the texture to update
  43931. */
  43932. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43933. /**
  43934. * Binds the frame buffer to the specified texture.
  43935. * @param texture The texture to render to or null for the default canvas
  43936. * @param faceIndex The face of the texture to render to in case of cube texture
  43937. * @param requiredWidth The width of the target to render to
  43938. * @param requiredHeight The height of the target to render to
  43939. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43940. * @param depthStencilTexture The depth stencil texture to use to render
  43941. * @param lodLevel defines le lod level to bind to the frame buffer
  43942. */
  43943. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43944. /**
  43945. * Unbind the current render target texture from the webGL context
  43946. * @param texture defines the render target texture to unbind
  43947. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43948. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43949. */
  43950. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43951. /**
  43952. * Creates a dynamic vertex buffer
  43953. * @param vertices the data for the dynamic vertex buffer
  43954. * @returns the new WebGL dynamic buffer
  43955. */
  43956. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43957. /**
  43958. * Update the content of a dynamic texture
  43959. * @param texture defines the texture to update
  43960. * @param canvas defines the canvas containing the source
  43961. * @param invertY defines if data must be stored with Y axis inverted
  43962. * @param premulAlpha defines if alpha is stored as premultiplied
  43963. * @param format defines the format of the data
  43964. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43965. */
  43966. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43967. /**
  43968. * Gets a boolean indicating if all created effects are ready
  43969. * @returns true if all effects are ready
  43970. */
  43971. areAllEffectsReady(): boolean;
  43972. /**
  43973. * @hidden
  43974. * Get the current error code of the webGL context
  43975. * @returns the error code
  43976. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43977. */
  43978. getError(): number;
  43979. /** @hidden */
  43980. _getUnpackAlignement(): number;
  43981. /** @hidden */
  43982. _unpackFlipY(value: boolean): void;
  43983. /**
  43984. * Update a dynamic index buffer
  43985. * @param indexBuffer defines the target index buffer
  43986. * @param indices defines the data to update
  43987. * @param offset defines the offset in the target index buffer where update should start
  43988. */
  43989. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43990. /**
  43991. * Updates a dynamic vertex buffer.
  43992. * @param vertexBuffer the vertex buffer to update
  43993. * @param vertices the data used to update the vertex buffer
  43994. * @param byteOffset the byte offset of the data (optional)
  43995. * @param byteLength the byte length of the data (optional)
  43996. */
  43997. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43998. /** @hidden */
  43999. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44000. /** @hidden */
  44001. _bindTexture(channel: number, texture: InternalTexture): void;
  44002. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44003. /**
  44004. * 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
  44005. */
  44006. releaseEffects(): void;
  44007. displayLoadingUI(): void;
  44008. hideLoadingUI(): void;
  44009. /** @hidden */
  44010. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44011. /** @hidden */
  44012. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44013. /** @hidden */
  44014. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44015. /** @hidden */
  44016. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44017. }
  44018. }
  44019. declare module BABYLON {
  44020. /** @hidden */
  44021. export class _OcclusionDataStorage {
  44022. /** @hidden */
  44023. occlusionInternalRetryCounter: number;
  44024. /** @hidden */
  44025. isOcclusionQueryInProgress: boolean;
  44026. /** @hidden */
  44027. isOccluded: boolean;
  44028. /** @hidden */
  44029. occlusionRetryCount: number;
  44030. /** @hidden */
  44031. occlusionType: number;
  44032. /** @hidden */
  44033. occlusionQueryAlgorithmType: number;
  44034. }
  44035. interface Engine {
  44036. /**
  44037. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44038. * @return the new query
  44039. */
  44040. createQuery(): WebGLQuery;
  44041. /**
  44042. * Delete and release a webGL query
  44043. * @param query defines the query to delete
  44044. * @return the current engine
  44045. */
  44046. deleteQuery(query: WebGLQuery): Engine;
  44047. /**
  44048. * Check if a given query has resolved and got its value
  44049. * @param query defines the query to check
  44050. * @returns true if the query got its value
  44051. */
  44052. isQueryResultAvailable(query: WebGLQuery): boolean;
  44053. /**
  44054. * Gets the value of a given query
  44055. * @param query defines the query to check
  44056. * @returns the value of the query
  44057. */
  44058. getQueryResult(query: WebGLQuery): number;
  44059. /**
  44060. * Initiates an occlusion query
  44061. * @param algorithmType defines the algorithm to use
  44062. * @param query defines the query to use
  44063. * @returns the current engine
  44064. * @see http://doc.babylonjs.com/features/occlusionquery
  44065. */
  44066. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44067. /**
  44068. * Ends an occlusion query
  44069. * @see http://doc.babylonjs.com/features/occlusionquery
  44070. * @param algorithmType defines the algorithm to use
  44071. * @returns the current engine
  44072. */
  44073. endOcclusionQuery(algorithmType: number): Engine;
  44074. /**
  44075. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44076. * Please note that only one query can be issued at a time
  44077. * @returns a time token used to track the time span
  44078. */
  44079. startTimeQuery(): Nullable<_TimeToken>;
  44080. /**
  44081. * Ends a time query
  44082. * @param token defines the token used to measure the time span
  44083. * @returns the time spent (in ns)
  44084. */
  44085. endTimeQuery(token: _TimeToken): int;
  44086. /** @hidden */
  44087. _currentNonTimestampToken: Nullable<_TimeToken>;
  44088. /** @hidden */
  44089. _createTimeQuery(): WebGLQuery;
  44090. /** @hidden */
  44091. _deleteTimeQuery(query: WebGLQuery): void;
  44092. /** @hidden */
  44093. _getGlAlgorithmType(algorithmType: number): number;
  44094. /** @hidden */
  44095. _getTimeQueryResult(query: WebGLQuery): any;
  44096. /** @hidden */
  44097. _getTimeQueryAvailability(query: WebGLQuery): any;
  44098. }
  44099. interface AbstractMesh {
  44100. /**
  44101. * Backing filed
  44102. * @hidden
  44103. */
  44104. __occlusionDataStorage: _OcclusionDataStorage;
  44105. /**
  44106. * Access property
  44107. * @hidden
  44108. */
  44109. _occlusionDataStorage: _OcclusionDataStorage;
  44110. /**
  44111. * 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.
  44112. * The default value is -1 which means don't break the query and wait till the result
  44113. * @see http://doc.babylonjs.com/features/occlusionquery
  44114. */
  44115. occlusionRetryCount: number;
  44116. /**
  44117. * 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:
  44118. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44119. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44120. * * 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.
  44121. * @see http://doc.babylonjs.com/features/occlusionquery
  44122. */
  44123. occlusionType: number;
  44124. /**
  44125. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44126. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44127. * * 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.
  44128. * @see http://doc.babylonjs.com/features/occlusionquery
  44129. */
  44130. occlusionQueryAlgorithmType: number;
  44131. /**
  44132. * 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
  44133. * @see http://doc.babylonjs.com/features/occlusionquery
  44134. */
  44135. isOccluded: boolean;
  44136. /**
  44137. * Flag to check the progress status of the query
  44138. * @see http://doc.babylonjs.com/features/occlusionquery
  44139. */
  44140. isOcclusionQueryInProgress: boolean;
  44141. }
  44142. }
  44143. declare module BABYLON {
  44144. /** @hidden */
  44145. export var _forceTransformFeedbackToBundle: boolean;
  44146. interface Engine {
  44147. /**
  44148. * Creates a webGL transform feedback object
  44149. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44150. * @returns the webGL transform feedback object
  44151. */
  44152. createTransformFeedback(): WebGLTransformFeedback;
  44153. /**
  44154. * Delete a webGL transform feedback object
  44155. * @param value defines the webGL transform feedback object to delete
  44156. */
  44157. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44158. /**
  44159. * Bind a webGL transform feedback object to the webgl context
  44160. * @param value defines the webGL transform feedback object to bind
  44161. */
  44162. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44163. /**
  44164. * Begins a transform feedback operation
  44165. * @param usePoints defines if points or triangles must be used
  44166. */
  44167. beginTransformFeedback(usePoints: boolean): void;
  44168. /**
  44169. * Ends a transform feedback operation
  44170. */
  44171. endTransformFeedback(): void;
  44172. /**
  44173. * Specify the varyings to use with transform feedback
  44174. * @param program defines the associated webGL program
  44175. * @param value defines the list of strings representing the varying names
  44176. */
  44177. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44178. /**
  44179. * Bind a webGL buffer for a transform feedback operation
  44180. * @param value defines the webGL buffer to bind
  44181. */
  44182. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44183. }
  44184. }
  44185. declare module BABYLON {
  44186. /**
  44187. * Creation options of the multi render target texture.
  44188. */
  44189. export interface IMultiRenderTargetOptions {
  44190. /**
  44191. * Define if the texture needs to create mip maps after render.
  44192. */
  44193. generateMipMaps?: boolean;
  44194. /**
  44195. * Define the types of all the draw buffers we want to create
  44196. */
  44197. types?: number[];
  44198. /**
  44199. * Define the sampling modes of all the draw buffers we want to create
  44200. */
  44201. samplingModes?: number[];
  44202. /**
  44203. * Define if a depth buffer is required
  44204. */
  44205. generateDepthBuffer?: boolean;
  44206. /**
  44207. * Define if a stencil buffer is required
  44208. */
  44209. generateStencilBuffer?: boolean;
  44210. /**
  44211. * Define if a depth texture is required instead of a depth buffer
  44212. */
  44213. generateDepthTexture?: boolean;
  44214. /**
  44215. * Define the number of desired draw buffers
  44216. */
  44217. textureCount?: number;
  44218. /**
  44219. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44220. */
  44221. doNotChangeAspectRatio?: boolean;
  44222. /**
  44223. * Define the default type of the buffers we are creating
  44224. */
  44225. defaultType?: number;
  44226. }
  44227. /**
  44228. * A multi render target, like a render target provides the ability to render to a texture.
  44229. * Unlike the render target, it can render to several draw buffers in one draw.
  44230. * This is specially interesting in deferred rendering or for any effects requiring more than
  44231. * just one color from a single pass.
  44232. */
  44233. export class MultiRenderTarget extends RenderTargetTexture {
  44234. private _internalTextures;
  44235. private _textures;
  44236. private _multiRenderTargetOptions;
  44237. /**
  44238. * Get if draw buffers are currently supported by the used hardware and browser.
  44239. */
  44240. readonly isSupported: boolean;
  44241. /**
  44242. * Get the list of textures generated by the multi render target.
  44243. */
  44244. readonly textures: Texture[];
  44245. /**
  44246. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44247. */
  44248. readonly depthTexture: Texture;
  44249. /**
  44250. * Set the wrapping mode on U of all the textures we are rendering to.
  44251. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44252. */
  44253. wrapU: number;
  44254. /**
  44255. * Set the wrapping mode on V of all the textures we are rendering to.
  44256. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44257. */
  44258. wrapV: number;
  44259. /**
  44260. * Instantiate a new multi render target texture.
  44261. * A multi render target, like a render target provides the ability to render to a texture.
  44262. * Unlike the render target, it can render to several draw buffers in one draw.
  44263. * This is specially interesting in deferred rendering or for any effects requiring more than
  44264. * just one color from a single pass.
  44265. * @param name Define the name of the texture
  44266. * @param size Define the size of the buffers to render to
  44267. * @param count Define the number of target we are rendering into
  44268. * @param scene Define the scene the texture belongs to
  44269. * @param options Define the options used to create the multi render target
  44270. */
  44271. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44272. /** @hidden */
  44273. _rebuild(): void;
  44274. private _createInternalTextures;
  44275. private _createTextures;
  44276. /**
  44277. * Define the number of samples used if MSAA is enabled.
  44278. */
  44279. samples: number;
  44280. /**
  44281. * Resize all the textures in the multi render target.
  44282. * Be carrefull as it will recreate all the data in the new texture.
  44283. * @param size Define the new size
  44284. */
  44285. resize(size: any): void;
  44286. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44287. /**
  44288. * Dispose the render targets and their associated resources
  44289. */
  44290. dispose(): void;
  44291. /**
  44292. * Release all the underlying texture used as draw buffers.
  44293. */
  44294. releaseInternalTextures(): void;
  44295. }
  44296. }
  44297. declare module BABYLON {
  44298. interface ThinEngine {
  44299. /**
  44300. * Unbind a list of render target textures from the webGL context
  44301. * This is used only when drawBuffer extension or webGL2 are active
  44302. * @param textures defines the render target textures to unbind
  44303. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44304. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44305. */
  44306. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44307. /**
  44308. * Create a multi render target texture
  44309. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44310. * @param size defines the size of the texture
  44311. * @param options defines the creation options
  44312. * @returns the cube texture as an InternalTexture
  44313. */
  44314. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44315. /**
  44316. * Update the sample count for a given multiple render target texture
  44317. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44318. * @param textures defines the textures to update
  44319. * @param samples defines the sample count to set
  44320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44321. */
  44322. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44323. }
  44324. }
  44325. declare module BABYLON {
  44326. /** @hidden */
  44327. export var rgbdEncodePixelShader: {
  44328. name: string;
  44329. shader: string;
  44330. };
  44331. }
  44332. declare module BABYLON {
  44333. /** @hidden */
  44334. export var rgbdDecodePixelShader: {
  44335. name: string;
  44336. shader: string;
  44337. };
  44338. }
  44339. declare module BABYLON {
  44340. /**
  44341. * Raw texture data and descriptor sufficient for WebGL texture upload
  44342. */
  44343. export interface EnvironmentTextureInfo {
  44344. /**
  44345. * Version of the environment map
  44346. */
  44347. version: number;
  44348. /**
  44349. * Width of image
  44350. */
  44351. width: number;
  44352. /**
  44353. * Irradiance information stored in the file.
  44354. */
  44355. irradiance: any;
  44356. /**
  44357. * Specular information stored in the file.
  44358. */
  44359. specular: any;
  44360. }
  44361. /**
  44362. * Defines One Image in the file. It requires only the position in the file
  44363. * as well as the length.
  44364. */
  44365. interface BufferImageData {
  44366. /**
  44367. * Length of the image data.
  44368. */
  44369. length: number;
  44370. /**
  44371. * Position of the data from the null terminator delimiting the end of the JSON.
  44372. */
  44373. position: number;
  44374. }
  44375. /**
  44376. * Defines the specular data enclosed in the file.
  44377. * This corresponds to the version 1 of the data.
  44378. */
  44379. export interface EnvironmentTextureSpecularInfoV1 {
  44380. /**
  44381. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44382. */
  44383. specularDataPosition?: number;
  44384. /**
  44385. * This contains all the images data needed to reconstruct the cubemap.
  44386. */
  44387. mipmaps: Array<BufferImageData>;
  44388. /**
  44389. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44390. */
  44391. lodGenerationScale: number;
  44392. }
  44393. /**
  44394. * Sets of helpers addressing the serialization and deserialization of environment texture
  44395. * stored in a BabylonJS env file.
  44396. * Those files are usually stored as .env files.
  44397. */
  44398. export class EnvironmentTextureTools {
  44399. /**
  44400. * Magic number identifying the env file.
  44401. */
  44402. private static _MagicBytes;
  44403. /**
  44404. * Gets the environment info from an env file.
  44405. * @param data The array buffer containing the .env bytes.
  44406. * @returns the environment file info (the json header) if successfully parsed.
  44407. */
  44408. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44409. /**
  44410. * Creates an environment texture from a loaded cube texture.
  44411. * @param texture defines the cube texture to convert in env file
  44412. * @return a promise containing the environment data if succesfull.
  44413. */
  44414. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44415. /**
  44416. * Creates a JSON representation of the spherical data.
  44417. * @param texture defines the texture containing the polynomials
  44418. * @return the JSON representation of the spherical info
  44419. */
  44420. private static _CreateEnvTextureIrradiance;
  44421. /**
  44422. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44423. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44424. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44425. * @return the views described by info providing access to the underlying buffer
  44426. */
  44427. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44428. /**
  44429. * Uploads the texture info contained in the env file to the GPU.
  44430. * @param texture defines the internal texture to upload to
  44431. * @param arrayBuffer defines the buffer cotaining the data to load
  44432. * @param info defines the texture info retrieved through the GetEnvInfo method
  44433. * @returns a promise
  44434. */
  44435. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44436. /**
  44437. * Uploads the levels of image data to the GPU.
  44438. * @param texture defines the internal texture to upload to
  44439. * @param imageData defines the array buffer views of image data [mipmap][face]
  44440. * @returns a promise
  44441. */
  44442. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44443. /**
  44444. * Uploads spherical polynomials information to the texture.
  44445. * @param texture defines the texture we are trying to upload the information to
  44446. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44447. */
  44448. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44449. /** @hidden */
  44450. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * Contains position and normal vectors for a vertex
  44456. */
  44457. export class PositionNormalVertex {
  44458. /** the position of the vertex (defaut: 0,0,0) */
  44459. position: Vector3;
  44460. /** the normal of the vertex (defaut: 0,1,0) */
  44461. normal: Vector3;
  44462. /**
  44463. * Creates a PositionNormalVertex
  44464. * @param position the position of the vertex (defaut: 0,0,0)
  44465. * @param normal the normal of the vertex (defaut: 0,1,0)
  44466. */
  44467. constructor(
  44468. /** the position of the vertex (defaut: 0,0,0) */
  44469. position?: Vector3,
  44470. /** the normal of the vertex (defaut: 0,1,0) */
  44471. normal?: Vector3);
  44472. /**
  44473. * Clones the PositionNormalVertex
  44474. * @returns the cloned PositionNormalVertex
  44475. */
  44476. clone(): PositionNormalVertex;
  44477. }
  44478. /**
  44479. * Contains position, normal and uv vectors for a vertex
  44480. */
  44481. export class PositionNormalTextureVertex {
  44482. /** the position of the vertex (defaut: 0,0,0) */
  44483. position: Vector3;
  44484. /** the normal of the vertex (defaut: 0,1,0) */
  44485. normal: Vector3;
  44486. /** the uv of the vertex (default: 0,0) */
  44487. uv: Vector2;
  44488. /**
  44489. * Creates a PositionNormalTextureVertex
  44490. * @param position the position of the vertex (defaut: 0,0,0)
  44491. * @param normal the normal of the vertex (defaut: 0,1,0)
  44492. * @param uv the uv of the vertex (default: 0,0)
  44493. */
  44494. constructor(
  44495. /** the position of the vertex (defaut: 0,0,0) */
  44496. position?: Vector3,
  44497. /** the normal of the vertex (defaut: 0,1,0) */
  44498. normal?: Vector3,
  44499. /** the uv of the vertex (default: 0,0) */
  44500. uv?: Vector2);
  44501. /**
  44502. * Clones the PositionNormalTextureVertex
  44503. * @returns the cloned PositionNormalTextureVertex
  44504. */
  44505. clone(): PositionNormalTextureVertex;
  44506. }
  44507. }
  44508. declare module BABYLON {
  44509. /** @hidden */
  44510. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44511. private _genericAttributeLocation;
  44512. private _varyingLocationCount;
  44513. private _varyingLocationMap;
  44514. private _replacements;
  44515. private _textureCount;
  44516. private _uniforms;
  44517. lineProcessor(line: string): string;
  44518. attributeProcessor(attribute: string): string;
  44519. varyingProcessor(varying: string, isFragment: boolean): string;
  44520. uniformProcessor(uniform: string): string;
  44521. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44522. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44523. }
  44524. }
  44525. declare module BABYLON {
  44526. /**
  44527. * Container for accessors for natively-stored mesh data buffers.
  44528. */
  44529. class NativeDataBuffer extends DataBuffer {
  44530. /**
  44531. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44532. */
  44533. nativeIndexBuffer?: any;
  44534. /**
  44535. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44536. */
  44537. nativeVertexBuffer?: any;
  44538. }
  44539. /** @hidden */
  44540. export class NativeEngine extends Engine {
  44541. private readonly _native;
  44542. getHardwareScalingLevel(): number;
  44543. constructor();
  44544. /**
  44545. * Can be used to override the current requestAnimationFrame requester.
  44546. * @hidden
  44547. */
  44548. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44549. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44550. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44551. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44552. recordVertexArrayObject(vertexBuffers: {
  44553. [key: string]: VertexBuffer;
  44554. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44555. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44556. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44558. /**
  44559. * Draw a list of indexed primitives
  44560. * @param fillMode defines the primitive to use
  44561. * @param indexStart defines the starting index
  44562. * @param indexCount defines the number of index to draw
  44563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44564. */
  44565. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44566. /**
  44567. * Draw a list of unindexed primitives
  44568. * @param fillMode defines the primitive to use
  44569. * @param verticesStart defines the index of first vertex to draw
  44570. * @param verticesCount defines the count of vertices to draw
  44571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44572. */
  44573. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44574. createPipelineContext(): IPipelineContext;
  44575. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44576. /** @hidden */
  44577. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44578. /** @hidden */
  44579. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44580. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44581. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44582. protected _setProgram(program: WebGLProgram): void;
  44583. _releaseEffect(effect: Effect): void;
  44584. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44585. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44586. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44587. bindSamplers(effect: Effect): void;
  44588. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44589. getRenderWidth(useScreen?: boolean): number;
  44590. getRenderHeight(useScreen?: boolean): number;
  44591. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44592. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44593. /**
  44594. * Set the z offset to apply to current rendering
  44595. * @param value defines the offset to apply
  44596. */
  44597. setZOffset(value: number): void;
  44598. /**
  44599. * Gets the current value of the zOffset
  44600. * @returns the current zOffset state
  44601. */
  44602. getZOffset(): number;
  44603. /**
  44604. * Enable or disable depth buffering
  44605. * @param enable defines the state to set
  44606. */
  44607. setDepthBuffer(enable: boolean): void;
  44608. /**
  44609. * Gets a boolean indicating if depth writing is enabled
  44610. * @returns the current depth writing state
  44611. */
  44612. getDepthWrite(): boolean;
  44613. /**
  44614. * Enable or disable depth writing
  44615. * @param enable defines the state to set
  44616. */
  44617. setDepthWrite(enable: boolean): void;
  44618. /**
  44619. * Enable or disable color writing
  44620. * @param enable defines the state to set
  44621. */
  44622. setColorWrite(enable: boolean): void;
  44623. /**
  44624. * Gets a boolean indicating if color writing is enabled
  44625. * @returns the current color writing state
  44626. */
  44627. getColorWrite(): boolean;
  44628. /**
  44629. * Sets alpha constants used by some alpha blending modes
  44630. * @param r defines the red component
  44631. * @param g defines the green component
  44632. * @param b defines the blue component
  44633. * @param a defines the alpha component
  44634. */
  44635. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44636. /**
  44637. * Sets the current alpha mode
  44638. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44641. */
  44642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44643. /**
  44644. * Gets the current alpha mode
  44645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44646. * @returns the current alpha mode
  44647. */
  44648. getAlphaMode(): number;
  44649. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44650. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44651. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44652. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44653. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44654. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44655. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44656. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44657. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44658. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44659. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44660. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44661. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44662. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44663. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44664. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44665. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44666. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44667. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44668. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44669. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44670. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44671. wipeCaches(bruteForce?: boolean): void;
  44672. _createTexture(): WebGLTexture;
  44673. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44674. /**
  44675. * Usually called from BABYLON.Texture.ts.
  44676. * Passed information to create a WebGLTexture
  44677. * @param urlArg defines a value which contains one of the following:
  44678. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44679. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44680. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44682. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44683. * @param scene needed for loading to the correct scene
  44684. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44685. * @param onLoad optional callback to be called upon successful completion
  44686. * @param onError optional callback to be called upon failure
  44687. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44688. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44689. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44690. * @param forcedExtension defines the extension to use to pick the right loader
  44691. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44692. */
  44693. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44694. /**
  44695. * Creates a cube texture
  44696. * @param rootUrl defines the url where the files to load is located
  44697. * @param scene defines the current scene
  44698. * @param files defines the list of files to load (1 per face)
  44699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44700. * @param onLoad defines an optional callback raised when the texture is loaded
  44701. * @param onError defines an optional callback raised if there is an issue to load the texture
  44702. * @param format defines the format of the data
  44703. * @param forcedExtension defines the extension to use to pick the right loader
  44704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44708. * @returns the cube texture as an InternalTexture
  44709. */
  44710. 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;
  44711. private _getSamplingFilter;
  44712. private static _GetNativeTextureFormat;
  44713. createRenderTargetTexture(size: number | {
  44714. width: number;
  44715. height: number;
  44716. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44717. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44718. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44719. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44720. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44721. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44722. /**
  44723. * Updates a dynamic vertex buffer.
  44724. * @param vertexBuffer the vertex buffer to update
  44725. * @param data the data used to update the vertex buffer
  44726. * @param byteOffset the byte offset of the data (optional)
  44727. * @param byteLength the byte length of the data (optional)
  44728. */
  44729. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44730. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44731. private _updateAnisotropicLevel;
  44732. private _getAddressMode;
  44733. /** @hidden */
  44734. _bindTexture(channel: number, texture: InternalTexture): void;
  44735. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44736. releaseEffects(): void;
  44737. /** @hidden */
  44738. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44739. /** @hidden */
  44740. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44741. /** @hidden */
  44742. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44743. /** @hidden */
  44744. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44745. }
  44746. }
  44747. declare module BABYLON {
  44748. /**
  44749. * Gather the list of clipboard event types as constants.
  44750. */
  44751. export class ClipboardEventTypes {
  44752. /**
  44753. * The clipboard event is fired when a copy command is active (pressed).
  44754. */
  44755. static readonly COPY: number;
  44756. /**
  44757. * The clipboard event is fired when a cut command is active (pressed).
  44758. */
  44759. static readonly CUT: number;
  44760. /**
  44761. * The clipboard event is fired when a paste command is active (pressed).
  44762. */
  44763. static readonly PASTE: number;
  44764. }
  44765. /**
  44766. * This class is used to store clipboard related info for the onClipboardObservable event.
  44767. */
  44768. export class ClipboardInfo {
  44769. /**
  44770. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44771. */
  44772. type: number;
  44773. /**
  44774. * Defines the related dom event
  44775. */
  44776. event: ClipboardEvent;
  44777. /**
  44778. *Creates an instance of ClipboardInfo.
  44779. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44780. * @param event Defines the related dom event
  44781. */
  44782. constructor(
  44783. /**
  44784. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44785. */
  44786. type: number,
  44787. /**
  44788. * Defines the related dom event
  44789. */
  44790. event: ClipboardEvent);
  44791. /**
  44792. * Get the clipboard event's type from the keycode.
  44793. * @param keyCode Defines the keyCode for the current keyboard event.
  44794. * @return {number}
  44795. */
  44796. static GetTypeFromCharacter(keyCode: number): number;
  44797. }
  44798. }
  44799. declare module BABYLON {
  44800. /**
  44801. * Google Daydream controller
  44802. */
  44803. export class DaydreamController extends WebVRController {
  44804. /**
  44805. * Base Url for the controller model.
  44806. */
  44807. static MODEL_BASE_URL: string;
  44808. /**
  44809. * File name for the controller model.
  44810. */
  44811. static MODEL_FILENAME: string;
  44812. /**
  44813. * Gamepad Id prefix used to identify Daydream Controller.
  44814. */
  44815. static readonly GAMEPAD_ID_PREFIX: string;
  44816. /**
  44817. * Creates a new DaydreamController from a gamepad
  44818. * @param vrGamepad the gamepad that the controller should be created from
  44819. */
  44820. constructor(vrGamepad: any);
  44821. /**
  44822. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44823. * @param scene scene in which to add meshes
  44824. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44825. */
  44826. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44827. /**
  44828. * Called once for each button that changed state since the last frame
  44829. * @param buttonIdx Which button index changed
  44830. * @param state New state of the button
  44831. * @param changes Which properties on the state changed since last frame
  44832. */
  44833. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44834. }
  44835. }
  44836. declare module BABYLON {
  44837. /**
  44838. * Gear VR Controller
  44839. */
  44840. export class GearVRController extends WebVRController {
  44841. /**
  44842. * Base Url for the controller model.
  44843. */
  44844. static MODEL_BASE_URL: string;
  44845. /**
  44846. * File name for the controller model.
  44847. */
  44848. static MODEL_FILENAME: string;
  44849. /**
  44850. * Gamepad Id prefix used to identify this controller.
  44851. */
  44852. static readonly GAMEPAD_ID_PREFIX: string;
  44853. private readonly _buttonIndexToObservableNameMap;
  44854. /**
  44855. * Creates a new GearVRController from a gamepad
  44856. * @param vrGamepad the gamepad that the controller should be created from
  44857. */
  44858. constructor(vrGamepad: any);
  44859. /**
  44860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44861. * @param scene scene in which to add meshes
  44862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44863. */
  44864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44865. /**
  44866. * Called once for each button that changed state since the last frame
  44867. * @param buttonIdx Which button index changed
  44868. * @param state New state of the button
  44869. * @param changes Which properties on the state changed since last frame
  44870. */
  44871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44872. }
  44873. }
  44874. declare module BABYLON {
  44875. /**
  44876. * Class containing static functions to help procedurally build meshes
  44877. */
  44878. export class PolyhedronBuilder {
  44879. /**
  44880. * Creates a polyhedron mesh
  44881. * * 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
  44882. * * The parameter `size` (positive float, default 1) sets the polygon size
  44883. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44884. * * 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`
  44885. * * 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
  44886. * * 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)`)
  44887. * * 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
  44888. * * 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
  44889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44890. * * 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
  44891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44892. * @param name defines the name of the mesh
  44893. * @param options defines the options used to create the mesh
  44894. * @param scene defines the hosting scene
  44895. * @returns the polyhedron mesh
  44896. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44897. */
  44898. static CreatePolyhedron(name: string, options: {
  44899. type?: number;
  44900. size?: number;
  44901. sizeX?: number;
  44902. sizeY?: number;
  44903. sizeZ?: number;
  44904. custom?: any;
  44905. faceUV?: Vector4[];
  44906. faceColors?: Color4[];
  44907. flat?: boolean;
  44908. updatable?: boolean;
  44909. sideOrientation?: number;
  44910. frontUVs?: Vector4;
  44911. backUVs?: Vector4;
  44912. }, scene?: Nullable<Scene>): Mesh;
  44913. }
  44914. }
  44915. declare module BABYLON {
  44916. /**
  44917. * Gizmo that enables scaling a mesh along 3 axis
  44918. */
  44919. export class ScaleGizmo extends Gizmo {
  44920. /**
  44921. * Internal gizmo used for interactions on the x axis
  44922. */
  44923. xGizmo: AxisScaleGizmo;
  44924. /**
  44925. * Internal gizmo used for interactions on the y axis
  44926. */
  44927. yGizmo: AxisScaleGizmo;
  44928. /**
  44929. * Internal gizmo used for interactions on the z axis
  44930. */
  44931. zGizmo: AxisScaleGizmo;
  44932. /**
  44933. * Internal gizmo used to scale all axis equally
  44934. */
  44935. uniformScaleGizmo: AxisScaleGizmo;
  44936. private _meshAttached;
  44937. private _updateGizmoRotationToMatchAttachedMesh;
  44938. private _snapDistance;
  44939. private _scaleRatio;
  44940. private _uniformScalingMesh;
  44941. private _octahedron;
  44942. /** Fires an event when any of it's sub gizmos are dragged */
  44943. onDragStartObservable: Observable<unknown>;
  44944. /** Fires an event when any of it's sub gizmos are released from dragging */
  44945. onDragEndObservable: Observable<unknown>;
  44946. attachedMesh: Nullable<AbstractMesh>;
  44947. /**
  44948. * Creates a ScaleGizmo
  44949. * @param gizmoLayer The utility layer the gizmo will be added to
  44950. */
  44951. constructor(gizmoLayer?: UtilityLayerRenderer);
  44952. updateGizmoRotationToMatchAttachedMesh: boolean;
  44953. /**
  44954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44955. */
  44956. snapDistance: number;
  44957. /**
  44958. * Ratio for the scale of the gizmo (Default: 1)
  44959. */
  44960. scaleRatio: number;
  44961. /**
  44962. * Disposes of the gizmo
  44963. */
  44964. dispose(): void;
  44965. }
  44966. }
  44967. declare module BABYLON {
  44968. /**
  44969. * Single axis scale gizmo
  44970. */
  44971. export class AxisScaleGizmo extends Gizmo {
  44972. /**
  44973. * Drag behavior responsible for the gizmos dragging interactions
  44974. */
  44975. dragBehavior: PointerDragBehavior;
  44976. private _pointerObserver;
  44977. /**
  44978. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44979. */
  44980. snapDistance: number;
  44981. /**
  44982. * Event that fires each time the gizmo snaps to a new location.
  44983. * * snapDistance is the the change in distance
  44984. */
  44985. onSnapObservable: Observable<{
  44986. snapDistance: number;
  44987. }>;
  44988. /**
  44989. * If the scaling operation should be done on all axis (default: false)
  44990. */
  44991. uniformScaling: boolean;
  44992. private _isEnabled;
  44993. private _parent;
  44994. private _arrow;
  44995. private _coloredMaterial;
  44996. private _hoverMaterial;
  44997. /**
  44998. * Creates an AxisScaleGizmo
  44999. * @param gizmoLayer The utility layer the gizmo will be added to
  45000. * @param dragAxis The axis which the gizmo will be able to scale on
  45001. * @param color The color of the gizmo
  45002. */
  45003. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45005. /**
  45006. * If the gizmo is enabled
  45007. */
  45008. isEnabled: boolean;
  45009. /**
  45010. * Disposes of the gizmo
  45011. */
  45012. dispose(): void;
  45013. /**
  45014. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45015. * @param mesh The mesh to replace the default mesh of the gizmo
  45016. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45017. */
  45018. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45019. }
  45020. }
  45021. declare module BABYLON {
  45022. /**
  45023. * Bounding box gizmo
  45024. */
  45025. export class BoundingBoxGizmo extends Gizmo {
  45026. private _lineBoundingBox;
  45027. private _rotateSpheresParent;
  45028. private _scaleBoxesParent;
  45029. private _boundingDimensions;
  45030. private _renderObserver;
  45031. private _pointerObserver;
  45032. private _scaleDragSpeed;
  45033. private _tmpQuaternion;
  45034. private _tmpVector;
  45035. private _tmpRotationMatrix;
  45036. /**
  45037. * 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)
  45038. */
  45039. ignoreChildren: boolean;
  45040. /**
  45041. * 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)
  45042. */
  45043. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45044. /**
  45045. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45046. */
  45047. rotationSphereSize: number;
  45048. /**
  45049. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45050. */
  45051. scaleBoxSize: number;
  45052. /**
  45053. * 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)
  45054. */
  45055. fixedDragMeshScreenSize: boolean;
  45056. /**
  45057. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45058. */
  45059. fixedDragMeshScreenSizeDistanceFactor: number;
  45060. /**
  45061. * Fired when a rotation sphere or scale box is dragged
  45062. */
  45063. onDragStartObservable: Observable<{}>;
  45064. /**
  45065. * Fired when a scale box is dragged
  45066. */
  45067. onScaleBoxDragObservable: Observable<{}>;
  45068. /**
  45069. * Fired when a scale box drag is ended
  45070. */
  45071. onScaleBoxDragEndObservable: Observable<{}>;
  45072. /**
  45073. * Fired when a rotation sphere is dragged
  45074. */
  45075. onRotationSphereDragObservable: Observable<{}>;
  45076. /**
  45077. * Fired when a rotation sphere drag is ended
  45078. */
  45079. onRotationSphereDragEndObservable: Observable<{}>;
  45080. /**
  45081. * 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)
  45082. */
  45083. scalePivot: Nullable<Vector3>;
  45084. /**
  45085. * Mesh used as a pivot to rotate the attached mesh
  45086. */
  45087. private _anchorMesh;
  45088. private _existingMeshScale;
  45089. private _dragMesh;
  45090. private pointerDragBehavior;
  45091. private coloredMaterial;
  45092. private hoverColoredMaterial;
  45093. /**
  45094. * Sets the color of the bounding box gizmo
  45095. * @param color the color to set
  45096. */
  45097. setColor(color: Color3): void;
  45098. /**
  45099. * Creates an BoundingBoxGizmo
  45100. * @param gizmoLayer The utility layer the gizmo will be added to
  45101. * @param color The color of the gizmo
  45102. */
  45103. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45104. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45105. private _selectNode;
  45106. /**
  45107. * Updates the bounding box information for the Gizmo
  45108. */
  45109. updateBoundingBox(): void;
  45110. private _updateRotationSpheres;
  45111. private _updateScaleBoxes;
  45112. /**
  45113. * Enables rotation on the specified axis and disables rotation on the others
  45114. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45115. */
  45116. setEnabledRotationAxis(axis: string): void;
  45117. /**
  45118. * Enables/disables scaling
  45119. * @param enable if scaling should be enabled
  45120. */
  45121. setEnabledScaling(enable: boolean): void;
  45122. private _updateDummy;
  45123. /**
  45124. * Enables a pointer drag behavior on the bounding box of the gizmo
  45125. */
  45126. enableDragBehavior(): void;
  45127. /**
  45128. * Disposes of the gizmo
  45129. */
  45130. dispose(): void;
  45131. /**
  45132. * 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)
  45133. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45134. * @returns the bounding box mesh with the passed in mesh as a child
  45135. */
  45136. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45137. /**
  45138. * CustomMeshes are not supported by this gizmo
  45139. * @param mesh The mesh to replace the default mesh of the gizmo
  45140. */
  45141. setCustomMesh(mesh: Mesh): void;
  45142. }
  45143. }
  45144. declare module BABYLON {
  45145. /**
  45146. * Single plane rotation gizmo
  45147. */
  45148. export class PlaneRotationGizmo extends Gizmo {
  45149. /**
  45150. * Drag behavior responsible for the gizmos dragging interactions
  45151. */
  45152. dragBehavior: PointerDragBehavior;
  45153. private _pointerObserver;
  45154. /**
  45155. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45156. */
  45157. snapDistance: number;
  45158. /**
  45159. * Event that fires each time the gizmo snaps to a new location.
  45160. * * snapDistance is the the change in distance
  45161. */
  45162. onSnapObservable: Observable<{
  45163. snapDistance: number;
  45164. }>;
  45165. private _isEnabled;
  45166. private _parent;
  45167. /**
  45168. * Creates a PlaneRotationGizmo
  45169. * @param gizmoLayer The utility layer the gizmo will be added to
  45170. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45171. * @param color The color of the gizmo
  45172. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45173. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45174. */
  45175. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45177. /**
  45178. * If the gizmo is enabled
  45179. */
  45180. isEnabled: boolean;
  45181. /**
  45182. * Disposes of the gizmo
  45183. */
  45184. dispose(): void;
  45185. }
  45186. }
  45187. declare module BABYLON {
  45188. /**
  45189. * Gizmo that enables rotating a mesh along 3 axis
  45190. */
  45191. export class RotationGizmo extends Gizmo {
  45192. /**
  45193. * Internal gizmo used for interactions on the x axis
  45194. */
  45195. xGizmo: PlaneRotationGizmo;
  45196. /**
  45197. * Internal gizmo used for interactions on the y axis
  45198. */
  45199. yGizmo: PlaneRotationGizmo;
  45200. /**
  45201. * Internal gizmo used for interactions on the z axis
  45202. */
  45203. zGizmo: PlaneRotationGizmo;
  45204. /** Fires an event when any of it's sub gizmos are dragged */
  45205. onDragStartObservable: Observable<unknown>;
  45206. /** Fires an event when any of it's sub gizmos are released from dragging */
  45207. onDragEndObservable: Observable<unknown>;
  45208. private _meshAttached;
  45209. attachedMesh: Nullable<AbstractMesh>;
  45210. /**
  45211. * Creates a RotationGizmo
  45212. * @param gizmoLayer The utility layer the gizmo will be added to
  45213. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45214. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45215. */
  45216. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45217. updateGizmoRotationToMatchAttachedMesh: boolean;
  45218. /**
  45219. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45220. */
  45221. snapDistance: number;
  45222. /**
  45223. * Ratio for the scale of the gizmo (Default: 1)
  45224. */
  45225. scaleRatio: number;
  45226. /**
  45227. * Disposes of the gizmo
  45228. */
  45229. dispose(): void;
  45230. /**
  45231. * CustomMeshes are not supported by this gizmo
  45232. * @param mesh The mesh to replace the default mesh of the gizmo
  45233. */
  45234. setCustomMesh(mesh: Mesh): void;
  45235. }
  45236. }
  45237. declare module BABYLON {
  45238. /**
  45239. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45240. */
  45241. export class GizmoManager implements IDisposable {
  45242. private scene;
  45243. /**
  45244. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45245. */
  45246. gizmos: {
  45247. positionGizmo: Nullable<PositionGizmo>;
  45248. rotationGizmo: Nullable<RotationGizmo>;
  45249. scaleGizmo: Nullable<ScaleGizmo>;
  45250. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45251. };
  45252. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45253. clearGizmoOnEmptyPointerEvent: boolean;
  45254. /** Fires an event when the manager is attached to a mesh */
  45255. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45256. private _gizmosEnabled;
  45257. private _pointerObserver;
  45258. private _attachedMesh;
  45259. private _boundingBoxColor;
  45260. private _defaultUtilityLayer;
  45261. private _defaultKeepDepthUtilityLayer;
  45262. /**
  45263. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45264. */
  45265. boundingBoxDragBehavior: SixDofDragBehavior;
  45266. /**
  45267. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45268. */
  45269. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45270. /**
  45271. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45272. */
  45273. usePointerToAttachGizmos: boolean;
  45274. /**
  45275. * Utility layer that the bounding box gizmo belongs to
  45276. */
  45277. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45278. /**
  45279. * Utility layer that all gizmos besides bounding box belong to
  45280. */
  45281. readonly utilityLayer: UtilityLayerRenderer;
  45282. /**
  45283. * Instatiates a gizmo manager
  45284. * @param scene the scene to overlay the gizmos on top of
  45285. */
  45286. constructor(scene: Scene);
  45287. /**
  45288. * Attaches a set of gizmos to the specified mesh
  45289. * @param mesh The mesh the gizmo's should be attached to
  45290. */
  45291. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45292. /**
  45293. * If the position gizmo is enabled
  45294. */
  45295. positionGizmoEnabled: boolean;
  45296. /**
  45297. * If the rotation gizmo is enabled
  45298. */
  45299. rotationGizmoEnabled: boolean;
  45300. /**
  45301. * If the scale gizmo is enabled
  45302. */
  45303. scaleGizmoEnabled: boolean;
  45304. /**
  45305. * If the boundingBox gizmo is enabled
  45306. */
  45307. boundingBoxGizmoEnabled: boolean;
  45308. /**
  45309. * Disposes of the gizmo manager
  45310. */
  45311. dispose(): void;
  45312. }
  45313. }
  45314. declare module BABYLON {
  45315. /**
  45316. * A directional light is defined by a direction (what a surprise!).
  45317. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45318. * 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.
  45319. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45320. */
  45321. export class DirectionalLight extends ShadowLight {
  45322. private _shadowFrustumSize;
  45323. /**
  45324. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45325. */
  45326. /**
  45327. * Specifies a fix frustum size for the shadow generation.
  45328. */
  45329. shadowFrustumSize: number;
  45330. private _shadowOrthoScale;
  45331. /**
  45332. * Gets the shadow projection scale against the optimal computed one.
  45333. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45334. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45335. */
  45336. /**
  45337. * Sets the shadow projection scale against the optimal computed one.
  45338. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45339. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45340. */
  45341. shadowOrthoScale: number;
  45342. /**
  45343. * Automatically compute the projection matrix to best fit (including all the casters)
  45344. * on each frame.
  45345. */
  45346. autoUpdateExtends: boolean;
  45347. private _orthoLeft;
  45348. private _orthoRight;
  45349. private _orthoTop;
  45350. private _orthoBottom;
  45351. /**
  45352. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45353. * The directional light is emitted from everywhere in the given direction.
  45354. * It can cast shadows.
  45355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45356. * @param name The friendly name of the light
  45357. * @param direction The direction of the light
  45358. * @param scene The scene the light belongs to
  45359. */
  45360. constructor(name: string, direction: Vector3, scene: Scene);
  45361. /**
  45362. * Returns the string "DirectionalLight".
  45363. * @return The class name
  45364. */
  45365. getClassName(): string;
  45366. /**
  45367. * Returns the integer 1.
  45368. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45369. */
  45370. getTypeID(): number;
  45371. /**
  45372. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45373. * Returns the DirectionalLight Shadow projection matrix.
  45374. */
  45375. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45376. /**
  45377. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45378. * Returns the DirectionalLight Shadow projection matrix.
  45379. */
  45380. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45381. /**
  45382. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45383. * Returns the DirectionalLight Shadow projection matrix.
  45384. */
  45385. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45386. protected _buildUniformLayout(): void;
  45387. /**
  45388. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45389. * @param effect The effect to update
  45390. * @param lightIndex The index of the light in the effect to update
  45391. * @returns The directional light
  45392. */
  45393. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45394. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45395. /**
  45396. * Gets the minZ used for shadow according to both the scene and the light.
  45397. *
  45398. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45399. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45400. * @param activeCamera The camera we are returning the min for
  45401. * @returns the depth min z
  45402. */
  45403. getDepthMinZ(activeCamera: Camera): number;
  45404. /**
  45405. * Gets the maxZ used for shadow according to both the scene and the light.
  45406. *
  45407. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45408. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45409. * @param activeCamera The camera we are returning the max for
  45410. * @returns the depth max z
  45411. */
  45412. getDepthMaxZ(activeCamera: Camera): number;
  45413. /**
  45414. * Prepares the list of defines specific to the light type.
  45415. * @param defines the list of defines
  45416. * @param lightIndex defines the index of the light for the effect
  45417. */
  45418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45419. }
  45420. }
  45421. declare module BABYLON {
  45422. /**
  45423. * Class containing static functions to help procedurally build meshes
  45424. */
  45425. export class HemisphereBuilder {
  45426. /**
  45427. * Creates a hemisphere mesh
  45428. * @param name defines the name of the mesh
  45429. * @param options defines the options used to create the mesh
  45430. * @param scene defines the hosting scene
  45431. * @returns the hemisphere mesh
  45432. */
  45433. static CreateHemisphere(name: string, options: {
  45434. segments?: number;
  45435. diameter?: number;
  45436. sideOrientation?: number;
  45437. }, scene: any): Mesh;
  45438. }
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45443. * These values define a cone of light starting from the position, emitting toward the direction.
  45444. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45445. * and the exponent defines the speed of the decay of the light with distance (reach).
  45446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45447. */
  45448. export class SpotLight extends ShadowLight {
  45449. private _angle;
  45450. private _innerAngle;
  45451. private _cosHalfAngle;
  45452. private _lightAngleScale;
  45453. private _lightAngleOffset;
  45454. /**
  45455. * Gets the cone angle of the spot light in Radians.
  45456. */
  45457. /**
  45458. * Sets the cone angle of the spot light in Radians.
  45459. */
  45460. angle: number;
  45461. /**
  45462. * Only used in gltf falloff mode, this defines the angle where
  45463. * the directional falloff will start before cutting at angle which could be seen
  45464. * as outer angle.
  45465. */
  45466. /**
  45467. * Only used in gltf falloff mode, this defines the angle where
  45468. * the directional falloff will start before cutting at angle which could be seen
  45469. * as outer angle.
  45470. */
  45471. innerAngle: number;
  45472. private _shadowAngleScale;
  45473. /**
  45474. * Allows scaling the angle of the light for shadow generation only.
  45475. */
  45476. /**
  45477. * Allows scaling the angle of the light for shadow generation only.
  45478. */
  45479. shadowAngleScale: number;
  45480. /**
  45481. * The light decay speed with the distance from the emission spot.
  45482. */
  45483. exponent: number;
  45484. private _projectionTextureMatrix;
  45485. /**
  45486. * Allows reading the projecton texture
  45487. */
  45488. readonly projectionTextureMatrix: Matrix;
  45489. protected _projectionTextureLightNear: number;
  45490. /**
  45491. * Gets the near clip of the Spotlight for texture projection.
  45492. */
  45493. /**
  45494. * Sets the near clip of the Spotlight for texture projection.
  45495. */
  45496. projectionTextureLightNear: number;
  45497. protected _projectionTextureLightFar: number;
  45498. /**
  45499. * Gets the far clip of the Spotlight for texture projection.
  45500. */
  45501. /**
  45502. * Sets the far clip of the Spotlight for texture projection.
  45503. */
  45504. projectionTextureLightFar: number;
  45505. protected _projectionTextureUpDirection: Vector3;
  45506. /**
  45507. * Gets the Up vector of the Spotlight for texture projection.
  45508. */
  45509. /**
  45510. * Sets the Up vector of the Spotlight for texture projection.
  45511. */
  45512. projectionTextureUpDirection: Vector3;
  45513. private _projectionTexture;
  45514. /**
  45515. * Gets the projection texture of the light.
  45516. */
  45517. /**
  45518. * Sets the projection texture of the light.
  45519. */
  45520. projectionTexture: Nullable<BaseTexture>;
  45521. private _projectionTextureViewLightDirty;
  45522. private _projectionTextureProjectionLightDirty;
  45523. private _projectionTextureDirty;
  45524. private _projectionTextureViewTargetVector;
  45525. private _projectionTextureViewLightMatrix;
  45526. private _projectionTextureProjectionLightMatrix;
  45527. private _projectionTextureScalingMatrix;
  45528. /**
  45529. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45530. * It can cast shadows.
  45531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45532. * @param name The light friendly name
  45533. * @param position The position of the spot light in the scene
  45534. * @param direction The direction of the light in the scene
  45535. * @param angle The cone angle of the light in Radians
  45536. * @param exponent The light decay speed with the distance from the emission spot
  45537. * @param scene The scene the lights belongs to
  45538. */
  45539. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45540. /**
  45541. * Returns the string "SpotLight".
  45542. * @returns the class name
  45543. */
  45544. getClassName(): string;
  45545. /**
  45546. * Returns the integer 2.
  45547. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45548. */
  45549. getTypeID(): number;
  45550. /**
  45551. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45552. */
  45553. protected _setDirection(value: Vector3): void;
  45554. /**
  45555. * Overrides the position setter to recompute the projection texture view light Matrix.
  45556. */
  45557. protected _setPosition(value: Vector3): void;
  45558. /**
  45559. * 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.
  45560. * Returns the SpotLight.
  45561. */
  45562. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45563. protected _computeProjectionTextureViewLightMatrix(): void;
  45564. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45565. /**
  45566. * Main function for light texture projection matrix computing.
  45567. */
  45568. protected _computeProjectionTextureMatrix(): void;
  45569. protected _buildUniformLayout(): void;
  45570. private _computeAngleValues;
  45571. /**
  45572. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45573. * @param effect The effect to update
  45574. * @param lightIndex The index of the light in the effect to update
  45575. * @returns The spot light
  45576. */
  45577. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45578. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45579. /**
  45580. * Disposes the light and the associated resources.
  45581. */
  45582. dispose(): void;
  45583. /**
  45584. * Prepares the list of defines specific to the light type.
  45585. * @param defines the list of defines
  45586. * @param lightIndex defines the index of the light for the effect
  45587. */
  45588. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45589. }
  45590. }
  45591. declare module BABYLON {
  45592. /**
  45593. * Gizmo that enables viewing a light
  45594. */
  45595. export class LightGizmo extends Gizmo {
  45596. private _lightMesh;
  45597. private _material;
  45598. private cachedPosition;
  45599. private cachedForward;
  45600. /**
  45601. * Creates a LightGizmo
  45602. * @param gizmoLayer The utility layer the gizmo will be added to
  45603. */
  45604. constructor(gizmoLayer?: UtilityLayerRenderer);
  45605. private _light;
  45606. /**
  45607. * The light that the gizmo is attached to
  45608. */
  45609. light: Nullable<Light>;
  45610. /**
  45611. * Gets the material used to render the light gizmo
  45612. */
  45613. readonly material: StandardMaterial;
  45614. /**
  45615. * @hidden
  45616. * Updates the gizmo to match the attached mesh's position/rotation
  45617. */
  45618. protected _update(): void;
  45619. private static _Scale;
  45620. /**
  45621. * Creates the lines for a light mesh
  45622. */
  45623. private static _createLightLines;
  45624. /**
  45625. * Disposes of the light gizmo
  45626. */
  45627. dispose(): void;
  45628. private static _CreateHemisphericLightMesh;
  45629. private static _CreatePointLightMesh;
  45630. private static _CreateSpotLightMesh;
  45631. private static _CreateDirectionalLightMesh;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /** @hidden */
  45636. export var backgroundFragmentDeclaration: {
  45637. name: string;
  45638. shader: string;
  45639. };
  45640. }
  45641. declare module BABYLON {
  45642. /** @hidden */
  45643. export var backgroundUboDeclaration: {
  45644. name: string;
  45645. shader: string;
  45646. };
  45647. }
  45648. declare module BABYLON {
  45649. /** @hidden */
  45650. export var backgroundPixelShader: {
  45651. name: string;
  45652. shader: string;
  45653. };
  45654. }
  45655. declare module BABYLON {
  45656. /** @hidden */
  45657. export var backgroundVertexDeclaration: {
  45658. name: string;
  45659. shader: string;
  45660. };
  45661. }
  45662. declare module BABYLON {
  45663. /** @hidden */
  45664. export var backgroundVertexShader: {
  45665. name: string;
  45666. shader: string;
  45667. };
  45668. }
  45669. declare module BABYLON {
  45670. /**
  45671. * Background material used to create an efficient environement around your scene.
  45672. */
  45673. export class BackgroundMaterial extends PushMaterial {
  45674. /**
  45675. * Standard reflectance value at parallel view angle.
  45676. */
  45677. static StandardReflectance0: number;
  45678. /**
  45679. * Standard reflectance value at grazing angle.
  45680. */
  45681. static StandardReflectance90: number;
  45682. protected _primaryColor: Color3;
  45683. /**
  45684. * Key light Color (multiply against the environement texture)
  45685. */
  45686. primaryColor: Color3;
  45687. protected __perceptualColor: Nullable<Color3>;
  45688. /**
  45689. * Experimental Internal Use Only.
  45690. *
  45691. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45692. * This acts as a helper to set the primary color to a more "human friendly" value.
  45693. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45694. * output color as close as possible from the chosen value.
  45695. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45696. * part of lighting setup.)
  45697. */
  45698. _perceptualColor: Nullable<Color3>;
  45699. protected _primaryColorShadowLevel: float;
  45700. /**
  45701. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45702. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45703. */
  45704. primaryColorShadowLevel: float;
  45705. protected _primaryColorHighlightLevel: float;
  45706. /**
  45707. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45708. * The primary color is used at the level chosen to define what the white area would look.
  45709. */
  45710. primaryColorHighlightLevel: float;
  45711. protected _reflectionTexture: Nullable<BaseTexture>;
  45712. /**
  45713. * Reflection Texture used in the material.
  45714. * Should be author in a specific way for the best result (refer to the documentation).
  45715. */
  45716. reflectionTexture: Nullable<BaseTexture>;
  45717. protected _reflectionBlur: float;
  45718. /**
  45719. * Reflection Texture level of blur.
  45720. *
  45721. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45722. * texture twice.
  45723. */
  45724. reflectionBlur: float;
  45725. protected _diffuseTexture: Nullable<BaseTexture>;
  45726. /**
  45727. * Diffuse Texture used in the material.
  45728. * Should be author in a specific way for the best result (refer to the documentation).
  45729. */
  45730. diffuseTexture: Nullable<BaseTexture>;
  45731. protected _shadowLights: Nullable<IShadowLight[]>;
  45732. /**
  45733. * Specify the list of lights casting shadow on the material.
  45734. * All scene shadow lights will be included if null.
  45735. */
  45736. shadowLights: Nullable<IShadowLight[]>;
  45737. protected _shadowLevel: float;
  45738. /**
  45739. * Helps adjusting the shadow to a softer level if required.
  45740. * 0 means black shadows and 1 means no shadows.
  45741. */
  45742. shadowLevel: float;
  45743. protected _sceneCenter: Vector3;
  45744. /**
  45745. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45746. * It is usually zero but might be interesting to modify according to your setup.
  45747. */
  45748. sceneCenter: Vector3;
  45749. protected _opacityFresnel: boolean;
  45750. /**
  45751. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45752. * This helps ensuring a nice transition when the camera goes under the ground.
  45753. */
  45754. opacityFresnel: boolean;
  45755. protected _reflectionFresnel: boolean;
  45756. /**
  45757. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45758. * This helps adding a mirror texture on the ground.
  45759. */
  45760. reflectionFresnel: boolean;
  45761. protected _reflectionFalloffDistance: number;
  45762. /**
  45763. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45764. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45765. */
  45766. reflectionFalloffDistance: number;
  45767. protected _reflectionAmount: number;
  45768. /**
  45769. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45770. */
  45771. reflectionAmount: number;
  45772. protected _reflectionReflectance0: number;
  45773. /**
  45774. * This specifies the weight of the reflection at grazing angle.
  45775. */
  45776. reflectionReflectance0: number;
  45777. protected _reflectionReflectance90: number;
  45778. /**
  45779. * This specifies the weight of the reflection at a perpendicular point of view.
  45780. */
  45781. reflectionReflectance90: number;
  45782. /**
  45783. * Sets the reflection reflectance fresnel values according to the default standard
  45784. * empirically know to work well :-)
  45785. */
  45786. reflectionStandardFresnelWeight: number;
  45787. protected _useRGBColor: boolean;
  45788. /**
  45789. * Helps to directly use the maps channels instead of their level.
  45790. */
  45791. useRGBColor: boolean;
  45792. protected _enableNoise: boolean;
  45793. /**
  45794. * This helps reducing the banding effect that could occur on the background.
  45795. */
  45796. enableNoise: boolean;
  45797. /**
  45798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45799. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45800. * Recommended to be keep at 1.0 except for special cases.
  45801. */
  45802. fovMultiplier: number;
  45803. private _fovMultiplier;
  45804. /**
  45805. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45806. */
  45807. useEquirectangularFOV: boolean;
  45808. private _maxSimultaneousLights;
  45809. /**
  45810. * Number of Simultaneous lights allowed on the material.
  45811. */
  45812. maxSimultaneousLights: int;
  45813. /**
  45814. * Default configuration related to image processing available in the Background Material.
  45815. */
  45816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45817. /**
  45818. * Keep track of the image processing observer to allow dispose and replace.
  45819. */
  45820. private _imageProcessingObserver;
  45821. /**
  45822. * Attaches a new image processing configuration to the PBR Material.
  45823. * @param configuration (if null the scene configuration will be use)
  45824. */
  45825. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45826. /**
  45827. * Gets the image processing configuration used either in this material.
  45828. */
  45829. /**
  45830. * Sets the Default image processing configuration used either in the this material.
  45831. *
  45832. * If sets to null, the scene one is in use.
  45833. */
  45834. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45835. /**
  45836. * Gets wether the color curves effect is enabled.
  45837. */
  45838. /**
  45839. * Sets wether the color curves effect is enabled.
  45840. */
  45841. cameraColorCurvesEnabled: boolean;
  45842. /**
  45843. * Gets wether the color grading effect is enabled.
  45844. */
  45845. /**
  45846. * Gets wether the color grading effect is enabled.
  45847. */
  45848. cameraColorGradingEnabled: boolean;
  45849. /**
  45850. * Gets wether tonemapping is enabled or not.
  45851. */
  45852. /**
  45853. * Sets wether tonemapping is enabled or not
  45854. */
  45855. cameraToneMappingEnabled: boolean;
  45856. /**
  45857. * The camera exposure used on this material.
  45858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45859. * This corresponds to a photographic exposure.
  45860. */
  45861. /**
  45862. * The camera exposure used on this material.
  45863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45864. * This corresponds to a photographic exposure.
  45865. */
  45866. cameraExposure: float;
  45867. /**
  45868. * Gets The camera contrast used on this material.
  45869. */
  45870. /**
  45871. * Sets The camera contrast used on this material.
  45872. */
  45873. cameraContrast: float;
  45874. /**
  45875. * Gets the Color Grading 2D Lookup Texture.
  45876. */
  45877. /**
  45878. * Sets the Color Grading 2D Lookup Texture.
  45879. */
  45880. cameraColorGradingTexture: Nullable<BaseTexture>;
  45881. /**
  45882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45884. * 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;
  45885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45886. */
  45887. /**
  45888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45890. * 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;
  45891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45892. */
  45893. cameraColorCurves: Nullable<ColorCurves>;
  45894. /**
  45895. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45896. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45897. */
  45898. switchToBGR: boolean;
  45899. private _renderTargets;
  45900. private _reflectionControls;
  45901. private _white;
  45902. private _primaryShadowColor;
  45903. private _primaryHighlightColor;
  45904. /**
  45905. * Instantiates a Background Material in the given scene
  45906. * @param name The friendly name of the material
  45907. * @param scene The scene to add the material to
  45908. */
  45909. constructor(name: string, scene: Scene);
  45910. /**
  45911. * Gets a boolean indicating that current material needs to register RTT
  45912. */
  45913. readonly hasRenderTargetTextures: boolean;
  45914. /**
  45915. * The entire material has been created in order to prevent overdraw.
  45916. * @returns false
  45917. */
  45918. needAlphaTesting(): boolean;
  45919. /**
  45920. * The entire material has been created in order to prevent overdraw.
  45921. * @returns true if blending is enable
  45922. */
  45923. needAlphaBlending(): boolean;
  45924. /**
  45925. * Checks wether the material is ready to be rendered for a given mesh.
  45926. * @param mesh The mesh to render
  45927. * @param subMesh The submesh to check against
  45928. * @param useInstances Specify wether or not the material is used with instances
  45929. * @returns true if all the dependencies are ready (Textures, Effects...)
  45930. */
  45931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45932. /**
  45933. * Compute the primary color according to the chosen perceptual color.
  45934. */
  45935. private _computePrimaryColorFromPerceptualColor;
  45936. /**
  45937. * Compute the highlights and shadow colors according to their chosen levels.
  45938. */
  45939. private _computePrimaryColors;
  45940. /**
  45941. * Build the uniform buffer used in the material.
  45942. */
  45943. buildUniformLayout(): void;
  45944. /**
  45945. * Unbind the material.
  45946. */
  45947. unbind(): void;
  45948. /**
  45949. * Bind only the world matrix to the material.
  45950. * @param world The world matrix to bind.
  45951. */
  45952. bindOnlyWorldMatrix(world: Matrix): void;
  45953. /**
  45954. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45955. * @param world The world matrix to bind.
  45956. * @param subMesh The submesh to bind for.
  45957. */
  45958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45959. /**
  45960. * Checks to see if a texture is used in the material.
  45961. * @param texture - Base texture to use.
  45962. * @returns - Boolean specifying if a texture is used in the material.
  45963. */
  45964. hasTexture(texture: BaseTexture): boolean;
  45965. /**
  45966. * Dispose the material.
  45967. * @param forceDisposeEffect Force disposal of the associated effect.
  45968. * @param forceDisposeTextures Force disposal of the associated textures.
  45969. */
  45970. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45971. /**
  45972. * Clones the material.
  45973. * @param name The cloned name.
  45974. * @returns The cloned material.
  45975. */
  45976. clone(name: string): BackgroundMaterial;
  45977. /**
  45978. * Serializes the current material to its JSON representation.
  45979. * @returns The JSON representation.
  45980. */
  45981. serialize(): any;
  45982. /**
  45983. * Gets the class name of the material
  45984. * @returns "BackgroundMaterial"
  45985. */
  45986. getClassName(): string;
  45987. /**
  45988. * Parse a JSON input to create back a background material.
  45989. * @param source The JSON data to parse
  45990. * @param scene The scene to create the parsed material in
  45991. * @param rootUrl The root url of the assets the material depends upon
  45992. * @returns the instantiated BackgroundMaterial.
  45993. */
  45994. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45995. }
  45996. }
  45997. declare module BABYLON {
  45998. /**
  45999. * Represents the different options available during the creation of
  46000. * a Environment helper.
  46001. *
  46002. * This can control the default ground, skybox and image processing setup of your scene.
  46003. */
  46004. export interface IEnvironmentHelperOptions {
  46005. /**
  46006. * Specifies wether or not to create a ground.
  46007. * True by default.
  46008. */
  46009. createGround: boolean;
  46010. /**
  46011. * Specifies the ground size.
  46012. * 15 by default.
  46013. */
  46014. groundSize: number;
  46015. /**
  46016. * The texture used on the ground for the main color.
  46017. * Comes from the BabylonJS CDN by default.
  46018. *
  46019. * Remarks: Can be either a texture or a url.
  46020. */
  46021. groundTexture: string | BaseTexture;
  46022. /**
  46023. * The color mixed in the ground texture by default.
  46024. * BabylonJS clearColor by default.
  46025. */
  46026. groundColor: Color3;
  46027. /**
  46028. * Specifies the ground opacity.
  46029. * 1 by default.
  46030. */
  46031. groundOpacity: number;
  46032. /**
  46033. * Enables the ground to receive shadows.
  46034. * True by default.
  46035. */
  46036. enableGroundShadow: boolean;
  46037. /**
  46038. * Helps preventing the shadow to be fully black on the ground.
  46039. * 0.5 by default.
  46040. */
  46041. groundShadowLevel: number;
  46042. /**
  46043. * Creates a mirror texture attach to the ground.
  46044. * false by default.
  46045. */
  46046. enableGroundMirror: boolean;
  46047. /**
  46048. * Specifies the ground mirror size ratio.
  46049. * 0.3 by default as the default kernel is 64.
  46050. */
  46051. groundMirrorSizeRatio: number;
  46052. /**
  46053. * Specifies the ground mirror blur kernel size.
  46054. * 64 by default.
  46055. */
  46056. groundMirrorBlurKernel: number;
  46057. /**
  46058. * Specifies the ground mirror visibility amount.
  46059. * 1 by default
  46060. */
  46061. groundMirrorAmount: number;
  46062. /**
  46063. * Specifies the ground mirror reflectance weight.
  46064. * This uses the standard weight of the background material to setup the fresnel effect
  46065. * of the mirror.
  46066. * 1 by default.
  46067. */
  46068. groundMirrorFresnelWeight: number;
  46069. /**
  46070. * Specifies the ground mirror Falloff distance.
  46071. * This can helps reducing the size of the reflection.
  46072. * 0 by Default.
  46073. */
  46074. groundMirrorFallOffDistance: number;
  46075. /**
  46076. * Specifies the ground mirror texture type.
  46077. * Unsigned Int by Default.
  46078. */
  46079. groundMirrorTextureType: number;
  46080. /**
  46081. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46082. * the shown objects.
  46083. */
  46084. groundYBias: number;
  46085. /**
  46086. * Specifies wether or not to create a skybox.
  46087. * True by default.
  46088. */
  46089. createSkybox: boolean;
  46090. /**
  46091. * Specifies the skybox size.
  46092. * 20 by default.
  46093. */
  46094. skyboxSize: number;
  46095. /**
  46096. * The texture used on the skybox for the main color.
  46097. * Comes from the BabylonJS CDN by default.
  46098. *
  46099. * Remarks: Can be either a texture or a url.
  46100. */
  46101. skyboxTexture: string | BaseTexture;
  46102. /**
  46103. * The color mixed in the skybox texture by default.
  46104. * BabylonJS clearColor by default.
  46105. */
  46106. skyboxColor: Color3;
  46107. /**
  46108. * The background rotation around the Y axis of the scene.
  46109. * This helps aligning the key lights of your scene with the background.
  46110. * 0 by default.
  46111. */
  46112. backgroundYRotation: number;
  46113. /**
  46114. * Compute automatically the size of the elements to best fit with the scene.
  46115. */
  46116. sizeAuto: boolean;
  46117. /**
  46118. * Default position of the rootMesh if autoSize is not true.
  46119. */
  46120. rootPosition: Vector3;
  46121. /**
  46122. * Sets up the image processing in the scene.
  46123. * true by default.
  46124. */
  46125. setupImageProcessing: boolean;
  46126. /**
  46127. * The texture used as your environment texture in the scene.
  46128. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46129. *
  46130. * Remarks: Can be either a texture or a url.
  46131. */
  46132. environmentTexture: string | BaseTexture;
  46133. /**
  46134. * The value of the exposure to apply to the scene.
  46135. * 0.6 by default if setupImageProcessing is true.
  46136. */
  46137. cameraExposure: number;
  46138. /**
  46139. * The value of the contrast to apply to the scene.
  46140. * 1.6 by default if setupImageProcessing is true.
  46141. */
  46142. cameraContrast: number;
  46143. /**
  46144. * Specifies wether or not tonemapping should be enabled in the scene.
  46145. * true by default if setupImageProcessing is true.
  46146. */
  46147. toneMappingEnabled: boolean;
  46148. }
  46149. /**
  46150. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46151. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46152. * It also helps with the default setup of your imageProcessing configuration.
  46153. */
  46154. export class EnvironmentHelper {
  46155. /**
  46156. * Default ground texture URL.
  46157. */
  46158. private static _groundTextureCDNUrl;
  46159. /**
  46160. * Default skybox texture URL.
  46161. */
  46162. private static _skyboxTextureCDNUrl;
  46163. /**
  46164. * Default environment texture URL.
  46165. */
  46166. private static _environmentTextureCDNUrl;
  46167. /**
  46168. * Creates the default options for the helper.
  46169. */
  46170. private static _getDefaultOptions;
  46171. private _rootMesh;
  46172. /**
  46173. * Gets the root mesh created by the helper.
  46174. */
  46175. readonly rootMesh: Mesh;
  46176. private _skybox;
  46177. /**
  46178. * Gets the skybox created by the helper.
  46179. */
  46180. readonly skybox: Nullable<Mesh>;
  46181. private _skyboxTexture;
  46182. /**
  46183. * Gets the skybox texture created by the helper.
  46184. */
  46185. readonly skyboxTexture: Nullable<BaseTexture>;
  46186. private _skyboxMaterial;
  46187. /**
  46188. * Gets the skybox material created by the helper.
  46189. */
  46190. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46191. private _ground;
  46192. /**
  46193. * Gets the ground mesh created by the helper.
  46194. */
  46195. readonly ground: Nullable<Mesh>;
  46196. private _groundTexture;
  46197. /**
  46198. * Gets the ground texture created by the helper.
  46199. */
  46200. readonly groundTexture: Nullable<BaseTexture>;
  46201. private _groundMirror;
  46202. /**
  46203. * Gets the ground mirror created by the helper.
  46204. */
  46205. readonly groundMirror: Nullable<MirrorTexture>;
  46206. /**
  46207. * Gets the ground mirror render list to helps pushing the meshes
  46208. * you wish in the ground reflection.
  46209. */
  46210. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46211. private _groundMaterial;
  46212. /**
  46213. * Gets the ground material created by the helper.
  46214. */
  46215. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46216. /**
  46217. * Stores the creation options.
  46218. */
  46219. private readonly _scene;
  46220. private _options;
  46221. /**
  46222. * This observable will be notified with any error during the creation of the environment,
  46223. * mainly texture creation errors.
  46224. */
  46225. onErrorObservable: Observable<{
  46226. message?: string;
  46227. exception?: any;
  46228. }>;
  46229. /**
  46230. * constructor
  46231. * @param options Defines the options we want to customize the helper
  46232. * @param scene The scene to add the material to
  46233. */
  46234. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46235. /**
  46236. * Updates the background according to the new options
  46237. * @param options
  46238. */
  46239. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46240. /**
  46241. * Sets the primary color of all the available elements.
  46242. * @param color the main color to affect to the ground and the background
  46243. */
  46244. setMainColor(color: Color3): void;
  46245. /**
  46246. * Setup the image processing according to the specified options.
  46247. */
  46248. private _setupImageProcessing;
  46249. /**
  46250. * Setup the environment texture according to the specified options.
  46251. */
  46252. private _setupEnvironmentTexture;
  46253. /**
  46254. * Setup the background according to the specified options.
  46255. */
  46256. private _setupBackground;
  46257. /**
  46258. * Get the scene sizes according to the setup.
  46259. */
  46260. private _getSceneSize;
  46261. /**
  46262. * Setup the ground according to the specified options.
  46263. */
  46264. private _setupGround;
  46265. /**
  46266. * Setup the ground material according to the specified options.
  46267. */
  46268. private _setupGroundMaterial;
  46269. /**
  46270. * Setup the ground diffuse texture according to the specified options.
  46271. */
  46272. private _setupGroundDiffuseTexture;
  46273. /**
  46274. * Setup the ground mirror texture according to the specified options.
  46275. */
  46276. private _setupGroundMirrorTexture;
  46277. /**
  46278. * Setup the ground to receive the mirror texture.
  46279. */
  46280. private _setupMirrorInGroundMaterial;
  46281. /**
  46282. * Setup the skybox according to the specified options.
  46283. */
  46284. private _setupSkybox;
  46285. /**
  46286. * Setup the skybox material according to the specified options.
  46287. */
  46288. private _setupSkyboxMaterial;
  46289. /**
  46290. * Setup the skybox reflection texture according to the specified options.
  46291. */
  46292. private _setupSkyboxReflectionTexture;
  46293. private _errorHandler;
  46294. /**
  46295. * Dispose all the elements created by the Helper.
  46296. */
  46297. dispose(): void;
  46298. }
  46299. }
  46300. declare module BABYLON {
  46301. /**
  46302. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46303. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46304. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46305. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46306. */
  46307. export class PhotoDome extends TransformNode {
  46308. /**
  46309. * Define the image as a Monoscopic panoramic 360 image.
  46310. */
  46311. static readonly MODE_MONOSCOPIC: number;
  46312. /**
  46313. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46314. */
  46315. static readonly MODE_TOPBOTTOM: number;
  46316. /**
  46317. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46318. */
  46319. static readonly MODE_SIDEBYSIDE: number;
  46320. private _useDirectMapping;
  46321. /**
  46322. * The texture being displayed on the sphere
  46323. */
  46324. protected _photoTexture: Texture;
  46325. /**
  46326. * Gets or sets the texture being displayed on the sphere
  46327. */
  46328. photoTexture: Texture;
  46329. /**
  46330. * Observable raised when an error occured while loading the 360 image
  46331. */
  46332. onLoadErrorObservable: Observable<string>;
  46333. /**
  46334. * The skybox material
  46335. */
  46336. protected _material: BackgroundMaterial;
  46337. /**
  46338. * The surface used for the skybox
  46339. */
  46340. protected _mesh: Mesh;
  46341. /**
  46342. * Gets the mesh used for the skybox.
  46343. */
  46344. readonly mesh: Mesh;
  46345. /**
  46346. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46347. * Also see the options.resolution property.
  46348. */
  46349. fovMultiplier: number;
  46350. private _imageMode;
  46351. /**
  46352. * Gets or set the current video mode for the video. It can be:
  46353. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46354. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46355. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46356. */
  46357. imageMode: number;
  46358. /**
  46359. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46360. * @param name Element's name, child elements will append suffixes for their own names.
  46361. * @param urlsOfPhoto defines the url of the photo to display
  46362. * @param options defines an object containing optional or exposed sub element properties
  46363. * @param onError defines a callback called when an error occured while loading the texture
  46364. */
  46365. constructor(name: string, urlOfPhoto: string, options: {
  46366. resolution?: number;
  46367. size?: number;
  46368. useDirectMapping?: boolean;
  46369. faceForward?: boolean;
  46370. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46371. private _onBeforeCameraRenderObserver;
  46372. private _changeImageMode;
  46373. /**
  46374. * Releases resources associated with this node.
  46375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46377. */
  46378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46379. }
  46380. }
  46381. declare module BABYLON {
  46382. /**
  46383. * Class used to host RGBD texture specific utilities
  46384. */
  46385. export class RGBDTextureTools {
  46386. /**
  46387. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46388. * @param texture the texture to expand.
  46389. */
  46390. static ExpandRGBDTexture(texture: Texture): void;
  46391. }
  46392. }
  46393. declare module BABYLON {
  46394. /**
  46395. * Class used to host texture specific utilities
  46396. */
  46397. export class BRDFTextureTools {
  46398. /**
  46399. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46400. * @param scene defines the hosting scene
  46401. * @returns the environment BRDF texture
  46402. */
  46403. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46404. private static _environmentBRDFBase64Texture;
  46405. }
  46406. }
  46407. declare module BABYLON {
  46408. /**
  46409. * @hidden
  46410. */
  46411. export interface IMaterialClearCoatDefines {
  46412. CLEARCOAT: boolean;
  46413. CLEARCOAT_DEFAULTIOR: boolean;
  46414. CLEARCOAT_TEXTURE: boolean;
  46415. CLEARCOAT_TEXTUREDIRECTUV: number;
  46416. CLEARCOAT_BUMP: boolean;
  46417. CLEARCOAT_BUMPDIRECTUV: number;
  46418. CLEARCOAT_TINT: boolean;
  46419. CLEARCOAT_TINT_TEXTURE: boolean;
  46420. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46421. /** @hidden */
  46422. _areTexturesDirty: boolean;
  46423. }
  46424. /**
  46425. * Define the code related to the clear coat parameters of the pbr material.
  46426. */
  46427. export class PBRClearCoatConfiguration {
  46428. /**
  46429. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46430. * The default fits with a polyurethane material.
  46431. */
  46432. private static readonly _DefaultIndexOfRefraction;
  46433. private _isEnabled;
  46434. /**
  46435. * Defines if the clear coat is enabled in the material.
  46436. */
  46437. isEnabled: boolean;
  46438. /**
  46439. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46440. */
  46441. intensity: number;
  46442. /**
  46443. * Defines the clear coat layer roughness.
  46444. */
  46445. roughness: number;
  46446. private _indexOfRefraction;
  46447. /**
  46448. * Defines the index of refraction of the clear coat.
  46449. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46450. * The default fits with a polyurethane material.
  46451. * Changing the default value is more performance intensive.
  46452. */
  46453. indexOfRefraction: number;
  46454. private _texture;
  46455. /**
  46456. * Stores the clear coat values in a texture.
  46457. */
  46458. texture: Nullable<BaseTexture>;
  46459. private _bumpTexture;
  46460. /**
  46461. * Define the clear coat specific bump texture.
  46462. */
  46463. bumpTexture: Nullable<BaseTexture>;
  46464. private _isTintEnabled;
  46465. /**
  46466. * Defines if the clear coat tint is enabled in the material.
  46467. */
  46468. isTintEnabled: boolean;
  46469. /**
  46470. * Defines the clear coat tint of the material.
  46471. * This is only use if tint is enabled
  46472. */
  46473. tintColor: Color3;
  46474. /**
  46475. * Defines the distance at which the tint color should be found in the
  46476. * clear coat media.
  46477. * This is only use if tint is enabled
  46478. */
  46479. tintColorAtDistance: number;
  46480. /**
  46481. * Defines the clear coat layer thickness.
  46482. * This is only use if tint is enabled
  46483. */
  46484. tintThickness: number;
  46485. private _tintTexture;
  46486. /**
  46487. * Stores the clear tint values in a texture.
  46488. * rgb is tint
  46489. * a is a thickness factor
  46490. */
  46491. tintTexture: Nullable<BaseTexture>;
  46492. /** @hidden */
  46493. private _internalMarkAllSubMeshesAsTexturesDirty;
  46494. /** @hidden */
  46495. _markAllSubMeshesAsTexturesDirty(): void;
  46496. /**
  46497. * Instantiate a new istance of clear coat configuration.
  46498. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46499. */
  46500. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46501. /**
  46502. * Gets wehter the submesh is ready to be used or not.
  46503. * @param defines the list of "defines" to update.
  46504. * @param scene defines the scene the material belongs to.
  46505. * @param engine defines the engine the material belongs to.
  46506. * @param disableBumpMap defines wether the material disables bump or not.
  46507. * @returns - boolean indicating that the submesh is ready or not.
  46508. */
  46509. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46510. /**
  46511. * Checks to see if a texture is used in the material.
  46512. * @param defines the list of "defines" to update.
  46513. * @param scene defines the scene to the material belongs to.
  46514. */
  46515. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46516. /**
  46517. * Binds the material data.
  46518. * @param uniformBuffer defines the Uniform buffer to fill in.
  46519. * @param scene defines the scene the material belongs to.
  46520. * @param engine defines the engine the material belongs to.
  46521. * @param disableBumpMap defines wether the material disables bump or not.
  46522. * @param isFrozen defines wether the material is frozen or not.
  46523. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46524. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46525. */
  46526. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46527. /**
  46528. * Checks to see if a texture is used in the material.
  46529. * @param texture - Base texture to use.
  46530. * @returns - Boolean specifying if a texture is used in the material.
  46531. */
  46532. hasTexture(texture: BaseTexture): boolean;
  46533. /**
  46534. * Returns an array of the actively used textures.
  46535. * @param activeTextures Array of BaseTextures
  46536. */
  46537. getActiveTextures(activeTextures: BaseTexture[]): void;
  46538. /**
  46539. * Returns the animatable textures.
  46540. * @param animatables Array of animatable textures.
  46541. */
  46542. getAnimatables(animatables: IAnimatable[]): void;
  46543. /**
  46544. * Disposes the resources of the material.
  46545. * @param forceDisposeTextures - Forces the disposal of all textures.
  46546. */
  46547. dispose(forceDisposeTextures?: boolean): void;
  46548. /**
  46549. * Get the current class name of the texture useful for serialization or dynamic coding.
  46550. * @returns "PBRClearCoatConfiguration"
  46551. */
  46552. getClassName(): string;
  46553. /**
  46554. * Add fallbacks to the effect fallbacks list.
  46555. * @param defines defines the Base texture to use.
  46556. * @param fallbacks defines the current fallback list.
  46557. * @param currentRank defines the current fallback rank.
  46558. * @returns the new fallback rank.
  46559. */
  46560. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46561. /**
  46562. * Add the required uniforms to the current list.
  46563. * @param uniforms defines the current uniform list.
  46564. */
  46565. static AddUniforms(uniforms: string[]): void;
  46566. /**
  46567. * Add the required samplers to the current list.
  46568. * @param samplers defines the current sampler list.
  46569. */
  46570. static AddSamplers(samplers: string[]): void;
  46571. /**
  46572. * Add the required uniforms to the current buffer.
  46573. * @param uniformBuffer defines the current uniform buffer.
  46574. */
  46575. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46576. /**
  46577. * Makes a duplicate of the current configuration into another one.
  46578. * @param clearCoatConfiguration define the config where to copy the info
  46579. */
  46580. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46581. /**
  46582. * Serializes this clear coat configuration.
  46583. * @returns - An object with the serialized config.
  46584. */
  46585. serialize(): any;
  46586. /**
  46587. * Parses a anisotropy Configuration from a serialized object.
  46588. * @param source - Serialized object.
  46589. * @param scene Defines the scene we are parsing for
  46590. * @param rootUrl Defines the rootUrl to load from
  46591. */
  46592. parse(source: any, scene: Scene, rootUrl: string): void;
  46593. }
  46594. }
  46595. declare module BABYLON {
  46596. /**
  46597. * @hidden
  46598. */
  46599. export interface IMaterialAnisotropicDefines {
  46600. ANISOTROPIC: boolean;
  46601. ANISOTROPIC_TEXTURE: boolean;
  46602. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46603. MAINUV1: boolean;
  46604. _areTexturesDirty: boolean;
  46605. _needUVs: boolean;
  46606. }
  46607. /**
  46608. * Define the code related to the anisotropic parameters of the pbr material.
  46609. */
  46610. export class PBRAnisotropicConfiguration {
  46611. private _isEnabled;
  46612. /**
  46613. * Defines if the anisotropy is enabled in the material.
  46614. */
  46615. isEnabled: boolean;
  46616. /**
  46617. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46618. */
  46619. intensity: number;
  46620. /**
  46621. * Defines if the effect is along the tangents, bitangents or in between.
  46622. * By default, the effect is "strectching" the highlights along the tangents.
  46623. */
  46624. direction: Vector2;
  46625. private _texture;
  46626. /**
  46627. * Stores the anisotropy values in a texture.
  46628. * rg is direction (like normal from -1 to 1)
  46629. * b is a intensity
  46630. */
  46631. texture: Nullable<BaseTexture>;
  46632. /** @hidden */
  46633. private _internalMarkAllSubMeshesAsTexturesDirty;
  46634. /** @hidden */
  46635. _markAllSubMeshesAsTexturesDirty(): void;
  46636. /**
  46637. * Instantiate a new istance of anisotropy configuration.
  46638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46639. */
  46640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46641. /**
  46642. * Specifies that the submesh is ready to be used.
  46643. * @param defines the list of "defines" to update.
  46644. * @param scene defines the scene the material belongs to.
  46645. * @returns - boolean indicating that the submesh is ready or not.
  46646. */
  46647. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46648. /**
  46649. * Checks to see if a texture is used in the material.
  46650. * @param defines the list of "defines" to update.
  46651. * @param mesh the mesh we are preparing the defines for.
  46652. * @param scene defines the scene the material belongs to.
  46653. */
  46654. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46655. /**
  46656. * Binds the material data.
  46657. * @param uniformBuffer defines the Uniform buffer to fill in.
  46658. * @param scene defines the scene the material belongs to.
  46659. * @param isFrozen defines wether the material is frozen or not.
  46660. */
  46661. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46662. /**
  46663. * Checks to see if a texture is used in the material.
  46664. * @param texture - Base texture to use.
  46665. * @returns - Boolean specifying if a texture is used in the material.
  46666. */
  46667. hasTexture(texture: BaseTexture): boolean;
  46668. /**
  46669. * Returns an array of the actively used textures.
  46670. * @param activeTextures Array of BaseTextures
  46671. */
  46672. getActiveTextures(activeTextures: BaseTexture[]): void;
  46673. /**
  46674. * Returns the animatable textures.
  46675. * @param animatables Array of animatable textures.
  46676. */
  46677. getAnimatables(animatables: IAnimatable[]): void;
  46678. /**
  46679. * Disposes the resources of the material.
  46680. * @param forceDisposeTextures - Forces the disposal of all textures.
  46681. */
  46682. dispose(forceDisposeTextures?: boolean): void;
  46683. /**
  46684. * Get the current class name of the texture useful for serialization or dynamic coding.
  46685. * @returns "PBRAnisotropicConfiguration"
  46686. */
  46687. getClassName(): string;
  46688. /**
  46689. * Add fallbacks to the effect fallbacks list.
  46690. * @param defines defines the Base texture to use.
  46691. * @param fallbacks defines the current fallback list.
  46692. * @param currentRank defines the current fallback rank.
  46693. * @returns the new fallback rank.
  46694. */
  46695. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46696. /**
  46697. * Add the required uniforms to the current list.
  46698. * @param uniforms defines the current uniform list.
  46699. */
  46700. static AddUniforms(uniforms: string[]): void;
  46701. /**
  46702. * Add the required uniforms to the current buffer.
  46703. * @param uniformBuffer defines the current uniform buffer.
  46704. */
  46705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46706. /**
  46707. * Add the required samplers to the current list.
  46708. * @param samplers defines the current sampler list.
  46709. */
  46710. static AddSamplers(samplers: string[]): void;
  46711. /**
  46712. * Makes a duplicate of the current configuration into another one.
  46713. * @param anisotropicConfiguration define the config where to copy the info
  46714. */
  46715. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46716. /**
  46717. * Serializes this anisotropy configuration.
  46718. * @returns - An object with the serialized config.
  46719. */
  46720. serialize(): any;
  46721. /**
  46722. * Parses a anisotropy Configuration from a serialized object.
  46723. * @param source - Serialized object.
  46724. * @param scene Defines the scene we are parsing for
  46725. * @param rootUrl Defines the rootUrl to load from
  46726. */
  46727. parse(source: any, scene: Scene, rootUrl: string): void;
  46728. }
  46729. }
  46730. declare module BABYLON {
  46731. /**
  46732. * @hidden
  46733. */
  46734. export interface IMaterialBRDFDefines {
  46735. BRDF_V_HEIGHT_CORRELATED: boolean;
  46736. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46737. SPHERICAL_HARMONICS: boolean;
  46738. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46739. /** @hidden */
  46740. _areMiscDirty: boolean;
  46741. }
  46742. /**
  46743. * Define the code related to the BRDF parameters of the pbr material.
  46744. */
  46745. export class PBRBRDFConfiguration {
  46746. /**
  46747. * Default value used for the energy conservation.
  46748. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46749. */
  46750. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46751. /**
  46752. * Default value used for the Smith Visibility Height Correlated mode.
  46753. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46754. */
  46755. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46756. /**
  46757. * Default value used for the IBL diffuse part.
  46758. * This can help switching back to the polynomials mode globally which is a tiny bit
  46759. * less GPU intensive at the drawback of a lower quality.
  46760. */
  46761. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46762. /**
  46763. * Default value used for activating energy conservation for the specular workflow.
  46764. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46765. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46766. */
  46767. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46768. private _useEnergyConservation;
  46769. /**
  46770. * Defines if the material uses energy conservation.
  46771. */
  46772. useEnergyConservation: boolean;
  46773. private _useSmithVisibilityHeightCorrelated;
  46774. /**
  46775. * LEGACY Mode set to false
  46776. * Defines if the material uses height smith correlated visibility term.
  46777. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46778. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46779. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46780. * Not relying on height correlated will also disable energy conservation.
  46781. */
  46782. useSmithVisibilityHeightCorrelated: boolean;
  46783. private _useSphericalHarmonics;
  46784. /**
  46785. * LEGACY Mode set to false
  46786. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46787. * diffuse part of the IBL.
  46788. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46789. * to the ground truth.
  46790. */
  46791. useSphericalHarmonics: boolean;
  46792. private _useSpecularGlossinessInputEnergyConservation;
  46793. /**
  46794. * Defines if the material uses energy conservation, when the specular workflow is active.
  46795. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46796. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46797. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46798. */
  46799. useSpecularGlossinessInputEnergyConservation: boolean;
  46800. /** @hidden */
  46801. private _internalMarkAllSubMeshesAsMiscDirty;
  46802. /** @hidden */
  46803. _markAllSubMeshesAsMiscDirty(): void;
  46804. /**
  46805. * Instantiate a new istance of clear coat configuration.
  46806. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46807. */
  46808. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46809. /**
  46810. * Checks to see if a texture is used in the material.
  46811. * @param defines the list of "defines" to update.
  46812. */
  46813. prepareDefines(defines: IMaterialBRDFDefines): void;
  46814. /**
  46815. * Get the current class name of the texture useful for serialization or dynamic coding.
  46816. * @returns "PBRClearCoatConfiguration"
  46817. */
  46818. getClassName(): string;
  46819. /**
  46820. * Makes a duplicate of the current configuration into another one.
  46821. * @param brdfConfiguration define the config where to copy the info
  46822. */
  46823. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46824. /**
  46825. * Serializes this BRDF configuration.
  46826. * @returns - An object with the serialized config.
  46827. */
  46828. serialize(): any;
  46829. /**
  46830. * Parses a anisotropy Configuration from a serialized object.
  46831. * @param source - Serialized object.
  46832. * @param scene Defines the scene we are parsing for
  46833. * @param rootUrl Defines the rootUrl to load from
  46834. */
  46835. parse(source: any, scene: Scene, rootUrl: string): void;
  46836. }
  46837. }
  46838. declare module BABYLON {
  46839. /**
  46840. * @hidden
  46841. */
  46842. export interface IMaterialSheenDefines {
  46843. SHEEN: boolean;
  46844. SHEEN_TEXTURE: boolean;
  46845. SHEEN_TEXTUREDIRECTUV: number;
  46846. SHEEN_LINKWITHALBEDO: boolean;
  46847. /** @hidden */
  46848. _areTexturesDirty: boolean;
  46849. }
  46850. /**
  46851. * Define the code related to the Sheen parameters of the pbr material.
  46852. */
  46853. export class PBRSheenConfiguration {
  46854. private _isEnabled;
  46855. /**
  46856. * Defines if the material uses sheen.
  46857. */
  46858. isEnabled: boolean;
  46859. private _linkSheenWithAlbedo;
  46860. /**
  46861. * Defines if the sheen is linked to the sheen color.
  46862. */
  46863. linkSheenWithAlbedo: boolean;
  46864. /**
  46865. * Defines the sheen intensity.
  46866. */
  46867. intensity: number;
  46868. /**
  46869. * Defines the sheen color.
  46870. */
  46871. color: Color3;
  46872. private _texture;
  46873. /**
  46874. * Stores the sheen tint values in a texture.
  46875. * rgb is tint
  46876. * a is a intensity
  46877. */
  46878. texture: Nullable<BaseTexture>;
  46879. /** @hidden */
  46880. private _internalMarkAllSubMeshesAsTexturesDirty;
  46881. /** @hidden */
  46882. _markAllSubMeshesAsTexturesDirty(): void;
  46883. /**
  46884. * Instantiate a new istance of clear coat configuration.
  46885. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46886. */
  46887. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46888. /**
  46889. * Specifies that the submesh is ready to be used.
  46890. * @param defines the list of "defines" to update.
  46891. * @param scene defines the scene the material belongs to.
  46892. * @returns - boolean indicating that the submesh is ready or not.
  46893. */
  46894. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46895. /**
  46896. * Checks to see if a texture is used in the material.
  46897. * @param defines the list of "defines" to update.
  46898. * @param scene defines the scene the material belongs to.
  46899. */
  46900. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46901. /**
  46902. * Binds the material data.
  46903. * @param uniformBuffer defines the Uniform buffer to fill in.
  46904. * @param scene defines the scene the material belongs to.
  46905. * @param isFrozen defines wether the material is frozen or not.
  46906. */
  46907. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46908. /**
  46909. * Checks to see if a texture is used in the material.
  46910. * @param texture - Base texture to use.
  46911. * @returns - Boolean specifying if a texture is used in the material.
  46912. */
  46913. hasTexture(texture: BaseTexture): boolean;
  46914. /**
  46915. * Returns an array of the actively used textures.
  46916. * @param activeTextures Array of BaseTextures
  46917. */
  46918. getActiveTextures(activeTextures: BaseTexture[]): void;
  46919. /**
  46920. * Returns the animatable textures.
  46921. * @param animatables Array of animatable textures.
  46922. */
  46923. getAnimatables(animatables: IAnimatable[]): void;
  46924. /**
  46925. * Disposes the resources of the material.
  46926. * @param forceDisposeTextures - Forces the disposal of all textures.
  46927. */
  46928. dispose(forceDisposeTextures?: boolean): void;
  46929. /**
  46930. * Get the current class name of the texture useful for serialization or dynamic coding.
  46931. * @returns "PBRSheenConfiguration"
  46932. */
  46933. getClassName(): string;
  46934. /**
  46935. * Add fallbacks to the effect fallbacks list.
  46936. * @param defines defines the Base texture to use.
  46937. * @param fallbacks defines the current fallback list.
  46938. * @param currentRank defines the current fallback rank.
  46939. * @returns the new fallback rank.
  46940. */
  46941. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46942. /**
  46943. * Add the required uniforms to the current list.
  46944. * @param uniforms defines the current uniform list.
  46945. */
  46946. static AddUniforms(uniforms: string[]): void;
  46947. /**
  46948. * Add the required uniforms to the current buffer.
  46949. * @param uniformBuffer defines the current uniform buffer.
  46950. */
  46951. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46952. /**
  46953. * Add the required samplers to the current list.
  46954. * @param samplers defines the current sampler list.
  46955. */
  46956. static AddSamplers(samplers: string[]): void;
  46957. /**
  46958. * Makes a duplicate of the current configuration into another one.
  46959. * @param sheenConfiguration define the config where to copy the info
  46960. */
  46961. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46962. /**
  46963. * Serializes this BRDF configuration.
  46964. * @returns - An object with the serialized config.
  46965. */
  46966. serialize(): any;
  46967. /**
  46968. * Parses a anisotropy Configuration from a serialized object.
  46969. * @param source - Serialized object.
  46970. * @param scene Defines the scene we are parsing for
  46971. * @param rootUrl Defines the rootUrl to load from
  46972. */
  46973. parse(source: any, scene: Scene, rootUrl: string): void;
  46974. }
  46975. }
  46976. declare module BABYLON {
  46977. /**
  46978. * @hidden
  46979. */
  46980. export interface IMaterialSubSurfaceDefines {
  46981. SUBSURFACE: boolean;
  46982. SS_REFRACTION: boolean;
  46983. SS_TRANSLUCENCY: boolean;
  46984. SS_SCATERRING: boolean;
  46985. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46986. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46987. SS_REFRACTIONMAP_3D: boolean;
  46988. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46989. SS_LODINREFRACTIONALPHA: boolean;
  46990. SS_GAMMAREFRACTION: boolean;
  46991. SS_RGBDREFRACTION: boolean;
  46992. SS_LINEARSPECULARREFRACTION: boolean;
  46993. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46994. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46995. /** @hidden */
  46996. _areTexturesDirty: boolean;
  46997. }
  46998. /**
  46999. * Define the code related to the sub surface parameters of the pbr material.
  47000. */
  47001. export class PBRSubSurfaceConfiguration {
  47002. private _isRefractionEnabled;
  47003. /**
  47004. * Defines if the refraction is enabled in the material.
  47005. */
  47006. isRefractionEnabled: boolean;
  47007. private _isTranslucencyEnabled;
  47008. /**
  47009. * Defines if the translucency is enabled in the material.
  47010. */
  47011. isTranslucencyEnabled: boolean;
  47012. private _isScatteringEnabled;
  47013. /**
  47014. * Defines the refraction intensity of the material.
  47015. * The refraction when enabled replaces the Diffuse part of the material.
  47016. * The intensity helps transitionning between diffuse and refraction.
  47017. */
  47018. refractionIntensity: number;
  47019. /**
  47020. * Defines the translucency intensity of the material.
  47021. * When translucency has been enabled, this defines how much of the "translucency"
  47022. * is addded to the diffuse part of the material.
  47023. */
  47024. translucencyIntensity: number;
  47025. /**
  47026. * Defines the scattering intensity of the material.
  47027. * When scattering has been enabled, this defines how much of the "scattered light"
  47028. * is addded to the diffuse part of the material.
  47029. */
  47030. scatteringIntensity: number;
  47031. private _thicknessTexture;
  47032. /**
  47033. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47034. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47035. * 0 would mean minimumThickness
  47036. * 1 would mean maximumThickness
  47037. * The other channels might be use as a mask to vary the different effects intensity.
  47038. */
  47039. thicknessTexture: Nullable<BaseTexture>;
  47040. private _refractionTexture;
  47041. /**
  47042. * Defines the texture to use for refraction.
  47043. */
  47044. refractionTexture: Nullable<BaseTexture>;
  47045. private _indexOfRefraction;
  47046. /**
  47047. * Defines the index of refraction used in the material.
  47048. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47049. */
  47050. indexOfRefraction: number;
  47051. private _invertRefractionY;
  47052. /**
  47053. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47054. */
  47055. invertRefractionY: boolean;
  47056. private _linkRefractionWithTransparency;
  47057. /**
  47058. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47059. * Materials half opaque for instance using refraction could benefit from this control.
  47060. */
  47061. linkRefractionWithTransparency: boolean;
  47062. /**
  47063. * Defines the minimum thickness stored in the thickness map.
  47064. * If no thickness map is defined, this value will be used to simulate thickness.
  47065. */
  47066. minimumThickness: number;
  47067. /**
  47068. * Defines the maximum thickness stored in the thickness map.
  47069. */
  47070. maximumThickness: number;
  47071. /**
  47072. * Defines the volume tint of the material.
  47073. * This is used for both translucency and scattering.
  47074. */
  47075. tintColor: Color3;
  47076. /**
  47077. * Defines the distance at which the tint color should be found in the media.
  47078. * This is used for refraction only.
  47079. */
  47080. tintColorAtDistance: number;
  47081. /**
  47082. * Defines how far each channel transmit through the media.
  47083. * It is defined as a color to simplify it selection.
  47084. */
  47085. diffusionDistance: Color3;
  47086. private _useMaskFromThicknessTexture;
  47087. /**
  47088. * Stores the intensity of the different subsurface effects in the thickness texture.
  47089. * * the green channel is the translucency intensity.
  47090. * * the blue channel is the scattering intensity.
  47091. * * the alpha channel is the refraction intensity.
  47092. */
  47093. useMaskFromThicknessTexture: boolean;
  47094. /** @hidden */
  47095. private _internalMarkAllSubMeshesAsTexturesDirty;
  47096. /** @hidden */
  47097. _markAllSubMeshesAsTexturesDirty(): void;
  47098. /**
  47099. * Instantiate a new istance of sub surface configuration.
  47100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47101. */
  47102. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47103. /**
  47104. * Gets wehter the submesh is ready to be used or not.
  47105. * @param defines the list of "defines" to update.
  47106. * @param scene defines the scene the material belongs to.
  47107. * @returns - boolean indicating that the submesh is ready or not.
  47108. */
  47109. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47110. /**
  47111. * Checks to see if a texture is used in the material.
  47112. * @param defines the list of "defines" to update.
  47113. * @param scene defines the scene to the material belongs to.
  47114. */
  47115. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47116. /**
  47117. * Binds the material data.
  47118. * @param uniformBuffer defines the Uniform buffer to fill in.
  47119. * @param scene defines the scene the material belongs to.
  47120. * @param engine defines the engine the material belongs to.
  47121. * @param isFrozen defines wether the material is frozen or not.
  47122. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47123. */
  47124. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47125. /**
  47126. * Unbinds the material from the mesh.
  47127. * @param activeEffect defines the effect that should be unbound from.
  47128. * @returns true if unbound, otherwise false
  47129. */
  47130. unbind(activeEffect: Effect): boolean;
  47131. /**
  47132. * Returns the texture used for refraction or null if none is used.
  47133. * @param scene defines the scene the material belongs to.
  47134. * @returns - Refraction texture if present. If no refraction texture and refraction
  47135. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47136. */
  47137. private _getRefractionTexture;
  47138. /**
  47139. * Returns true if alpha blending should be disabled.
  47140. */
  47141. readonly disableAlphaBlending: boolean;
  47142. /**
  47143. * Fills the list of render target textures.
  47144. * @param renderTargets the list of render targets to update
  47145. */
  47146. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47147. /**
  47148. * Checks to see if a texture is used in the material.
  47149. * @param texture - Base texture to use.
  47150. * @returns - Boolean specifying if a texture is used in the material.
  47151. */
  47152. hasTexture(texture: BaseTexture): boolean;
  47153. /**
  47154. * Gets a boolean indicating that current material needs to register RTT
  47155. * @returns true if this uses a render target otherwise false.
  47156. */
  47157. hasRenderTargetTextures(): boolean;
  47158. /**
  47159. * Returns an array of the actively used textures.
  47160. * @param activeTextures Array of BaseTextures
  47161. */
  47162. getActiveTextures(activeTextures: BaseTexture[]): void;
  47163. /**
  47164. * Returns the animatable textures.
  47165. * @param animatables Array of animatable textures.
  47166. */
  47167. getAnimatables(animatables: IAnimatable[]): void;
  47168. /**
  47169. * Disposes the resources of the material.
  47170. * @param forceDisposeTextures - Forces the disposal of all textures.
  47171. */
  47172. dispose(forceDisposeTextures?: boolean): void;
  47173. /**
  47174. * Get the current class name of the texture useful for serialization or dynamic coding.
  47175. * @returns "PBRSubSurfaceConfiguration"
  47176. */
  47177. getClassName(): string;
  47178. /**
  47179. * Add fallbacks to the effect fallbacks list.
  47180. * @param defines defines the Base texture to use.
  47181. * @param fallbacks defines the current fallback list.
  47182. * @param currentRank defines the current fallback rank.
  47183. * @returns the new fallback rank.
  47184. */
  47185. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47186. /**
  47187. * Add the required uniforms to the current list.
  47188. * @param uniforms defines the current uniform list.
  47189. */
  47190. static AddUniforms(uniforms: string[]): void;
  47191. /**
  47192. * Add the required samplers to the current list.
  47193. * @param samplers defines the current sampler list.
  47194. */
  47195. static AddSamplers(samplers: string[]): void;
  47196. /**
  47197. * Add the required uniforms to the current buffer.
  47198. * @param uniformBuffer defines the current uniform buffer.
  47199. */
  47200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47201. /**
  47202. * Makes a duplicate of the current configuration into another one.
  47203. * @param configuration define the config where to copy the info
  47204. */
  47205. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47206. /**
  47207. * Serializes this Sub Surface configuration.
  47208. * @returns - An object with the serialized config.
  47209. */
  47210. serialize(): any;
  47211. /**
  47212. * Parses a anisotropy Configuration from a serialized object.
  47213. * @param source - Serialized object.
  47214. * @param scene Defines the scene we are parsing for
  47215. * @param rootUrl Defines the rootUrl to load from
  47216. */
  47217. parse(source: any, scene: Scene, rootUrl: string): void;
  47218. }
  47219. }
  47220. declare module BABYLON {
  47221. /** @hidden */
  47222. export var pbrFragmentDeclaration: {
  47223. name: string;
  47224. shader: string;
  47225. };
  47226. }
  47227. declare module BABYLON {
  47228. /** @hidden */
  47229. export var pbrUboDeclaration: {
  47230. name: string;
  47231. shader: string;
  47232. };
  47233. }
  47234. declare module BABYLON {
  47235. /** @hidden */
  47236. export var pbrFragmentExtraDeclaration: {
  47237. name: string;
  47238. shader: string;
  47239. };
  47240. }
  47241. declare module BABYLON {
  47242. /** @hidden */
  47243. export var pbrFragmentSamplersDeclaration: {
  47244. name: string;
  47245. shader: string;
  47246. };
  47247. }
  47248. declare module BABYLON {
  47249. /** @hidden */
  47250. export var pbrHelperFunctions: {
  47251. name: string;
  47252. shader: string;
  47253. };
  47254. }
  47255. declare module BABYLON {
  47256. /** @hidden */
  47257. export var harmonicsFunctions: {
  47258. name: string;
  47259. shader: string;
  47260. };
  47261. }
  47262. declare module BABYLON {
  47263. /** @hidden */
  47264. export var pbrDirectLightingSetupFunctions: {
  47265. name: string;
  47266. shader: string;
  47267. };
  47268. }
  47269. declare module BABYLON {
  47270. /** @hidden */
  47271. export var pbrDirectLightingFalloffFunctions: {
  47272. name: string;
  47273. shader: string;
  47274. };
  47275. }
  47276. declare module BABYLON {
  47277. /** @hidden */
  47278. export var pbrBRDFFunctions: {
  47279. name: string;
  47280. shader: string;
  47281. };
  47282. }
  47283. declare module BABYLON {
  47284. /** @hidden */
  47285. export var pbrDirectLightingFunctions: {
  47286. name: string;
  47287. shader: string;
  47288. };
  47289. }
  47290. declare module BABYLON {
  47291. /** @hidden */
  47292. export var pbrIBLFunctions: {
  47293. name: string;
  47294. shader: string;
  47295. };
  47296. }
  47297. declare module BABYLON {
  47298. /** @hidden */
  47299. export var pbrDebug: {
  47300. name: string;
  47301. shader: string;
  47302. };
  47303. }
  47304. declare module BABYLON {
  47305. /** @hidden */
  47306. export var pbrPixelShader: {
  47307. name: string;
  47308. shader: string;
  47309. };
  47310. }
  47311. declare module BABYLON {
  47312. /** @hidden */
  47313. export var pbrVertexDeclaration: {
  47314. name: string;
  47315. shader: string;
  47316. };
  47317. }
  47318. declare module BABYLON {
  47319. /** @hidden */
  47320. export var pbrVertexShader: {
  47321. name: string;
  47322. shader: string;
  47323. };
  47324. }
  47325. declare module BABYLON {
  47326. /**
  47327. * Manages the defines for the PBR Material.
  47328. * @hidden
  47329. */
  47330. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47331. PBR: boolean;
  47332. MAINUV1: boolean;
  47333. MAINUV2: boolean;
  47334. UV1: boolean;
  47335. UV2: boolean;
  47336. ALBEDO: boolean;
  47337. ALBEDODIRECTUV: number;
  47338. VERTEXCOLOR: boolean;
  47339. AMBIENT: boolean;
  47340. AMBIENTDIRECTUV: number;
  47341. AMBIENTINGRAYSCALE: boolean;
  47342. OPACITY: boolean;
  47343. VERTEXALPHA: boolean;
  47344. OPACITYDIRECTUV: number;
  47345. OPACITYRGB: boolean;
  47346. ALPHATEST: boolean;
  47347. DEPTHPREPASS: boolean;
  47348. ALPHABLEND: boolean;
  47349. ALPHAFROMALBEDO: boolean;
  47350. ALPHATESTVALUE: string;
  47351. SPECULAROVERALPHA: boolean;
  47352. RADIANCEOVERALPHA: boolean;
  47353. ALPHAFRESNEL: boolean;
  47354. LINEARALPHAFRESNEL: boolean;
  47355. PREMULTIPLYALPHA: boolean;
  47356. EMISSIVE: boolean;
  47357. EMISSIVEDIRECTUV: number;
  47358. REFLECTIVITY: boolean;
  47359. REFLECTIVITYDIRECTUV: number;
  47360. SPECULARTERM: boolean;
  47361. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47362. MICROSURFACEAUTOMATIC: boolean;
  47363. LODBASEDMICROSFURACE: boolean;
  47364. MICROSURFACEMAP: boolean;
  47365. MICROSURFACEMAPDIRECTUV: number;
  47366. METALLICWORKFLOW: boolean;
  47367. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47368. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47369. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47370. AOSTOREINMETALMAPRED: boolean;
  47371. ENVIRONMENTBRDF: boolean;
  47372. ENVIRONMENTBRDF_RGBD: boolean;
  47373. NORMAL: boolean;
  47374. TANGENT: boolean;
  47375. BUMP: boolean;
  47376. BUMPDIRECTUV: number;
  47377. OBJECTSPACE_NORMALMAP: boolean;
  47378. PARALLAX: boolean;
  47379. PARALLAXOCCLUSION: boolean;
  47380. NORMALXYSCALE: boolean;
  47381. LIGHTMAP: boolean;
  47382. LIGHTMAPDIRECTUV: number;
  47383. USELIGHTMAPASSHADOWMAP: boolean;
  47384. GAMMALIGHTMAP: boolean;
  47385. RGBDLIGHTMAP: boolean;
  47386. REFLECTION: boolean;
  47387. REFLECTIONMAP_3D: boolean;
  47388. REFLECTIONMAP_SPHERICAL: boolean;
  47389. REFLECTIONMAP_PLANAR: boolean;
  47390. REFLECTIONMAP_CUBIC: boolean;
  47391. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47392. REFLECTIONMAP_PROJECTION: boolean;
  47393. REFLECTIONMAP_SKYBOX: boolean;
  47394. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47395. REFLECTIONMAP_EXPLICIT: boolean;
  47396. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47397. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47398. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47399. INVERTCUBICMAP: boolean;
  47400. USESPHERICALFROMREFLECTIONMAP: boolean;
  47401. USEIRRADIANCEMAP: boolean;
  47402. SPHERICAL_HARMONICS: boolean;
  47403. USESPHERICALINVERTEX: boolean;
  47404. REFLECTIONMAP_OPPOSITEZ: boolean;
  47405. LODINREFLECTIONALPHA: boolean;
  47406. GAMMAREFLECTION: boolean;
  47407. RGBDREFLECTION: boolean;
  47408. LINEARSPECULARREFLECTION: boolean;
  47409. RADIANCEOCCLUSION: boolean;
  47410. HORIZONOCCLUSION: boolean;
  47411. INSTANCES: boolean;
  47412. NUM_BONE_INFLUENCERS: number;
  47413. BonesPerMesh: number;
  47414. BONETEXTURE: boolean;
  47415. NONUNIFORMSCALING: boolean;
  47416. MORPHTARGETS: boolean;
  47417. MORPHTARGETS_NORMAL: boolean;
  47418. MORPHTARGETS_TANGENT: boolean;
  47419. MORPHTARGETS_UV: boolean;
  47420. NUM_MORPH_INFLUENCERS: number;
  47421. IMAGEPROCESSING: boolean;
  47422. VIGNETTE: boolean;
  47423. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47424. VIGNETTEBLENDMODEOPAQUE: boolean;
  47425. TONEMAPPING: boolean;
  47426. TONEMAPPING_ACES: boolean;
  47427. CONTRAST: boolean;
  47428. COLORCURVES: boolean;
  47429. COLORGRADING: boolean;
  47430. COLORGRADING3D: boolean;
  47431. SAMPLER3DGREENDEPTH: boolean;
  47432. SAMPLER3DBGRMAP: boolean;
  47433. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47434. EXPOSURE: boolean;
  47435. MULTIVIEW: boolean;
  47436. USEPHYSICALLIGHTFALLOFF: boolean;
  47437. USEGLTFLIGHTFALLOFF: boolean;
  47438. TWOSIDEDLIGHTING: boolean;
  47439. SHADOWFLOAT: boolean;
  47440. CLIPPLANE: boolean;
  47441. CLIPPLANE2: boolean;
  47442. CLIPPLANE3: boolean;
  47443. CLIPPLANE4: boolean;
  47444. POINTSIZE: boolean;
  47445. FOG: boolean;
  47446. LOGARITHMICDEPTH: boolean;
  47447. FORCENORMALFORWARD: boolean;
  47448. SPECULARAA: boolean;
  47449. CLEARCOAT: boolean;
  47450. CLEARCOAT_DEFAULTIOR: boolean;
  47451. CLEARCOAT_TEXTURE: boolean;
  47452. CLEARCOAT_TEXTUREDIRECTUV: number;
  47453. CLEARCOAT_BUMP: boolean;
  47454. CLEARCOAT_BUMPDIRECTUV: number;
  47455. CLEARCOAT_TINT: boolean;
  47456. CLEARCOAT_TINT_TEXTURE: boolean;
  47457. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47458. ANISOTROPIC: boolean;
  47459. ANISOTROPIC_TEXTURE: boolean;
  47460. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47461. BRDF_V_HEIGHT_CORRELATED: boolean;
  47462. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47463. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47464. SHEEN: boolean;
  47465. SHEEN_TEXTURE: boolean;
  47466. SHEEN_TEXTUREDIRECTUV: number;
  47467. SHEEN_LINKWITHALBEDO: boolean;
  47468. SUBSURFACE: boolean;
  47469. SS_REFRACTION: boolean;
  47470. SS_TRANSLUCENCY: boolean;
  47471. SS_SCATERRING: boolean;
  47472. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47473. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47474. SS_REFRACTIONMAP_3D: boolean;
  47475. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47476. SS_LODINREFRACTIONALPHA: boolean;
  47477. SS_GAMMAREFRACTION: boolean;
  47478. SS_RGBDREFRACTION: boolean;
  47479. SS_LINEARSPECULARREFRACTION: boolean;
  47480. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47481. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47482. UNLIT: boolean;
  47483. DEBUGMODE: number;
  47484. /**
  47485. * Initializes the PBR Material defines.
  47486. */
  47487. constructor();
  47488. /**
  47489. * Resets the PBR Material defines.
  47490. */
  47491. reset(): void;
  47492. }
  47493. /**
  47494. * The Physically based material base class of BJS.
  47495. *
  47496. * This offers the main features of a standard PBR material.
  47497. * For more information, please refer to the documentation :
  47498. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47499. */
  47500. export abstract class PBRBaseMaterial extends PushMaterial {
  47501. /**
  47502. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47503. */
  47504. static readonly PBRMATERIAL_OPAQUE: number;
  47505. /**
  47506. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47507. */
  47508. static readonly PBRMATERIAL_ALPHATEST: number;
  47509. /**
  47510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47511. */
  47512. static readonly PBRMATERIAL_ALPHABLEND: number;
  47513. /**
  47514. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47515. * They are also discarded below the alpha cutoff threshold to improve performances.
  47516. */
  47517. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47518. /**
  47519. * Defines the default value of how much AO map is occluding the analytical lights
  47520. * (point spot...).
  47521. */
  47522. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47523. /**
  47524. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47525. */
  47526. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47527. /**
  47528. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47529. * to enhance interoperability with other engines.
  47530. */
  47531. static readonly LIGHTFALLOFF_GLTF: number;
  47532. /**
  47533. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47534. * to enhance interoperability with other materials.
  47535. */
  47536. static readonly LIGHTFALLOFF_STANDARD: number;
  47537. /**
  47538. * Intensity of the direct lights e.g. the four lights available in your scene.
  47539. * This impacts both the direct diffuse and specular highlights.
  47540. */
  47541. protected _directIntensity: number;
  47542. /**
  47543. * Intensity of the emissive part of the material.
  47544. * This helps controlling the emissive effect without modifying the emissive color.
  47545. */
  47546. protected _emissiveIntensity: number;
  47547. /**
  47548. * Intensity of the environment e.g. how much the environment will light the object
  47549. * either through harmonics for rough material or through the refelction for shiny ones.
  47550. */
  47551. protected _environmentIntensity: number;
  47552. /**
  47553. * This is a special control allowing the reduction of the specular highlights coming from the
  47554. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47555. */
  47556. protected _specularIntensity: number;
  47557. /**
  47558. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47559. */
  47560. private _lightingInfos;
  47561. /**
  47562. * Debug Control allowing disabling the bump map on this material.
  47563. */
  47564. protected _disableBumpMap: boolean;
  47565. /**
  47566. * AKA Diffuse Texture in standard nomenclature.
  47567. */
  47568. protected _albedoTexture: Nullable<BaseTexture>;
  47569. /**
  47570. * AKA Occlusion Texture in other nomenclature.
  47571. */
  47572. protected _ambientTexture: Nullable<BaseTexture>;
  47573. /**
  47574. * AKA Occlusion Texture Intensity in other nomenclature.
  47575. */
  47576. protected _ambientTextureStrength: number;
  47577. /**
  47578. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47579. * 1 means it completely occludes it
  47580. * 0 mean it has no impact
  47581. */
  47582. protected _ambientTextureImpactOnAnalyticalLights: number;
  47583. /**
  47584. * Stores the alpha values in a texture.
  47585. */
  47586. protected _opacityTexture: Nullable<BaseTexture>;
  47587. /**
  47588. * Stores the reflection values in a texture.
  47589. */
  47590. protected _reflectionTexture: Nullable<BaseTexture>;
  47591. /**
  47592. * Stores the emissive values in a texture.
  47593. */
  47594. protected _emissiveTexture: Nullable<BaseTexture>;
  47595. /**
  47596. * AKA Specular texture in other nomenclature.
  47597. */
  47598. protected _reflectivityTexture: Nullable<BaseTexture>;
  47599. /**
  47600. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47601. */
  47602. protected _metallicTexture: Nullable<BaseTexture>;
  47603. /**
  47604. * Specifies the metallic scalar of the metallic/roughness workflow.
  47605. * Can also be used to scale the metalness values of the metallic texture.
  47606. */
  47607. protected _metallic: Nullable<number>;
  47608. /**
  47609. * Specifies the roughness scalar of the metallic/roughness workflow.
  47610. * Can also be used to scale the roughness values of the metallic texture.
  47611. */
  47612. protected _roughness: Nullable<number>;
  47613. /**
  47614. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47615. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47616. */
  47617. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47618. /**
  47619. * Stores surface normal data used to displace a mesh in a texture.
  47620. */
  47621. protected _bumpTexture: Nullable<BaseTexture>;
  47622. /**
  47623. * Stores the pre-calculated light information of a mesh in a texture.
  47624. */
  47625. protected _lightmapTexture: Nullable<BaseTexture>;
  47626. /**
  47627. * The color of a material in ambient lighting.
  47628. */
  47629. protected _ambientColor: Color3;
  47630. /**
  47631. * AKA Diffuse Color in other nomenclature.
  47632. */
  47633. protected _albedoColor: Color3;
  47634. /**
  47635. * AKA Specular Color in other nomenclature.
  47636. */
  47637. protected _reflectivityColor: Color3;
  47638. /**
  47639. * The color applied when light is reflected from a material.
  47640. */
  47641. protected _reflectionColor: Color3;
  47642. /**
  47643. * The color applied when light is emitted from a material.
  47644. */
  47645. protected _emissiveColor: Color3;
  47646. /**
  47647. * AKA Glossiness in other nomenclature.
  47648. */
  47649. protected _microSurface: number;
  47650. /**
  47651. * Specifies that the material will use the light map as a show map.
  47652. */
  47653. protected _useLightmapAsShadowmap: boolean;
  47654. /**
  47655. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47656. * makes the reflect vector face the model (under horizon).
  47657. */
  47658. protected _useHorizonOcclusion: boolean;
  47659. /**
  47660. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47661. * too much the area relying on ambient texture to define their ambient occlusion.
  47662. */
  47663. protected _useRadianceOcclusion: boolean;
  47664. /**
  47665. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47666. */
  47667. protected _useAlphaFromAlbedoTexture: boolean;
  47668. /**
  47669. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47670. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47671. */
  47672. protected _useSpecularOverAlpha: boolean;
  47673. /**
  47674. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47675. */
  47676. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47677. /**
  47678. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47679. */
  47680. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47681. /**
  47682. * Specifies if the metallic texture contains the roughness information in its green channel.
  47683. */
  47684. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47685. /**
  47686. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47687. */
  47688. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47689. /**
  47690. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47691. */
  47692. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47693. /**
  47694. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47695. */
  47696. protected _useAmbientInGrayScale: boolean;
  47697. /**
  47698. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47699. * The material will try to infer what glossiness each pixel should be.
  47700. */
  47701. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47702. /**
  47703. * Defines the falloff type used in this material.
  47704. * It by default is Physical.
  47705. */
  47706. protected _lightFalloff: number;
  47707. /**
  47708. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47709. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47710. */
  47711. protected _useRadianceOverAlpha: boolean;
  47712. /**
  47713. * Allows using an object space normal map (instead of tangent space).
  47714. */
  47715. protected _useObjectSpaceNormalMap: boolean;
  47716. /**
  47717. * Allows using the bump map in parallax mode.
  47718. */
  47719. protected _useParallax: boolean;
  47720. /**
  47721. * Allows using the bump map in parallax occlusion mode.
  47722. */
  47723. protected _useParallaxOcclusion: boolean;
  47724. /**
  47725. * Controls the scale bias of the parallax mode.
  47726. */
  47727. protected _parallaxScaleBias: number;
  47728. /**
  47729. * If sets to true, disables all the lights affecting the material.
  47730. */
  47731. protected _disableLighting: boolean;
  47732. /**
  47733. * Number of Simultaneous lights allowed on the material.
  47734. */
  47735. protected _maxSimultaneousLights: number;
  47736. /**
  47737. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47738. */
  47739. protected _invertNormalMapX: boolean;
  47740. /**
  47741. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47742. */
  47743. protected _invertNormalMapY: boolean;
  47744. /**
  47745. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47746. */
  47747. protected _twoSidedLighting: boolean;
  47748. /**
  47749. * Defines the alpha limits in alpha test mode.
  47750. */
  47751. protected _alphaCutOff: number;
  47752. /**
  47753. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47754. */
  47755. protected _forceAlphaTest: boolean;
  47756. /**
  47757. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47758. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47759. */
  47760. protected _useAlphaFresnel: boolean;
  47761. /**
  47762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47763. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47764. */
  47765. protected _useLinearAlphaFresnel: boolean;
  47766. /**
  47767. * The transparency mode of the material.
  47768. */
  47769. protected _transparencyMode: Nullable<number>;
  47770. /**
  47771. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47772. * from cos thetav and roughness:
  47773. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47774. */
  47775. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47776. /**
  47777. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47778. */
  47779. protected _forceIrradianceInFragment: boolean;
  47780. /**
  47781. * Force normal to face away from face.
  47782. */
  47783. protected _forceNormalForward: boolean;
  47784. /**
  47785. * Enables specular anti aliasing in the PBR shader.
  47786. * It will both interacts on the Geometry for analytical and IBL lighting.
  47787. * It also prefilter the roughness map based on the bump values.
  47788. */
  47789. protected _enableSpecularAntiAliasing: boolean;
  47790. /**
  47791. * Default configuration related to image processing available in the PBR Material.
  47792. */
  47793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47794. /**
  47795. * Keep track of the image processing observer to allow dispose and replace.
  47796. */
  47797. private _imageProcessingObserver;
  47798. /**
  47799. * Attaches a new image processing configuration to the PBR Material.
  47800. * @param configuration
  47801. */
  47802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47803. /**
  47804. * Stores the available render targets.
  47805. */
  47806. private _renderTargets;
  47807. /**
  47808. * Sets the global ambient color for the material used in lighting calculations.
  47809. */
  47810. private _globalAmbientColor;
  47811. /**
  47812. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47813. */
  47814. private _useLogarithmicDepth;
  47815. /**
  47816. * If set to true, no lighting calculations will be applied.
  47817. */
  47818. private _unlit;
  47819. private _debugMode;
  47820. /**
  47821. * @hidden
  47822. * This is reserved for the inspector.
  47823. * Defines the material debug mode.
  47824. * It helps seeing only some components of the material while troubleshooting.
  47825. */
  47826. debugMode: number;
  47827. /**
  47828. * @hidden
  47829. * This is reserved for the inspector.
  47830. * Specify from where on screen the debug mode should start.
  47831. * The value goes from -1 (full screen) to 1 (not visible)
  47832. * It helps with side by side comparison against the final render
  47833. * This defaults to -1
  47834. */
  47835. private debugLimit;
  47836. /**
  47837. * @hidden
  47838. * This is reserved for the inspector.
  47839. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47840. * You can use the factor to better multiply the final value.
  47841. */
  47842. private debugFactor;
  47843. /**
  47844. * Defines the clear coat layer parameters for the material.
  47845. */
  47846. readonly clearCoat: PBRClearCoatConfiguration;
  47847. /**
  47848. * Defines the anisotropic parameters for the material.
  47849. */
  47850. readonly anisotropy: PBRAnisotropicConfiguration;
  47851. /**
  47852. * Defines the BRDF parameters for the material.
  47853. */
  47854. readonly brdf: PBRBRDFConfiguration;
  47855. /**
  47856. * Defines the Sheen parameters for the material.
  47857. */
  47858. readonly sheen: PBRSheenConfiguration;
  47859. /**
  47860. * Defines the SubSurface parameters for the material.
  47861. */
  47862. readonly subSurface: PBRSubSurfaceConfiguration;
  47863. /**
  47864. * Custom callback helping to override the default shader used in the material.
  47865. */
  47866. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47867. protected _rebuildInParallel: boolean;
  47868. /**
  47869. * Instantiates a new PBRMaterial instance.
  47870. *
  47871. * @param name The material name
  47872. * @param scene The scene the material will be use in.
  47873. */
  47874. constructor(name: string, scene: Scene);
  47875. /**
  47876. * Gets a boolean indicating that current material needs to register RTT
  47877. */
  47878. readonly hasRenderTargetTextures: boolean;
  47879. /**
  47880. * Gets the name of the material class.
  47881. */
  47882. getClassName(): string;
  47883. /**
  47884. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47885. */
  47886. /**
  47887. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47888. */
  47889. useLogarithmicDepth: boolean;
  47890. /**
  47891. * Gets the current transparency mode.
  47892. */
  47893. /**
  47894. * Sets the transparency mode of the material.
  47895. *
  47896. * | Value | Type | Description |
  47897. * | ----- | ----------------------------------- | ----------- |
  47898. * | 0 | OPAQUE | |
  47899. * | 1 | ALPHATEST | |
  47900. * | 2 | ALPHABLEND | |
  47901. * | 3 | ALPHATESTANDBLEND | |
  47902. *
  47903. */
  47904. transparencyMode: Nullable<number>;
  47905. /**
  47906. * Returns true if alpha blending should be disabled.
  47907. */
  47908. private readonly _disableAlphaBlending;
  47909. /**
  47910. * Specifies whether or not this material should be rendered in alpha blend mode.
  47911. */
  47912. needAlphaBlending(): boolean;
  47913. /**
  47914. * Specifies if the mesh will require alpha blending.
  47915. * @param mesh - BJS mesh.
  47916. */
  47917. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47918. /**
  47919. * Specifies whether or not this material should be rendered in alpha test mode.
  47920. */
  47921. needAlphaTesting(): boolean;
  47922. /**
  47923. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47924. */
  47925. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47926. /**
  47927. * Gets the texture used for the alpha test.
  47928. */
  47929. getAlphaTestTexture(): Nullable<BaseTexture>;
  47930. /**
  47931. * Specifies that the submesh is ready to be used.
  47932. * @param mesh - BJS mesh.
  47933. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47934. * @param useInstances - Specifies that instances should be used.
  47935. * @returns - boolean indicating that the submesh is ready or not.
  47936. */
  47937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47938. /**
  47939. * Specifies if the material uses metallic roughness workflow.
  47940. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47941. */
  47942. isMetallicWorkflow(): boolean;
  47943. private _prepareEffect;
  47944. private _prepareDefines;
  47945. /**
  47946. * Force shader compilation
  47947. */
  47948. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47949. clipPlane: boolean;
  47950. }>): void;
  47951. /**
  47952. * Initializes the uniform buffer layout for the shader.
  47953. */
  47954. buildUniformLayout(): void;
  47955. /**
  47956. * Unbinds the material from the mesh
  47957. */
  47958. unbind(): void;
  47959. /**
  47960. * Binds the submesh data.
  47961. * @param world - The world matrix.
  47962. * @param mesh - The BJS mesh.
  47963. * @param subMesh - A submesh of the BJS mesh.
  47964. */
  47965. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47966. /**
  47967. * Returns the animatable textures.
  47968. * @returns - Array of animatable textures.
  47969. */
  47970. getAnimatables(): IAnimatable[];
  47971. /**
  47972. * Returns the texture used for reflections.
  47973. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47974. */
  47975. private _getReflectionTexture;
  47976. /**
  47977. * Returns an array of the actively used textures.
  47978. * @returns - Array of BaseTextures
  47979. */
  47980. getActiveTextures(): BaseTexture[];
  47981. /**
  47982. * Checks to see if a texture is used in the material.
  47983. * @param texture - Base texture to use.
  47984. * @returns - Boolean specifying if a texture is used in the material.
  47985. */
  47986. hasTexture(texture: BaseTexture): boolean;
  47987. /**
  47988. * Disposes the resources of the material.
  47989. * @param forceDisposeEffect - Forces the disposal of effects.
  47990. * @param forceDisposeTextures - Forces the disposal of all textures.
  47991. */
  47992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47993. }
  47994. }
  47995. declare module BABYLON {
  47996. /**
  47997. * The Physically based material of BJS.
  47998. *
  47999. * This offers the main features of a standard PBR material.
  48000. * For more information, please refer to the documentation :
  48001. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48002. */
  48003. export class PBRMaterial extends PBRBaseMaterial {
  48004. /**
  48005. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48006. */
  48007. static readonly PBRMATERIAL_OPAQUE: number;
  48008. /**
  48009. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48010. */
  48011. static readonly PBRMATERIAL_ALPHATEST: number;
  48012. /**
  48013. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48014. */
  48015. static readonly PBRMATERIAL_ALPHABLEND: number;
  48016. /**
  48017. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48018. * They are also discarded below the alpha cutoff threshold to improve performances.
  48019. */
  48020. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48021. /**
  48022. * Defines the default value of how much AO map is occluding the analytical lights
  48023. * (point spot...).
  48024. */
  48025. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48026. /**
  48027. * Intensity of the direct lights e.g. the four lights available in your scene.
  48028. * This impacts both the direct diffuse and specular highlights.
  48029. */
  48030. directIntensity: number;
  48031. /**
  48032. * Intensity of the emissive part of the material.
  48033. * This helps controlling the emissive effect without modifying the emissive color.
  48034. */
  48035. emissiveIntensity: number;
  48036. /**
  48037. * Intensity of the environment e.g. how much the environment will light the object
  48038. * either through harmonics for rough material or through the refelction for shiny ones.
  48039. */
  48040. environmentIntensity: number;
  48041. /**
  48042. * This is a special control allowing the reduction of the specular highlights coming from the
  48043. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48044. */
  48045. specularIntensity: number;
  48046. /**
  48047. * Debug Control allowing disabling the bump map on this material.
  48048. */
  48049. disableBumpMap: boolean;
  48050. /**
  48051. * AKA Diffuse Texture in standard nomenclature.
  48052. */
  48053. albedoTexture: BaseTexture;
  48054. /**
  48055. * AKA Occlusion Texture in other nomenclature.
  48056. */
  48057. ambientTexture: BaseTexture;
  48058. /**
  48059. * AKA Occlusion Texture Intensity in other nomenclature.
  48060. */
  48061. ambientTextureStrength: number;
  48062. /**
  48063. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48064. * 1 means it completely occludes it
  48065. * 0 mean it has no impact
  48066. */
  48067. ambientTextureImpactOnAnalyticalLights: number;
  48068. /**
  48069. * Stores the alpha values in a texture.
  48070. */
  48071. opacityTexture: BaseTexture;
  48072. /**
  48073. * Stores the reflection values in a texture.
  48074. */
  48075. reflectionTexture: Nullable<BaseTexture>;
  48076. /**
  48077. * Stores the emissive values in a texture.
  48078. */
  48079. emissiveTexture: BaseTexture;
  48080. /**
  48081. * AKA Specular texture in other nomenclature.
  48082. */
  48083. reflectivityTexture: BaseTexture;
  48084. /**
  48085. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48086. */
  48087. metallicTexture: BaseTexture;
  48088. /**
  48089. * Specifies the metallic scalar of the metallic/roughness workflow.
  48090. * Can also be used to scale the metalness values of the metallic texture.
  48091. */
  48092. metallic: Nullable<number>;
  48093. /**
  48094. * Specifies the roughness scalar of the metallic/roughness workflow.
  48095. * Can also be used to scale the roughness values of the metallic texture.
  48096. */
  48097. roughness: Nullable<number>;
  48098. /**
  48099. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48100. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48101. */
  48102. microSurfaceTexture: BaseTexture;
  48103. /**
  48104. * Stores surface normal data used to displace a mesh in a texture.
  48105. */
  48106. bumpTexture: BaseTexture;
  48107. /**
  48108. * Stores the pre-calculated light information of a mesh in a texture.
  48109. */
  48110. lightmapTexture: BaseTexture;
  48111. /**
  48112. * Stores the refracted light information in a texture.
  48113. */
  48114. refractionTexture: Nullable<BaseTexture>;
  48115. /**
  48116. * The color of a material in ambient lighting.
  48117. */
  48118. ambientColor: Color3;
  48119. /**
  48120. * AKA Diffuse Color in other nomenclature.
  48121. */
  48122. albedoColor: Color3;
  48123. /**
  48124. * AKA Specular Color in other nomenclature.
  48125. */
  48126. reflectivityColor: Color3;
  48127. /**
  48128. * The color reflected from the material.
  48129. */
  48130. reflectionColor: Color3;
  48131. /**
  48132. * The color emitted from the material.
  48133. */
  48134. emissiveColor: Color3;
  48135. /**
  48136. * AKA Glossiness in other nomenclature.
  48137. */
  48138. microSurface: number;
  48139. /**
  48140. * source material index of refraction (IOR)' / 'destination material IOR.
  48141. */
  48142. indexOfRefraction: number;
  48143. /**
  48144. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48145. */
  48146. invertRefractionY: boolean;
  48147. /**
  48148. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48149. * Materials half opaque for instance using refraction could benefit from this control.
  48150. */
  48151. linkRefractionWithTransparency: boolean;
  48152. /**
  48153. * If true, the light map contains occlusion information instead of lighting info.
  48154. */
  48155. useLightmapAsShadowmap: boolean;
  48156. /**
  48157. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48158. */
  48159. useAlphaFromAlbedoTexture: boolean;
  48160. /**
  48161. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48162. */
  48163. forceAlphaTest: boolean;
  48164. /**
  48165. * Defines the alpha limits in alpha test mode.
  48166. */
  48167. alphaCutOff: number;
  48168. /**
  48169. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48170. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48171. */
  48172. useSpecularOverAlpha: boolean;
  48173. /**
  48174. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48175. */
  48176. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48177. /**
  48178. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48179. */
  48180. useRoughnessFromMetallicTextureAlpha: boolean;
  48181. /**
  48182. * Specifies if the metallic texture contains the roughness information in its green channel.
  48183. */
  48184. useRoughnessFromMetallicTextureGreen: boolean;
  48185. /**
  48186. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48187. */
  48188. useMetallnessFromMetallicTextureBlue: boolean;
  48189. /**
  48190. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48191. */
  48192. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48193. /**
  48194. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48195. */
  48196. useAmbientInGrayScale: boolean;
  48197. /**
  48198. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48199. * The material will try to infer what glossiness each pixel should be.
  48200. */
  48201. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48202. /**
  48203. * BJS is using an harcoded light falloff based on a manually sets up range.
  48204. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48205. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48206. */
  48207. /**
  48208. * BJS is using an harcoded light falloff based on a manually sets up range.
  48209. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48210. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48211. */
  48212. usePhysicalLightFalloff: boolean;
  48213. /**
  48214. * In order to support the falloff compatibility with gltf, a special mode has been added
  48215. * to reproduce the gltf light falloff.
  48216. */
  48217. /**
  48218. * In order to support the falloff compatibility with gltf, a special mode has been added
  48219. * to reproduce the gltf light falloff.
  48220. */
  48221. useGLTFLightFalloff: boolean;
  48222. /**
  48223. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48224. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48225. */
  48226. useRadianceOverAlpha: boolean;
  48227. /**
  48228. * Allows using an object space normal map (instead of tangent space).
  48229. */
  48230. useObjectSpaceNormalMap: boolean;
  48231. /**
  48232. * Allows using the bump map in parallax mode.
  48233. */
  48234. useParallax: boolean;
  48235. /**
  48236. * Allows using the bump map in parallax occlusion mode.
  48237. */
  48238. useParallaxOcclusion: boolean;
  48239. /**
  48240. * Controls the scale bias of the parallax mode.
  48241. */
  48242. parallaxScaleBias: number;
  48243. /**
  48244. * If sets to true, disables all the lights affecting the material.
  48245. */
  48246. disableLighting: boolean;
  48247. /**
  48248. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48249. */
  48250. forceIrradianceInFragment: boolean;
  48251. /**
  48252. * Number of Simultaneous lights allowed on the material.
  48253. */
  48254. maxSimultaneousLights: number;
  48255. /**
  48256. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48257. */
  48258. invertNormalMapX: boolean;
  48259. /**
  48260. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48261. */
  48262. invertNormalMapY: boolean;
  48263. /**
  48264. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48265. */
  48266. twoSidedLighting: boolean;
  48267. /**
  48268. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48269. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48270. */
  48271. useAlphaFresnel: boolean;
  48272. /**
  48273. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48274. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48275. */
  48276. useLinearAlphaFresnel: boolean;
  48277. /**
  48278. * Let user defines the brdf lookup texture used for IBL.
  48279. * A default 8bit version is embedded but you could point at :
  48280. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48281. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48282. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48283. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48284. */
  48285. environmentBRDFTexture: Nullable<BaseTexture>;
  48286. /**
  48287. * Force normal to face away from face.
  48288. */
  48289. forceNormalForward: boolean;
  48290. /**
  48291. * Enables specular anti aliasing in the PBR shader.
  48292. * It will both interacts on the Geometry for analytical and IBL lighting.
  48293. * It also prefilter the roughness map based on the bump values.
  48294. */
  48295. enableSpecularAntiAliasing: boolean;
  48296. /**
  48297. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48298. * makes the reflect vector face the model (under horizon).
  48299. */
  48300. useHorizonOcclusion: boolean;
  48301. /**
  48302. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48303. * too much the area relying on ambient texture to define their ambient occlusion.
  48304. */
  48305. useRadianceOcclusion: boolean;
  48306. /**
  48307. * If set to true, no lighting calculations will be applied.
  48308. */
  48309. unlit: boolean;
  48310. /**
  48311. * Gets the image processing configuration used either in this material.
  48312. */
  48313. /**
  48314. * Sets the Default image processing configuration used either in the this material.
  48315. *
  48316. * If sets to null, the scene one is in use.
  48317. */
  48318. imageProcessingConfiguration: ImageProcessingConfiguration;
  48319. /**
  48320. * Gets wether the color curves effect is enabled.
  48321. */
  48322. /**
  48323. * Sets wether the color curves effect is enabled.
  48324. */
  48325. cameraColorCurvesEnabled: boolean;
  48326. /**
  48327. * Gets wether the color grading effect is enabled.
  48328. */
  48329. /**
  48330. * Gets wether the color grading effect is enabled.
  48331. */
  48332. cameraColorGradingEnabled: boolean;
  48333. /**
  48334. * Gets wether tonemapping is enabled or not.
  48335. */
  48336. /**
  48337. * Sets wether tonemapping is enabled or not
  48338. */
  48339. cameraToneMappingEnabled: boolean;
  48340. /**
  48341. * The camera exposure used on this material.
  48342. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48343. * This corresponds to a photographic exposure.
  48344. */
  48345. /**
  48346. * The camera exposure used on this material.
  48347. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48348. * This corresponds to a photographic exposure.
  48349. */
  48350. cameraExposure: number;
  48351. /**
  48352. * Gets The camera contrast used on this material.
  48353. */
  48354. /**
  48355. * Sets The camera contrast used on this material.
  48356. */
  48357. cameraContrast: number;
  48358. /**
  48359. * Gets the Color Grading 2D Lookup Texture.
  48360. */
  48361. /**
  48362. * Sets the Color Grading 2D Lookup Texture.
  48363. */
  48364. cameraColorGradingTexture: Nullable<BaseTexture>;
  48365. /**
  48366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48368. * 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;
  48369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48370. */
  48371. /**
  48372. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48373. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48374. * 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;
  48375. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48376. */
  48377. cameraColorCurves: Nullable<ColorCurves>;
  48378. /**
  48379. * Instantiates a new PBRMaterial instance.
  48380. *
  48381. * @param name The material name
  48382. * @param scene The scene the material will be use in.
  48383. */
  48384. constructor(name: string, scene: Scene);
  48385. /**
  48386. * Returns the name of this material class.
  48387. */
  48388. getClassName(): string;
  48389. /**
  48390. * Makes a duplicate of the current material.
  48391. * @param name - name to use for the new material.
  48392. */
  48393. clone(name: string): PBRMaterial;
  48394. /**
  48395. * Serializes this PBR Material.
  48396. * @returns - An object with the serialized material.
  48397. */
  48398. serialize(): any;
  48399. /**
  48400. * Parses a PBR Material from a serialized object.
  48401. * @param source - Serialized object.
  48402. * @param scene - BJS scene instance.
  48403. * @param rootUrl - url for the scene object
  48404. * @returns - PBRMaterial
  48405. */
  48406. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * Direct draw surface info
  48412. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48413. */
  48414. export interface DDSInfo {
  48415. /**
  48416. * Width of the texture
  48417. */
  48418. width: number;
  48419. /**
  48420. * Width of the texture
  48421. */
  48422. height: number;
  48423. /**
  48424. * Number of Mipmaps for the texture
  48425. * @see https://en.wikipedia.org/wiki/Mipmap
  48426. */
  48427. mipmapCount: number;
  48428. /**
  48429. * If the textures format is a known fourCC format
  48430. * @see https://www.fourcc.org/
  48431. */
  48432. isFourCC: boolean;
  48433. /**
  48434. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48435. */
  48436. isRGB: boolean;
  48437. /**
  48438. * If the texture is a lumincance format
  48439. */
  48440. isLuminance: boolean;
  48441. /**
  48442. * If this is a cube texture
  48443. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48444. */
  48445. isCube: boolean;
  48446. /**
  48447. * If the texture is a compressed format eg. FOURCC_DXT1
  48448. */
  48449. isCompressed: boolean;
  48450. /**
  48451. * The dxgiFormat of the texture
  48452. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48453. */
  48454. dxgiFormat: number;
  48455. /**
  48456. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48457. */
  48458. textureType: number;
  48459. /**
  48460. * Sphericle polynomial created for the dds texture
  48461. */
  48462. sphericalPolynomial?: SphericalPolynomial;
  48463. }
  48464. /**
  48465. * Class used to provide DDS decompression tools
  48466. */
  48467. export class DDSTools {
  48468. /**
  48469. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48470. */
  48471. static StoreLODInAlphaChannel: boolean;
  48472. /**
  48473. * Gets DDS information from an array buffer
  48474. * @param arrayBuffer defines the array buffer to read data from
  48475. * @returns the DDS information
  48476. */
  48477. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48478. private static _FloatView;
  48479. private static _Int32View;
  48480. private static _ToHalfFloat;
  48481. private static _FromHalfFloat;
  48482. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48483. private static _GetHalfFloatRGBAArrayBuffer;
  48484. private static _GetFloatRGBAArrayBuffer;
  48485. private static _GetFloatAsUIntRGBAArrayBuffer;
  48486. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48487. private static _GetRGBAArrayBuffer;
  48488. private static _ExtractLongWordOrder;
  48489. private static _GetRGBArrayBuffer;
  48490. private static _GetLuminanceArrayBuffer;
  48491. /**
  48492. * Uploads DDS Levels to a Babylon Texture
  48493. * @hidden
  48494. */
  48495. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48496. }
  48497. interface ThinEngine {
  48498. /**
  48499. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48500. * @param rootUrl defines the url where the file to load is located
  48501. * @param scene defines the current scene
  48502. * @param lodScale defines scale to apply to the mip map selection
  48503. * @param lodOffset defines offset to apply to the mip map selection
  48504. * @param onLoad defines an optional callback raised when the texture is loaded
  48505. * @param onError defines an optional callback raised if there is an issue to load the texture
  48506. * @param format defines the format of the data
  48507. * @param forcedExtension defines the extension to use to pick the right loader
  48508. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48509. * @returns the cube texture as an InternalTexture
  48510. */
  48511. 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;
  48512. }
  48513. }
  48514. declare module BABYLON {
  48515. /**
  48516. * Implementation of the DDS Texture Loader.
  48517. * @hidden
  48518. */
  48519. export class _DDSTextureLoader implements IInternalTextureLoader {
  48520. /**
  48521. * Defines wether the loader supports cascade loading the different faces.
  48522. */
  48523. readonly supportCascades: boolean;
  48524. /**
  48525. * This returns if the loader support the current file information.
  48526. * @param extension defines the file extension of the file being loaded
  48527. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48528. * @param fallback defines the fallback internal texture if any
  48529. * @param isBase64 defines whether the texture is encoded as a base64
  48530. * @param isBuffer defines whether the texture data are stored as a buffer
  48531. * @returns true if the loader can load the specified file
  48532. */
  48533. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48534. /**
  48535. * Transform the url before loading if required.
  48536. * @param rootUrl the url of the texture
  48537. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48538. * @returns the transformed texture
  48539. */
  48540. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48541. /**
  48542. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48543. * @param rootUrl the url of the texture
  48544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48545. * @returns the fallback texture
  48546. */
  48547. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48548. /**
  48549. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48550. * @param data contains the texture data
  48551. * @param texture defines the BabylonJS internal texture
  48552. * @param createPolynomials will be true if polynomials have been requested
  48553. * @param onLoad defines the callback to trigger once the texture is ready
  48554. * @param onError defines the callback to trigger in case of error
  48555. */
  48556. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48557. /**
  48558. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48559. * @param data contains the texture data
  48560. * @param texture defines the BabylonJS internal texture
  48561. * @param callback defines the method to call once ready to upload
  48562. */
  48563. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48564. }
  48565. }
  48566. declare module BABYLON {
  48567. /**
  48568. * Implementation of the ENV Texture Loader.
  48569. * @hidden
  48570. */
  48571. export class _ENVTextureLoader implements IInternalTextureLoader {
  48572. /**
  48573. * Defines wether the loader supports cascade loading the different faces.
  48574. */
  48575. readonly supportCascades: boolean;
  48576. /**
  48577. * This returns if the loader support the current file information.
  48578. * @param extension defines the file extension of the file being loaded
  48579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48580. * @param fallback defines the fallback internal texture if any
  48581. * @param isBase64 defines whether the texture is encoded as a base64
  48582. * @param isBuffer defines whether the texture data are stored as a buffer
  48583. * @returns true if the loader can load the specified file
  48584. */
  48585. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48586. /**
  48587. * Transform the url before loading if required.
  48588. * @param rootUrl the url of the texture
  48589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48590. * @returns the transformed texture
  48591. */
  48592. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48593. /**
  48594. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48595. * @param rootUrl the url of the texture
  48596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48597. * @returns the fallback texture
  48598. */
  48599. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48600. /**
  48601. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48602. * @param data contains the texture data
  48603. * @param texture defines the BabylonJS internal texture
  48604. * @param createPolynomials will be true if polynomials have been requested
  48605. * @param onLoad defines the callback to trigger once the texture is ready
  48606. * @param onError defines the callback to trigger in case of error
  48607. */
  48608. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48609. /**
  48610. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48611. * @param data contains the texture data
  48612. * @param texture defines the BabylonJS internal texture
  48613. * @param callback defines the method to call once ready to upload
  48614. */
  48615. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. /**
  48620. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48621. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48622. */
  48623. export class KhronosTextureContainer {
  48624. /** contents of the KTX container file */
  48625. arrayBuffer: any;
  48626. private static HEADER_LEN;
  48627. private static COMPRESSED_2D;
  48628. private static COMPRESSED_3D;
  48629. private static TEX_2D;
  48630. private static TEX_3D;
  48631. /**
  48632. * Gets the openGL type
  48633. */
  48634. glType: number;
  48635. /**
  48636. * Gets the openGL type size
  48637. */
  48638. glTypeSize: number;
  48639. /**
  48640. * Gets the openGL format
  48641. */
  48642. glFormat: number;
  48643. /**
  48644. * Gets the openGL internal format
  48645. */
  48646. glInternalFormat: number;
  48647. /**
  48648. * Gets the base internal format
  48649. */
  48650. glBaseInternalFormat: number;
  48651. /**
  48652. * Gets image width in pixel
  48653. */
  48654. pixelWidth: number;
  48655. /**
  48656. * Gets image height in pixel
  48657. */
  48658. pixelHeight: number;
  48659. /**
  48660. * Gets image depth in pixels
  48661. */
  48662. pixelDepth: number;
  48663. /**
  48664. * Gets the number of array elements
  48665. */
  48666. numberOfArrayElements: number;
  48667. /**
  48668. * Gets the number of faces
  48669. */
  48670. numberOfFaces: number;
  48671. /**
  48672. * Gets the number of mipmap levels
  48673. */
  48674. numberOfMipmapLevels: number;
  48675. /**
  48676. * Gets the bytes of key value data
  48677. */
  48678. bytesOfKeyValueData: number;
  48679. /**
  48680. * Gets the load type
  48681. */
  48682. loadType: number;
  48683. /**
  48684. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48685. */
  48686. isInvalid: boolean;
  48687. /**
  48688. * Creates a new KhronosTextureContainer
  48689. * @param arrayBuffer contents of the KTX container file
  48690. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48691. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48692. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48693. */
  48694. constructor(
  48695. /** contents of the KTX container file */
  48696. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48697. /**
  48698. * Uploads KTX content to a Babylon Texture.
  48699. * It is assumed that the texture has already been created & is currently bound
  48700. * @hidden
  48701. */
  48702. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48703. private _upload2DCompressedLevels;
  48704. }
  48705. }
  48706. declare module BABYLON {
  48707. /**
  48708. * Implementation of the KTX Texture Loader.
  48709. * @hidden
  48710. */
  48711. export class _KTXTextureLoader implements IInternalTextureLoader {
  48712. /**
  48713. * Defines wether the loader supports cascade loading the different faces.
  48714. */
  48715. readonly supportCascades: boolean;
  48716. /**
  48717. * This returns if the loader support the current file information.
  48718. * @param extension defines the file extension of the file being loaded
  48719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48720. * @param fallback defines the fallback internal texture if any
  48721. * @param isBase64 defines whether the texture is encoded as a base64
  48722. * @param isBuffer defines whether the texture data are stored as a buffer
  48723. * @returns true if the loader can load the specified file
  48724. */
  48725. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48726. /**
  48727. * Transform the url before loading if required.
  48728. * @param rootUrl the url of the texture
  48729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48730. * @returns the transformed texture
  48731. */
  48732. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48733. /**
  48734. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48735. * @param rootUrl the url of the texture
  48736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48737. * @returns the fallback texture
  48738. */
  48739. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48740. /**
  48741. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48742. * @param data contains the texture data
  48743. * @param texture defines the BabylonJS internal texture
  48744. * @param createPolynomials will be true if polynomials have been requested
  48745. * @param onLoad defines the callback to trigger once the texture is ready
  48746. * @param onError defines the callback to trigger in case of error
  48747. */
  48748. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48749. /**
  48750. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48751. * @param data contains the texture data
  48752. * @param texture defines the BabylonJS internal texture
  48753. * @param callback defines the method to call once ready to upload
  48754. */
  48755. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. /**
  48760. * Options for the default xr helper
  48761. */
  48762. export class WebXRDefaultExperienceOptions {
  48763. /**
  48764. * Floor meshes that should be used for teleporting
  48765. */
  48766. floorMeshes: Array<AbstractMesh>;
  48767. }
  48768. /**
  48769. * Default experience which provides a similar setup to the previous webVRExperience
  48770. */
  48771. export class WebXRDefaultExperience {
  48772. /**
  48773. * Base experience
  48774. */
  48775. baseExperience: WebXRExperienceHelper;
  48776. /**
  48777. * Input experience extension
  48778. */
  48779. input: WebXRInput;
  48780. /**
  48781. * Loads the controller models
  48782. */
  48783. controllerModelLoader: WebXRControllerModelLoader;
  48784. /**
  48785. * Enables laser pointer and selection
  48786. */
  48787. pointerSelection: WebXRControllerPointerSelection;
  48788. /**
  48789. * Enables teleportation
  48790. */
  48791. teleportation: WebXRControllerTeleportation;
  48792. /**
  48793. * Enables ui for enetering/exiting xr
  48794. */
  48795. enterExitUI: WebXREnterExitUI;
  48796. /**
  48797. * Default output canvas xr should render to
  48798. */
  48799. outputCanvas: WebXRManagedOutputCanvas;
  48800. /**
  48801. * Creates the default xr experience
  48802. * @param scene scene
  48803. * @param options options for basic configuration
  48804. * @returns resulting WebXRDefaultExperience
  48805. */
  48806. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48807. private constructor();
  48808. /**
  48809. * DIsposes of the experience helper
  48810. */
  48811. dispose(): void;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /** @hidden */
  48816. export var _forceSceneHelpersToBundle: boolean;
  48817. interface Scene {
  48818. /**
  48819. * Creates a default light for the scene.
  48820. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48821. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48822. */
  48823. createDefaultLight(replace?: boolean): void;
  48824. /**
  48825. * Creates a default camera for the scene.
  48826. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48827. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48828. * @param replace has default false, when true replaces the active camera in the scene
  48829. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48830. */
  48831. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48832. /**
  48833. * Creates a default camera and a default light.
  48834. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48835. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48836. * @param replace has the default false, when true replaces the active camera/light in the scene
  48837. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48838. */
  48839. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48840. /**
  48841. * Creates a new sky box
  48842. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48843. * @param environmentTexture defines the texture to use as environment texture
  48844. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48845. * @param scale defines the overall scale of the skybox
  48846. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48847. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48848. * @returns a new mesh holding the sky box
  48849. */
  48850. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48851. /**
  48852. * Creates a new environment
  48853. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48854. * @param options defines the options you can use to configure the environment
  48855. * @returns the new EnvironmentHelper
  48856. */
  48857. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48858. /**
  48859. * Creates a new VREXperienceHelper
  48860. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48861. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48862. * @returns a new VREXperienceHelper
  48863. */
  48864. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48865. /**
  48866. * Creates a new WebXRDefaultExperience
  48867. * @see http://doc.babylonjs.com/how_to/webxr
  48868. * @param options experience options
  48869. * @returns a promise for a new WebXRDefaultExperience
  48870. */
  48871. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48872. }
  48873. }
  48874. declare module BABYLON {
  48875. /**
  48876. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48877. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48878. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48879. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48880. */
  48881. export class VideoDome extends TransformNode {
  48882. /**
  48883. * Define the video source as a Monoscopic panoramic 360 video.
  48884. */
  48885. static readonly MODE_MONOSCOPIC: number;
  48886. /**
  48887. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48888. */
  48889. static readonly MODE_TOPBOTTOM: number;
  48890. /**
  48891. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48892. */
  48893. static readonly MODE_SIDEBYSIDE: number;
  48894. private _halfDome;
  48895. private _useDirectMapping;
  48896. /**
  48897. * The video texture being displayed on the sphere
  48898. */
  48899. protected _videoTexture: VideoTexture;
  48900. /**
  48901. * Gets the video texture being displayed on the sphere
  48902. */
  48903. readonly videoTexture: VideoTexture;
  48904. /**
  48905. * The skybox material
  48906. */
  48907. protected _material: BackgroundMaterial;
  48908. /**
  48909. * The surface used for the skybox
  48910. */
  48911. protected _mesh: Mesh;
  48912. /**
  48913. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48914. */
  48915. private _halfDomeMask;
  48916. /**
  48917. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48918. * Also see the options.resolution property.
  48919. */
  48920. fovMultiplier: number;
  48921. private _videoMode;
  48922. /**
  48923. * Gets or set the current video mode for the video. It can be:
  48924. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48925. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48926. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48927. */
  48928. videoMode: number;
  48929. /**
  48930. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48931. *
  48932. */
  48933. /**
  48934. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48935. */
  48936. halfDome: boolean;
  48937. /**
  48938. * Oberserver used in Stereoscopic VR Mode.
  48939. */
  48940. private _onBeforeCameraRenderObserver;
  48941. /**
  48942. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48943. * @param name Element's name, child elements will append suffixes for their own names.
  48944. * @param urlsOrVideo defines the url(s) or the video element to use
  48945. * @param options An object containing optional or exposed sub element properties
  48946. */
  48947. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48948. resolution?: number;
  48949. clickToPlay?: boolean;
  48950. autoPlay?: boolean;
  48951. loop?: boolean;
  48952. size?: number;
  48953. poster?: string;
  48954. faceForward?: boolean;
  48955. useDirectMapping?: boolean;
  48956. halfDomeMode?: boolean;
  48957. }, scene: Scene);
  48958. private _changeVideoMode;
  48959. /**
  48960. * Releases resources associated with this node.
  48961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48963. */
  48964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48965. }
  48966. }
  48967. declare module BABYLON {
  48968. /**
  48969. * This class can be used to get instrumentation data from a Babylon engine
  48970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48971. */
  48972. export class EngineInstrumentation implements IDisposable {
  48973. /**
  48974. * Define the instrumented engine.
  48975. */
  48976. engine: Engine;
  48977. private _captureGPUFrameTime;
  48978. private _gpuFrameTimeToken;
  48979. private _gpuFrameTime;
  48980. private _captureShaderCompilationTime;
  48981. private _shaderCompilationTime;
  48982. private _onBeginFrameObserver;
  48983. private _onEndFrameObserver;
  48984. private _onBeforeShaderCompilationObserver;
  48985. private _onAfterShaderCompilationObserver;
  48986. /**
  48987. * Gets the perf counter used for GPU frame time
  48988. */
  48989. readonly gpuFrameTimeCounter: PerfCounter;
  48990. /**
  48991. * Gets the GPU frame time capture status
  48992. */
  48993. /**
  48994. * Enable or disable the GPU frame time capture
  48995. */
  48996. captureGPUFrameTime: boolean;
  48997. /**
  48998. * Gets the perf counter used for shader compilation time
  48999. */
  49000. readonly shaderCompilationTimeCounter: PerfCounter;
  49001. /**
  49002. * Gets the shader compilation time capture status
  49003. */
  49004. /**
  49005. * Enable or disable the shader compilation time capture
  49006. */
  49007. captureShaderCompilationTime: boolean;
  49008. /**
  49009. * Instantiates a new engine instrumentation.
  49010. * This class can be used to get instrumentation data from a Babylon engine
  49011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49012. * @param engine Defines the engine to instrument
  49013. */
  49014. constructor(
  49015. /**
  49016. * Define the instrumented engine.
  49017. */
  49018. engine: Engine);
  49019. /**
  49020. * Dispose and release associated resources.
  49021. */
  49022. dispose(): void;
  49023. }
  49024. }
  49025. declare module BABYLON {
  49026. /**
  49027. * This class can be used to get instrumentation data from a Babylon engine
  49028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49029. */
  49030. export class SceneInstrumentation implements IDisposable {
  49031. /**
  49032. * Defines the scene to instrument
  49033. */
  49034. scene: Scene;
  49035. private _captureActiveMeshesEvaluationTime;
  49036. private _activeMeshesEvaluationTime;
  49037. private _captureRenderTargetsRenderTime;
  49038. private _renderTargetsRenderTime;
  49039. private _captureFrameTime;
  49040. private _frameTime;
  49041. private _captureRenderTime;
  49042. private _renderTime;
  49043. private _captureInterFrameTime;
  49044. private _interFrameTime;
  49045. private _captureParticlesRenderTime;
  49046. private _particlesRenderTime;
  49047. private _captureSpritesRenderTime;
  49048. private _spritesRenderTime;
  49049. private _capturePhysicsTime;
  49050. private _physicsTime;
  49051. private _captureAnimationsTime;
  49052. private _animationsTime;
  49053. private _captureCameraRenderTime;
  49054. private _cameraRenderTime;
  49055. private _onBeforeActiveMeshesEvaluationObserver;
  49056. private _onAfterActiveMeshesEvaluationObserver;
  49057. private _onBeforeRenderTargetsRenderObserver;
  49058. private _onAfterRenderTargetsRenderObserver;
  49059. private _onAfterRenderObserver;
  49060. private _onBeforeDrawPhaseObserver;
  49061. private _onAfterDrawPhaseObserver;
  49062. private _onBeforeAnimationsObserver;
  49063. private _onBeforeParticlesRenderingObserver;
  49064. private _onAfterParticlesRenderingObserver;
  49065. private _onBeforeSpritesRenderingObserver;
  49066. private _onAfterSpritesRenderingObserver;
  49067. private _onBeforePhysicsObserver;
  49068. private _onAfterPhysicsObserver;
  49069. private _onAfterAnimationsObserver;
  49070. private _onBeforeCameraRenderObserver;
  49071. private _onAfterCameraRenderObserver;
  49072. /**
  49073. * Gets the perf counter used for active meshes evaluation time
  49074. */
  49075. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49076. /**
  49077. * Gets the active meshes evaluation time capture status
  49078. */
  49079. /**
  49080. * Enable or disable the active meshes evaluation time capture
  49081. */
  49082. captureActiveMeshesEvaluationTime: boolean;
  49083. /**
  49084. * Gets the perf counter used for render targets render time
  49085. */
  49086. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49087. /**
  49088. * Gets the render targets render time capture status
  49089. */
  49090. /**
  49091. * Enable or disable the render targets render time capture
  49092. */
  49093. captureRenderTargetsRenderTime: boolean;
  49094. /**
  49095. * Gets the perf counter used for particles render time
  49096. */
  49097. readonly particlesRenderTimeCounter: PerfCounter;
  49098. /**
  49099. * Gets the particles render time capture status
  49100. */
  49101. /**
  49102. * Enable or disable the particles render time capture
  49103. */
  49104. captureParticlesRenderTime: boolean;
  49105. /**
  49106. * Gets the perf counter used for sprites render time
  49107. */
  49108. readonly spritesRenderTimeCounter: PerfCounter;
  49109. /**
  49110. * Gets the sprites render time capture status
  49111. */
  49112. /**
  49113. * Enable or disable the sprites render time capture
  49114. */
  49115. captureSpritesRenderTime: boolean;
  49116. /**
  49117. * Gets the perf counter used for physics time
  49118. */
  49119. readonly physicsTimeCounter: PerfCounter;
  49120. /**
  49121. * Gets the physics time capture status
  49122. */
  49123. /**
  49124. * Enable or disable the physics time capture
  49125. */
  49126. capturePhysicsTime: boolean;
  49127. /**
  49128. * Gets the perf counter used for animations time
  49129. */
  49130. readonly animationsTimeCounter: PerfCounter;
  49131. /**
  49132. * Gets the animations time capture status
  49133. */
  49134. /**
  49135. * Enable or disable the animations time capture
  49136. */
  49137. captureAnimationsTime: boolean;
  49138. /**
  49139. * Gets the perf counter used for frame time capture
  49140. */
  49141. readonly frameTimeCounter: PerfCounter;
  49142. /**
  49143. * Gets the frame time capture status
  49144. */
  49145. /**
  49146. * Enable or disable the frame time capture
  49147. */
  49148. captureFrameTime: boolean;
  49149. /**
  49150. * Gets the perf counter used for inter-frames time capture
  49151. */
  49152. readonly interFrameTimeCounter: PerfCounter;
  49153. /**
  49154. * Gets the inter-frames time capture status
  49155. */
  49156. /**
  49157. * Enable or disable the inter-frames time capture
  49158. */
  49159. captureInterFrameTime: boolean;
  49160. /**
  49161. * Gets the perf counter used for render time capture
  49162. */
  49163. readonly renderTimeCounter: PerfCounter;
  49164. /**
  49165. * Gets the render time capture status
  49166. */
  49167. /**
  49168. * Enable or disable the render time capture
  49169. */
  49170. captureRenderTime: boolean;
  49171. /**
  49172. * Gets the perf counter used for camera render time capture
  49173. */
  49174. readonly cameraRenderTimeCounter: PerfCounter;
  49175. /**
  49176. * Gets the camera render time capture status
  49177. */
  49178. /**
  49179. * Enable or disable the camera render time capture
  49180. */
  49181. captureCameraRenderTime: boolean;
  49182. /**
  49183. * Gets the perf counter used for draw calls
  49184. */
  49185. readonly drawCallsCounter: PerfCounter;
  49186. /**
  49187. * Instantiates a new scene instrumentation.
  49188. * This class can be used to get instrumentation data from a Babylon engine
  49189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49190. * @param scene Defines the scene to instrument
  49191. */
  49192. constructor(
  49193. /**
  49194. * Defines the scene to instrument
  49195. */
  49196. scene: Scene);
  49197. /**
  49198. * Dispose and release associated resources.
  49199. */
  49200. dispose(): void;
  49201. }
  49202. }
  49203. declare module BABYLON {
  49204. /** @hidden */
  49205. export var glowMapGenerationPixelShader: {
  49206. name: string;
  49207. shader: string;
  49208. };
  49209. }
  49210. declare module BABYLON {
  49211. /** @hidden */
  49212. export var glowMapGenerationVertexShader: {
  49213. name: string;
  49214. shader: string;
  49215. };
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Effect layer options. This helps customizing the behaviour
  49220. * of the effect layer.
  49221. */
  49222. export interface IEffectLayerOptions {
  49223. /**
  49224. * Multiplication factor apply to the canvas size to compute the render target size
  49225. * used to generated the objects (the smaller the faster).
  49226. */
  49227. mainTextureRatio: number;
  49228. /**
  49229. * Enforces a fixed size texture to ensure effect stability across devices.
  49230. */
  49231. mainTextureFixedSize?: number;
  49232. /**
  49233. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49234. */
  49235. alphaBlendingMode: number;
  49236. /**
  49237. * The camera attached to the layer.
  49238. */
  49239. camera: Nullable<Camera>;
  49240. /**
  49241. * The rendering group to draw the layer in.
  49242. */
  49243. renderingGroupId: number;
  49244. }
  49245. /**
  49246. * The effect layer Helps adding post process effect blended with the main pass.
  49247. *
  49248. * This can be for instance use to generate glow or higlight effects on the scene.
  49249. *
  49250. * The effect layer class can not be used directly and is intented to inherited from to be
  49251. * customized per effects.
  49252. */
  49253. export abstract class EffectLayer {
  49254. private _vertexBuffers;
  49255. private _indexBuffer;
  49256. private _cachedDefines;
  49257. private _effectLayerMapGenerationEffect;
  49258. private _effectLayerOptions;
  49259. private _mergeEffect;
  49260. protected _scene: Scene;
  49261. protected _engine: Engine;
  49262. protected _maxSize: number;
  49263. protected _mainTextureDesiredSize: ISize;
  49264. protected _mainTexture: RenderTargetTexture;
  49265. protected _shouldRender: boolean;
  49266. protected _postProcesses: PostProcess[];
  49267. protected _textures: BaseTexture[];
  49268. protected _emissiveTextureAndColor: {
  49269. texture: Nullable<BaseTexture>;
  49270. color: Color4;
  49271. };
  49272. /**
  49273. * The name of the layer
  49274. */
  49275. name: string;
  49276. /**
  49277. * The clear color of the texture used to generate the glow map.
  49278. */
  49279. neutralColor: Color4;
  49280. /**
  49281. * Specifies wether the highlight layer is enabled or not.
  49282. */
  49283. isEnabled: boolean;
  49284. /**
  49285. * Gets the camera attached to the layer.
  49286. */
  49287. readonly camera: Nullable<Camera>;
  49288. /**
  49289. * Gets the rendering group id the layer should render in.
  49290. */
  49291. renderingGroupId: number;
  49292. /**
  49293. * An event triggered when the effect layer has been disposed.
  49294. */
  49295. onDisposeObservable: Observable<EffectLayer>;
  49296. /**
  49297. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49298. */
  49299. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49300. /**
  49301. * An event triggered when the generated texture is being merged in the scene.
  49302. */
  49303. onBeforeComposeObservable: Observable<EffectLayer>;
  49304. /**
  49305. * An event triggered when the generated texture has been merged in the scene.
  49306. */
  49307. onAfterComposeObservable: Observable<EffectLayer>;
  49308. /**
  49309. * An event triggered when the efffect layer changes its size.
  49310. */
  49311. onSizeChangedObservable: Observable<EffectLayer>;
  49312. /** @hidden */
  49313. static _SceneComponentInitialization: (scene: Scene) => void;
  49314. /**
  49315. * Instantiates a new effect Layer and references it in the scene.
  49316. * @param name The name of the layer
  49317. * @param scene The scene to use the layer in
  49318. */
  49319. constructor(
  49320. /** The Friendly of the effect in the scene */
  49321. name: string, scene: Scene);
  49322. /**
  49323. * Get the effect name of the layer.
  49324. * @return The effect name
  49325. */
  49326. abstract getEffectName(): string;
  49327. /**
  49328. * Checks for the readiness of the element composing the layer.
  49329. * @param subMesh the mesh to check for
  49330. * @param useInstances specify wether or not to use instances to render the mesh
  49331. * @return true if ready otherwise, false
  49332. */
  49333. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49334. /**
  49335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49336. * @returns true if the effect requires stencil during the main canvas render pass.
  49337. */
  49338. abstract needStencil(): boolean;
  49339. /**
  49340. * Create the merge effect. This is the shader use to blit the information back
  49341. * to the main canvas at the end of the scene rendering.
  49342. * @returns The effect containing the shader used to merge the effect on the main canvas
  49343. */
  49344. protected abstract _createMergeEffect(): Effect;
  49345. /**
  49346. * Creates the render target textures and post processes used in the effect layer.
  49347. */
  49348. protected abstract _createTextureAndPostProcesses(): void;
  49349. /**
  49350. * Implementation specific of rendering the generating effect on the main canvas.
  49351. * @param effect The effect used to render through
  49352. */
  49353. protected abstract _internalRender(effect: Effect): void;
  49354. /**
  49355. * Sets the required values for both the emissive texture and and the main color.
  49356. */
  49357. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49358. /**
  49359. * Free any resources and references associated to a mesh.
  49360. * Internal use
  49361. * @param mesh The mesh to free.
  49362. */
  49363. abstract _disposeMesh(mesh: Mesh): void;
  49364. /**
  49365. * Serializes this layer (Glow or Highlight for example)
  49366. * @returns a serialized layer object
  49367. */
  49368. abstract serialize?(): any;
  49369. /**
  49370. * Initializes the effect layer with the required options.
  49371. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49372. */
  49373. protected _init(options: Partial<IEffectLayerOptions>): void;
  49374. /**
  49375. * Generates the index buffer of the full screen quad blending to the main canvas.
  49376. */
  49377. private _generateIndexBuffer;
  49378. /**
  49379. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49380. */
  49381. private _generateVertexBuffer;
  49382. /**
  49383. * Sets the main texture desired size which is the closest power of two
  49384. * of the engine canvas size.
  49385. */
  49386. private _setMainTextureSize;
  49387. /**
  49388. * Creates the main texture for the effect layer.
  49389. */
  49390. protected _createMainTexture(): void;
  49391. /**
  49392. * Adds specific effects defines.
  49393. * @param defines The defines to add specifics to.
  49394. */
  49395. protected _addCustomEffectDefines(defines: string[]): void;
  49396. /**
  49397. * Checks for the readiness of the element composing the layer.
  49398. * @param subMesh the mesh to check for
  49399. * @param useInstances specify wether or not to use instances to render the mesh
  49400. * @param emissiveTexture the associated emissive texture used to generate the glow
  49401. * @return true if ready otherwise, false
  49402. */
  49403. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49404. /**
  49405. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49406. */
  49407. render(): void;
  49408. /**
  49409. * Determine if a given mesh will be used in the current effect.
  49410. * @param mesh mesh to test
  49411. * @returns true if the mesh will be used
  49412. */
  49413. hasMesh(mesh: AbstractMesh): boolean;
  49414. /**
  49415. * Returns true if the layer contains information to display, otherwise false.
  49416. * @returns true if the glow layer should be rendered
  49417. */
  49418. shouldRender(): boolean;
  49419. /**
  49420. * Returns true if the mesh should render, otherwise false.
  49421. * @param mesh The mesh to render
  49422. * @returns true if it should render otherwise false
  49423. */
  49424. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49425. /**
  49426. * Returns true if the mesh can be rendered, otherwise false.
  49427. * @param mesh The mesh to render
  49428. * @param material The material used on the mesh
  49429. * @returns true if it can be rendered otherwise false
  49430. */
  49431. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49432. /**
  49433. * Returns true if the mesh should render, otherwise false.
  49434. * @param mesh The mesh to render
  49435. * @returns true if it should render otherwise false
  49436. */
  49437. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49438. /**
  49439. * Renders the submesh passed in parameter to the generation map.
  49440. */
  49441. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49442. /**
  49443. * Rebuild the required buffers.
  49444. * @hidden Internal use only.
  49445. */
  49446. _rebuild(): void;
  49447. /**
  49448. * Dispose only the render target textures and post process.
  49449. */
  49450. private _disposeTextureAndPostProcesses;
  49451. /**
  49452. * Dispose the highlight layer and free resources.
  49453. */
  49454. dispose(): void;
  49455. /**
  49456. * Gets the class name of the effect layer
  49457. * @returns the string with the class name of the effect layer
  49458. */
  49459. getClassName(): string;
  49460. /**
  49461. * Creates an effect layer from parsed effect layer data
  49462. * @param parsedEffectLayer defines effect layer data
  49463. * @param scene defines the current scene
  49464. * @param rootUrl defines the root URL containing the effect layer information
  49465. * @returns a parsed effect Layer
  49466. */
  49467. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49468. }
  49469. }
  49470. declare module BABYLON {
  49471. interface AbstractScene {
  49472. /**
  49473. * The list of effect layers (highlights/glow) added to the scene
  49474. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49475. * @see http://doc.babylonjs.com/how_to/glow_layer
  49476. */
  49477. effectLayers: Array<EffectLayer>;
  49478. /**
  49479. * Removes the given effect layer from this scene.
  49480. * @param toRemove defines the effect layer to remove
  49481. * @returns the index of the removed effect layer
  49482. */
  49483. removeEffectLayer(toRemove: EffectLayer): number;
  49484. /**
  49485. * Adds the given effect layer to this scene
  49486. * @param newEffectLayer defines the effect layer to add
  49487. */
  49488. addEffectLayer(newEffectLayer: EffectLayer): void;
  49489. }
  49490. /**
  49491. * Defines the layer scene component responsible to manage any effect layers
  49492. * in a given scene.
  49493. */
  49494. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49495. /**
  49496. * The component name helpfull to identify the component in the list of scene components.
  49497. */
  49498. readonly name: string;
  49499. /**
  49500. * The scene the component belongs to.
  49501. */
  49502. scene: Scene;
  49503. private _engine;
  49504. private _renderEffects;
  49505. private _needStencil;
  49506. private _previousStencilState;
  49507. /**
  49508. * Creates a new instance of the component for the given scene
  49509. * @param scene Defines the scene to register the component in
  49510. */
  49511. constructor(scene: Scene);
  49512. /**
  49513. * Registers the component in a given scene
  49514. */
  49515. register(): void;
  49516. /**
  49517. * Rebuilds the elements related to this component in case of
  49518. * context lost for instance.
  49519. */
  49520. rebuild(): void;
  49521. /**
  49522. * Serializes the component data to the specified json object
  49523. * @param serializationObject The object to serialize to
  49524. */
  49525. serialize(serializationObject: any): void;
  49526. /**
  49527. * Adds all the elements from the container to the scene
  49528. * @param container the container holding the elements
  49529. */
  49530. addFromContainer(container: AbstractScene): void;
  49531. /**
  49532. * Removes all the elements in the container from the scene
  49533. * @param container contains the elements to remove
  49534. * @param dispose if the removed element should be disposed (default: false)
  49535. */
  49536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49537. /**
  49538. * Disposes the component and the associated ressources.
  49539. */
  49540. dispose(): void;
  49541. private _isReadyForMesh;
  49542. private _renderMainTexture;
  49543. private _setStencil;
  49544. private _setStencilBack;
  49545. private _draw;
  49546. private _drawCamera;
  49547. private _drawRenderingGroup;
  49548. }
  49549. }
  49550. declare module BABYLON {
  49551. /** @hidden */
  49552. export var glowMapMergePixelShader: {
  49553. name: string;
  49554. shader: string;
  49555. };
  49556. }
  49557. declare module BABYLON {
  49558. /** @hidden */
  49559. export var glowMapMergeVertexShader: {
  49560. name: string;
  49561. shader: string;
  49562. };
  49563. }
  49564. declare module BABYLON {
  49565. interface AbstractScene {
  49566. /**
  49567. * Return a the first highlight layer of the scene with a given name.
  49568. * @param name The name of the highlight layer to look for.
  49569. * @return The highlight layer if found otherwise null.
  49570. */
  49571. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49572. }
  49573. /**
  49574. * Glow layer options. This helps customizing the behaviour
  49575. * of the glow layer.
  49576. */
  49577. export interface IGlowLayerOptions {
  49578. /**
  49579. * Multiplication factor apply to the canvas size to compute the render target size
  49580. * used to generated the glowing objects (the smaller the faster).
  49581. */
  49582. mainTextureRatio: number;
  49583. /**
  49584. * Enforces a fixed size texture to ensure resize independant blur.
  49585. */
  49586. mainTextureFixedSize?: number;
  49587. /**
  49588. * How big is the kernel of the blur texture.
  49589. */
  49590. blurKernelSize: number;
  49591. /**
  49592. * The camera attached to the layer.
  49593. */
  49594. camera: Nullable<Camera>;
  49595. /**
  49596. * Enable MSAA by chosing the number of samples.
  49597. */
  49598. mainTextureSamples?: number;
  49599. /**
  49600. * The rendering group to draw the layer in.
  49601. */
  49602. renderingGroupId: number;
  49603. }
  49604. /**
  49605. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49606. *
  49607. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49608. * glowy meshes to your scene.
  49609. *
  49610. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49611. */
  49612. export class GlowLayer extends EffectLayer {
  49613. /**
  49614. * Effect Name of the layer.
  49615. */
  49616. static readonly EffectName: string;
  49617. /**
  49618. * The default blur kernel size used for the glow.
  49619. */
  49620. static DefaultBlurKernelSize: number;
  49621. /**
  49622. * The default texture size ratio used for the glow.
  49623. */
  49624. static DefaultTextureRatio: number;
  49625. /**
  49626. * Sets the kernel size of the blur.
  49627. */
  49628. /**
  49629. * Gets the kernel size of the blur.
  49630. */
  49631. blurKernelSize: number;
  49632. /**
  49633. * Sets the glow intensity.
  49634. */
  49635. /**
  49636. * Gets the glow intensity.
  49637. */
  49638. intensity: number;
  49639. private _options;
  49640. private _intensity;
  49641. private _horizontalBlurPostprocess1;
  49642. private _verticalBlurPostprocess1;
  49643. private _horizontalBlurPostprocess2;
  49644. private _verticalBlurPostprocess2;
  49645. private _blurTexture1;
  49646. private _blurTexture2;
  49647. private _postProcesses1;
  49648. private _postProcesses2;
  49649. private _includedOnlyMeshes;
  49650. private _excludedMeshes;
  49651. /**
  49652. * Callback used to let the user override the color selection on a per mesh basis
  49653. */
  49654. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49655. /**
  49656. * Callback used to let the user override the texture selection on a per mesh basis
  49657. */
  49658. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49659. /**
  49660. * Instantiates a new glow Layer and references it to the scene.
  49661. * @param name The name of the layer
  49662. * @param scene The scene to use the layer in
  49663. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49664. */
  49665. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49666. /**
  49667. * Get the effect name of the layer.
  49668. * @return The effect name
  49669. */
  49670. getEffectName(): string;
  49671. /**
  49672. * Create the merge effect. This is the shader use to blit the information back
  49673. * to the main canvas at the end of the scene rendering.
  49674. */
  49675. protected _createMergeEffect(): Effect;
  49676. /**
  49677. * Creates the render target textures and post processes used in the glow layer.
  49678. */
  49679. protected _createTextureAndPostProcesses(): void;
  49680. /**
  49681. * Checks for the readiness of the element composing the layer.
  49682. * @param subMesh the mesh to check for
  49683. * @param useInstances specify wether or not to use instances to render the mesh
  49684. * @param emissiveTexture the associated emissive texture used to generate the glow
  49685. * @return true if ready otherwise, false
  49686. */
  49687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49688. /**
  49689. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49690. */
  49691. needStencil(): boolean;
  49692. /**
  49693. * Returns true if the mesh can be rendered, otherwise false.
  49694. * @param mesh The mesh to render
  49695. * @param material The material used on the mesh
  49696. * @returns true if it can be rendered otherwise false
  49697. */
  49698. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49699. /**
  49700. * Implementation specific of rendering the generating effect on the main canvas.
  49701. * @param effect The effect used to render through
  49702. */
  49703. protected _internalRender(effect: Effect): void;
  49704. /**
  49705. * Sets the required values for both the emissive texture and and the main color.
  49706. */
  49707. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49708. /**
  49709. * Returns true if the mesh should render, otherwise false.
  49710. * @param mesh The mesh to render
  49711. * @returns true if it should render otherwise false
  49712. */
  49713. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49714. /**
  49715. * Adds specific effects defines.
  49716. * @param defines The defines to add specifics to.
  49717. */
  49718. protected _addCustomEffectDefines(defines: string[]): void;
  49719. /**
  49720. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49721. * @param mesh The mesh to exclude from the glow layer
  49722. */
  49723. addExcludedMesh(mesh: Mesh): void;
  49724. /**
  49725. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49726. * @param mesh The mesh to remove
  49727. */
  49728. removeExcludedMesh(mesh: Mesh): void;
  49729. /**
  49730. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49731. * @param mesh The mesh to include in the glow layer
  49732. */
  49733. addIncludedOnlyMesh(mesh: Mesh): void;
  49734. /**
  49735. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49736. * @param mesh The mesh to remove
  49737. */
  49738. removeIncludedOnlyMesh(mesh: Mesh): void;
  49739. /**
  49740. * Determine if a given mesh will be used in the glow layer
  49741. * @param mesh The mesh to test
  49742. * @returns true if the mesh will be highlighted by the current glow layer
  49743. */
  49744. hasMesh(mesh: AbstractMesh): boolean;
  49745. /**
  49746. * Free any resources and references associated to a mesh.
  49747. * Internal use
  49748. * @param mesh The mesh to free.
  49749. * @hidden
  49750. */
  49751. _disposeMesh(mesh: Mesh): void;
  49752. /**
  49753. * Gets the class name of the effect layer
  49754. * @returns the string with the class name of the effect layer
  49755. */
  49756. getClassName(): string;
  49757. /**
  49758. * Serializes this glow layer
  49759. * @returns a serialized glow layer object
  49760. */
  49761. serialize(): any;
  49762. /**
  49763. * Creates a Glow Layer from parsed glow layer data
  49764. * @param parsedGlowLayer defines glow layer data
  49765. * @param scene defines the current scene
  49766. * @param rootUrl defines the root URL containing the glow layer information
  49767. * @returns a parsed Glow Layer
  49768. */
  49769. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49770. }
  49771. }
  49772. declare module BABYLON {
  49773. /** @hidden */
  49774. export var glowBlurPostProcessPixelShader: {
  49775. name: string;
  49776. shader: string;
  49777. };
  49778. }
  49779. declare module BABYLON {
  49780. interface AbstractScene {
  49781. /**
  49782. * Return a the first highlight layer of the scene with a given name.
  49783. * @param name The name of the highlight layer to look for.
  49784. * @return The highlight layer if found otherwise null.
  49785. */
  49786. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49787. }
  49788. /**
  49789. * Highlight layer options. This helps customizing the behaviour
  49790. * of the highlight layer.
  49791. */
  49792. export interface IHighlightLayerOptions {
  49793. /**
  49794. * Multiplication factor apply to the canvas size to compute the render target size
  49795. * used to generated the glowing objects (the smaller the faster).
  49796. */
  49797. mainTextureRatio: number;
  49798. /**
  49799. * Enforces a fixed size texture to ensure resize independant blur.
  49800. */
  49801. mainTextureFixedSize?: number;
  49802. /**
  49803. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49804. * of the picture to blur (the smaller the faster).
  49805. */
  49806. blurTextureSizeRatio: number;
  49807. /**
  49808. * How big in texel of the blur texture is the vertical blur.
  49809. */
  49810. blurVerticalSize: number;
  49811. /**
  49812. * How big in texel of the blur texture is the horizontal blur.
  49813. */
  49814. blurHorizontalSize: number;
  49815. /**
  49816. * Alpha blending mode used to apply the blur. Default is combine.
  49817. */
  49818. alphaBlendingMode: number;
  49819. /**
  49820. * The camera attached to the layer.
  49821. */
  49822. camera: Nullable<Camera>;
  49823. /**
  49824. * Should we display highlight as a solid stroke?
  49825. */
  49826. isStroke?: boolean;
  49827. /**
  49828. * The rendering group to draw the layer in.
  49829. */
  49830. renderingGroupId: number;
  49831. }
  49832. /**
  49833. * The highlight layer Helps adding a glow effect around a mesh.
  49834. *
  49835. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49836. * glowy meshes to your scene.
  49837. *
  49838. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49839. */
  49840. export class HighlightLayer extends EffectLayer {
  49841. name: string;
  49842. /**
  49843. * Effect Name of the highlight layer.
  49844. */
  49845. static readonly EffectName: string;
  49846. /**
  49847. * The neutral color used during the preparation of the glow effect.
  49848. * This is black by default as the blend operation is a blend operation.
  49849. */
  49850. static NeutralColor: Color4;
  49851. /**
  49852. * Stencil value used for glowing meshes.
  49853. */
  49854. static GlowingMeshStencilReference: number;
  49855. /**
  49856. * Stencil value used for the other meshes in the scene.
  49857. */
  49858. static NormalMeshStencilReference: number;
  49859. /**
  49860. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49861. */
  49862. innerGlow: boolean;
  49863. /**
  49864. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49865. */
  49866. outerGlow: boolean;
  49867. /**
  49868. * Specifies the horizontal size of the blur.
  49869. */
  49870. /**
  49871. * Gets the horizontal size of the blur.
  49872. */
  49873. blurHorizontalSize: number;
  49874. /**
  49875. * Specifies the vertical size of the blur.
  49876. */
  49877. /**
  49878. * Gets the vertical size of the blur.
  49879. */
  49880. blurVerticalSize: number;
  49881. /**
  49882. * An event triggered when the highlight layer is being blurred.
  49883. */
  49884. onBeforeBlurObservable: Observable<HighlightLayer>;
  49885. /**
  49886. * An event triggered when the highlight layer has been blurred.
  49887. */
  49888. onAfterBlurObservable: Observable<HighlightLayer>;
  49889. private _instanceGlowingMeshStencilReference;
  49890. private _options;
  49891. private _downSamplePostprocess;
  49892. private _horizontalBlurPostprocess;
  49893. private _verticalBlurPostprocess;
  49894. private _blurTexture;
  49895. private _meshes;
  49896. private _excludedMeshes;
  49897. /**
  49898. * Instantiates a new highlight Layer and references it to the scene..
  49899. * @param name The name of the layer
  49900. * @param scene The scene to use the layer in
  49901. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49902. */
  49903. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49904. /**
  49905. * Get the effect name of the layer.
  49906. * @return The effect name
  49907. */
  49908. getEffectName(): string;
  49909. /**
  49910. * Create the merge effect. This is the shader use to blit the information back
  49911. * to the main canvas at the end of the scene rendering.
  49912. */
  49913. protected _createMergeEffect(): Effect;
  49914. /**
  49915. * Creates the render target textures and post processes used in the highlight layer.
  49916. */
  49917. protected _createTextureAndPostProcesses(): void;
  49918. /**
  49919. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49920. */
  49921. needStencil(): boolean;
  49922. /**
  49923. * Checks for the readiness of the element composing the layer.
  49924. * @param subMesh the mesh to check for
  49925. * @param useInstances specify wether or not to use instances to render the mesh
  49926. * @param emissiveTexture the associated emissive texture used to generate the glow
  49927. * @return true if ready otherwise, false
  49928. */
  49929. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49930. /**
  49931. * Implementation specific of rendering the generating effect on the main canvas.
  49932. * @param effect The effect used to render through
  49933. */
  49934. protected _internalRender(effect: Effect): void;
  49935. /**
  49936. * Returns true if the layer contains information to display, otherwise false.
  49937. */
  49938. shouldRender(): boolean;
  49939. /**
  49940. * Returns true if the mesh should render, otherwise false.
  49941. * @param mesh The mesh to render
  49942. * @returns true if it should render otherwise false
  49943. */
  49944. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49945. /**
  49946. * Sets the required values for both the emissive texture and and the main color.
  49947. */
  49948. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49949. /**
  49950. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49951. * @param mesh The mesh to exclude from the highlight layer
  49952. */
  49953. addExcludedMesh(mesh: Mesh): void;
  49954. /**
  49955. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49956. * @param mesh The mesh to highlight
  49957. */
  49958. removeExcludedMesh(mesh: Mesh): void;
  49959. /**
  49960. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49961. * @param mesh mesh to test
  49962. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49963. */
  49964. hasMesh(mesh: AbstractMesh): boolean;
  49965. /**
  49966. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49967. * @param mesh The mesh to highlight
  49968. * @param color The color of the highlight
  49969. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49970. */
  49971. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49972. /**
  49973. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49974. * @param mesh The mesh to highlight
  49975. */
  49976. removeMesh(mesh: Mesh): void;
  49977. /**
  49978. * Force the stencil to the normal expected value for none glowing parts
  49979. */
  49980. private _defaultStencilReference;
  49981. /**
  49982. * Free any resources and references associated to a mesh.
  49983. * Internal use
  49984. * @param mesh The mesh to free.
  49985. * @hidden
  49986. */
  49987. _disposeMesh(mesh: Mesh): void;
  49988. /**
  49989. * Dispose the highlight layer and free resources.
  49990. */
  49991. dispose(): void;
  49992. /**
  49993. * Gets the class name of the effect layer
  49994. * @returns the string with the class name of the effect layer
  49995. */
  49996. getClassName(): string;
  49997. /**
  49998. * Serializes this Highlight layer
  49999. * @returns a serialized Highlight layer object
  50000. */
  50001. serialize(): any;
  50002. /**
  50003. * Creates a Highlight layer from parsed Highlight layer data
  50004. * @param parsedHightlightLayer defines the Highlight layer data
  50005. * @param scene defines the current scene
  50006. * @param rootUrl defines the root URL containing the Highlight layer information
  50007. * @returns a parsed Highlight layer
  50008. */
  50009. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50010. }
  50011. }
  50012. declare module BABYLON {
  50013. interface AbstractScene {
  50014. /**
  50015. * The list of layers (background and foreground) of the scene
  50016. */
  50017. layers: Array<Layer>;
  50018. }
  50019. /**
  50020. * Defines the layer scene component responsible to manage any layers
  50021. * in a given scene.
  50022. */
  50023. export class LayerSceneComponent implements ISceneComponent {
  50024. /**
  50025. * The component name helpfull to identify the component in the list of scene components.
  50026. */
  50027. readonly name: string;
  50028. /**
  50029. * The scene the component belongs to.
  50030. */
  50031. scene: Scene;
  50032. private _engine;
  50033. /**
  50034. * Creates a new instance of the component for the given scene
  50035. * @param scene Defines the scene to register the component in
  50036. */
  50037. constructor(scene: Scene);
  50038. /**
  50039. * Registers the component in a given scene
  50040. */
  50041. register(): void;
  50042. /**
  50043. * Rebuilds the elements related to this component in case of
  50044. * context lost for instance.
  50045. */
  50046. rebuild(): void;
  50047. /**
  50048. * Disposes the component and the associated ressources.
  50049. */
  50050. dispose(): void;
  50051. private _draw;
  50052. private _drawCameraPredicate;
  50053. private _drawCameraBackground;
  50054. private _drawCameraForeground;
  50055. private _drawRenderTargetPredicate;
  50056. private _drawRenderTargetBackground;
  50057. private _drawRenderTargetForeground;
  50058. /**
  50059. * Adds all the elements from the container to the scene
  50060. * @param container the container holding the elements
  50061. */
  50062. addFromContainer(container: AbstractScene): void;
  50063. /**
  50064. * Removes all the elements in the container from the scene
  50065. * @param container contains the elements to remove
  50066. * @param dispose if the removed element should be disposed (default: false)
  50067. */
  50068. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /** @hidden */
  50073. export var layerPixelShader: {
  50074. name: string;
  50075. shader: string;
  50076. };
  50077. }
  50078. declare module BABYLON {
  50079. /** @hidden */
  50080. export var layerVertexShader: {
  50081. name: string;
  50082. shader: string;
  50083. };
  50084. }
  50085. declare module BABYLON {
  50086. /**
  50087. * This represents a full screen 2d layer.
  50088. * This can be useful to display a picture in the background of your scene for instance.
  50089. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50090. */
  50091. export class Layer {
  50092. /**
  50093. * Define the name of the layer.
  50094. */
  50095. name: string;
  50096. /**
  50097. * Define the texture the layer should display.
  50098. */
  50099. texture: Nullable<Texture>;
  50100. /**
  50101. * Is the layer in background or foreground.
  50102. */
  50103. isBackground: boolean;
  50104. /**
  50105. * Define the color of the layer (instead of texture).
  50106. */
  50107. color: Color4;
  50108. /**
  50109. * Define the scale of the layer in order to zoom in out of the texture.
  50110. */
  50111. scale: Vector2;
  50112. /**
  50113. * Define an offset for the layer in order to shift the texture.
  50114. */
  50115. offset: Vector2;
  50116. /**
  50117. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50118. */
  50119. alphaBlendingMode: number;
  50120. /**
  50121. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50122. * Alpha test will not mix with the background color in case of transparency.
  50123. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50124. */
  50125. alphaTest: boolean;
  50126. /**
  50127. * Define a mask to restrict the layer to only some of the scene cameras.
  50128. */
  50129. layerMask: number;
  50130. /**
  50131. * Define the list of render target the layer is visible into.
  50132. */
  50133. renderTargetTextures: RenderTargetTexture[];
  50134. /**
  50135. * Define if the layer is only used in renderTarget or if it also
  50136. * renders in the main frame buffer of the canvas.
  50137. */
  50138. renderOnlyInRenderTargetTextures: boolean;
  50139. private _scene;
  50140. private _vertexBuffers;
  50141. private _indexBuffer;
  50142. private _effect;
  50143. private _alphaTestEffect;
  50144. /**
  50145. * An event triggered when the layer is disposed.
  50146. */
  50147. onDisposeObservable: Observable<Layer>;
  50148. private _onDisposeObserver;
  50149. /**
  50150. * Back compatibility with callback before the onDisposeObservable existed.
  50151. * The set callback will be triggered when the layer has been disposed.
  50152. */
  50153. onDispose: () => void;
  50154. /**
  50155. * An event triggered before rendering the scene
  50156. */
  50157. onBeforeRenderObservable: Observable<Layer>;
  50158. private _onBeforeRenderObserver;
  50159. /**
  50160. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50161. * The set callback will be triggered just before rendering the layer.
  50162. */
  50163. onBeforeRender: () => void;
  50164. /**
  50165. * An event triggered after rendering the scene
  50166. */
  50167. onAfterRenderObservable: Observable<Layer>;
  50168. private _onAfterRenderObserver;
  50169. /**
  50170. * Back compatibility with callback before the onAfterRenderObservable existed.
  50171. * The set callback will be triggered just after rendering the layer.
  50172. */
  50173. onAfterRender: () => void;
  50174. /**
  50175. * Instantiates a new layer.
  50176. * This represents a full screen 2d layer.
  50177. * This can be useful to display a picture in the background of your scene for instance.
  50178. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50179. * @param name Define the name of the layer in the scene
  50180. * @param imgUrl Define the url of the texture to display in the layer
  50181. * @param scene Define the scene the layer belongs to
  50182. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50183. * @param color Defines a color for the layer
  50184. */
  50185. constructor(
  50186. /**
  50187. * Define the name of the layer.
  50188. */
  50189. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50190. private _createIndexBuffer;
  50191. /** @hidden */
  50192. _rebuild(): void;
  50193. /**
  50194. * Renders the layer in the scene.
  50195. */
  50196. render(): void;
  50197. /**
  50198. * Disposes and releases the associated ressources.
  50199. */
  50200. dispose(): void;
  50201. }
  50202. }
  50203. declare module BABYLON {
  50204. /** @hidden */
  50205. export var lensFlarePixelShader: {
  50206. name: string;
  50207. shader: string;
  50208. };
  50209. }
  50210. declare module BABYLON {
  50211. /** @hidden */
  50212. export var lensFlareVertexShader: {
  50213. name: string;
  50214. shader: string;
  50215. };
  50216. }
  50217. declare module BABYLON {
  50218. /**
  50219. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50220. * It is usually composed of several `lensFlare`.
  50221. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50222. */
  50223. export class LensFlareSystem {
  50224. /**
  50225. * Define the name of the lens flare system
  50226. */
  50227. name: string;
  50228. /**
  50229. * List of lens flares used in this system.
  50230. */
  50231. lensFlares: LensFlare[];
  50232. /**
  50233. * Define a limit from the border the lens flare can be visible.
  50234. */
  50235. borderLimit: number;
  50236. /**
  50237. * Define a viewport border we do not want to see the lens flare in.
  50238. */
  50239. viewportBorder: number;
  50240. /**
  50241. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50242. */
  50243. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50244. /**
  50245. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50246. */
  50247. layerMask: number;
  50248. /**
  50249. * Define the id of the lens flare system in the scene.
  50250. * (equal to name by default)
  50251. */
  50252. id: string;
  50253. private _scene;
  50254. private _emitter;
  50255. private _vertexBuffers;
  50256. private _indexBuffer;
  50257. private _effect;
  50258. private _positionX;
  50259. private _positionY;
  50260. private _isEnabled;
  50261. /** @hidden */
  50262. static _SceneComponentInitialization: (scene: Scene) => void;
  50263. /**
  50264. * Instantiates a lens flare system.
  50265. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50266. * It is usually composed of several `lensFlare`.
  50267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50268. * @param name Define the name of the lens flare system in the scene
  50269. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50270. * @param scene Define the scene the lens flare system belongs to
  50271. */
  50272. constructor(
  50273. /**
  50274. * Define the name of the lens flare system
  50275. */
  50276. name: string, emitter: any, scene: Scene);
  50277. /**
  50278. * Define if the lens flare system is enabled.
  50279. */
  50280. isEnabled: boolean;
  50281. /**
  50282. * Get the scene the effects belongs to.
  50283. * @returns the scene holding the lens flare system
  50284. */
  50285. getScene(): Scene;
  50286. /**
  50287. * Get the emitter of the lens flare system.
  50288. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50289. * @returns the emitter of the lens flare system
  50290. */
  50291. getEmitter(): any;
  50292. /**
  50293. * Set the emitter of the lens flare system.
  50294. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50295. * @param newEmitter Define the new emitter of the system
  50296. */
  50297. setEmitter(newEmitter: any): void;
  50298. /**
  50299. * Get the lens flare system emitter position.
  50300. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50301. * @returns the position
  50302. */
  50303. getEmitterPosition(): Vector3;
  50304. /**
  50305. * @hidden
  50306. */
  50307. computeEffectivePosition(globalViewport: Viewport): boolean;
  50308. /** @hidden */
  50309. _isVisible(): boolean;
  50310. /**
  50311. * @hidden
  50312. */
  50313. render(): boolean;
  50314. /**
  50315. * Dispose and release the lens flare with its associated resources.
  50316. */
  50317. dispose(): void;
  50318. /**
  50319. * Parse a lens flare system from a JSON repressentation
  50320. * @param parsedLensFlareSystem Define the JSON to parse
  50321. * @param scene Define the scene the parsed system should be instantiated in
  50322. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50323. * @returns the parsed system
  50324. */
  50325. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50326. /**
  50327. * Serialize the current Lens Flare System into a JSON representation.
  50328. * @returns the serialized JSON
  50329. */
  50330. serialize(): any;
  50331. }
  50332. }
  50333. declare module BABYLON {
  50334. /**
  50335. * This represents one of the lens effect in a `lensFlareSystem`.
  50336. * It controls one of the indiviual texture used in the effect.
  50337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50338. */
  50339. export class LensFlare {
  50340. /**
  50341. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50342. */
  50343. size: number;
  50344. /**
  50345. * 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.
  50346. */
  50347. position: number;
  50348. /**
  50349. * Define the lens color.
  50350. */
  50351. color: Color3;
  50352. /**
  50353. * Define the lens texture.
  50354. */
  50355. texture: Nullable<Texture>;
  50356. /**
  50357. * Define the alpha mode to render this particular lens.
  50358. */
  50359. alphaMode: number;
  50360. private _system;
  50361. /**
  50362. * Creates a new Lens Flare.
  50363. * This represents one of the lens effect in a `lensFlareSystem`.
  50364. * It controls one of the indiviual texture used in the effect.
  50365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50366. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50367. * @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.
  50368. * @param color Define the lens color
  50369. * @param imgUrl Define the lens texture url
  50370. * @param system Define the `lensFlareSystem` this flare is part of
  50371. * @returns The newly created Lens Flare
  50372. */
  50373. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50374. /**
  50375. * Instantiates a new Lens Flare.
  50376. * This represents one of the lens effect in a `lensFlareSystem`.
  50377. * It controls one of the indiviual texture used in the effect.
  50378. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50379. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50380. * @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.
  50381. * @param color Define the lens color
  50382. * @param imgUrl Define the lens texture url
  50383. * @param system Define the `lensFlareSystem` this flare is part of
  50384. */
  50385. constructor(
  50386. /**
  50387. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50388. */
  50389. size: number,
  50390. /**
  50391. * 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.
  50392. */
  50393. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50394. /**
  50395. * Dispose and release the lens flare with its associated resources.
  50396. */
  50397. dispose(): void;
  50398. }
  50399. }
  50400. declare module BABYLON {
  50401. interface AbstractScene {
  50402. /**
  50403. * The list of lens flare system added to the scene
  50404. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50405. */
  50406. lensFlareSystems: Array<LensFlareSystem>;
  50407. /**
  50408. * Removes the given lens flare system from this scene.
  50409. * @param toRemove The lens flare system to remove
  50410. * @returns The index of the removed lens flare system
  50411. */
  50412. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50413. /**
  50414. * Adds the given lens flare system to this scene
  50415. * @param newLensFlareSystem The lens flare system to add
  50416. */
  50417. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50418. /**
  50419. * Gets a lens flare system using its name
  50420. * @param name defines the name to look for
  50421. * @returns the lens flare system or null if not found
  50422. */
  50423. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50424. /**
  50425. * Gets a lens flare system using its id
  50426. * @param id defines the id to look for
  50427. * @returns the lens flare system or null if not found
  50428. */
  50429. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50430. }
  50431. /**
  50432. * Defines the lens flare scene component responsible to manage any lens flares
  50433. * in a given scene.
  50434. */
  50435. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50436. /**
  50437. * The component name helpfull to identify the component in the list of scene components.
  50438. */
  50439. readonly name: string;
  50440. /**
  50441. * The scene the component belongs to.
  50442. */
  50443. scene: Scene;
  50444. /**
  50445. * Creates a new instance of the component for the given scene
  50446. * @param scene Defines the scene to register the component in
  50447. */
  50448. constructor(scene: Scene);
  50449. /**
  50450. * Registers the component in a given scene
  50451. */
  50452. register(): void;
  50453. /**
  50454. * Rebuilds the elements related to this component in case of
  50455. * context lost for instance.
  50456. */
  50457. rebuild(): void;
  50458. /**
  50459. * Adds all the elements from the container to the scene
  50460. * @param container the container holding the elements
  50461. */
  50462. addFromContainer(container: AbstractScene): void;
  50463. /**
  50464. * Removes all the elements in the container from the scene
  50465. * @param container contains the elements to remove
  50466. * @param dispose if the removed element should be disposed (default: false)
  50467. */
  50468. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50469. /**
  50470. * Serializes the component data to the specified json object
  50471. * @param serializationObject The object to serialize to
  50472. */
  50473. serialize(serializationObject: any): void;
  50474. /**
  50475. * Disposes the component and the associated ressources.
  50476. */
  50477. dispose(): void;
  50478. private _draw;
  50479. }
  50480. }
  50481. declare module BABYLON {
  50482. /**
  50483. * Defines the shadow generator component responsible to manage any shadow generators
  50484. * in a given scene.
  50485. */
  50486. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50487. /**
  50488. * The component name helpfull to identify the component in the list of scene components.
  50489. */
  50490. readonly name: string;
  50491. /**
  50492. * The scene the component belongs to.
  50493. */
  50494. scene: Scene;
  50495. /**
  50496. * Creates a new instance of the component for the given scene
  50497. * @param scene Defines the scene to register the component in
  50498. */
  50499. constructor(scene: Scene);
  50500. /**
  50501. * Registers the component in a given scene
  50502. */
  50503. register(): void;
  50504. /**
  50505. * Rebuilds the elements related to this component in case of
  50506. * context lost for instance.
  50507. */
  50508. rebuild(): void;
  50509. /**
  50510. * Serializes the component data to the specified json object
  50511. * @param serializationObject The object to serialize to
  50512. */
  50513. serialize(serializationObject: any): void;
  50514. /**
  50515. * Adds all the elements from the container to the scene
  50516. * @param container the container holding the elements
  50517. */
  50518. addFromContainer(container: AbstractScene): void;
  50519. /**
  50520. * Removes all the elements in the container from the scene
  50521. * @param container contains the elements to remove
  50522. * @param dispose if the removed element should be disposed (default: false)
  50523. */
  50524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50525. /**
  50526. * Rebuilds the elements related to this component in case of
  50527. * context lost for instance.
  50528. */
  50529. dispose(): void;
  50530. private _gatherRenderTargets;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * A point light is a light defined by an unique point in world space.
  50536. * The light is emitted in every direction from this point.
  50537. * A good example of a point light is a standard light bulb.
  50538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50539. */
  50540. export class PointLight extends ShadowLight {
  50541. private _shadowAngle;
  50542. /**
  50543. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50544. * This specifies what angle the shadow will use to be created.
  50545. *
  50546. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50547. */
  50548. /**
  50549. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50550. * This specifies what angle the shadow will use to be created.
  50551. *
  50552. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50553. */
  50554. shadowAngle: number;
  50555. /**
  50556. * Gets the direction if it has been set.
  50557. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50558. */
  50559. /**
  50560. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50561. */
  50562. direction: Vector3;
  50563. /**
  50564. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50565. * A PointLight emits the light in every direction.
  50566. * It can cast shadows.
  50567. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50568. * ```javascript
  50569. * var pointLight = new PointLight("pl", camera.position, scene);
  50570. * ```
  50571. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50572. * @param name The light friendly name
  50573. * @param position The position of the point light in the scene
  50574. * @param scene The scene the lights belongs to
  50575. */
  50576. constructor(name: string, position: Vector3, scene: Scene);
  50577. /**
  50578. * Returns the string "PointLight"
  50579. * @returns the class name
  50580. */
  50581. getClassName(): string;
  50582. /**
  50583. * Returns the integer 0.
  50584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50585. */
  50586. getTypeID(): number;
  50587. /**
  50588. * Specifies wether or not the shadowmap should be a cube texture.
  50589. * @returns true if the shadowmap needs to be a cube texture.
  50590. */
  50591. needCube(): boolean;
  50592. /**
  50593. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50594. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50595. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50596. */
  50597. getShadowDirection(faceIndex?: number): Vector3;
  50598. /**
  50599. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50600. * - fov = PI / 2
  50601. * - aspect ratio : 1.0
  50602. * - z-near and far equal to the active camera minZ and maxZ.
  50603. * Returns the PointLight.
  50604. */
  50605. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50606. protected _buildUniformLayout(): void;
  50607. /**
  50608. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50609. * @param effect The effect to update
  50610. * @param lightIndex The index of the light in the effect to update
  50611. * @returns The point light
  50612. */
  50613. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50614. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50615. /**
  50616. * Prepares the list of defines specific to the light type.
  50617. * @param defines the list of defines
  50618. * @param lightIndex defines the index of the light for the effect
  50619. */
  50620. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50621. }
  50622. }
  50623. declare module BABYLON {
  50624. /**
  50625. * Header information of HDR texture files.
  50626. */
  50627. export interface HDRInfo {
  50628. /**
  50629. * The height of the texture in pixels.
  50630. */
  50631. height: number;
  50632. /**
  50633. * The width of the texture in pixels.
  50634. */
  50635. width: number;
  50636. /**
  50637. * The index of the beginning of the data in the binary file.
  50638. */
  50639. dataPosition: number;
  50640. }
  50641. /**
  50642. * This groups tools to convert HDR texture to native colors array.
  50643. */
  50644. export class HDRTools {
  50645. private static Ldexp;
  50646. private static Rgbe2float;
  50647. private static readStringLine;
  50648. /**
  50649. * Reads header information from an RGBE texture stored in a native array.
  50650. * More information on this format are available here:
  50651. * https://en.wikipedia.org/wiki/RGBE_image_format
  50652. *
  50653. * @param uint8array The binary file stored in native array.
  50654. * @return The header information.
  50655. */
  50656. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50657. /**
  50658. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50659. * This RGBE texture needs to store the information as a panorama.
  50660. *
  50661. * More information on this format are available here:
  50662. * https://en.wikipedia.org/wiki/RGBE_image_format
  50663. *
  50664. * @param buffer The binary file stored in an array buffer.
  50665. * @param size The expected size of the extracted cubemap.
  50666. * @return The Cube Map information.
  50667. */
  50668. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50669. /**
  50670. * Returns the pixels data extracted from an RGBE texture.
  50671. * This pixels will be stored left to right up to down in the R G B order in one array.
  50672. *
  50673. * More information on this format are available here:
  50674. * https://en.wikipedia.org/wiki/RGBE_image_format
  50675. *
  50676. * @param uint8array The binary file stored in an array buffer.
  50677. * @param hdrInfo The header information of the file.
  50678. * @return The pixels data in RGB right to left up to down order.
  50679. */
  50680. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50681. private static RGBE_ReadPixels_RLE;
  50682. }
  50683. }
  50684. declare module BABYLON {
  50685. /**
  50686. * This represents a texture coming from an HDR input.
  50687. *
  50688. * The only supported format is currently panorama picture stored in RGBE format.
  50689. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50690. */
  50691. export class HDRCubeTexture extends BaseTexture {
  50692. private static _facesMapping;
  50693. private _generateHarmonics;
  50694. private _noMipmap;
  50695. private _textureMatrix;
  50696. private _size;
  50697. private _onLoad;
  50698. private _onError;
  50699. /**
  50700. * The texture URL.
  50701. */
  50702. url: string;
  50703. /**
  50704. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50705. */
  50706. coordinatesMode: number;
  50707. protected _isBlocking: boolean;
  50708. /**
  50709. * Sets wether or not the texture is blocking during loading.
  50710. */
  50711. /**
  50712. * Gets wether or not the texture is blocking during loading.
  50713. */
  50714. isBlocking: boolean;
  50715. protected _rotationY: number;
  50716. /**
  50717. * Sets texture matrix rotation angle around Y axis in radians.
  50718. */
  50719. /**
  50720. * Gets texture matrix rotation angle around Y axis radians.
  50721. */
  50722. rotationY: number;
  50723. /**
  50724. * Gets or sets the center of the bounding box associated with the cube texture
  50725. * It must define where the camera used to render the texture was set
  50726. */
  50727. boundingBoxPosition: Vector3;
  50728. private _boundingBoxSize;
  50729. /**
  50730. * Gets or sets the size of the bounding box associated with the cube texture
  50731. * When defined, the cubemap will switch to local mode
  50732. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50733. * @example https://www.babylonjs-playground.com/#RNASML
  50734. */
  50735. boundingBoxSize: Vector3;
  50736. /**
  50737. * Instantiates an HDRTexture from the following parameters.
  50738. *
  50739. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50740. * @param scene The scene the texture will be used in
  50741. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50742. * @param noMipmap Forces to not generate the mipmap if true
  50743. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50744. * @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)
  50745. * @param reserved Reserved flag for internal use.
  50746. */
  50747. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50748. /**
  50749. * Get the current class name of the texture useful for serialization or dynamic coding.
  50750. * @returns "HDRCubeTexture"
  50751. */
  50752. getClassName(): string;
  50753. /**
  50754. * Occurs when the file is raw .hdr file.
  50755. */
  50756. private loadTexture;
  50757. clone(): HDRCubeTexture;
  50758. delayLoad(): void;
  50759. /**
  50760. * Get the texture reflection matrix used to rotate/transform the reflection.
  50761. * @returns the reflection matrix
  50762. */
  50763. getReflectionTextureMatrix(): Matrix;
  50764. /**
  50765. * Set the texture reflection matrix used to rotate/transform the reflection.
  50766. * @param value Define the reflection matrix to set
  50767. */
  50768. setReflectionTextureMatrix(value: Matrix): void;
  50769. /**
  50770. * Parses a JSON representation of an HDR Texture in order to create the texture
  50771. * @param parsedTexture Define the JSON representation
  50772. * @param scene Define the scene the texture should be created in
  50773. * @param rootUrl Define the root url in case we need to load relative dependencies
  50774. * @returns the newly created texture after parsing
  50775. */
  50776. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50777. serialize(): any;
  50778. }
  50779. }
  50780. declare module BABYLON {
  50781. /**
  50782. * Class used to control physics engine
  50783. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50784. */
  50785. export class PhysicsEngine implements IPhysicsEngine {
  50786. private _physicsPlugin;
  50787. /**
  50788. * Global value used to control the smallest number supported by the simulation
  50789. */
  50790. static Epsilon: number;
  50791. private _impostors;
  50792. private _joints;
  50793. /**
  50794. * Gets the gravity vector used by the simulation
  50795. */
  50796. gravity: Vector3;
  50797. /**
  50798. * Factory used to create the default physics plugin.
  50799. * @returns The default physics plugin
  50800. */
  50801. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50802. /**
  50803. * Creates a new Physics Engine
  50804. * @param gravity defines the gravity vector used by the simulation
  50805. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50806. */
  50807. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50808. /**
  50809. * Sets the gravity vector used by the simulation
  50810. * @param gravity defines the gravity vector to use
  50811. */
  50812. setGravity(gravity: Vector3): void;
  50813. /**
  50814. * Set the time step of the physics engine.
  50815. * Default is 1/60.
  50816. * To slow it down, enter 1/600 for example.
  50817. * To speed it up, 1/30
  50818. * @param newTimeStep defines the new timestep to apply to this world.
  50819. */
  50820. setTimeStep(newTimeStep?: number): void;
  50821. /**
  50822. * Get the time step of the physics engine.
  50823. * @returns the current time step
  50824. */
  50825. getTimeStep(): number;
  50826. /**
  50827. * Release all resources
  50828. */
  50829. dispose(): void;
  50830. /**
  50831. * Gets the name of the current physics plugin
  50832. * @returns the name of the plugin
  50833. */
  50834. getPhysicsPluginName(): string;
  50835. /**
  50836. * Adding a new impostor for the impostor tracking.
  50837. * This will be done by the impostor itself.
  50838. * @param impostor the impostor to add
  50839. */
  50840. addImpostor(impostor: PhysicsImpostor): void;
  50841. /**
  50842. * Remove an impostor from the engine.
  50843. * This impostor and its mesh will not longer be updated by the physics engine.
  50844. * @param impostor the impostor to remove
  50845. */
  50846. removeImpostor(impostor: PhysicsImpostor): void;
  50847. /**
  50848. * Add a joint to the physics engine
  50849. * @param mainImpostor defines the main impostor to which the joint is added.
  50850. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50851. * @param joint defines the joint that will connect both impostors.
  50852. */
  50853. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50854. /**
  50855. * Removes a joint from the simulation
  50856. * @param mainImpostor defines the impostor used with the joint
  50857. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50858. * @param joint defines the joint to remove
  50859. */
  50860. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50861. /**
  50862. * Called by the scene. No need to call it.
  50863. * @param delta defines the timespam between frames
  50864. */
  50865. _step(delta: number): void;
  50866. /**
  50867. * Gets the current plugin used to run the simulation
  50868. * @returns current plugin
  50869. */
  50870. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50871. /**
  50872. * Gets the list of physic impostors
  50873. * @returns an array of PhysicsImpostor
  50874. */
  50875. getImpostors(): Array<PhysicsImpostor>;
  50876. /**
  50877. * Gets the impostor for a physics enabled object
  50878. * @param object defines the object impersonated by the impostor
  50879. * @returns the PhysicsImpostor or null if not found
  50880. */
  50881. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50882. /**
  50883. * Gets the impostor for a physics body object
  50884. * @param body defines physics body used by the impostor
  50885. * @returns the PhysicsImpostor or null if not found
  50886. */
  50887. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50888. /**
  50889. * Does a raycast in the physics world
  50890. * @param from when should the ray start?
  50891. * @param to when should the ray end?
  50892. * @returns PhysicsRaycastResult
  50893. */
  50894. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50895. }
  50896. }
  50897. declare module BABYLON {
  50898. /** @hidden */
  50899. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50900. private _useDeltaForWorldStep;
  50901. world: any;
  50902. name: string;
  50903. private _physicsMaterials;
  50904. private _fixedTimeStep;
  50905. private _cannonRaycastResult;
  50906. private _raycastResult;
  50907. private _physicsBodysToRemoveAfterStep;
  50908. BJSCANNON: any;
  50909. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50910. setGravity(gravity: Vector3): void;
  50911. setTimeStep(timeStep: number): void;
  50912. getTimeStep(): number;
  50913. executeStep(delta: number): void;
  50914. private _removeMarkedPhysicsBodiesFromWorld;
  50915. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50916. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50917. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50918. private _processChildMeshes;
  50919. removePhysicsBody(impostor: PhysicsImpostor): void;
  50920. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50921. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50922. private _addMaterial;
  50923. private _checkWithEpsilon;
  50924. private _createShape;
  50925. private _createHeightmap;
  50926. private _minus90X;
  50927. private _plus90X;
  50928. private _tmpPosition;
  50929. private _tmpDeltaPosition;
  50930. private _tmpUnityRotation;
  50931. private _updatePhysicsBodyTransformation;
  50932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50934. isSupported(): boolean;
  50935. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50936. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50937. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50939. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50940. getBodyMass(impostor: PhysicsImpostor): number;
  50941. getBodyFriction(impostor: PhysicsImpostor): number;
  50942. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50943. getBodyRestitution(impostor: PhysicsImpostor): number;
  50944. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50945. sleepBody(impostor: PhysicsImpostor): void;
  50946. wakeUpBody(impostor: PhysicsImpostor): void;
  50947. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50948. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50949. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50950. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50951. getRadius(impostor: PhysicsImpostor): number;
  50952. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50953. dispose(): void;
  50954. private _extendNamespace;
  50955. /**
  50956. * Does a raycast in the physics world
  50957. * @param from when should the ray start?
  50958. * @param to when should the ray end?
  50959. * @returns PhysicsRaycastResult
  50960. */
  50961. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /** @hidden */
  50966. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50967. world: any;
  50968. name: string;
  50969. BJSOIMO: any;
  50970. private _raycastResult;
  50971. constructor(iterations?: number, oimoInjection?: any);
  50972. setGravity(gravity: Vector3): void;
  50973. setTimeStep(timeStep: number): void;
  50974. getTimeStep(): number;
  50975. private _tmpImpostorsArray;
  50976. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50980. private _tmpPositionVector;
  50981. removePhysicsBody(impostor: PhysicsImpostor): void;
  50982. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50983. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50984. isSupported(): boolean;
  50985. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50986. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50988. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50990. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50992. getBodyMass(impostor: PhysicsImpostor): number;
  50993. getBodyFriction(impostor: PhysicsImpostor): number;
  50994. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50995. getBodyRestitution(impostor: PhysicsImpostor): number;
  50996. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50997. sleepBody(impostor: PhysicsImpostor): void;
  50998. wakeUpBody(impostor: PhysicsImpostor): void;
  50999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51000. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51002. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51003. getRadius(impostor: PhysicsImpostor): number;
  51004. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51005. dispose(): void;
  51006. /**
  51007. * Does a raycast in the physics world
  51008. * @param from when should the ray start?
  51009. * @param to when should the ray end?
  51010. * @returns PhysicsRaycastResult
  51011. */
  51012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51013. }
  51014. }
  51015. declare module BABYLON {
  51016. /**
  51017. * Class containing static functions to help procedurally build meshes
  51018. */
  51019. export class RibbonBuilder {
  51020. /**
  51021. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51022. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51023. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51024. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51025. * * 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
  51026. * * 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
  51027. * * 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
  51028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51029. * * 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
  51030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51031. * * 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
  51032. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51033. * * 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
  51034. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51036. * @param name defines the name of the mesh
  51037. * @param options defines the options used to create the mesh
  51038. * @param scene defines the hosting scene
  51039. * @returns the ribbon mesh
  51040. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51042. */
  51043. static CreateRibbon(name: string, options: {
  51044. pathArray: Vector3[][];
  51045. closeArray?: boolean;
  51046. closePath?: boolean;
  51047. offset?: number;
  51048. updatable?: boolean;
  51049. sideOrientation?: number;
  51050. frontUVs?: Vector4;
  51051. backUVs?: Vector4;
  51052. instance?: Mesh;
  51053. invertUV?: boolean;
  51054. uvs?: Vector2[];
  51055. colors?: Color4[];
  51056. }, scene?: Nullable<Scene>): Mesh;
  51057. }
  51058. }
  51059. declare module BABYLON {
  51060. /**
  51061. * Class containing static functions to help procedurally build meshes
  51062. */
  51063. export class ShapeBuilder {
  51064. /**
  51065. * 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.
  51066. * * 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.
  51067. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51068. * * 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.
  51069. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51070. * * 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
  51071. * * 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
  51072. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51074. * * 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
  51075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51077. * @param name defines the name of the mesh
  51078. * @param options defines the options used to create the mesh
  51079. * @param scene defines the hosting scene
  51080. * @returns the extruded shape mesh
  51081. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51083. */
  51084. static ExtrudeShape(name: string, options: {
  51085. shape: Vector3[];
  51086. path: Vector3[];
  51087. scale?: number;
  51088. rotation?: number;
  51089. cap?: number;
  51090. updatable?: boolean;
  51091. sideOrientation?: number;
  51092. frontUVs?: Vector4;
  51093. backUVs?: Vector4;
  51094. instance?: Mesh;
  51095. invertUV?: boolean;
  51096. }, scene?: Nullable<Scene>): Mesh;
  51097. /**
  51098. * Creates an custom extruded shape mesh.
  51099. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51100. * * 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.
  51101. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51102. * * 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
  51103. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51104. * * 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
  51105. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51106. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51107. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51108. * * 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
  51109. * * 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
  51110. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51112. * * 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
  51113. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51115. * @param name defines the name of the mesh
  51116. * @param options defines the options used to create the mesh
  51117. * @param scene defines the hosting scene
  51118. * @returns the custom extruded shape mesh
  51119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51122. */
  51123. static ExtrudeShapeCustom(name: string, options: {
  51124. shape: Vector3[];
  51125. path: Vector3[];
  51126. scaleFunction?: any;
  51127. rotationFunction?: any;
  51128. ribbonCloseArray?: boolean;
  51129. ribbonClosePath?: boolean;
  51130. cap?: number;
  51131. updatable?: boolean;
  51132. sideOrientation?: number;
  51133. frontUVs?: Vector4;
  51134. backUVs?: Vector4;
  51135. instance?: Mesh;
  51136. invertUV?: boolean;
  51137. }, scene?: Nullable<Scene>): Mesh;
  51138. private static _ExtrudeShapeGeneric;
  51139. }
  51140. }
  51141. declare module BABYLON {
  51142. /**
  51143. * AmmoJS Physics plugin
  51144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51145. * @see https://github.com/kripken/ammo.js/
  51146. */
  51147. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51148. private _useDeltaForWorldStep;
  51149. /**
  51150. * Reference to the Ammo library
  51151. */
  51152. bjsAMMO: any;
  51153. /**
  51154. * Created ammoJS world which physics bodies are added to
  51155. */
  51156. world: any;
  51157. /**
  51158. * Name of the plugin
  51159. */
  51160. name: string;
  51161. private _timeStep;
  51162. private _fixedTimeStep;
  51163. private _maxSteps;
  51164. private _tmpQuaternion;
  51165. private _tmpAmmoTransform;
  51166. private _tmpAmmoQuaternion;
  51167. private _tmpAmmoConcreteContactResultCallback;
  51168. private _collisionConfiguration;
  51169. private _dispatcher;
  51170. private _overlappingPairCache;
  51171. private _solver;
  51172. private _softBodySolver;
  51173. private _tmpAmmoVectorA;
  51174. private _tmpAmmoVectorB;
  51175. private _tmpAmmoVectorC;
  51176. private _tmpAmmoVectorD;
  51177. private _tmpContactCallbackResult;
  51178. private _tmpAmmoVectorRCA;
  51179. private _tmpAmmoVectorRCB;
  51180. private _raycastResult;
  51181. private static readonly DISABLE_COLLISION_FLAG;
  51182. private static readonly KINEMATIC_FLAG;
  51183. private static readonly DISABLE_DEACTIVATION_FLAG;
  51184. /**
  51185. * Initializes the ammoJS plugin
  51186. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51187. * @param ammoInjection can be used to inject your own ammo reference
  51188. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51189. */
  51190. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51191. /**
  51192. * Sets the gravity of the physics world (m/(s^2))
  51193. * @param gravity Gravity to set
  51194. */
  51195. setGravity(gravity: Vector3): void;
  51196. /**
  51197. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51198. * @param timeStep timestep to use in seconds
  51199. */
  51200. setTimeStep(timeStep: number): void;
  51201. /**
  51202. * 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)
  51203. * @param fixedTimeStep fixedTimeStep to use in seconds
  51204. */
  51205. setFixedTimeStep(fixedTimeStep: number): void;
  51206. /**
  51207. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51208. * @param maxSteps the maximum number of steps by the physics engine per frame
  51209. */
  51210. setMaxSteps(maxSteps: number): void;
  51211. /**
  51212. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51213. * @returns the current timestep in seconds
  51214. */
  51215. getTimeStep(): number;
  51216. private _isImpostorInContact;
  51217. private _isImpostorPairInContact;
  51218. private _stepSimulation;
  51219. /**
  51220. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51221. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51222. * After the step the babylon meshes are set to the position of the physics imposters
  51223. * @param delta amount of time to step forward
  51224. * @param impostors array of imposters to update before/after the step
  51225. */
  51226. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51227. /**
  51228. * Update babylon mesh to match physics world object
  51229. * @param impostor imposter to match
  51230. */
  51231. private _afterSoftStep;
  51232. /**
  51233. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51234. * @param impostor imposter to match
  51235. */
  51236. private _ropeStep;
  51237. /**
  51238. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51239. * @param impostor imposter to match
  51240. */
  51241. private _softbodyOrClothStep;
  51242. private _tmpVector;
  51243. private _tmpMatrix;
  51244. /**
  51245. * Applies an impulse on the imposter
  51246. * @param impostor imposter to apply impulse to
  51247. * @param force amount of force to be applied to the imposter
  51248. * @param contactPoint the location to apply the impulse on the imposter
  51249. */
  51250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51251. /**
  51252. * Applies a force on the imposter
  51253. * @param impostor imposter to apply force
  51254. * @param force amount of force to be applied to the imposter
  51255. * @param contactPoint the location to apply the force on the imposter
  51256. */
  51257. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51258. /**
  51259. * Creates a physics body using the plugin
  51260. * @param impostor the imposter to create the physics body on
  51261. */
  51262. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51263. /**
  51264. * Removes the physics body from the imposter and disposes of the body's memory
  51265. * @param impostor imposter to remove the physics body from
  51266. */
  51267. removePhysicsBody(impostor: PhysicsImpostor): void;
  51268. /**
  51269. * Generates a joint
  51270. * @param impostorJoint the imposter joint to create the joint with
  51271. */
  51272. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51273. /**
  51274. * Removes a joint
  51275. * @param impostorJoint the imposter joint to remove the joint from
  51276. */
  51277. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51278. private _addMeshVerts;
  51279. /**
  51280. * Initialise the soft body vertices to match its object's (mesh) vertices
  51281. * Softbody vertices (nodes) are in world space and to match this
  51282. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51283. * @param impostor to create the softbody for
  51284. */
  51285. private _softVertexData;
  51286. /**
  51287. * Create an impostor's soft body
  51288. * @param impostor to create the softbody for
  51289. */
  51290. private _createSoftbody;
  51291. /**
  51292. * Create cloth for an impostor
  51293. * @param impostor to create the softbody for
  51294. */
  51295. private _createCloth;
  51296. /**
  51297. * Create rope for an impostor
  51298. * @param impostor to create the softbody for
  51299. */
  51300. private _createRope;
  51301. private _addHullVerts;
  51302. private _createShape;
  51303. /**
  51304. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51305. * @param impostor imposter containing the physics body and babylon object
  51306. */
  51307. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51308. /**
  51309. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51310. * @param impostor imposter containing the physics body and babylon object
  51311. * @param newPosition new position
  51312. * @param newRotation new rotation
  51313. */
  51314. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51315. /**
  51316. * If this plugin is supported
  51317. * @returns true if its supported
  51318. */
  51319. isSupported(): boolean;
  51320. /**
  51321. * Sets the linear velocity of the physics body
  51322. * @param impostor imposter to set the velocity on
  51323. * @param velocity velocity to set
  51324. */
  51325. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51326. /**
  51327. * Sets the angular velocity of the physics body
  51328. * @param impostor imposter to set the velocity on
  51329. * @param velocity velocity to set
  51330. */
  51331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51332. /**
  51333. * gets the linear velocity
  51334. * @param impostor imposter to get linear velocity from
  51335. * @returns linear velocity
  51336. */
  51337. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51338. /**
  51339. * gets the angular velocity
  51340. * @param impostor imposter to get angular velocity from
  51341. * @returns angular velocity
  51342. */
  51343. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51344. /**
  51345. * Sets the mass of physics body
  51346. * @param impostor imposter to set the mass on
  51347. * @param mass mass to set
  51348. */
  51349. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51350. /**
  51351. * Gets the mass of the physics body
  51352. * @param impostor imposter to get the mass from
  51353. * @returns mass
  51354. */
  51355. getBodyMass(impostor: PhysicsImpostor): number;
  51356. /**
  51357. * Gets friction of the impostor
  51358. * @param impostor impostor to get friction from
  51359. * @returns friction value
  51360. */
  51361. getBodyFriction(impostor: PhysicsImpostor): number;
  51362. /**
  51363. * Sets friction of the impostor
  51364. * @param impostor impostor to set friction on
  51365. * @param friction friction value
  51366. */
  51367. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51368. /**
  51369. * Gets restitution of the impostor
  51370. * @param impostor impostor to get restitution from
  51371. * @returns restitution value
  51372. */
  51373. getBodyRestitution(impostor: PhysicsImpostor): number;
  51374. /**
  51375. * Sets resitution of the impostor
  51376. * @param impostor impostor to set resitution on
  51377. * @param restitution resitution value
  51378. */
  51379. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51380. /**
  51381. * Gets pressure inside the impostor
  51382. * @param impostor impostor to get pressure from
  51383. * @returns pressure value
  51384. */
  51385. getBodyPressure(impostor: PhysicsImpostor): number;
  51386. /**
  51387. * Sets pressure inside a soft body impostor
  51388. * Cloth and rope must remain 0 pressure
  51389. * @param impostor impostor to set pressure on
  51390. * @param pressure pressure value
  51391. */
  51392. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51393. /**
  51394. * Gets stiffness of the impostor
  51395. * @param impostor impostor to get stiffness from
  51396. * @returns pressure value
  51397. */
  51398. getBodyStiffness(impostor: PhysicsImpostor): number;
  51399. /**
  51400. * Sets stiffness of the impostor
  51401. * @param impostor impostor to set stiffness on
  51402. * @param stiffness stiffness value from 0 to 1
  51403. */
  51404. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51405. /**
  51406. * Gets velocityIterations of the impostor
  51407. * @param impostor impostor to get velocity iterations from
  51408. * @returns velocityIterations value
  51409. */
  51410. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51411. /**
  51412. * Sets velocityIterations of the impostor
  51413. * @param impostor impostor to set velocity iterations on
  51414. * @param velocityIterations velocityIterations value
  51415. */
  51416. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51417. /**
  51418. * Gets positionIterations of the impostor
  51419. * @param impostor impostor to get position iterations from
  51420. * @returns positionIterations value
  51421. */
  51422. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51423. /**
  51424. * Sets positionIterations of the impostor
  51425. * @param impostor impostor to set position on
  51426. * @param positionIterations positionIterations value
  51427. */
  51428. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51429. /**
  51430. * Append an anchor to a cloth object
  51431. * @param impostor is the cloth impostor to add anchor to
  51432. * @param otherImpostor is the rigid impostor to anchor to
  51433. * @param width ratio across width from 0 to 1
  51434. * @param height ratio up height from 0 to 1
  51435. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51436. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51437. */
  51438. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51439. /**
  51440. * Append an hook to a rope object
  51441. * @param impostor is the rope impostor to add hook to
  51442. * @param otherImpostor is the rigid impostor to hook to
  51443. * @param length ratio along the rope from 0 to 1
  51444. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51445. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51446. */
  51447. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51448. /**
  51449. * Sleeps the physics body and stops it from being active
  51450. * @param impostor impostor to sleep
  51451. */
  51452. sleepBody(impostor: PhysicsImpostor): void;
  51453. /**
  51454. * Activates the physics body
  51455. * @param impostor impostor to activate
  51456. */
  51457. wakeUpBody(impostor: PhysicsImpostor): void;
  51458. /**
  51459. * Updates the distance parameters of the joint
  51460. * @param joint joint to update
  51461. * @param maxDistance maximum distance of the joint
  51462. * @param minDistance minimum distance of the joint
  51463. */
  51464. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51465. /**
  51466. * Sets a motor on the joint
  51467. * @param joint joint to set motor on
  51468. * @param speed speed of the motor
  51469. * @param maxForce maximum force of the motor
  51470. * @param motorIndex index of the motor
  51471. */
  51472. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51473. /**
  51474. * Sets the motors limit
  51475. * @param joint joint to set limit on
  51476. * @param upperLimit upper limit
  51477. * @param lowerLimit lower limit
  51478. */
  51479. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51480. /**
  51481. * Syncs the position and rotation of a mesh with the impostor
  51482. * @param mesh mesh to sync
  51483. * @param impostor impostor to update the mesh with
  51484. */
  51485. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51486. /**
  51487. * Gets the radius of the impostor
  51488. * @param impostor impostor to get radius from
  51489. * @returns the radius
  51490. */
  51491. getRadius(impostor: PhysicsImpostor): number;
  51492. /**
  51493. * Gets the box size of the impostor
  51494. * @param impostor impostor to get box size from
  51495. * @param result the resulting box size
  51496. */
  51497. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51498. /**
  51499. * Disposes of the impostor
  51500. */
  51501. dispose(): void;
  51502. /**
  51503. * Does a raycast in the physics world
  51504. * @param from when should the ray start?
  51505. * @param to when should the ray end?
  51506. * @returns PhysicsRaycastResult
  51507. */
  51508. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51509. }
  51510. }
  51511. declare module BABYLON {
  51512. interface AbstractScene {
  51513. /**
  51514. * The list of reflection probes added to the scene
  51515. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51516. */
  51517. reflectionProbes: Array<ReflectionProbe>;
  51518. /**
  51519. * Removes the given reflection probe from this scene.
  51520. * @param toRemove The reflection probe to remove
  51521. * @returns The index of the removed reflection probe
  51522. */
  51523. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51524. /**
  51525. * Adds the given reflection probe to this scene.
  51526. * @param newReflectionProbe The reflection probe to add
  51527. */
  51528. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51529. }
  51530. /**
  51531. * Class used to generate realtime reflection / refraction cube textures
  51532. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51533. */
  51534. export class ReflectionProbe {
  51535. /** defines the name of the probe */
  51536. name: string;
  51537. private _scene;
  51538. private _renderTargetTexture;
  51539. private _projectionMatrix;
  51540. private _viewMatrix;
  51541. private _target;
  51542. private _add;
  51543. private _attachedMesh;
  51544. private _invertYAxis;
  51545. /** Gets or sets probe position (center of the cube map) */
  51546. position: Vector3;
  51547. /**
  51548. * Creates a new reflection probe
  51549. * @param name defines the name of the probe
  51550. * @param size defines the texture resolution (for each face)
  51551. * @param scene defines the hosting scene
  51552. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51553. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51554. */
  51555. constructor(
  51556. /** defines the name of the probe */
  51557. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51558. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51559. samples: number;
  51560. /** Gets or sets the refresh rate to use (on every frame by default) */
  51561. refreshRate: number;
  51562. /**
  51563. * Gets the hosting scene
  51564. * @returns a Scene
  51565. */
  51566. getScene(): Scene;
  51567. /** Gets the internal CubeTexture used to render to */
  51568. readonly cubeTexture: RenderTargetTexture;
  51569. /** Gets the list of meshes to render */
  51570. readonly renderList: Nullable<AbstractMesh[]>;
  51571. /**
  51572. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51573. * @param mesh defines the mesh to attach to
  51574. */
  51575. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51576. /**
  51577. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51578. * @param renderingGroupId The rendering group id corresponding to its index
  51579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51580. */
  51581. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51582. /**
  51583. * Clean all associated resources
  51584. */
  51585. dispose(): void;
  51586. /**
  51587. * Converts the reflection probe information to a readable string for debug purpose.
  51588. * @param fullDetails Supports for multiple levels of logging within scene loading
  51589. * @returns the human readable reflection probe info
  51590. */
  51591. toString(fullDetails?: boolean): string;
  51592. /**
  51593. * Get the class name of the relfection probe.
  51594. * @returns "ReflectionProbe"
  51595. */
  51596. getClassName(): string;
  51597. /**
  51598. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51599. * @returns The JSON representation of the texture
  51600. */
  51601. serialize(): any;
  51602. /**
  51603. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51604. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51605. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51606. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51607. * @returns The parsed reflection probe if successful
  51608. */
  51609. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51610. }
  51611. }
  51612. declare module BABYLON {
  51613. /** @hidden */
  51614. export var _BabylonLoaderRegistered: boolean;
  51615. }
  51616. declare module BABYLON {
  51617. /**
  51618. * The Physically based simple base material of BJS.
  51619. *
  51620. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51621. * It is used as the base class for both the specGloss and metalRough conventions.
  51622. */
  51623. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51624. /**
  51625. * Number of Simultaneous lights allowed on the material.
  51626. */
  51627. maxSimultaneousLights: number;
  51628. /**
  51629. * If sets to true, disables all the lights affecting the material.
  51630. */
  51631. disableLighting: boolean;
  51632. /**
  51633. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51634. */
  51635. environmentTexture: BaseTexture;
  51636. /**
  51637. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51638. */
  51639. invertNormalMapX: boolean;
  51640. /**
  51641. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51642. */
  51643. invertNormalMapY: boolean;
  51644. /**
  51645. * Normal map used in the model.
  51646. */
  51647. normalTexture: BaseTexture;
  51648. /**
  51649. * Emissivie color used to self-illuminate the model.
  51650. */
  51651. emissiveColor: Color3;
  51652. /**
  51653. * Emissivie texture used to self-illuminate the model.
  51654. */
  51655. emissiveTexture: BaseTexture;
  51656. /**
  51657. * Occlusion Channel Strenght.
  51658. */
  51659. occlusionStrength: number;
  51660. /**
  51661. * Occlusion Texture of the material (adding extra occlusion effects).
  51662. */
  51663. occlusionTexture: BaseTexture;
  51664. /**
  51665. * Defines the alpha limits in alpha test mode.
  51666. */
  51667. alphaCutOff: number;
  51668. /**
  51669. * Gets the current double sided mode.
  51670. */
  51671. /**
  51672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51673. */
  51674. doubleSided: boolean;
  51675. /**
  51676. * Stores the pre-calculated light information of a mesh in a texture.
  51677. */
  51678. lightmapTexture: BaseTexture;
  51679. /**
  51680. * If true, the light map contains occlusion information instead of lighting info.
  51681. */
  51682. useLightmapAsShadowmap: boolean;
  51683. /**
  51684. * Instantiates a new PBRMaterial instance.
  51685. *
  51686. * @param name The material name
  51687. * @param scene The scene the material will be use in.
  51688. */
  51689. constructor(name: string, scene: Scene);
  51690. getClassName(): string;
  51691. }
  51692. }
  51693. declare module BABYLON {
  51694. /**
  51695. * The PBR material of BJS following the metal roughness convention.
  51696. *
  51697. * This fits to the PBR convention in the GLTF definition:
  51698. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51699. */
  51700. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51701. /**
  51702. * The base color has two different interpretations depending on the value of metalness.
  51703. * When the material is a metal, the base color is the specific measured reflectance value
  51704. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51705. * of the material.
  51706. */
  51707. baseColor: Color3;
  51708. /**
  51709. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51710. * well as opacity information in the alpha channel.
  51711. */
  51712. baseTexture: BaseTexture;
  51713. /**
  51714. * Specifies the metallic scalar value of the material.
  51715. * Can also be used to scale the metalness values of the metallic texture.
  51716. */
  51717. metallic: number;
  51718. /**
  51719. * Specifies the roughness scalar value of the material.
  51720. * Can also be used to scale the roughness values of the metallic texture.
  51721. */
  51722. roughness: number;
  51723. /**
  51724. * Texture containing both the metallic value in the B channel and the
  51725. * roughness value in the G channel to keep better precision.
  51726. */
  51727. metallicRoughnessTexture: BaseTexture;
  51728. /**
  51729. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51730. *
  51731. * @param name The material name
  51732. * @param scene The scene the material will be use in.
  51733. */
  51734. constructor(name: string, scene: Scene);
  51735. /**
  51736. * Return the currrent class name of the material.
  51737. */
  51738. getClassName(): string;
  51739. /**
  51740. * Makes a duplicate of the current material.
  51741. * @param name - name to use for the new material.
  51742. */
  51743. clone(name: string): PBRMetallicRoughnessMaterial;
  51744. /**
  51745. * Serialize the material to a parsable JSON object.
  51746. */
  51747. serialize(): any;
  51748. /**
  51749. * Parses a JSON object correponding to the serialize function.
  51750. */
  51751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51752. }
  51753. }
  51754. declare module BABYLON {
  51755. /**
  51756. * The PBR material of BJS following the specular glossiness convention.
  51757. *
  51758. * This fits to the PBR convention in the GLTF definition:
  51759. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51760. */
  51761. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51762. /**
  51763. * Specifies the diffuse color of the material.
  51764. */
  51765. diffuseColor: Color3;
  51766. /**
  51767. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51768. * channel.
  51769. */
  51770. diffuseTexture: BaseTexture;
  51771. /**
  51772. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51773. */
  51774. specularColor: Color3;
  51775. /**
  51776. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51777. */
  51778. glossiness: number;
  51779. /**
  51780. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51781. */
  51782. specularGlossinessTexture: BaseTexture;
  51783. /**
  51784. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51785. *
  51786. * @param name The material name
  51787. * @param scene The scene the material will be use in.
  51788. */
  51789. constructor(name: string, scene: Scene);
  51790. /**
  51791. * Return the currrent class name of the material.
  51792. */
  51793. getClassName(): string;
  51794. /**
  51795. * Makes a duplicate of the current material.
  51796. * @param name - name to use for the new material.
  51797. */
  51798. clone(name: string): PBRSpecularGlossinessMaterial;
  51799. /**
  51800. * Serialize the material to a parsable JSON object.
  51801. */
  51802. serialize(): any;
  51803. /**
  51804. * Parses a JSON object correponding to the serialize function.
  51805. */
  51806. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51812. * It can help converting any input color in a desired output one. This can then be used to create effects
  51813. * from sepia, black and white to sixties or futuristic rendering...
  51814. *
  51815. * The only supported format is currently 3dl.
  51816. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51817. */
  51818. export class ColorGradingTexture extends BaseTexture {
  51819. /**
  51820. * The current texture matrix. (will always be identity in color grading texture)
  51821. */
  51822. private _textureMatrix;
  51823. /**
  51824. * The texture URL.
  51825. */
  51826. url: string;
  51827. /**
  51828. * Empty line regex stored for GC.
  51829. */
  51830. private static _noneEmptyLineRegex;
  51831. private _engine;
  51832. /**
  51833. * Instantiates a ColorGradingTexture from the following parameters.
  51834. *
  51835. * @param url The location of the color gradind data (currently only supporting 3dl)
  51836. * @param scene The scene the texture will be used in
  51837. */
  51838. constructor(url: string, scene: Scene);
  51839. /**
  51840. * Returns the texture matrix used in most of the material.
  51841. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51842. */
  51843. getTextureMatrix(): Matrix;
  51844. /**
  51845. * Occurs when the file being loaded is a .3dl LUT file.
  51846. */
  51847. private load3dlTexture;
  51848. /**
  51849. * Starts the loading process of the texture.
  51850. */
  51851. private loadTexture;
  51852. /**
  51853. * Clones the color gradind texture.
  51854. */
  51855. clone(): ColorGradingTexture;
  51856. /**
  51857. * Called during delayed load for textures.
  51858. */
  51859. delayLoad(): void;
  51860. /**
  51861. * Parses a color grading texture serialized by Babylon.
  51862. * @param parsedTexture The texture information being parsedTexture
  51863. * @param scene The scene to load the texture in
  51864. * @param rootUrl The root url of the data assets to load
  51865. * @return A color gradind texture
  51866. */
  51867. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51868. /**
  51869. * Serializes the LUT texture to json format.
  51870. */
  51871. serialize(): any;
  51872. }
  51873. }
  51874. declare module BABYLON {
  51875. /**
  51876. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51877. */
  51878. export class EquiRectangularCubeTexture extends BaseTexture {
  51879. /** The six faces of the cube. */
  51880. private static _FacesMapping;
  51881. private _noMipmap;
  51882. private _onLoad;
  51883. private _onError;
  51884. /** The size of the cubemap. */
  51885. private _size;
  51886. /** The buffer of the image. */
  51887. private _buffer;
  51888. /** The width of the input image. */
  51889. private _width;
  51890. /** The height of the input image. */
  51891. private _height;
  51892. /** The URL to the image. */
  51893. url: string;
  51894. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51895. coordinatesMode: number;
  51896. /**
  51897. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51898. * @param url The location of the image
  51899. * @param scene The scene the texture will be used in
  51900. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51901. * @param noMipmap Forces to not generate the mipmap if true
  51902. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51903. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51904. * @param onLoad — defines a callback called when texture is loaded
  51905. * @param onError — defines a callback called if there is an error
  51906. */
  51907. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51908. /**
  51909. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51910. */
  51911. private loadImage;
  51912. /**
  51913. * Convert the image buffer into a cubemap and create a CubeTexture.
  51914. */
  51915. private loadTexture;
  51916. /**
  51917. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51918. * @param buffer The ArrayBuffer that should be converted.
  51919. * @returns The buffer as Float32Array.
  51920. */
  51921. private getFloat32ArrayFromArrayBuffer;
  51922. /**
  51923. * Get the current class name of the texture useful for serialization or dynamic coding.
  51924. * @returns "EquiRectangularCubeTexture"
  51925. */
  51926. getClassName(): string;
  51927. /**
  51928. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51929. * @returns A clone of the current EquiRectangularCubeTexture.
  51930. */
  51931. clone(): EquiRectangularCubeTexture;
  51932. }
  51933. }
  51934. declare module BABYLON {
  51935. /**
  51936. * Based on jsTGALoader - Javascript loader for TGA file
  51937. * By Vincent Thibault
  51938. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51939. */
  51940. export class TGATools {
  51941. private static _TYPE_INDEXED;
  51942. private static _TYPE_RGB;
  51943. private static _TYPE_GREY;
  51944. private static _TYPE_RLE_INDEXED;
  51945. private static _TYPE_RLE_RGB;
  51946. private static _TYPE_RLE_GREY;
  51947. private static _ORIGIN_MASK;
  51948. private static _ORIGIN_SHIFT;
  51949. private static _ORIGIN_BL;
  51950. private static _ORIGIN_BR;
  51951. private static _ORIGIN_UL;
  51952. private static _ORIGIN_UR;
  51953. /**
  51954. * Gets the header of a TGA file
  51955. * @param data defines the TGA data
  51956. * @returns the header
  51957. */
  51958. static GetTGAHeader(data: Uint8Array): any;
  51959. /**
  51960. * Uploads TGA content to a Babylon Texture
  51961. * @hidden
  51962. */
  51963. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51964. /** @hidden */
  51965. 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;
  51966. /** @hidden */
  51967. 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;
  51968. /** @hidden */
  51969. 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;
  51970. /** @hidden */
  51971. 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;
  51972. /** @hidden */
  51973. 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;
  51974. /** @hidden */
  51975. 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;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * Implementation of the TGA Texture Loader.
  51981. * @hidden
  51982. */
  51983. export class _TGATextureLoader implements IInternalTextureLoader {
  51984. /**
  51985. * Defines wether the loader supports cascade loading the different faces.
  51986. */
  51987. readonly supportCascades: boolean;
  51988. /**
  51989. * This returns if the loader support the current file information.
  51990. * @param extension defines the file extension of the file being loaded
  51991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51992. * @param fallback defines the fallback internal texture if any
  51993. * @param isBase64 defines whether the texture is encoded as a base64
  51994. * @param isBuffer defines whether the texture data are stored as a buffer
  51995. * @returns true if the loader can load the specified file
  51996. */
  51997. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51998. /**
  51999. * Transform the url before loading if required.
  52000. * @param rootUrl the url of the texture
  52001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52002. * @returns the transformed texture
  52003. */
  52004. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52005. /**
  52006. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52007. * @param rootUrl the url of the texture
  52008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52009. * @returns the fallback texture
  52010. */
  52011. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52012. /**
  52013. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52014. * @param data contains the texture data
  52015. * @param texture defines the BabylonJS internal texture
  52016. * @param createPolynomials will be true if polynomials have been requested
  52017. * @param onLoad defines the callback to trigger once the texture is ready
  52018. * @param onError defines the callback to trigger in case of error
  52019. */
  52020. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52021. /**
  52022. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52023. * @param data contains the texture data
  52024. * @param texture defines the BabylonJS internal texture
  52025. * @param callback defines the method to call once ready to upload
  52026. */
  52027. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52028. }
  52029. }
  52030. declare module BABYLON {
  52031. /**
  52032. * Info about the .basis files
  52033. */
  52034. class BasisFileInfo {
  52035. /**
  52036. * If the file has alpha
  52037. */
  52038. hasAlpha: boolean;
  52039. /**
  52040. * Info about each image of the basis file
  52041. */
  52042. images: Array<{
  52043. levels: Array<{
  52044. width: number;
  52045. height: number;
  52046. transcodedPixels: ArrayBufferView;
  52047. }>;
  52048. }>;
  52049. }
  52050. /**
  52051. * Result of transcoding a basis file
  52052. */
  52053. class TranscodeResult {
  52054. /**
  52055. * Info about the .basis file
  52056. */
  52057. fileInfo: BasisFileInfo;
  52058. /**
  52059. * Format to use when loading the file
  52060. */
  52061. format: number;
  52062. }
  52063. /**
  52064. * Configuration options for the Basis transcoder
  52065. */
  52066. export class BasisTranscodeConfiguration {
  52067. /**
  52068. * Supported compression formats used to determine the supported output format of the transcoder
  52069. */
  52070. supportedCompressionFormats?: {
  52071. /**
  52072. * etc1 compression format
  52073. */
  52074. etc1?: boolean;
  52075. /**
  52076. * s3tc compression format
  52077. */
  52078. s3tc?: boolean;
  52079. /**
  52080. * pvrtc compression format
  52081. */
  52082. pvrtc?: boolean;
  52083. /**
  52084. * etc2 compression format
  52085. */
  52086. etc2?: boolean;
  52087. };
  52088. /**
  52089. * If mipmap levels should be loaded for transcoded images (Default: true)
  52090. */
  52091. loadMipmapLevels?: boolean;
  52092. /**
  52093. * Index of a single image to load (Default: all images)
  52094. */
  52095. loadSingleImage?: number;
  52096. }
  52097. /**
  52098. * Used to load .Basis files
  52099. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52100. */
  52101. export class BasisTools {
  52102. private static _IgnoreSupportedFormats;
  52103. /**
  52104. * URL to use when loading the basis transcoder
  52105. */
  52106. static JSModuleURL: string;
  52107. /**
  52108. * URL to use when loading the wasm module for the transcoder
  52109. */
  52110. static WasmModuleURL: string;
  52111. /**
  52112. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52113. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52114. * @returns internal format corresponding to the Basis format
  52115. */
  52116. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52117. private static _WorkerPromise;
  52118. private static _Worker;
  52119. private static _actionId;
  52120. private static _CreateWorkerAsync;
  52121. /**
  52122. * Transcodes a loaded image file to compressed pixel data
  52123. * @param imageData image data to transcode
  52124. * @param config configuration options for the transcoding
  52125. * @returns a promise resulting in the transcoded image
  52126. */
  52127. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52128. /**
  52129. * Loads a texture from the transcode result
  52130. * @param texture texture load to
  52131. * @param transcodeResult the result of transcoding the basis file to load from
  52132. */
  52133. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52134. }
  52135. }
  52136. declare module BABYLON {
  52137. /**
  52138. * Loader for .basis file format
  52139. */
  52140. export class _BasisTextureLoader implements IInternalTextureLoader {
  52141. /**
  52142. * Defines whether the loader supports cascade loading the different faces.
  52143. */
  52144. readonly supportCascades: boolean;
  52145. /**
  52146. * This returns if the loader support the current file information.
  52147. * @param extension defines the file extension of the file being loaded
  52148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52149. * @param fallback defines the fallback internal texture if any
  52150. * @param isBase64 defines whether the texture is encoded as a base64
  52151. * @param isBuffer defines whether the texture data are stored as a buffer
  52152. * @returns true if the loader can load the specified file
  52153. */
  52154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52155. /**
  52156. * Transform the url before loading if required.
  52157. * @param rootUrl the url of the texture
  52158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52159. * @returns the transformed texture
  52160. */
  52161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52162. /**
  52163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52164. * @param rootUrl the url of the texture
  52165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52166. * @returns the fallback texture
  52167. */
  52168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52169. /**
  52170. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52171. * @param data contains the texture data
  52172. * @param texture defines the BabylonJS internal texture
  52173. * @param createPolynomials will be true if polynomials have been requested
  52174. * @param onLoad defines the callback to trigger once the texture is ready
  52175. * @param onError defines the callback to trigger in case of error
  52176. */
  52177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52178. /**
  52179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52180. * @param data contains the texture data
  52181. * @param texture defines the BabylonJS internal texture
  52182. * @param callback defines the method to call once ready to upload
  52183. */
  52184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52185. }
  52186. }
  52187. declare module BABYLON {
  52188. /**
  52189. * 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.
  52190. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52192. */
  52193. export class CustomProceduralTexture extends ProceduralTexture {
  52194. private _animate;
  52195. private _time;
  52196. private _config;
  52197. private _texturePath;
  52198. /**
  52199. * Instantiates a new Custom Procedural Texture.
  52200. * 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.
  52201. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52203. * @param name Define the name of the texture
  52204. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52205. * @param size Define the size of the texture to create
  52206. * @param scene Define the scene the texture belongs to
  52207. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52208. * @param generateMipMaps Define if the texture should creates mip maps or not
  52209. */
  52210. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52211. private _loadJson;
  52212. /**
  52213. * Is the texture ready to be used ? (rendered at least once)
  52214. * @returns true if ready, otherwise, false.
  52215. */
  52216. isReady(): boolean;
  52217. /**
  52218. * Render the texture to its associated render target.
  52219. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52220. */
  52221. render(useCameraPostProcess?: boolean): void;
  52222. /**
  52223. * Update the list of dependant textures samplers in the shader.
  52224. */
  52225. updateTextures(): void;
  52226. /**
  52227. * Update the uniform values of the procedural texture in the shader.
  52228. */
  52229. updateShaderUniforms(): void;
  52230. /**
  52231. * Define if the texture animates or not.
  52232. */
  52233. animate: boolean;
  52234. }
  52235. }
  52236. declare module BABYLON {
  52237. /** @hidden */
  52238. export var noisePixelShader: {
  52239. name: string;
  52240. shader: string;
  52241. };
  52242. }
  52243. declare module BABYLON {
  52244. /**
  52245. * Class used to generate noise procedural textures
  52246. */
  52247. export class NoiseProceduralTexture extends ProceduralTexture {
  52248. private _time;
  52249. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52250. brightness: number;
  52251. /** Defines the number of octaves to process */
  52252. octaves: number;
  52253. /** Defines the level of persistence (0.8 by default) */
  52254. persistence: number;
  52255. /** Gets or sets animation speed factor (default is 1) */
  52256. animationSpeedFactor: number;
  52257. /**
  52258. * Creates a new NoiseProceduralTexture
  52259. * @param name defines the name fo the texture
  52260. * @param size defines the size of the texture (default is 256)
  52261. * @param scene defines the hosting scene
  52262. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52263. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52264. */
  52265. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52266. private _updateShaderUniforms;
  52267. protected _getDefines(): string;
  52268. /** Generate the current state of the procedural texture */
  52269. render(useCameraPostProcess?: boolean): void;
  52270. /**
  52271. * Serializes this noise procedural texture
  52272. * @returns a serialized noise procedural texture object
  52273. */
  52274. serialize(): any;
  52275. /**
  52276. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52277. * @param parsedTexture defines parsed texture data
  52278. * @param scene defines the current scene
  52279. * @param rootUrl defines the root URL containing noise procedural texture information
  52280. * @returns a parsed NoiseProceduralTexture
  52281. */
  52282. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52283. }
  52284. }
  52285. declare module BABYLON {
  52286. /**
  52287. * Raw cube texture where the raw buffers are passed in
  52288. */
  52289. export class RawCubeTexture extends CubeTexture {
  52290. /**
  52291. * Creates a cube texture where the raw buffers are passed in.
  52292. * @param scene defines the scene the texture is attached to
  52293. * @param data defines the array of data to use to create each face
  52294. * @param size defines the size of the textures
  52295. * @param format defines the format of the data
  52296. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52297. * @param generateMipMaps defines if the engine should generate the mip levels
  52298. * @param invertY defines if data must be stored with Y axis inverted
  52299. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52300. * @param compression defines the compression used (null by default)
  52301. */
  52302. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52303. /**
  52304. * Updates the raw cube texture.
  52305. * @param data defines the data to store
  52306. * @param format defines the data format
  52307. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52308. * @param invertY defines if data must be stored with Y axis inverted
  52309. * @param compression defines the compression used (null by default)
  52310. * @param level defines which level of the texture to update
  52311. */
  52312. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52313. /**
  52314. * Updates a raw cube texture with RGBD encoded data.
  52315. * @param data defines the array of data [mipmap][face] to use to create each face
  52316. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52317. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52318. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52319. * @returns a promsie that resolves when the operation is complete
  52320. */
  52321. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52322. /**
  52323. * Clones the raw cube texture.
  52324. * @return a new cube texture
  52325. */
  52326. clone(): CubeTexture;
  52327. /** @hidden */
  52328. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52329. }
  52330. }
  52331. declare module BABYLON {
  52332. /**
  52333. * Class used to store 3D textures containing user data
  52334. */
  52335. export class RawTexture3D extends Texture {
  52336. /** Gets or sets the texture format to use */
  52337. format: number;
  52338. private _engine;
  52339. /**
  52340. * Create a new RawTexture3D
  52341. * @param data defines the data of the texture
  52342. * @param width defines the width of the texture
  52343. * @param height defines the height of the texture
  52344. * @param depth defines the depth of the texture
  52345. * @param format defines the texture format to use
  52346. * @param scene defines the hosting scene
  52347. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52348. * @param invertY defines if texture must be stored with Y axis inverted
  52349. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52350. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52351. */
  52352. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52353. /** Gets or sets the texture format to use */
  52354. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52355. /**
  52356. * Update the texture with new data
  52357. * @param data defines the data to store in the texture
  52358. */
  52359. update(data: ArrayBufferView): void;
  52360. }
  52361. }
  52362. declare module BABYLON {
  52363. /**
  52364. * Creates a refraction texture used by refraction channel of the standard material.
  52365. * It is like a mirror but to see through a material.
  52366. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52367. */
  52368. export class RefractionTexture extends RenderTargetTexture {
  52369. /**
  52370. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52371. * 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.
  52372. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52373. */
  52374. refractionPlane: Plane;
  52375. /**
  52376. * Define how deep under the surface we should see.
  52377. */
  52378. depth: number;
  52379. /**
  52380. * Creates a refraction texture used by refraction channel of the standard material.
  52381. * It is like a mirror but to see through a material.
  52382. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52383. * @param name Define the texture name
  52384. * @param size Define the size of the underlying texture
  52385. * @param scene Define the scene the refraction belongs to
  52386. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52387. */
  52388. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52389. /**
  52390. * Clone the refraction texture.
  52391. * @returns the cloned texture
  52392. */
  52393. clone(): RefractionTexture;
  52394. /**
  52395. * Serialize the texture to a JSON representation you could use in Parse later on
  52396. * @returns the serialized JSON representation
  52397. */
  52398. serialize(): any;
  52399. }
  52400. }
  52401. declare module BABYLON {
  52402. /**
  52403. * Defines the options related to the creation of an HtmlElementTexture
  52404. */
  52405. export interface IHtmlElementTextureOptions {
  52406. /**
  52407. * Defines wether mip maps should be created or not.
  52408. */
  52409. generateMipMaps?: boolean;
  52410. /**
  52411. * Defines the sampling mode of the texture.
  52412. */
  52413. samplingMode?: number;
  52414. /**
  52415. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52416. */
  52417. engine: Nullable<Engine>;
  52418. /**
  52419. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52420. */
  52421. scene: Nullable<Scene>;
  52422. }
  52423. /**
  52424. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52425. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52426. * is automatically managed.
  52427. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52428. * in your application.
  52429. *
  52430. * As the update is not automatic, you need to call them manually.
  52431. */
  52432. export class HtmlElementTexture extends BaseTexture {
  52433. /**
  52434. * The texture URL.
  52435. */
  52436. element: HTMLVideoElement | HTMLCanvasElement;
  52437. private static readonly DefaultOptions;
  52438. private _textureMatrix;
  52439. private _engine;
  52440. private _isVideo;
  52441. private _generateMipMaps;
  52442. private _samplingMode;
  52443. /**
  52444. * Instantiates a HtmlElementTexture from the following parameters.
  52445. *
  52446. * @param name Defines the name of the texture
  52447. * @param element Defines the video or canvas the texture is filled with
  52448. * @param options Defines the other none mandatory texture creation options
  52449. */
  52450. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52451. private _createInternalTexture;
  52452. /**
  52453. * Returns the texture matrix used in most of the material.
  52454. */
  52455. getTextureMatrix(): Matrix;
  52456. /**
  52457. * Updates the content of the texture.
  52458. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52459. */
  52460. update(invertY?: Nullable<boolean>): void;
  52461. }
  52462. }
  52463. declare module BABYLON {
  52464. /**
  52465. * Enum used to define the target of a block
  52466. */
  52467. export enum NodeMaterialBlockTargets {
  52468. /** Vertex shader */
  52469. Vertex = 1,
  52470. /** Fragment shader */
  52471. Fragment = 2,
  52472. /** Neutral */
  52473. Neutral = 4,
  52474. /** Vertex and Fragment */
  52475. VertexAndFragment = 3
  52476. }
  52477. }
  52478. declare module BABYLON {
  52479. /**
  52480. * Defines the kind of connection point for node based material
  52481. */
  52482. export enum NodeMaterialBlockConnectionPointTypes {
  52483. /** Float */
  52484. Float = 1,
  52485. /** Int */
  52486. Int = 2,
  52487. /** Vector2 */
  52488. Vector2 = 4,
  52489. /** Vector3 */
  52490. Vector3 = 8,
  52491. /** Vector4 */
  52492. Vector4 = 16,
  52493. /** Color3 */
  52494. Color3 = 32,
  52495. /** Color4 */
  52496. Color4 = 64,
  52497. /** Matrix */
  52498. Matrix = 128,
  52499. /** Detect type based on connection */
  52500. AutoDetect = 1024,
  52501. /** Output type that will be defined by input type */
  52502. BasedOnInput = 2048
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /**
  52507. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52508. */
  52509. export enum NodeMaterialBlockConnectionPointMode {
  52510. /** Value is an uniform */
  52511. Uniform = 0,
  52512. /** Value is a mesh attribute */
  52513. Attribute = 1,
  52514. /** Value is a varying between vertex and fragment shaders */
  52515. Varying = 2,
  52516. /** Mode is undefined */
  52517. Undefined = 3
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /**
  52522. * Enum used to define system values e.g. values automatically provided by the system
  52523. */
  52524. export enum NodeMaterialSystemValues {
  52525. /** World */
  52526. World = 1,
  52527. /** View */
  52528. View = 2,
  52529. /** Projection */
  52530. Projection = 3,
  52531. /** ViewProjection */
  52532. ViewProjection = 4,
  52533. /** WorldView */
  52534. WorldView = 5,
  52535. /** WorldViewProjection */
  52536. WorldViewProjection = 6,
  52537. /** CameraPosition */
  52538. CameraPosition = 7,
  52539. /** Fog Color */
  52540. FogColor = 8
  52541. }
  52542. }
  52543. declare module BABYLON {
  52544. /**
  52545. * Root class for all node material optimizers
  52546. */
  52547. export class NodeMaterialOptimizer {
  52548. /**
  52549. * Function used to optimize a NodeMaterial graph
  52550. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52551. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52552. */
  52553. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52559. */
  52560. export class TransformBlock extends NodeMaterialBlock {
  52561. /**
  52562. * Defines the value to use to complement W value to transform it to a Vector4
  52563. */
  52564. complementW: number;
  52565. /**
  52566. * Defines the value to use to complement z value to transform it to a Vector4
  52567. */
  52568. complementZ: number;
  52569. /**
  52570. * Creates a new TransformBlock
  52571. * @param name defines the block name
  52572. */
  52573. constructor(name: string);
  52574. /**
  52575. * Gets the current class name
  52576. * @returns the class name
  52577. */
  52578. getClassName(): string;
  52579. /**
  52580. * Gets the vector input
  52581. */
  52582. readonly vector: NodeMaterialConnectionPoint;
  52583. /**
  52584. * Gets the output component
  52585. */
  52586. readonly output: NodeMaterialConnectionPoint;
  52587. /**
  52588. * Gets the matrix transform input
  52589. */
  52590. readonly transform: NodeMaterialConnectionPoint;
  52591. protected _buildBlock(state: NodeMaterialBuildState): this;
  52592. serialize(): any;
  52593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52594. protected _dumpPropertiesCode(): string;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Block used to output the vertex position
  52600. */
  52601. export class VertexOutputBlock extends NodeMaterialBlock {
  52602. /**
  52603. * Creates a new VertexOutputBlock
  52604. * @param name defines the block name
  52605. */
  52606. constructor(name: string);
  52607. /**
  52608. * Gets the current class name
  52609. * @returns the class name
  52610. */
  52611. getClassName(): string;
  52612. /**
  52613. * Gets the vector input component
  52614. */
  52615. readonly vector: NodeMaterialConnectionPoint;
  52616. protected _buildBlock(state: NodeMaterialBuildState): this;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * Block used to output the final color
  52622. */
  52623. export class FragmentOutputBlock extends NodeMaterialBlock {
  52624. /**
  52625. * Create a new FragmentOutputBlock
  52626. * @param name defines the block name
  52627. */
  52628. constructor(name: string);
  52629. /**
  52630. * Gets the current class name
  52631. * @returns the class name
  52632. */
  52633. getClassName(): string;
  52634. /**
  52635. * Gets the rgba input component
  52636. */
  52637. readonly rgba: NodeMaterialConnectionPoint;
  52638. /**
  52639. * Gets the rgb input component
  52640. */
  52641. readonly rgb: NodeMaterialConnectionPoint;
  52642. /**
  52643. * Gets the a input component
  52644. */
  52645. readonly a: NodeMaterialConnectionPoint;
  52646. protected _buildBlock(state: NodeMaterialBuildState): this;
  52647. }
  52648. }
  52649. declare module BABYLON {
  52650. /**
  52651. * Block used to read a reflection texture from a sampler
  52652. */
  52653. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52654. private _define3DName;
  52655. private _defineCubicName;
  52656. private _defineExplicitName;
  52657. private _defineProjectionName;
  52658. private _defineLocalCubicName;
  52659. private _defineSphericalName;
  52660. private _definePlanarName;
  52661. private _defineEquirectangularName;
  52662. private _defineMirroredEquirectangularFixedName;
  52663. private _defineEquirectangularFixedName;
  52664. private _defineSkyboxName;
  52665. private _cubeSamplerName;
  52666. private _2DSamplerName;
  52667. private _positionUVWName;
  52668. private _directionWName;
  52669. private _reflectionCoordsName;
  52670. private _reflection2DCoordsName;
  52671. private _reflectionColorName;
  52672. private _reflectionMatrixName;
  52673. /**
  52674. * Gets or sets the texture associated with the node
  52675. */
  52676. texture: Nullable<BaseTexture>;
  52677. /**
  52678. * Create a new TextureBlock
  52679. * @param name defines the block name
  52680. */
  52681. constructor(name: string);
  52682. /**
  52683. * Gets the current class name
  52684. * @returns the class name
  52685. */
  52686. getClassName(): string;
  52687. /**
  52688. * Gets the world position input component
  52689. */
  52690. readonly position: NodeMaterialConnectionPoint;
  52691. /**
  52692. * Gets the world position input component
  52693. */
  52694. readonly worldPosition: NodeMaterialConnectionPoint;
  52695. /**
  52696. * Gets the world normal input component
  52697. */
  52698. readonly worldNormal: NodeMaterialConnectionPoint;
  52699. /**
  52700. * Gets the world input component
  52701. */
  52702. readonly world: NodeMaterialConnectionPoint;
  52703. /**
  52704. * Gets the camera (or eye) position component
  52705. */
  52706. readonly cameraPosition: NodeMaterialConnectionPoint;
  52707. /**
  52708. * Gets the view input component
  52709. */
  52710. readonly view: NodeMaterialConnectionPoint;
  52711. /**
  52712. * Gets the rgb output component
  52713. */
  52714. readonly rgb: NodeMaterialConnectionPoint;
  52715. /**
  52716. * Gets the r output component
  52717. */
  52718. readonly r: NodeMaterialConnectionPoint;
  52719. /**
  52720. * Gets the g output component
  52721. */
  52722. readonly g: NodeMaterialConnectionPoint;
  52723. /**
  52724. * Gets the b output component
  52725. */
  52726. readonly b: NodeMaterialConnectionPoint;
  52727. autoConfigure(material: NodeMaterial): void;
  52728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52729. isReady(): boolean;
  52730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52731. private _injectVertexCode;
  52732. private _writeOutput;
  52733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52734. serialize(): any;
  52735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52736. }
  52737. }
  52738. declare module BABYLON {
  52739. /**
  52740. * Interface used to configure the node material editor
  52741. */
  52742. export interface INodeMaterialEditorOptions {
  52743. /** Define the URl to load node editor script */
  52744. editorURL?: string;
  52745. }
  52746. /** @hidden */
  52747. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52748. /** BONES */
  52749. NUM_BONE_INFLUENCERS: number;
  52750. BonesPerMesh: number;
  52751. BONETEXTURE: boolean;
  52752. /** MORPH TARGETS */
  52753. MORPHTARGETS: boolean;
  52754. MORPHTARGETS_NORMAL: boolean;
  52755. MORPHTARGETS_TANGENT: boolean;
  52756. MORPHTARGETS_UV: boolean;
  52757. NUM_MORPH_INFLUENCERS: number;
  52758. /** IMAGE PROCESSING */
  52759. IMAGEPROCESSING: boolean;
  52760. VIGNETTE: boolean;
  52761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52762. VIGNETTEBLENDMODEOPAQUE: boolean;
  52763. TONEMAPPING: boolean;
  52764. TONEMAPPING_ACES: boolean;
  52765. CONTRAST: boolean;
  52766. EXPOSURE: boolean;
  52767. COLORCURVES: boolean;
  52768. COLORGRADING: boolean;
  52769. COLORGRADING3D: boolean;
  52770. SAMPLER3DGREENDEPTH: boolean;
  52771. SAMPLER3DBGRMAP: boolean;
  52772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52773. /** MISC. */
  52774. BUMPDIRECTUV: number;
  52775. constructor();
  52776. setValue(name: string, value: boolean): void;
  52777. }
  52778. /**
  52779. * Class used to configure NodeMaterial
  52780. */
  52781. export interface INodeMaterialOptions {
  52782. /**
  52783. * Defines if blocks should emit comments
  52784. */
  52785. emitComments: boolean;
  52786. }
  52787. /**
  52788. * Class used to create a node based material built by assembling shader blocks
  52789. */
  52790. export class NodeMaterial extends PushMaterial {
  52791. private static _BuildIdGenerator;
  52792. private _options;
  52793. private _vertexCompilationState;
  52794. private _fragmentCompilationState;
  52795. private _sharedData;
  52796. private _buildId;
  52797. private _buildWasSuccessful;
  52798. private _cachedWorldViewMatrix;
  52799. private _cachedWorldViewProjectionMatrix;
  52800. private _optimizers;
  52801. private _animationFrame;
  52802. /** Define the URl to load node editor script */
  52803. static EditorURL: string;
  52804. private BJSNODEMATERIALEDITOR;
  52805. /** Get the inspector from bundle or global */
  52806. private _getGlobalNodeMaterialEditor;
  52807. /**
  52808. * 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)
  52809. */
  52810. ignoreAlpha: boolean;
  52811. /**
  52812. * Defines the maximum number of lights that can be used in the material
  52813. */
  52814. maxSimultaneousLights: number;
  52815. /**
  52816. * Observable raised when the material is built
  52817. */
  52818. onBuildObservable: Observable<NodeMaterial>;
  52819. /**
  52820. * Gets or sets the root nodes of the material vertex shader
  52821. */
  52822. _vertexOutputNodes: NodeMaterialBlock[];
  52823. /**
  52824. * Gets or sets the root nodes of the material fragment (pixel) shader
  52825. */
  52826. _fragmentOutputNodes: NodeMaterialBlock[];
  52827. /** Gets or sets options to control the node material overall behavior */
  52828. options: INodeMaterialOptions;
  52829. /**
  52830. * Default configuration related to image processing available in the standard Material.
  52831. */
  52832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52833. /**
  52834. * Gets the image processing configuration used either in this material.
  52835. */
  52836. /**
  52837. * Sets the Default image processing configuration used either in the this material.
  52838. *
  52839. * If sets to null, the scene one is in use.
  52840. */
  52841. imageProcessingConfiguration: ImageProcessingConfiguration;
  52842. /**
  52843. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52844. */
  52845. attachedBlocks: NodeMaterialBlock[];
  52846. /**
  52847. * Create a new node based material
  52848. * @param name defines the material name
  52849. * @param scene defines the hosting scene
  52850. * @param options defines creation option
  52851. */
  52852. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52853. /**
  52854. * Gets the current class name of the material e.g. "NodeMaterial"
  52855. * @returns the class name
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Keep track of the image processing observer to allow dispose and replace.
  52860. */
  52861. private _imageProcessingObserver;
  52862. /**
  52863. * Attaches a new image processing configuration to the Standard Material.
  52864. * @param configuration
  52865. */
  52866. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52867. /**
  52868. * Get a block by its name
  52869. * @param name defines the name of the block to retrieve
  52870. * @returns the required block or null if not found
  52871. */
  52872. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52873. /**
  52874. * Get a block by its name
  52875. * @param predicate defines the predicate used to find the good candidate
  52876. * @returns the required block or null if not found
  52877. */
  52878. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52879. /**
  52880. * Get an input block by its name
  52881. * @param predicate defines the predicate used to find the good candidate
  52882. * @returns the required input block or null if not found
  52883. */
  52884. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52885. /**
  52886. * Gets the list of input blocks attached to this material
  52887. * @returns an array of InputBlocks
  52888. */
  52889. getInputBlocks(): InputBlock[];
  52890. /**
  52891. * Adds a new optimizer to the list of optimizers
  52892. * @param optimizer defines the optimizers to add
  52893. * @returns the current material
  52894. */
  52895. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52896. /**
  52897. * Remove an optimizer from the list of optimizers
  52898. * @param optimizer defines the optimizers to remove
  52899. * @returns the current material
  52900. */
  52901. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52902. /**
  52903. * Add a new block to the list of output nodes
  52904. * @param node defines the node to add
  52905. * @returns the current material
  52906. */
  52907. addOutputNode(node: NodeMaterialBlock): this;
  52908. /**
  52909. * Remove a block from the list of root nodes
  52910. * @param node defines the node to remove
  52911. * @returns the current material
  52912. */
  52913. removeOutputNode(node: NodeMaterialBlock): this;
  52914. private _addVertexOutputNode;
  52915. private _removeVertexOutputNode;
  52916. private _addFragmentOutputNode;
  52917. private _removeFragmentOutputNode;
  52918. /**
  52919. * Specifies if the material will require alpha blending
  52920. * @returns a boolean specifying if alpha blending is needed
  52921. */
  52922. needAlphaBlending(): boolean;
  52923. /**
  52924. * Specifies if this material should be rendered in alpha test mode
  52925. * @returns a boolean specifying if an alpha test is needed.
  52926. */
  52927. needAlphaTesting(): boolean;
  52928. private _initializeBlock;
  52929. private _resetDualBlocks;
  52930. /**
  52931. * Build the material and generates the inner effect
  52932. * @param verbose defines if the build should log activity
  52933. */
  52934. build(verbose?: boolean): void;
  52935. /**
  52936. * Runs an otpimization phase to try to improve the shader code
  52937. */
  52938. optimize(): void;
  52939. private _prepareDefinesForAttributes;
  52940. /**
  52941. * Get if the submesh is ready to be used and all its information available.
  52942. * Child classes can use it to update shaders
  52943. * @param mesh defines the mesh to check
  52944. * @param subMesh defines which submesh to check
  52945. * @param useInstances specifies that instances should be used
  52946. * @returns a boolean indicating that the submesh is ready or not
  52947. */
  52948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52949. /**
  52950. * Get a string representing the shaders built by the current node graph
  52951. */
  52952. readonly compiledShaders: string;
  52953. /**
  52954. * Binds the world matrix to the material
  52955. * @param world defines the world transformation matrix
  52956. */
  52957. bindOnlyWorldMatrix(world: Matrix): void;
  52958. /**
  52959. * Binds the submesh to this material by preparing the effect and shader to draw
  52960. * @param world defines the world transformation matrix
  52961. * @param mesh defines the mesh containing the submesh
  52962. * @param subMesh defines the submesh to bind the material to
  52963. */
  52964. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52965. /**
  52966. * Gets the active textures from the material
  52967. * @returns an array of textures
  52968. */
  52969. getActiveTextures(): BaseTexture[];
  52970. /**
  52971. * Gets the list of texture blocks
  52972. * @returns an array of texture blocks
  52973. */
  52974. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52975. /**
  52976. * Specifies if the material uses a texture
  52977. * @param texture defines the texture to check against the material
  52978. * @returns a boolean specifying if the material uses the texture
  52979. */
  52980. hasTexture(texture: BaseTexture): boolean;
  52981. /**
  52982. * Disposes the material
  52983. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52984. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52985. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52986. */
  52987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52988. /** Creates the node editor window. */
  52989. private _createNodeEditor;
  52990. /**
  52991. * Launch the node material editor
  52992. * @param config Define the configuration of the editor
  52993. * @return a promise fulfilled when the node editor is visible
  52994. */
  52995. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52996. /**
  52997. * Clear the current material
  52998. */
  52999. clear(): void;
  53000. /**
  53001. * Clear the current material and set it to a default state
  53002. */
  53003. setToDefault(): void;
  53004. /**
  53005. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53006. * @param url defines the url to load from
  53007. * @returns a promise that will fullfil when the material is fully loaded
  53008. */
  53009. loadAsync(url: string): Promise<unknown>;
  53010. private _gatherBlocks;
  53011. /**
  53012. * Generate a string containing the code declaration required to create an equivalent of this material
  53013. * @returns a string
  53014. */
  53015. generateCode(): string;
  53016. /**
  53017. * Serializes this material in a JSON representation
  53018. * @returns the serialized material object
  53019. */
  53020. serialize(): any;
  53021. private _restoreConnections;
  53022. /**
  53023. * Clear the current graph and load a new one from a serialization object
  53024. * @param source defines the JSON representation of the material
  53025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53026. */
  53027. loadFromSerialization(source: any, rootUrl?: string): void;
  53028. /**
  53029. * Creates a node material from parsed material data
  53030. * @param source defines the JSON representation of the material
  53031. * @param scene defines the hosting scene
  53032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53033. * @returns a new node material
  53034. */
  53035. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53036. /**
  53037. * Creates a new node material set to default basic configuration
  53038. * @param name defines the name of the material
  53039. * @param scene defines the hosting scene
  53040. * @returns a new NodeMaterial
  53041. */
  53042. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53043. }
  53044. }
  53045. declare module BABYLON {
  53046. /**
  53047. * Block used to read a texture from a sampler
  53048. */
  53049. export class TextureBlock extends NodeMaterialBlock {
  53050. private _defineName;
  53051. private _samplerName;
  53052. private _transformedUVName;
  53053. private _textureTransformName;
  53054. private _textureInfoName;
  53055. private _mainUVName;
  53056. private _mainUVDefineName;
  53057. /**
  53058. * Gets or sets the texture associated with the node
  53059. */
  53060. texture: Nullable<Texture>;
  53061. /**
  53062. * Create a new TextureBlock
  53063. * @param name defines the block name
  53064. */
  53065. constructor(name: string);
  53066. /**
  53067. * Gets the current class name
  53068. * @returns the class name
  53069. */
  53070. getClassName(): string;
  53071. /**
  53072. * Gets the uv input component
  53073. */
  53074. readonly uv: NodeMaterialConnectionPoint;
  53075. /**
  53076. * Gets the rgba output component
  53077. */
  53078. readonly rgba: NodeMaterialConnectionPoint;
  53079. /**
  53080. * Gets the rgb output component
  53081. */
  53082. readonly rgb: NodeMaterialConnectionPoint;
  53083. /**
  53084. * Gets the r output component
  53085. */
  53086. readonly r: NodeMaterialConnectionPoint;
  53087. /**
  53088. * Gets the g output component
  53089. */
  53090. readonly g: NodeMaterialConnectionPoint;
  53091. /**
  53092. * Gets the b output component
  53093. */
  53094. readonly b: NodeMaterialConnectionPoint;
  53095. /**
  53096. * Gets the a output component
  53097. */
  53098. readonly a: NodeMaterialConnectionPoint;
  53099. readonly target: NodeMaterialBlockTargets;
  53100. autoConfigure(material: NodeMaterial): void;
  53101. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53103. isReady(): boolean;
  53104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53105. private readonly _isMixed;
  53106. private _injectVertexCode;
  53107. private _writeOutput;
  53108. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53109. protected _dumpPropertiesCode(): string;
  53110. serialize(): any;
  53111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53112. }
  53113. }
  53114. declare module BABYLON {
  53115. /**
  53116. * Class used to store shared data between 2 NodeMaterialBuildState
  53117. */
  53118. export class NodeMaterialBuildStateSharedData {
  53119. /**
  53120. * Gets the list of emitted varyings
  53121. */
  53122. temps: string[];
  53123. /**
  53124. * Gets the list of emitted varyings
  53125. */
  53126. varyings: string[];
  53127. /**
  53128. * Gets the varying declaration string
  53129. */
  53130. varyingDeclaration: string;
  53131. /**
  53132. * Input blocks
  53133. */
  53134. inputBlocks: InputBlock[];
  53135. /**
  53136. * Input blocks
  53137. */
  53138. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53139. /**
  53140. * Bindable blocks (Blocks that need to set data to the effect)
  53141. */
  53142. bindableBlocks: NodeMaterialBlock[];
  53143. /**
  53144. * List of blocks that can provide a compilation fallback
  53145. */
  53146. blocksWithFallbacks: NodeMaterialBlock[];
  53147. /**
  53148. * List of blocks that can provide a define update
  53149. */
  53150. blocksWithDefines: NodeMaterialBlock[];
  53151. /**
  53152. * List of blocks that can provide a repeatable content
  53153. */
  53154. repeatableContentBlocks: NodeMaterialBlock[];
  53155. /**
  53156. * List of blocks that can provide a dynamic list of uniforms
  53157. */
  53158. dynamicUniformBlocks: NodeMaterialBlock[];
  53159. /**
  53160. * List of blocks that can block the isReady function for the material
  53161. */
  53162. blockingBlocks: NodeMaterialBlock[];
  53163. /**
  53164. * Gets the list of animated inputs
  53165. */
  53166. animatedInputs: InputBlock[];
  53167. /**
  53168. * Build Id used to avoid multiple recompilations
  53169. */
  53170. buildId: number;
  53171. /** List of emitted variables */
  53172. variableNames: {
  53173. [key: string]: number;
  53174. };
  53175. /** List of emitted defines */
  53176. defineNames: {
  53177. [key: string]: number;
  53178. };
  53179. /** Should emit comments? */
  53180. emitComments: boolean;
  53181. /** Emit build activity */
  53182. verbose: boolean;
  53183. /** Gets or sets the hosting scene */
  53184. scene: Scene;
  53185. /**
  53186. * Gets the compilation hints emitted at compilation time
  53187. */
  53188. hints: {
  53189. needWorldViewMatrix: boolean;
  53190. needWorldViewProjectionMatrix: boolean;
  53191. needAlphaBlending: boolean;
  53192. needAlphaTesting: boolean;
  53193. };
  53194. /**
  53195. * List of compilation checks
  53196. */
  53197. checks: {
  53198. emitVertex: boolean;
  53199. emitFragment: boolean;
  53200. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53201. };
  53202. /** Creates a new shared data */
  53203. constructor();
  53204. /**
  53205. * Emits console errors and exceptions if there is a failing check
  53206. */
  53207. emitErrors(): void;
  53208. }
  53209. }
  53210. declare module BABYLON {
  53211. /**
  53212. * Class used to store node based material build state
  53213. */
  53214. export class NodeMaterialBuildState {
  53215. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53216. supportUniformBuffers: boolean;
  53217. /**
  53218. * Gets the list of emitted attributes
  53219. */
  53220. attributes: string[];
  53221. /**
  53222. * Gets the list of emitted uniforms
  53223. */
  53224. uniforms: string[];
  53225. /**
  53226. * Gets the list of emitted constants
  53227. */
  53228. constants: string[];
  53229. /**
  53230. * Gets the list of emitted uniform buffers
  53231. */
  53232. uniformBuffers: string[];
  53233. /**
  53234. * Gets the list of emitted samplers
  53235. */
  53236. samplers: string[];
  53237. /**
  53238. * Gets the list of emitted functions
  53239. */
  53240. functions: {
  53241. [key: string]: string;
  53242. };
  53243. /**
  53244. * Gets the list of emitted extensions
  53245. */
  53246. extensions: {
  53247. [key: string]: string;
  53248. };
  53249. /**
  53250. * Gets the target of the compilation state
  53251. */
  53252. target: NodeMaterialBlockTargets;
  53253. /**
  53254. * Gets the list of emitted counters
  53255. */
  53256. counters: {
  53257. [key: string]: number;
  53258. };
  53259. /**
  53260. * Shared data between multiple NodeMaterialBuildState instances
  53261. */
  53262. sharedData: NodeMaterialBuildStateSharedData;
  53263. /** @hidden */
  53264. _vertexState: NodeMaterialBuildState;
  53265. /** @hidden */
  53266. _attributeDeclaration: string;
  53267. /** @hidden */
  53268. _uniformDeclaration: string;
  53269. /** @hidden */
  53270. _constantDeclaration: string;
  53271. /** @hidden */
  53272. _samplerDeclaration: string;
  53273. /** @hidden */
  53274. _varyingTransfer: string;
  53275. private _repeatableContentAnchorIndex;
  53276. /** @hidden */
  53277. _builtCompilationString: string;
  53278. /**
  53279. * Gets the emitted compilation strings
  53280. */
  53281. compilationString: string;
  53282. /**
  53283. * Finalize the compilation strings
  53284. * @param state defines the current compilation state
  53285. */
  53286. finalize(state: NodeMaterialBuildState): void;
  53287. /** @hidden */
  53288. readonly _repeatableContentAnchor: string;
  53289. /** @hidden */
  53290. _getFreeVariableName(prefix: string): string;
  53291. /** @hidden */
  53292. _getFreeDefineName(prefix: string): string;
  53293. /** @hidden */
  53294. _excludeVariableName(name: string): void;
  53295. /** @hidden */
  53296. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53297. /** @hidden */
  53298. _emitExtension(name: string, extension: string): void;
  53299. /** @hidden */
  53300. _emitFunction(name: string, code: string, comments: string): void;
  53301. /** @hidden */
  53302. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53303. replaceStrings?: {
  53304. search: RegExp;
  53305. replace: string;
  53306. }[];
  53307. repeatKey?: string;
  53308. }): string;
  53309. /** @hidden */
  53310. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53311. repeatKey?: string;
  53312. removeAttributes?: boolean;
  53313. removeUniforms?: boolean;
  53314. removeVaryings?: boolean;
  53315. removeIfDef?: boolean;
  53316. replaceStrings?: {
  53317. search: RegExp;
  53318. replace: string;
  53319. }[];
  53320. }, storeKey?: string): void;
  53321. /** @hidden */
  53322. _registerTempVariable(name: string): boolean;
  53323. /** @hidden */
  53324. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53325. /** @hidden */
  53326. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53327. }
  53328. }
  53329. declare module BABYLON {
  53330. /**
  53331. * Defines a block that can be used inside a node based material
  53332. */
  53333. export class NodeMaterialBlock {
  53334. private _buildId;
  53335. private _buildTarget;
  53336. private _target;
  53337. private _isFinalMerger;
  53338. private _isInput;
  53339. /** @hidden */
  53340. _codeVariableName: string;
  53341. /** @hidden */
  53342. _inputs: NodeMaterialConnectionPoint[];
  53343. /** @hidden */
  53344. _outputs: NodeMaterialConnectionPoint[];
  53345. /** @hidden */
  53346. _preparationId: number;
  53347. /**
  53348. * Gets or sets the name of the block
  53349. */
  53350. name: string;
  53351. /**
  53352. * Gets or sets the unique id of the node
  53353. */
  53354. uniqueId: number;
  53355. /**
  53356. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53357. */
  53358. readonly isFinalMerger: boolean;
  53359. /**
  53360. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53361. */
  53362. readonly isInput: boolean;
  53363. /**
  53364. * Gets or sets the build Id
  53365. */
  53366. buildId: number;
  53367. /**
  53368. * Gets or sets the target of the block
  53369. */
  53370. target: NodeMaterialBlockTargets;
  53371. /**
  53372. * Gets the list of input points
  53373. */
  53374. readonly inputs: NodeMaterialConnectionPoint[];
  53375. /** Gets the list of output points */
  53376. readonly outputs: NodeMaterialConnectionPoint[];
  53377. /**
  53378. * Find an input by its name
  53379. * @param name defines the name of the input to look for
  53380. * @returns the input or null if not found
  53381. */
  53382. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53383. /**
  53384. * Find an output by its name
  53385. * @param name defines the name of the outputto look for
  53386. * @returns the output or null if not found
  53387. */
  53388. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53389. /**
  53390. * Creates a new NodeMaterialBlock
  53391. * @param name defines the block name
  53392. * @param target defines the target of that block (Vertex by default)
  53393. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53394. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53395. */
  53396. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53397. /**
  53398. * Initialize the block and prepare the context for build
  53399. * @param state defines the state that will be used for the build
  53400. */
  53401. initialize(state: NodeMaterialBuildState): void;
  53402. /**
  53403. * Bind data to effect. Will only be called for blocks with isBindable === true
  53404. * @param effect defines the effect to bind data to
  53405. * @param nodeMaterial defines the hosting NodeMaterial
  53406. * @param mesh defines the mesh that will be rendered
  53407. */
  53408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53409. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53410. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53411. protected _writeFloat(value: number): string;
  53412. /**
  53413. * Gets the current class name e.g. "NodeMaterialBlock"
  53414. * @returns the class name
  53415. */
  53416. getClassName(): string;
  53417. /**
  53418. * Register a new input. Must be called inside a block constructor
  53419. * @param name defines the connection point name
  53420. * @param type defines the connection point type
  53421. * @param isOptional defines a boolean indicating that this input can be omitted
  53422. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53423. * @returns the current block
  53424. */
  53425. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53426. /**
  53427. * Register a new output. Must be called inside a block constructor
  53428. * @param name defines the connection point name
  53429. * @param type defines the connection point type
  53430. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53431. * @returns the current block
  53432. */
  53433. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53434. /**
  53435. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53436. * @param forOutput defines an optional connection point to check compatibility with
  53437. * @returns the first available input or null
  53438. */
  53439. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53440. /**
  53441. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53442. * @param forBlock defines an optional block to check compatibility with
  53443. * @returns the first available input or null
  53444. */
  53445. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53446. /**
  53447. * Gets the sibling of the given output
  53448. * @param current defines the current output
  53449. * @returns the next output in the list or null
  53450. */
  53451. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53452. /**
  53453. * Connect current block with another block
  53454. * @param other defines the block to connect with
  53455. * @param options define the various options to help pick the right connections
  53456. * @returns the current block
  53457. */
  53458. connectTo(other: NodeMaterialBlock, options?: {
  53459. input?: string;
  53460. output?: string;
  53461. outputSwizzle?: string;
  53462. }): this | undefined;
  53463. protected _buildBlock(state: NodeMaterialBuildState): void;
  53464. /**
  53465. * Add uniforms, samplers and uniform buffers at compilation time
  53466. * @param state defines the state to update
  53467. * @param nodeMaterial defines the node material requesting the update
  53468. * @param defines defines the material defines to update
  53469. */
  53470. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53471. /**
  53472. * Add potential fallbacks if shader compilation fails
  53473. * @param mesh defines the mesh to be rendered
  53474. * @param fallbacks defines the current prioritized list of fallbacks
  53475. */
  53476. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53477. /**
  53478. * Initialize defines for shader compilation
  53479. * @param mesh defines the mesh to be rendered
  53480. * @param nodeMaterial defines the node material requesting the update
  53481. * @param defines defines the material defines to update
  53482. * @param useInstances specifies that instances should be used
  53483. */
  53484. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53485. /**
  53486. * Update defines for shader compilation
  53487. * @param mesh defines the mesh to be rendered
  53488. * @param nodeMaterial defines the node material requesting the update
  53489. * @param defines defines the material defines to update
  53490. * @param useInstances specifies that instances should be used
  53491. */
  53492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53493. /**
  53494. * Lets the block try to connect some inputs automatically
  53495. * @param material defines the hosting NodeMaterial
  53496. */
  53497. autoConfigure(material: NodeMaterial): void;
  53498. /**
  53499. * Function called when a block is declared as repeatable content generator
  53500. * @param vertexShaderState defines the current compilation state for the vertex shader
  53501. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53502. * @param mesh defines the mesh to be rendered
  53503. * @param defines defines the material defines to update
  53504. */
  53505. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53506. /**
  53507. * Checks if the block is ready
  53508. * @param mesh defines the mesh to be rendered
  53509. * @param nodeMaterial defines the node material requesting the update
  53510. * @param defines defines the material defines to update
  53511. * @param useInstances specifies that instances should be used
  53512. * @returns true if the block is ready
  53513. */
  53514. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53515. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53516. private _processBuild;
  53517. /**
  53518. * Compile the current node and generate the shader code
  53519. * @param state defines the current compilation state (uniforms, samplers, current string)
  53520. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53521. * @returns true if already built
  53522. */
  53523. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53524. protected _inputRename(name: string): string;
  53525. protected _outputRename(name: string): string;
  53526. protected _dumpPropertiesCode(): string;
  53527. /** @hidden */
  53528. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53529. /**
  53530. * Clone the current block to a new identical block
  53531. * @param scene defines the hosting scene
  53532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53533. * @returns a copy of the current block
  53534. */
  53535. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53536. /**
  53537. * Serializes this block in a JSON representation
  53538. * @returns the serialized block object
  53539. */
  53540. serialize(): any;
  53541. /** @hidden */
  53542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53543. }
  53544. }
  53545. declare module BABYLON {
  53546. /**
  53547. * Enum defining the type of animations supported by InputBlock
  53548. */
  53549. export enum AnimatedInputBlockTypes {
  53550. /** No animation */
  53551. None = 0,
  53552. /** Time based animation. Will only work for floats */
  53553. Time = 1
  53554. }
  53555. }
  53556. declare module BABYLON {
  53557. /**
  53558. * Block used to expose an input value
  53559. */
  53560. export class InputBlock extends NodeMaterialBlock {
  53561. private _mode;
  53562. private _associatedVariableName;
  53563. private _storedValue;
  53564. private _valueCallback;
  53565. private _type;
  53566. private _animationType;
  53567. /** Gets or set a value used to limit the range of float values */
  53568. min: number;
  53569. /** Gets or set a value used to limit the range of float values */
  53570. max: number;
  53571. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53572. matrixMode: number;
  53573. /** @hidden */
  53574. _systemValue: Nullable<NodeMaterialSystemValues>;
  53575. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53576. visibleInInspector: boolean;
  53577. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53578. isConstant: boolean;
  53579. /**
  53580. * Gets or sets the connection point type (default is float)
  53581. */
  53582. readonly type: NodeMaterialBlockConnectionPointTypes;
  53583. /**
  53584. * Creates a new InputBlock
  53585. * @param name defines the block name
  53586. * @param target defines the target of that block (Vertex by default)
  53587. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53588. */
  53589. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53590. /**
  53591. * Gets the output component
  53592. */
  53593. readonly output: NodeMaterialConnectionPoint;
  53594. /**
  53595. * Set the source of this connection point to a vertex attribute
  53596. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53597. * @returns the current connection point
  53598. */
  53599. setAsAttribute(attributeName?: string): InputBlock;
  53600. /**
  53601. * Set the source of this connection point to a system value
  53602. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53603. * @returns the current connection point
  53604. */
  53605. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53606. /**
  53607. * Gets or sets the value of that point.
  53608. * Please note that this value will be ignored if valueCallback is defined
  53609. */
  53610. value: any;
  53611. /**
  53612. * Gets or sets a callback used to get the value of that point.
  53613. * Please note that setting this value will force the connection point to ignore the value property
  53614. */
  53615. valueCallback: () => any;
  53616. /**
  53617. * Gets or sets the associated variable name in the shader
  53618. */
  53619. associatedVariableName: string;
  53620. /** Gets or sets the type of animation applied to the input */
  53621. animationType: AnimatedInputBlockTypes;
  53622. /**
  53623. * Gets a boolean indicating that this connection point not defined yet
  53624. */
  53625. readonly isUndefined: boolean;
  53626. /**
  53627. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53628. * In this case the connection point name must be the name of the uniform to use.
  53629. * Can only be set on inputs
  53630. */
  53631. isUniform: boolean;
  53632. /**
  53633. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53634. * In this case the connection point name must be the name of the attribute to use
  53635. * Can only be set on inputs
  53636. */
  53637. isAttribute: boolean;
  53638. /**
  53639. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53640. * Can only be set on exit points
  53641. */
  53642. isVarying: boolean;
  53643. /**
  53644. * Gets a boolean indicating that the current connection point is a system value
  53645. */
  53646. readonly isSystemValue: boolean;
  53647. /**
  53648. * Gets or sets the current well known value or null if not defined as a system value
  53649. */
  53650. systemValue: Nullable<NodeMaterialSystemValues>;
  53651. /**
  53652. * Gets the current class name
  53653. * @returns the class name
  53654. */
  53655. getClassName(): string;
  53656. /**
  53657. * Animate the input if animationType !== None
  53658. * @param scene defines the rendering scene
  53659. */
  53660. animate(scene: Scene): void;
  53661. private _emitDefine;
  53662. initialize(state: NodeMaterialBuildState): void;
  53663. /**
  53664. * Set the input block to its default value (based on its type)
  53665. */
  53666. setDefaultValue(): void;
  53667. private _emitConstant;
  53668. private _emit;
  53669. /** @hidden */
  53670. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53671. /** @hidden */
  53672. _transmit(effect: Effect, scene: Scene): void;
  53673. protected _buildBlock(state: NodeMaterialBuildState): void;
  53674. protected _dumpPropertiesCode(): string;
  53675. serialize(): any;
  53676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53677. }
  53678. }
  53679. declare module BABYLON {
  53680. /**
  53681. * Defines a connection point for a block
  53682. */
  53683. export class NodeMaterialConnectionPoint {
  53684. /** @hidden */
  53685. _ownerBlock: NodeMaterialBlock;
  53686. /** @hidden */
  53687. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53688. private _endpoints;
  53689. private _associatedVariableName;
  53690. /** @hidden */
  53691. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53692. /** @hidden */
  53693. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53694. private _type;
  53695. /** @hidden */
  53696. _enforceAssociatedVariableName: boolean;
  53697. /**
  53698. * Gets or sets the additional types supported by this connection point
  53699. */
  53700. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53701. /**
  53702. * Gets or sets the additional types excluded by this connection point
  53703. */
  53704. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53705. /**
  53706. * Gets or sets the associated variable name in the shader
  53707. */
  53708. associatedVariableName: string;
  53709. /**
  53710. * Gets or sets the connection point type (default is float)
  53711. */
  53712. type: NodeMaterialBlockConnectionPointTypes;
  53713. /**
  53714. * Gets or sets the connection point name
  53715. */
  53716. name: string;
  53717. /**
  53718. * Gets or sets a boolean indicating that this connection point can be omitted
  53719. */
  53720. isOptional: boolean;
  53721. /**
  53722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53723. */
  53724. define: string;
  53725. /** Gets or sets the target of that connection point */
  53726. target: NodeMaterialBlockTargets;
  53727. /**
  53728. * Gets a boolean indicating that the current point is connected
  53729. */
  53730. readonly isConnected: boolean;
  53731. /**
  53732. * Gets a boolean indicating that the current point is connected to an input block
  53733. */
  53734. readonly isConnectedToInputBlock: boolean;
  53735. /**
  53736. * Gets a the connected input block (if any)
  53737. */
  53738. readonly connectInputBlock: Nullable<InputBlock>;
  53739. /** Get the other side of the connection (if any) */
  53740. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53741. /** Get the block that owns this connection point */
  53742. readonly ownerBlock: NodeMaterialBlock;
  53743. /** Get the block connected on the other side of this connection (if any) */
  53744. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53745. /** Get the block connected on the endpoints of this connection (if any) */
  53746. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53747. /** Gets the list of connected endpoints */
  53748. readonly endpoints: NodeMaterialConnectionPoint[];
  53749. /** Gets a boolean indicating if that output point is connected to at least one input */
  53750. readonly hasEndpoints: boolean;
  53751. /**
  53752. * Creates a new connection point
  53753. * @param name defines the connection point name
  53754. * @param ownerBlock defines the block hosting this connection point
  53755. */
  53756. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53757. /**
  53758. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53759. * @returns the class name
  53760. */
  53761. getClassName(): string;
  53762. /**
  53763. * Gets an boolean indicating if the current point can be connected to another point
  53764. * @param connectionPoint defines the other connection point
  53765. * @returns true if the connection is possible
  53766. */
  53767. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53768. /**
  53769. * Connect this point to another connection point
  53770. * @param connectionPoint defines the other connection point
  53771. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53772. * @returns the current connection point
  53773. */
  53774. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53775. /**
  53776. * Disconnect this point from one of his endpoint
  53777. * @param endpoint defines the other connection point
  53778. * @returns the current connection point
  53779. */
  53780. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53781. /**
  53782. * Serializes this point in a JSON representation
  53783. * @returns the serialized point object
  53784. */
  53785. serialize(): any;
  53786. }
  53787. }
  53788. declare module BABYLON {
  53789. /**
  53790. * Block used to add support for vertex skinning (bones)
  53791. */
  53792. export class BonesBlock extends NodeMaterialBlock {
  53793. /**
  53794. * Creates a new BonesBlock
  53795. * @param name defines the block name
  53796. */
  53797. constructor(name: string);
  53798. /**
  53799. * Initialize the block and prepare the context for build
  53800. * @param state defines the state that will be used for the build
  53801. */
  53802. initialize(state: NodeMaterialBuildState): void;
  53803. /**
  53804. * Gets the current class name
  53805. * @returns the class name
  53806. */
  53807. getClassName(): string;
  53808. /**
  53809. * Gets the matrix indices input component
  53810. */
  53811. readonly matricesIndices: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the matrix weights input component
  53814. */
  53815. readonly matricesWeights: NodeMaterialConnectionPoint;
  53816. /**
  53817. * Gets the extra matrix indices input component
  53818. */
  53819. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53820. /**
  53821. * Gets the extra matrix weights input component
  53822. */
  53823. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53824. /**
  53825. * Gets the world input component
  53826. */
  53827. readonly world: NodeMaterialConnectionPoint;
  53828. /**
  53829. * Gets the output component
  53830. */
  53831. readonly output: NodeMaterialConnectionPoint;
  53832. autoConfigure(material: NodeMaterial): void;
  53833. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53836. protected _buildBlock(state: NodeMaterialBuildState): this;
  53837. }
  53838. }
  53839. declare module BABYLON {
  53840. /**
  53841. * Block used to add support for instances
  53842. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53843. */
  53844. export class InstancesBlock extends NodeMaterialBlock {
  53845. /**
  53846. * Creates a new InstancesBlock
  53847. * @param name defines the block name
  53848. */
  53849. constructor(name: string);
  53850. /**
  53851. * Gets the current class name
  53852. * @returns the class name
  53853. */
  53854. getClassName(): string;
  53855. /**
  53856. * Gets the first world row input component
  53857. */
  53858. readonly world0: NodeMaterialConnectionPoint;
  53859. /**
  53860. * Gets the second world row input component
  53861. */
  53862. readonly world1: NodeMaterialConnectionPoint;
  53863. /**
  53864. * Gets the third world row input component
  53865. */
  53866. readonly world2: NodeMaterialConnectionPoint;
  53867. /**
  53868. * Gets the forth world row input component
  53869. */
  53870. readonly world3: NodeMaterialConnectionPoint;
  53871. /**
  53872. * Gets the world input component
  53873. */
  53874. readonly world: NodeMaterialConnectionPoint;
  53875. /**
  53876. * Gets the output component
  53877. */
  53878. readonly output: NodeMaterialConnectionPoint;
  53879. autoConfigure(material: NodeMaterial): void;
  53880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53881. protected _buildBlock(state: NodeMaterialBuildState): this;
  53882. }
  53883. }
  53884. declare module BABYLON {
  53885. /**
  53886. * Block used to add morph targets support to vertex shader
  53887. */
  53888. export class MorphTargetsBlock extends NodeMaterialBlock {
  53889. private _repeatableContentAnchor;
  53890. private _repeatebleContentGenerated;
  53891. /**
  53892. * Create a new MorphTargetsBlock
  53893. * @param name defines the block name
  53894. */
  53895. constructor(name: string);
  53896. /**
  53897. * Gets the current class name
  53898. * @returns the class name
  53899. */
  53900. getClassName(): string;
  53901. /**
  53902. * Gets the position input component
  53903. */
  53904. readonly position: NodeMaterialConnectionPoint;
  53905. /**
  53906. * Gets the normal input component
  53907. */
  53908. readonly normal: NodeMaterialConnectionPoint;
  53909. /**
  53910. * Gets the tangent input component
  53911. */
  53912. readonly tangent: NodeMaterialConnectionPoint;
  53913. /**
  53914. * Gets the tangent input component
  53915. */
  53916. readonly uv: NodeMaterialConnectionPoint;
  53917. /**
  53918. * Gets the position output component
  53919. */
  53920. readonly positionOutput: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the normal output component
  53923. */
  53924. readonly normalOutput: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the tangent output component
  53927. */
  53928. readonly tangentOutput: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Gets the tangent output component
  53931. */
  53932. readonly uvOutput: NodeMaterialConnectionPoint;
  53933. initialize(state: NodeMaterialBuildState): void;
  53934. autoConfigure(material: NodeMaterial): void;
  53935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53937. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53938. protected _buildBlock(state: NodeMaterialBuildState): this;
  53939. }
  53940. }
  53941. declare module BABYLON {
  53942. /**
  53943. * Block used to get data information from a light
  53944. */
  53945. export class LightInformationBlock extends NodeMaterialBlock {
  53946. private _lightDataUniformName;
  53947. private _lightColorUniformName;
  53948. private _lightTypeDefineName;
  53949. /**
  53950. * Gets or sets the light associated with this block
  53951. */
  53952. light: Nullable<Light>;
  53953. /**
  53954. * Creates a new LightInformationBlock
  53955. * @param name defines the block name
  53956. */
  53957. constructor(name: string);
  53958. /**
  53959. * Gets the current class name
  53960. * @returns the class name
  53961. */
  53962. getClassName(): string;
  53963. /**
  53964. * Gets the world position input component
  53965. */
  53966. readonly worldPosition: NodeMaterialConnectionPoint;
  53967. /**
  53968. * Gets the direction output component
  53969. */
  53970. readonly direction: NodeMaterialConnectionPoint;
  53971. /**
  53972. * Gets the direction output component
  53973. */
  53974. readonly color: NodeMaterialConnectionPoint;
  53975. /**
  53976. * Gets the direction output component
  53977. */
  53978. readonly intensity: NodeMaterialConnectionPoint;
  53979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53981. protected _buildBlock(state: NodeMaterialBuildState): this;
  53982. serialize(): any;
  53983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53984. }
  53985. }
  53986. declare module BABYLON {
  53987. /**
  53988. * Block used to add image processing support to fragment shader
  53989. */
  53990. export class ImageProcessingBlock extends NodeMaterialBlock {
  53991. /**
  53992. * Create a new ImageProcessingBlock
  53993. * @param name defines the block name
  53994. */
  53995. constructor(name: string);
  53996. /**
  53997. * Gets the current class name
  53998. * @returns the class name
  53999. */
  54000. getClassName(): string;
  54001. /**
  54002. * Gets the color input component
  54003. */
  54004. readonly color: NodeMaterialConnectionPoint;
  54005. /**
  54006. * Gets the output component
  54007. */
  54008. readonly output: NodeMaterialConnectionPoint;
  54009. /**
  54010. * Initialize the block and prepare the context for build
  54011. * @param state defines the state that will be used for the build
  54012. */
  54013. initialize(state: NodeMaterialBuildState): void;
  54014. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54017. protected _buildBlock(state: NodeMaterialBuildState): this;
  54018. }
  54019. }
  54020. declare module BABYLON {
  54021. /**
  54022. * Block used to pertub normals based on a normal map
  54023. */
  54024. export class PerturbNormalBlock extends NodeMaterialBlock {
  54025. private _tangentSpaceParameterName;
  54026. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54027. invertX: boolean;
  54028. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54029. invertY: boolean;
  54030. /**
  54031. * Create a new PerturbNormalBlock
  54032. * @param name defines the block name
  54033. */
  54034. constructor(name: string);
  54035. /**
  54036. * Gets the current class name
  54037. * @returns the class name
  54038. */
  54039. getClassName(): string;
  54040. /**
  54041. * Gets the world position input component
  54042. */
  54043. readonly worldPosition: NodeMaterialConnectionPoint;
  54044. /**
  54045. * Gets the world normal input component
  54046. */
  54047. readonly worldNormal: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the uv input component
  54050. */
  54051. readonly uv: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the normal map color input component
  54054. */
  54055. readonly normalMapColor: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the strength input component
  54058. */
  54059. readonly strength: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the output component
  54062. */
  54063. readonly output: NodeMaterialConnectionPoint;
  54064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54066. autoConfigure(material: NodeMaterial): void;
  54067. protected _buildBlock(state: NodeMaterialBuildState): this;
  54068. protected _dumpPropertiesCode(): string;
  54069. serialize(): any;
  54070. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54071. }
  54072. }
  54073. declare module BABYLON {
  54074. /**
  54075. * Block used to discard a pixel if a value is smaller than a cutoff
  54076. */
  54077. export class DiscardBlock extends NodeMaterialBlock {
  54078. /**
  54079. * Create a new DiscardBlock
  54080. * @param name defines the block name
  54081. */
  54082. constructor(name: string);
  54083. /**
  54084. * Gets the current class name
  54085. * @returns the class name
  54086. */
  54087. getClassName(): string;
  54088. /**
  54089. * Gets the color input component
  54090. */
  54091. readonly value: NodeMaterialConnectionPoint;
  54092. /**
  54093. * Gets the cutoff input component
  54094. */
  54095. readonly cutoff: NodeMaterialConnectionPoint;
  54096. protected _buildBlock(state: NodeMaterialBuildState): this;
  54097. }
  54098. }
  54099. declare module BABYLON {
  54100. /**
  54101. * Block used to add support for scene fog
  54102. */
  54103. export class FogBlock extends NodeMaterialBlock {
  54104. private _fogDistanceName;
  54105. private _fogParameters;
  54106. /**
  54107. * Create a new FogBlock
  54108. * @param name defines the block name
  54109. */
  54110. constructor(name: string);
  54111. /**
  54112. * Gets the current class name
  54113. * @returns the class name
  54114. */
  54115. getClassName(): string;
  54116. /**
  54117. * Gets the world position input component
  54118. */
  54119. readonly worldPosition: NodeMaterialConnectionPoint;
  54120. /**
  54121. * Gets the view input component
  54122. */
  54123. readonly view: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the color input component
  54126. */
  54127. readonly input: NodeMaterialConnectionPoint;
  54128. /**
  54129. * Gets the fog color input component
  54130. */
  54131. readonly fogColor: NodeMaterialConnectionPoint;
  54132. /**
  54133. * Gets the output component
  54134. */
  54135. readonly output: NodeMaterialConnectionPoint;
  54136. autoConfigure(material: NodeMaterial): void;
  54137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54139. protected _buildBlock(state: NodeMaterialBuildState): this;
  54140. }
  54141. }
  54142. declare module BABYLON {
  54143. /**
  54144. * Block used to add light in the fragment shader
  54145. */
  54146. export class LightBlock extends NodeMaterialBlock {
  54147. private _lightId;
  54148. /**
  54149. * Gets or sets the light associated with this block
  54150. */
  54151. light: Nullable<Light>;
  54152. /**
  54153. * Create a new LightBlock
  54154. * @param name defines the block name
  54155. */
  54156. constructor(name: string);
  54157. /**
  54158. * Gets the current class name
  54159. * @returns the class name
  54160. */
  54161. getClassName(): string;
  54162. /**
  54163. * Gets the world position input component
  54164. */
  54165. readonly worldPosition: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the world normal input component
  54168. */
  54169. readonly worldNormal: NodeMaterialConnectionPoint;
  54170. /**
  54171. * Gets the camera (or eye) position component
  54172. */
  54173. readonly cameraPosition: NodeMaterialConnectionPoint;
  54174. /**
  54175. * Gets the glossiness component
  54176. */
  54177. readonly glossiness: NodeMaterialConnectionPoint;
  54178. /**
  54179. * Gets the diffuse color component
  54180. */
  54181. readonly diffuseColor: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the specular color component
  54184. */
  54185. readonly specularColor: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the diffuse output component
  54188. */
  54189. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the specular output component
  54192. */
  54193. readonly specularOutput: NodeMaterialConnectionPoint;
  54194. autoConfigure(material: NodeMaterial): void;
  54195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54196. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54198. private _injectVertexCode;
  54199. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54200. serialize(): any;
  54201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54202. }
  54203. }
  54204. declare module BABYLON {
  54205. /**
  54206. * Block used to multiply 2 values
  54207. */
  54208. export class MultiplyBlock extends NodeMaterialBlock {
  54209. /**
  54210. * Creates a new MultiplyBlock
  54211. * @param name defines the block name
  54212. */
  54213. constructor(name: string);
  54214. /**
  54215. * Gets the current class name
  54216. * @returns the class name
  54217. */
  54218. getClassName(): string;
  54219. /**
  54220. * Gets the left operand input component
  54221. */
  54222. readonly left: NodeMaterialConnectionPoint;
  54223. /**
  54224. * Gets the right operand input component
  54225. */
  54226. readonly right: NodeMaterialConnectionPoint;
  54227. /**
  54228. * Gets the output component
  54229. */
  54230. readonly output: NodeMaterialConnectionPoint;
  54231. protected _buildBlock(state: NodeMaterialBuildState): this;
  54232. }
  54233. }
  54234. declare module BABYLON {
  54235. /**
  54236. * Block used to add 2 vectors
  54237. */
  54238. export class AddBlock extends NodeMaterialBlock {
  54239. /**
  54240. * Creates a new AddBlock
  54241. * @param name defines the block name
  54242. */
  54243. constructor(name: string);
  54244. /**
  54245. * Gets the current class name
  54246. * @returns the class name
  54247. */
  54248. getClassName(): string;
  54249. /**
  54250. * Gets the left operand input component
  54251. */
  54252. readonly left: NodeMaterialConnectionPoint;
  54253. /**
  54254. * Gets the right operand input component
  54255. */
  54256. readonly right: NodeMaterialConnectionPoint;
  54257. /**
  54258. * Gets the output component
  54259. */
  54260. readonly output: NodeMaterialConnectionPoint;
  54261. protected _buildBlock(state: NodeMaterialBuildState): this;
  54262. }
  54263. }
  54264. declare module BABYLON {
  54265. /**
  54266. * Block used to scale a vector by a float
  54267. */
  54268. export class ScaleBlock extends NodeMaterialBlock {
  54269. /**
  54270. * Creates a new ScaleBlock
  54271. * @param name defines the block name
  54272. */
  54273. constructor(name: string);
  54274. /**
  54275. * Gets the current class name
  54276. * @returns the class name
  54277. */
  54278. getClassName(): string;
  54279. /**
  54280. * Gets the input component
  54281. */
  54282. readonly input: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the factor input component
  54285. */
  54286. readonly factor: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the output component
  54289. */
  54290. readonly output: NodeMaterialConnectionPoint;
  54291. protected _buildBlock(state: NodeMaterialBuildState): this;
  54292. }
  54293. }
  54294. declare module BABYLON {
  54295. /**
  54296. * Block used to clamp a float
  54297. */
  54298. export class ClampBlock extends NodeMaterialBlock {
  54299. /** Gets or sets the minimum range */
  54300. minimum: number;
  54301. /** Gets or sets the maximum range */
  54302. maximum: number;
  54303. /**
  54304. * Creates a new ClampBlock
  54305. * @param name defines the block name
  54306. */
  54307. constructor(name: string);
  54308. /**
  54309. * Gets the current class name
  54310. * @returns the class name
  54311. */
  54312. getClassName(): string;
  54313. /**
  54314. * Gets the value input component
  54315. */
  54316. readonly value: NodeMaterialConnectionPoint;
  54317. /**
  54318. * Gets the output component
  54319. */
  54320. readonly output: NodeMaterialConnectionPoint;
  54321. protected _buildBlock(state: NodeMaterialBuildState): this;
  54322. protected _dumpPropertiesCode(): string;
  54323. serialize(): any;
  54324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54325. }
  54326. }
  54327. declare module BABYLON {
  54328. /**
  54329. * Block used to apply a cross product between 2 vectors
  54330. */
  54331. export class CrossBlock extends NodeMaterialBlock {
  54332. /**
  54333. * Creates a new CrossBlock
  54334. * @param name defines the block name
  54335. */
  54336. constructor(name: string);
  54337. /**
  54338. * Gets the current class name
  54339. * @returns the class name
  54340. */
  54341. getClassName(): string;
  54342. /**
  54343. * Gets the left operand input component
  54344. */
  54345. readonly left: NodeMaterialConnectionPoint;
  54346. /**
  54347. * Gets the right operand input component
  54348. */
  54349. readonly right: NodeMaterialConnectionPoint;
  54350. /**
  54351. * Gets the output component
  54352. */
  54353. readonly output: NodeMaterialConnectionPoint;
  54354. protected _buildBlock(state: NodeMaterialBuildState): this;
  54355. }
  54356. }
  54357. declare module BABYLON {
  54358. /**
  54359. * Block used to apply a dot product between 2 vectors
  54360. */
  54361. export class DotBlock extends NodeMaterialBlock {
  54362. /**
  54363. * Creates a new DotBlock
  54364. * @param name defines the block name
  54365. */
  54366. constructor(name: string);
  54367. /**
  54368. * Gets the current class name
  54369. * @returns the class name
  54370. */
  54371. getClassName(): string;
  54372. /**
  54373. * Gets the left operand input component
  54374. */
  54375. readonly left: NodeMaterialConnectionPoint;
  54376. /**
  54377. * Gets the right operand input component
  54378. */
  54379. readonly right: NodeMaterialConnectionPoint;
  54380. /**
  54381. * Gets the output component
  54382. */
  54383. readonly output: NodeMaterialConnectionPoint;
  54384. protected _buildBlock(state: NodeMaterialBuildState): this;
  54385. }
  54386. }
  54387. declare module BABYLON {
  54388. /**
  54389. * Block used to remap a float from a range to a new one
  54390. */
  54391. export class RemapBlock extends NodeMaterialBlock {
  54392. /**
  54393. * Gets or sets the source range
  54394. */
  54395. sourceRange: Vector2;
  54396. /**
  54397. * Gets or sets the target range
  54398. */
  54399. targetRange: Vector2;
  54400. /**
  54401. * Creates a new RemapBlock
  54402. * @param name defines the block name
  54403. */
  54404. constructor(name: string);
  54405. /**
  54406. * Gets the current class name
  54407. * @returns the class name
  54408. */
  54409. getClassName(): string;
  54410. /**
  54411. * Gets the input component
  54412. */
  54413. readonly input: NodeMaterialConnectionPoint;
  54414. /**
  54415. * Gets the source min input component
  54416. */
  54417. readonly sourceMin: NodeMaterialConnectionPoint;
  54418. /**
  54419. * Gets the source max input component
  54420. */
  54421. readonly sourceMax: NodeMaterialConnectionPoint;
  54422. /**
  54423. * Gets the target min input component
  54424. */
  54425. readonly targetMin: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the target max input component
  54428. */
  54429. readonly targetMax: NodeMaterialConnectionPoint;
  54430. /**
  54431. * Gets the output component
  54432. */
  54433. readonly output: NodeMaterialConnectionPoint;
  54434. protected _buildBlock(state: NodeMaterialBuildState): this;
  54435. protected _dumpPropertiesCode(): string;
  54436. serialize(): any;
  54437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. /**
  54442. * Block used to normalize a vector
  54443. */
  54444. export class NormalizeBlock extends NodeMaterialBlock {
  54445. /**
  54446. * Creates a new NormalizeBlock
  54447. * @param name defines the block name
  54448. */
  54449. constructor(name: string);
  54450. /**
  54451. * Gets the current class name
  54452. * @returns the class name
  54453. */
  54454. getClassName(): string;
  54455. /**
  54456. * Gets the input component
  54457. */
  54458. readonly input: NodeMaterialConnectionPoint;
  54459. /**
  54460. * Gets the output component
  54461. */
  54462. readonly output: NodeMaterialConnectionPoint;
  54463. protected _buildBlock(state: NodeMaterialBuildState): this;
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. /**
  54468. * Operations supported by the Trigonometry block
  54469. */
  54470. export enum TrigonometryBlockOperations {
  54471. /** Cos */
  54472. Cos = 0,
  54473. /** Sin */
  54474. Sin = 1,
  54475. /** Abs */
  54476. Abs = 2,
  54477. /** Exp */
  54478. Exp = 3,
  54479. /** Exp2 */
  54480. Exp2 = 4,
  54481. /** Round */
  54482. Round = 5,
  54483. /** Floor */
  54484. Floor = 6,
  54485. /** Ceiling */
  54486. Ceiling = 7,
  54487. /** Square root */
  54488. Sqrt = 8
  54489. }
  54490. /**
  54491. * Block used to apply trigonometry operation to floats
  54492. */
  54493. export class TrigonometryBlock extends NodeMaterialBlock {
  54494. /**
  54495. * Gets or sets the operation applied by the block
  54496. */
  54497. operation: TrigonometryBlockOperations;
  54498. /**
  54499. * Creates a new TrigonometryBlock
  54500. * @param name defines the block name
  54501. */
  54502. constructor(name: string);
  54503. /**
  54504. * Gets the current class name
  54505. * @returns the class name
  54506. */
  54507. getClassName(): string;
  54508. /**
  54509. * Gets the input component
  54510. */
  54511. readonly input: NodeMaterialConnectionPoint;
  54512. /**
  54513. * Gets the output component
  54514. */
  54515. readonly output: NodeMaterialConnectionPoint;
  54516. protected _buildBlock(state: NodeMaterialBuildState): this;
  54517. serialize(): any;
  54518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54519. }
  54520. }
  54521. declare module BABYLON {
  54522. /**
  54523. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54524. */
  54525. export class ColorMergerBlock extends NodeMaterialBlock {
  54526. /**
  54527. * Create a new ColorMergerBlock
  54528. * @param name defines the block name
  54529. */
  54530. constructor(name: string);
  54531. /**
  54532. * Gets the current class name
  54533. * @returns the class name
  54534. */
  54535. getClassName(): string;
  54536. /**
  54537. * Gets the r component (input)
  54538. */
  54539. readonly r: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Gets the g component (input)
  54542. */
  54543. readonly g: NodeMaterialConnectionPoint;
  54544. /**
  54545. * Gets the b component (input)
  54546. */
  54547. readonly b: NodeMaterialConnectionPoint;
  54548. /**
  54549. * Gets the a component (input)
  54550. */
  54551. readonly a: NodeMaterialConnectionPoint;
  54552. /**
  54553. * Gets the rgba component (output)
  54554. */
  54555. readonly rgba: NodeMaterialConnectionPoint;
  54556. /**
  54557. * Gets the rgb component (output)
  54558. */
  54559. readonly rgb: NodeMaterialConnectionPoint;
  54560. protected _buildBlock(state: NodeMaterialBuildState): this;
  54561. }
  54562. }
  54563. declare module BABYLON {
  54564. /**
  54565. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54566. */
  54567. export class VectorMergerBlock extends NodeMaterialBlock {
  54568. /**
  54569. * Create a new VectorMergerBlock
  54570. * @param name defines the block name
  54571. */
  54572. constructor(name: string);
  54573. /**
  54574. * Gets the current class name
  54575. * @returns the class name
  54576. */
  54577. getClassName(): string;
  54578. /**
  54579. * Gets the x component (input)
  54580. */
  54581. readonly x: NodeMaterialConnectionPoint;
  54582. /**
  54583. * Gets the y component (input)
  54584. */
  54585. readonly y: NodeMaterialConnectionPoint;
  54586. /**
  54587. * Gets the z component (input)
  54588. */
  54589. readonly z: NodeMaterialConnectionPoint;
  54590. /**
  54591. * Gets the w component (input)
  54592. */
  54593. readonly w: NodeMaterialConnectionPoint;
  54594. /**
  54595. * Gets the xyzw component (output)
  54596. */
  54597. readonly xyzw: NodeMaterialConnectionPoint;
  54598. /**
  54599. * Gets the xyz component (output)
  54600. */
  54601. readonly xyz: NodeMaterialConnectionPoint;
  54602. /**
  54603. * Gets the xy component (output)
  54604. */
  54605. readonly xy: NodeMaterialConnectionPoint;
  54606. protected _buildBlock(state: NodeMaterialBuildState): this;
  54607. }
  54608. }
  54609. declare module BABYLON {
  54610. /**
  54611. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54612. */
  54613. export class ColorSplitterBlock extends NodeMaterialBlock {
  54614. /**
  54615. * Create a new ColorSplitterBlock
  54616. * @param name defines the block name
  54617. */
  54618. constructor(name: string);
  54619. /**
  54620. * Gets the current class name
  54621. * @returns the class name
  54622. */
  54623. getClassName(): string;
  54624. /**
  54625. * Gets the rgba component (input)
  54626. */
  54627. readonly rgba: NodeMaterialConnectionPoint;
  54628. /**
  54629. * Gets the rgb component (input)
  54630. */
  54631. readonly rgbIn: NodeMaterialConnectionPoint;
  54632. /**
  54633. * Gets the rgb component (output)
  54634. */
  54635. readonly rgbOut: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the r component (output)
  54638. */
  54639. readonly r: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the g component (output)
  54642. */
  54643. readonly g: NodeMaterialConnectionPoint;
  54644. /**
  54645. * Gets the b component (output)
  54646. */
  54647. readonly b: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the a component (output)
  54650. */
  54651. readonly a: NodeMaterialConnectionPoint;
  54652. protected _inputRename(name: string): string;
  54653. protected _outputRename(name: string): string;
  54654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54655. }
  54656. }
  54657. declare module BABYLON {
  54658. /**
  54659. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54660. */
  54661. export class VectorSplitterBlock extends NodeMaterialBlock {
  54662. /**
  54663. * Create a new VectorSplitterBlock
  54664. * @param name defines the block name
  54665. */
  54666. constructor(name: string);
  54667. /**
  54668. * Gets the current class name
  54669. * @returns the class name
  54670. */
  54671. getClassName(): string;
  54672. /**
  54673. * Gets the xyzw component (input)
  54674. */
  54675. readonly xyzw: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the xyz component (input)
  54678. */
  54679. readonly xyzIn: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the xy component (input)
  54682. */
  54683. readonly xyIn: NodeMaterialConnectionPoint;
  54684. /**
  54685. * Gets the xyz component (output)
  54686. */
  54687. readonly xyzOut: NodeMaterialConnectionPoint;
  54688. /**
  54689. * Gets the xy component (output)
  54690. */
  54691. readonly xyOut: NodeMaterialConnectionPoint;
  54692. /**
  54693. * Gets the x component (output)
  54694. */
  54695. readonly x: NodeMaterialConnectionPoint;
  54696. /**
  54697. * Gets the y component (output)
  54698. */
  54699. readonly y: NodeMaterialConnectionPoint;
  54700. /**
  54701. * Gets the z component (output)
  54702. */
  54703. readonly z: NodeMaterialConnectionPoint;
  54704. /**
  54705. * Gets the w component (output)
  54706. */
  54707. readonly w: NodeMaterialConnectionPoint;
  54708. protected _inputRename(name: string): string;
  54709. protected _outputRename(name: string): string;
  54710. protected _buildBlock(state: NodeMaterialBuildState): this;
  54711. }
  54712. }
  54713. declare module BABYLON {
  54714. /**
  54715. * Block used to lerp 2 values
  54716. */
  54717. export class LerpBlock extends NodeMaterialBlock {
  54718. /**
  54719. * Creates a new LerpBlock
  54720. * @param name defines the block name
  54721. */
  54722. constructor(name: string);
  54723. /**
  54724. * Gets the current class name
  54725. * @returns the class name
  54726. */
  54727. getClassName(): string;
  54728. /**
  54729. * Gets the left operand input component
  54730. */
  54731. readonly left: NodeMaterialConnectionPoint;
  54732. /**
  54733. * Gets the right operand input component
  54734. */
  54735. readonly right: NodeMaterialConnectionPoint;
  54736. /**
  54737. * Gets the gradient operand input component
  54738. */
  54739. readonly gradient: NodeMaterialConnectionPoint;
  54740. /**
  54741. * Gets the output component
  54742. */
  54743. readonly output: NodeMaterialConnectionPoint;
  54744. protected _buildBlock(state: NodeMaterialBuildState): this;
  54745. }
  54746. }
  54747. declare module BABYLON {
  54748. /**
  54749. * Block used to divide 2 vectors
  54750. */
  54751. export class DivideBlock extends NodeMaterialBlock {
  54752. /**
  54753. * Creates a new DivideBlock
  54754. * @param name defines the block name
  54755. */
  54756. constructor(name: string);
  54757. /**
  54758. * Gets the current class name
  54759. * @returns the class name
  54760. */
  54761. getClassName(): string;
  54762. /**
  54763. * Gets the left operand input component
  54764. */
  54765. readonly left: NodeMaterialConnectionPoint;
  54766. /**
  54767. * Gets the right operand input component
  54768. */
  54769. readonly right: NodeMaterialConnectionPoint;
  54770. /**
  54771. * Gets the output component
  54772. */
  54773. readonly output: NodeMaterialConnectionPoint;
  54774. protected _buildBlock(state: NodeMaterialBuildState): this;
  54775. }
  54776. }
  54777. declare module BABYLON {
  54778. /**
  54779. * Block used to subtract 2 vectors
  54780. */
  54781. export class SubtractBlock extends NodeMaterialBlock {
  54782. /**
  54783. * Creates a new SubtractBlock
  54784. * @param name defines the block name
  54785. */
  54786. constructor(name: string);
  54787. /**
  54788. * Gets the current class name
  54789. * @returns the class name
  54790. */
  54791. getClassName(): string;
  54792. /**
  54793. * Gets the left operand input component
  54794. */
  54795. readonly left: NodeMaterialConnectionPoint;
  54796. /**
  54797. * Gets the right operand input component
  54798. */
  54799. readonly right: NodeMaterialConnectionPoint;
  54800. /**
  54801. * Gets the output component
  54802. */
  54803. readonly output: NodeMaterialConnectionPoint;
  54804. protected _buildBlock(state: NodeMaterialBuildState): this;
  54805. }
  54806. }
  54807. declare module BABYLON {
  54808. /**
  54809. * Block used to step a value
  54810. */
  54811. export class StepBlock extends NodeMaterialBlock {
  54812. /**
  54813. * Creates a new AddBlock
  54814. * @param name defines the block name
  54815. */
  54816. constructor(name: string);
  54817. /**
  54818. * Gets the current class name
  54819. * @returns the class name
  54820. */
  54821. getClassName(): string;
  54822. /**
  54823. * Gets the value operand input component
  54824. */
  54825. readonly value: NodeMaterialConnectionPoint;
  54826. /**
  54827. * Gets the edge operand input component
  54828. */
  54829. readonly edge: NodeMaterialConnectionPoint;
  54830. /**
  54831. * Gets the output component
  54832. */
  54833. readonly output: NodeMaterialConnectionPoint;
  54834. protected _buildBlock(state: NodeMaterialBuildState): this;
  54835. }
  54836. }
  54837. declare module BABYLON {
  54838. /**
  54839. * Block used to get the opposite (1 - x) of a value
  54840. */
  54841. export class OneMinusBlock extends NodeMaterialBlock {
  54842. /**
  54843. * Creates a new OneMinusBlock
  54844. * @param name defines the block name
  54845. */
  54846. constructor(name: string);
  54847. /**
  54848. * Gets the current class name
  54849. * @returns the class name
  54850. */
  54851. getClassName(): string;
  54852. /**
  54853. * Gets the input component
  54854. */
  54855. readonly input: NodeMaterialConnectionPoint;
  54856. /**
  54857. * Gets the output component
  54858. */
  54859. readonly output: NodeMaterialConnectionPoint;
  54860. protected _buildBlock(state: NodeMaterialBuildState): this;
  54861. }
  54862. }
  54863. declare module BABYLON {
  54864. /**
  54865. * Block used to get the view direction
  54866. */
  54867. export class ViewDirectionBlock extends NodeMaterialBlock {
  54868. /**
  54869. * Creates a new ViewDirectionBlock
  54870. * @param name defines the block name
  54871. */
  54872. constructor(name: string);
  54873. /**
  54874. * Gets the current class name
  54875. * @returns the class name
  54876. */
  54877. getClassName(): string;
  54878. /**
  54879. * Gets the world position component
  54880. */
  54881. readonly worldPosition: NodeMaterialConnectionPoint;
  54882. /**
  54883. * Gets the camera position component
  54884. */
  54885. readonly cameraPosition: NodeMaterialConnectionPoint;
  54886. /**
  54887. * Gets the output component
  54888. */
  54889. readonly output: NodeMaterialConnectionPoint;
  54890. autoConfigure(material: NodeMaterial): void;
  54891. protected _buildBlock(state: NodeMaterialBuildState): this;
  54892. }
  54893. }
  54894. declare module BABYLON {
  54895. /**
  54896. * Block used to compute fresnel value
  54897. */
  54898. export class FresnelBlock extends NodeMaterialBlock {
  54899. /**
  54900. * Create a new FresnelBlock
  54901. * @param name defines the block name
  54902. */
  54903. constructor(name: string);
  54904. /**
  54905. * Gets the current class name
  54906. * @returns the class name
  54907. */
  54908. getClassName(): string;
  54909. /**
  54910. * Gets the world normal input component
  54911. */
  54912. readonly worldNormal: NodeMaterialConnectionPoint;
  54913. /**
  54914. * Gets the view direction input component
  54915. */
  54916. readonly viewDirection: NodeMaterialConnectionPoint;
  54917. /**
  54918. * Gets the bias input component
  54919. */
  54920. readonly bias: NodeMaterialConnectionPoint;
  54921. /**
  54922. * Gets the camera (or eye) position component
  54923. */
  54924. readonly power: NodeMaterialConnectionPoint;
  54925. /**
  54926. * Gets the fresnel output component
  54927. */
  54928. readonly fresnel: NodeMaterialConnectionPoint;
  54929. autoConfigure(material: NodeMaterial): void;
  54930. protected _buildBlock(state: NodeMaterialBuildState): this;
  54931. }
  54932. }
  54933. declare module BABYLON {
  54934. /**
  54935. * Block used to get the max of 2 values
  54936. */
  54937. export class MaxBlock extends NodeMaterialBlock {
  54938. /**
  54939. * Creates a new MaxBlock
  54940. * @param name defines the block name
  54941. */
  54942. constructor(name: string);
  54943. /**
  54944. * Gets the current class name
  54945. * @returns the class name
  54946. */
  54947. getClassName(): string;
  54948. /**
  54949. * Gets the left operand input component
  54950. */
  54951. readonly left: NodeMaterialConnectionPoint;
  54952. /**
  54953. * Gets the right operand input component
  54954. */
  54955. readonly right: NodeMaterialConnectionPoint;
  54956. /**
  54957. * Gets the output component
  54958. */
  54959. readonly output: NodeMaterialConnectionPoint;
  54960. protected _buildBlock(state: NodeMaterialBuildState): this;
  54961. }
  54962. }
  54963. declare module BABYLON {
  54964. /**
  54965. * Block used to get the min of 2 values
  54966. */
  54967. export class MinBlock extends NodeMaterialBlock {
  54968. /**
  54969. * Creates a new MinBlock
  54970. * @param name defines the block name
  54971. */
  54972. constructor(name: string);
  54973. /**
  54974. * Gets the current class name
  54975. * @returns the class name
  54976. */
  54977. getClassName(): string;
  54978. /**
  54979. * Gets the left operand input component
  54980. */
  54981. readonly left: NodeMaterialConnectionPoint;
  54982. /**
  54983. * Gets the right operand input component
  54984. */
  54985. readonly right: NodeMaterialConnectionPoint;
  54986. /**
  54987. * Gets the output component
  54988. */
  54989. readonly output: NodeMaterialConnectionPoint;
  54990. protected _buildBlock(state: NodeMaterialBuildState): this;
  54991. }
  54992. }
  54993. declare module BABYLON {
  54994. /**
  54995. * Block used to get the distance between 2 values
  54996. */
  54997. export class DistanceBlock extends NodeMaterialBlock {
  54998. /**
  54999. * Creates a new DistanceBlock
  55000. * @param name defines the block name
  55001. */
  55002. constructor(name: string);
  55003. /**
  55004. * Gets the current class name
  55005. * @returns the class name
  55006. */
  55007. getClassName(): string;
  55008. /**
  55009. * Gets the left operand input component
  55010. */
  55011. readonly left: NodeMaterialConnectionPoint;
  55012. /**
  55013. * Gets the right operand input component
  55014. */
  55015. readonly right: NodeMaterialConnectionPoint;
  55016. /**
  55017. * Gets the output component
  55018. */
  55019. readonly output: NodeMaterialConnectionPoint;
  55020. protected _buildBlock(state: NodeMaterialBuildState): this;
  55021. }
  55022. }
  55023. declare module BABYLON {
  55024. /**
  55025. * Block used to get the length of a vector
  55026. */
  55027. export class LengthBlock extends NodeMaterialBlock {
  55028. /**
  55029. * Creates a new LengthBlock
  55030. * @param name defines the block name
  55031. */
  55032. constructor(name: string);
  55033. /**
  55034. * Gets the current class name
  55035. * @returns the class name
  55036. */
  55037. getClassName(): string;
  55038. /**
  55039. * Gets the value input component
  55040. */
  55041. readonly value: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the output component
  55044. */
  55045. readonly output: NodeMaterialConnectionPoint;
  55046. protected _buildBlock(state: NodeMaterialBuildState): this;
  55047. }
  55048. }
  55049. declare module BABYLON {
  55050. /**
  55051. * Block used to get negative version of a value (i.e. x * -1)
  55052. */
  55053. export class NegateBlock extends NodeMaterialBlock {
  55054. /**
  55055. * Creates a new NegateBlock
  55056. * @param name defines the block name
  55057. */
  55058. constructor(name: string);
  55059. /**
  55060. * Gets the current class name
  55061. * @returns the class name
  55062. */
  55063. getClassName(): string;
  55064. /**
  55065. * Gets the value input component
  55066. */
  55067. readonly value: NodeMaterialConnectionPoint;
  55068. /**
  55069. * Gets the output component
  55070. */
  55071. readonly output: NodeMaterialConnectionPoint;
  55072. protected _buildBlock(state: NodeMaterialBuildState): this;
  55073. }
  55074. }
  55075. declare module BABYLON {
  55076. /**
  55077. * Block used to get the value of the first parameter raised to the power of the second
  55078. */
  55079. export class PowBlock extends NodeMaterialBlock {
  55080. /**
  55081. * Creates a new PowBlock
  55082. * @param name defines the block name
  55083. */
  55084. constructor(name: string);
  55085. /**
  55086. * Gets the current class name
  55087. * @returns the class name
  55088. */
  55089. getClassName(): string;
  55090. /**
  55091. * Gets the value operand input component
  55092. */
  55093. readonly value: NodeMaterialConnectionPoint;
  55094. /**
  55095. * Gets the power operand input component
  55096. */
  55097. readonly power: NodeMaterialConnectionPoint;
  55098. /**
  55099. * Gets the output component
  55100. */
  55101. readonly output: NodeMaterialConnectionPoint;
  55102. protected _buildBlock(state: NodeMaterialBuildState): this;
  55103. }
  55104. }
  55105. declare module BABYLON {
  55106. /**
  55107. * Block used to get a random number
  55108. */
  55109. export class RandomNumberBlock extends NodeMaterialBlock {
  55110. /**
  55111. * Creates a new RandomNumberBlock
  55112. * @param name defines the block name
  55113. */
  55114. constructor(name: string);
  55115. /**
  55116. * Gets the current class name
  55117. * @returns the class name
  55118. */
  55119. getClassName(): string;
  55120. /**
  55121. * Gets the seed input component
  55122. */
  55123. readonly seed: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the output component
  55126. */
  55127. readonly output: NodeMaterialConnectionPoint;
  55128. protected _buildBlock(state: NodeMaterialBuildState): this;
  55129. }
  55130. }
  55131. declare module BABYLON {
  55132. /**
  55133. * Effect Render Options
  55134. */
  55135. export interface IEffectRendererOptions {
  55136. /**
  55137. * Defines the vertices positions.
  55138. */
  55139. positions?: number[];
  55140. /**
  55141. * Defines the indices.
  55142. */
  55143. indices?: number[];
  55144. }
  55145. /**
  55146. * Helper class to render one or more effects
  55147. */
  55148. export class EffectRenderer {
  55149. private engine;
  55150. private static _DefaultOptions;
  55151. private _vertexBuffers;
  55152. private _indexBuffer;
  55153. private _ringBufferIndex;
  55154. private _ringScreenBuffer;
  55155. private _fullscreenViewport;
  55156. private _getNextFrameBuffer;
  55157. /**
  55158. * Creates an effect renderer
  55159. * @param engine the engine to use for rendering
  55160. * @param options defines the options of the effect renderer
  55161. */
  55162. constructor(engine: Engine, options?: IEffectRendererOptions);
  55163. /**
  55164. * Sets the current viewport in normalized coordinates 0-1
  55165. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55166. */
  55167. setViewport(viewport?: Viewport): void;
  55168. /**
  55169. * Binds the embedded attributes buffer to the effect.
  55170. * @param effect Defines the effect to bind the attributes for
  55171. */
  55172. bindBuffers(effect: Effect): void;
  55173. /**
  55174. * Sets the current effect wrapper to use during draw.
  55175. * The effect needs to be ready before calling this api.
  55176. * This also sets the default full screen position attribute.
  55177. * @param effectWrapper Defines the effect to draw with
  55178. */
  55179. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55180. /**
  55181. * Draws a full screen quad.
  55182. */
  55183. draw(): void;
  55184. /**
  55185. * renders one or more effects to a specified texture
  55186. * @param effectWrappers list of effects to renderer
  55187. * @param outputTexture texture to draw to, if null it will render to the screen
  55188. */
  55189. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55190. /**
  55191. * Disposes of the effect renderer
  55192. */
  55193. dispose(): void;
  55194. }
  55195. /**
  55196. * Options to create an EffectWrapper
  55197. */
  55198. interface EffectWrapperCreationOptions {
  55199. /**
  55200. * Engine to use to create the effect
  55201. */
  55202. engine: Engine;
  55203. /**
  55204. * Fragment shader for the effect
  55205. */
  55206. fragmentShader: string;
  55207. /**
  55208. * Vertex shader for the effect
  55209. */
  55210. vertexShader?: string;
  55211. /**
  55212. * Attributes to use in the shader
  55213. */
  55214. attributeNames?: Array<string>;
  55215. /**
  55216. * Uniforms to use in the shader
  55217. */
  55218. uniformNames?: Array<string>;
  55219. /**
  55220. * Texture sampler names to use in the shader
  55221. */
  55222. samplerNames?: Array<string>;
  55223. /**
  55224. * The friendly name of the effect displayed in Spector.
  55225. */
  55226. name?: string;
  55227. }
  55228. /**
  55229. * Wraps an effect to be used for rendering
  55230. */
  55231. export class EffectWrapper {
  55232. /**
  55233. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55234. */
  55235. onApplyObservable: Observable<{}>;
  55236. /**
  55237. * The underlying effect
  55238. */
  55239. effect: Effect;
  55240. /**
  55241. * Creates an effect to be renderer
  55242. * @param creationOptions options to create the effect
  55243. */
  55244. constructor(creationOptions: EffectWrapperCreationOptions);
  55245. /**
  55246. * Disposes of the effect wrapper
  55247. */
  55248. dispose(): void;
  55249. }
  55250. }
  55251. declare module BABYLON {
  55252. /**
  55253. * Helper class to push actions to a pool of workers.
  55254. */
  55255. export class WorkerPool implements IDisposable {
  55256. private _workerInfos;
  55257. private _pendingActions;
  55258. /**
  55259. * Constructor
  55260. * @param workers Array of workers to use for actions
  55261. */
  55262. constructor(workers: Array<Worker>);
  55263. /**
  55264. * Terminates all workers and clears any pending actions.
  55265. */
  55266. dispose(): void;
  55267. /**
  55268. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55269. * pended until a worker has completed its action.
  55270. * @param action The action to perform. Call onComplete when the action is complete.
  55271. */
  55272. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55273. private _execute;
  55274. }
  55275. }
  55276. declare module BABYLON {
  55277. /**
  55278. * Configuration for Draco compression
  55279. */
  55280. export interface IDracoCompressionConfiguration {
  55281. /**
  55282. * Configuration for the decoder.
  55283. */
  55284. decoder: {
  55285. /**
  55286. * The url to the WebAssembly module.
  55287. */
  55288. wasmUrl?: string;
  55289. /**
  55290. * The url to the WebAssembly binary.
  55291. */
  55292. wasmBinaryUrl?: string;
  55293. /**
  55294. * The url to the fallback JavaScript module.
  55295. */
  55296. fallbackUrl?: string;
  55297. };
  55298. }
  55299. /**
  55300. * Draco compression (https://google.github.io/draco/)
  55301. *
  55302. * This class wraps the Draco module.
  55303. *
  55304. * **Encoder**
  55305. *
  55306. * The encoder is not currently implemented.
  55307. *
  55308. * **Decoder**
  55309. *
  55310. * 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.
  55311. *
  55312. * To update the configuration, use the following code:
  55313. * ```javascript
  55314. * DracoCompression.Configuration = {
  55315. * decoder: {
  55316. * wasmUrl: "<url to the WebAssembly library>",
  55317. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55318. * fallbackUrl: "<url to the fallback JavaScript library>",
  55319. * }
  55320. * };
  55321. * ```
  55322. *
  55323. * 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.
  55324. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55325. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55326. *
  55327. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55328. * ```javascript
  55329. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55330. * ```
  55331. *
  55332. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55333. */
  55334. export class DracoCompression implements IDisposable {
  55335. private _workerPoolPromise?;
  55336. private _decoderModulePromise?;
  55337. /**
  55338. * The configuration. Defaults to the following urls:
  55339. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55340. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55341. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55342. */
  55343. static Configuration: IDracoCompressionConfiguration;
  55344. /**
  55345. * Returns true if the decoder configuration is available.
  55346. */
  55347. static readonly DecoderAvailable: boolean;
  55348. /**
  55349. * Default number of workers to create when creating the draco compression object.
  55350. */
  55351. static DefaultNumWorkers: number;
  55352. private static GetDefaultNumWorkers;
  55353. private static _Default;
  55354. /**
  55355. * Default instance for the draco compression object.
  55356. */
  55357. static readonly Default: DracoCompression;
  55358. /**
  55359. * Constructor
  55360. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55361. */
  55362. constructor(numWorkers?: number);
  55363. /**
  55364. * Stop all async operations and release resources.
  55365. */
  55366. dispose(): void;
  55367. /**
  55368. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55369. * @returns a promise that resolves when ready
  55370. */
  55371. whenReadyAsync(): Promise<void>;
  55372. /**
  55373. * Decode Draco compressed mesh data to vertex data.
  55374. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55375. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55376. * @returns A promise that resolves with the decoded vertex data
  55377. */
  55378. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55379. [kind: string]: number;
  55380. }): Promise<VertexData>;
  55381. }
  55382. }
  55383. declare module BABYLON {
  55384. /**
  55385. * Class for building Constructive Solid Geometry
  55386. */
  55387. export class CSG {
  55388. private polygons;
  55389. /**
  55390. * The world matrix
  55391. */
  55392. matrix: Matrix;
  55393. /**
  55394. * Stores the position
  55395. */
  55396. position: Vector3;
  55397. /**
  55398. * Stores the rotation
  55399. */
  55400. rotation: Vector3;
  55401. /**
  55402. * Stores the rotation quaternion
  55403. */
  55404. rotationQuaternion: Nullable<Quaternion>;
  55405. /**
  55406. * Stores the scaling vector
  55407. */
  55408. scaling: Vector3;
  55409. /**
  55410. * Convert the Mesh to CSG
  55411. * @param mesh The Mesh to convert to CSG
  55412. * @returns A new CSG from the Mesh
  55413. */
  55414. static FromMesh(mesh: Mesh): CSG;
  55415. /**
  55416. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55417. * @param polygons Polygons used to construct a CSG solid
  55418. */
  55419. private static FromPolygons;
  55420. /**
  55421. * Clones, or makes a deep copy, of the CSG
  55422. * @returns A new CSG
  55423. */
  55424. clone(): CSG;
  55425. /**
  55426. * Unions this CSG with another CSG
  55427. * @param csg The CSG to union against this CSG
  55428. * @returns The unioned CSG
  55429. */
  55430. union(csg: CSG): CSG;
  55431. /**
  55432. * Unions this CSG with another CSG in place
  55433. * @param csg The CSG to union against this CSG
  55434. */
  55435. unionInPlace(csg: CSG): void;
  55436. /**
  55437. * Subtracts this CSG with another CSG
  55438. * @param csg The CSG to subtract against this CSG
  55439. * @returns A new CSG
  55440. */
  55441. subtract(csg: CSG): CSG;
  55442. /**
  55443. * Subtracts this CSG with another CSG in place
  55444. * @param csg The CSG to subtact against this CSG
  55445. */
  55446. subtractInPlace(csg: CSG): void;
  55447. /**
  55448. * Intersect this CSG with another CSG
  55449. * @param csg The CSG to intersect against this CSG
  55450. * @returns A new CSG
  55451. */
  55452. intersect(csg: CSG): CSG;
  55453. /**
  55454. * Intersects this CSG with another CSG in place
  55455. * @param csg The CSG to intersect against this CSG
  55456. */
  55457. intersectInPlace(csg: CSG): void;
  55458. /**
  55459. * Return a new CSG solid with solid and empty space switched. This solid is
  55460. * not modified.
  55461. * @returns A new CSG solid with solid and empty space switched
  55462. */
  55463. inverse(): CSG;
  55464. /**
  55465. * Inverses the CSG in place
  55466. */
  55467. inverseInPlace(): void;
  55468. /**
  55469. * This is used to keep meshes transformations so they can be restored
  55470. * when we build back a Babylon Mesh
  55471. * NB : All CSG operations are performed in world coordinates
  55472. * @param csg The CSG to copy the transform attributes from
  55473. * @returns This CSG
  55474. */
  55475. copyTransformAttributes(csg: CSG): CSG;
  55476. /**
  55477. * Build Raw mesh from CSG
  55478. * Coordinates here are in world space
  55479. * @param name The name of the mesh geometry
  55480. * @param scene The Scene
  55481. * @param keepSubMeshes Specifies if the submeshes should be kept
  55482. * @returns A new Mesh
  55483. */
  55484. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55485. /**
  55486. * Build Mesh from CSG taking material and transforms into account
  55487. * @param name The name of the Mesh
  55488. * @param material The material of the Mesh
  55489. * @param scene The Scene
  55490. * @param keepSubMeshes Specifies if submeshes should be kept
  55491. * @returns The new Mesh
  55492. */
  55493. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55494. }
  55495. }
  55496. declare module BABYLON {
  55497. /**
  55498. * Class used to create a trail following a mesh
  55499. */
  55500. export class TrailMesh extends Mesh {
  55501. private _generator;
  55502. private _autoStart;
  55503. private _running;
  55504. private _diameter;
  55505. private _length;
  55506. private _sectionPolygonPointsCount;
  55507. private _sectionVectors;
  55508. private _sectionNormalVectors;
  55509. private _beforeRenderObserver;
  55510. /**
  55511. * @constructor
  55512. * @param name The value used by scene.getMeshByName() to do a lookup.
  55513. * @param generator The mesh to generate a trail.
  55514. * @param scene The scene to add this mesh to.
  55515. * @param diameter Diameter of trailing mesh. Default is 1.
  55516. * @param length Length of trailing mesh. Default is 60.
  55517. * @param autoStart Automatically start trailing mesh. Default true.
  55518. */
  55519. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55520. /**
  55521. * "TrailMesh"
  55522. * @returns "TrailMesh"
  55523. */
  55524. getClassName(): string;
  55525. private _createMesh;
  55526. /**
  55527. * Start trailing mesh.
  55528. */
  55529. start(): void;
  55530. /**
  55531. * Stop trailing mesh.
  55532. */
  55533. stop(): void;
  55534. /**
  55535. * Update trailing mesh geometry.
  55536. */
  55537. update(): void;
  55538. /**
  55539. * Returns a new TrailMesh object.
  55540. * @param name is a string, the name given to the new mesh
  55541. * @param newGenerator use new generator object for cloned trail mesh
  55542. * @returns a new mesh
  55543. */
  55544. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55545. /**
  55546. * Serializes this trail mesh
  55547. * @param serializationObject object to write serialization to
  55548. */
  55549. serialize(serializationObject: any): void;
  55550. /**
  55551. * Parses a serialized trail mesh
  55552. * @param parsedMesh the serialized mesh
  55553. * @param scene the scene to create the trail mesh in
  55554. * @returns the created trail mesh
  55555. */
  55556. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. /**
  55561. * Class containing static functions to help procedurally build meshes
  55562. */
  55563. export class TiledBoxBuilder {
  55564. /**
  55565. * Creates a box mesh
  55566. * 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)
  55567. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55569. * * 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
  55570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55571. * @param name defines the name of the mesh
  55572. * @param options defines the options used to create the mesh
  55573. * @param scene defines the hosting scene
  55574. * @returns the box mesh
  55575. */
  55576. static CreateTiledBox(name: string, options: {
  55577. pattern?: number;
  55578. width?: number;
  55579. height?: number;
  55580. depth?: number;
  55581. tileSize?: number;
  55582. tileWidth?: number;
  55583. tileHeight?: number;
  55584. alignHorizontal?: number;
  55585. alignVertical?: number;
  55586. faceUV?: Vector4[];
  55587. faceColors?: Color4[];
  55588. sideOrientation?: number;
  55589. updatable?: boolean;
  55590. }, scene?: Nullable<Scene>): Mesh;
  55591. }
  55592. }
  55593. declare module BABYLON {
  55594. /**
  55595. * Class containing static functions to help procedurally build meshes
  55596. */
  55597. export class TorusKnotBuilder {
  55598. /**
  55599. * Creates a torus knot mesh
  55600. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55601. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55602. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55603. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55605. * * 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
  55606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55607. * @param name defines the name of the mesh
  55608. * @param options defines the options used to create the mesh
  55609. * @param scene defines the hosting scene
  55610. * @returns the torus knot mesh
  55611. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55612. */
  55613. static CreateTorusKnot(name: string, options: {
  55614. radius?: number;
  55615. tube?: number;
  55616. radialSegments?: number;
  55617. tubularSegments?: number;
  55618. p?: number;
  55619. q?: number;
  55620. updatable?: boolean;
  55621. sideOrientation?: number;
  55622. frontUVs?: Vector4;
  55623. backUVs?: Vector4;
  55624. }, scene: any): Mesh;
  55625. }
  55626. }
  55627. declare module BABYLON {
  55628. /**
  55629. * Polygon
  55630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55631. */
  55632. export class Polygon {
  55633. /**
  55634. * Creates a rectangle
  55635. * @param xmin bottom X coord
  55636. * @param ymin bottom Y coord
  55637. * @param xmax top X coord
  55638. * @param ymax top Y coord
  55639. * @returns points that make the resulting rectation
  55640. */
  55641. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55642. /**
  55643. * Creates a circle
  55644. * @param radius radius of circle
  55645. * @param cx scale in x
  55646. * @param cy scale in y
  55647. * @param numberOfSides number of sides that make up the circle
  55648. * @returns points that make the resulting circle
  55649. */
  55650. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55651. /**
  55652. * Creates a polygon from input string
  55653. * @param input Input polygon data
  55654. * @returns the parsed points
  55655. */
  55656. static Parse(input: string): Vector2[];
  55657. /**
  55658. * Starts building a polygon from x and y coordinates
  55659. * @param x x coordinate
  55660. * @param y y coordinate
  55661. * @returns the started path2
  55662. */
  55663. static StartingAt(x: number, y: number): Path2;
  55664. }
  55665. /**
  55666. * Builds a polygon
  55667. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55668. */
  55669. export class PolygonMeshBuilder {
  55670. private _points;
  55671. private _outlinepoints;
  55672. private _holes;
  55673. private _name;
  55674. private _scene;
  55675. private _epoints;
  55676. private _eholes;
  55677. private _addToepoint;
  55678. /**
  55679. * Babylon reference to the earcut plugin.
  55680. */
  55681. bjsEarcut: any;
  55682. /**
  55683. * Creates a PolygonMeshBuilder
  55684. * @param name name of the builder
  55685. * @param contours Path of the polygon
  55686. * @param scene scene to add to when creating the mesh
  55687. * @param earcutInjection can be used to inject your own earcut reference
  55688. */
  55689. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55690. /**
  55691. * Adds a whole within the polygon
  55692. * @param hole Array of points defining the hole
  55693. * @returns this
  55694. */
  55695. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55696. /**
  55697. * Creates the polygon
  55698. * @param updatable If the mesh should be updatable
  55699. * @param depth The depth of the mesh created
  55700. * @returns the created mesh
  55701. */
  55702. build(updatable?: boolean, depth?: number): Mesh;
  55703. /**
  55704. * Creates the polygon
  55705. * @param depth The depth of the mesh created
  55706. * @returns the created VertexData
  55707. */
  55708. buildVertexData(depth?: number): VertexData;
  55709. /**
  55710. * Adds a side to the polygon
  55711. * @param positions points that make the polygon
  55712. * @param normals normals of the polygon
  55713. * @param uvs uvs of the polygon
  55714. * @param indices indices of the polygon
  55715. * @param bounds bounds of the polygon
  55716. * @param points points of the polygon
  55717. * @param depth depth of the polygon
  55718. * @param flip flip of the polygon
  55719. */
  55720. private addSide;
  55721. }
  55722. }
  55723. declare module BABYLON {
  55724. /**
  55725. * Class containing static functions to help procedurally build meshes
  55726. */
  55727. export class PolygonBuilder {
  55728. /**
  55729. * Creates a polygon mesh
  55730. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55731. * * 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
  55732. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55734. * * 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)
  55735. * * Remember you can only change the shape positions, not their number when updating a polygon
  55736. * @param name defines the name of the mesh
  55737. * @param options defines the options used to create the mesh
  55738. * @param scene defines the hosting scene
  55739. * @param earcutInjection can be used to inject your own earcut reference
  55740. * @returns the polygon mesh
  55741. */
  55742. static CreatePolygon(name: string, options: {
  55743. shape: Vector3[];
  55744. holes?: Vector3[][];
  55745. depth?: number;
  55746. faceUV?: Vector4[];
  55747. faceColors?: Color4[];
  55748. updatable?: boolean;
  55749. sideOrientation?: number;
  55750. frontUVs?: Vector4;
  55751. backUVs?: Vector4;
  55752. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55753. /**
  55754. * Creates an extruded polygon mesh, with depth in the Y direction.
  55755. * * 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)
  55756. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55757. * @param name defines the name of the mesh
  55758. * @param options defines the options used to create the mesh
  55759. * @param scene defines the hosting scene
  55760. * @param earcutInjection can be used to inject your own earcut reference
  55761. * @returns the polygon mesh
  55762. */
  55763. static ExtrudePolygon(name: string, options: {
  55764. shape: Vector3[];
  55765. holes?: Vector3[][];
  55766. depth?: number;
  55767. faceUV?: Vector4[];
  55768. faceColors?: Color4[];
  55769. updatable?: boolean;
  55770. sideOrientation?: number;
  55771. frontUVs?: Vector4;
  55772. backUVs?: Vector4;
  55773. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /**
  55778. * Class containing static functions to help procedurally build meshes
  55779. */
  55780. export class LatheBuilder {
  55781. /**
  55782. * Creates lathe mesh.
  55783. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55784. * * 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
  55785. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55786. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55787. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55788. * * 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
  55789. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55790. * * 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
  55791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55792. * * 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
  55793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55795. * @param name defines the name of the mesh
  55796. * @param options defines the options used to create the mesh
  55797. * @param scene defines the hosting scene
  55798. * @returns the lathe mesh
  55799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55800. */
  55801. static CreateLathe(name: string, options: {
  55802. shape: Vector3[];
  55803. radius?: number;
  55804. tessellation?: number;
  55805. clip?: number;
  55806. arc?: number;
  55807. closed?: boolean;
  55808. updatable?: boolean;
  55809. sideOrientation?: number;
  55810. frontUVs?: Vector4;
  55811. backUVs?: Vector4;
  55812. cap?: number;
  55813. invertUV?: boolean;
  55814. }, scene?: Nullable<Scene>): Mesh;
  55815. }
  55816. }
  55817. declare module BABYLON {
  55818. /**
  55819. * Class containing static functions to help procedurally build meshes
  55820. */
  55821. export class TiledPlaneBuilder {
  55822. /**
  55823. * Creates a tiled plane mesh
  55824. * * The parameter `pattern` will, depending on value, do nothing or
  55825. * * * flip (reflect about central vertical) alternate tiles across and up
  55826. * * * flip every tile on alternate rows
  55827. * * * rotate (180 degs) alternate tiles across and up
  55828. * * * rotate every tile on alternate rows
  55829. * * * flip and rotate alternate tiles across and up
  55830. * * * flip and rotate every tile on alternate rows
  55831. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55832. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55833. * * 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
  55834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55835. * * 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)
  55836. * * 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)
  55837. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55838. * @param name defines the name of the mesh
  55839. * @param options defines the options used to create the mesh
  55840. * @param scene defines the hosting scene
  55841. * @returns the box mesh
  55842. */
  55843. static CreateTiledPlane(name: string, options: {
  55844. pattern?: number;
  55845. tileSize?: number;
  55846. tileWidth?: number;
  55847. tileHeight?: number;
  55848. size?: number;
  55849. width?: number;
  55850. height?: number;
  55851. alignHorizontal?: number;
  55852. alignVertical?: number;
  55853. sideOrientation?: number;
  55854. frontUVs?: Vector4;
  55855. backUVs?: Vector4;
  55856. updatable?: boolean;
  55857. }, scene?: Nullable<Scene>): Mesh;
  55858. }
  55859. }
  55860. declare module BABYLON {
  55861. /**
  55862. * Class containing static functions to help procedurally build meshes
  55863. */
  55864. export class TubeBuilder {
  55865. /**
  55866. * Creates a tube mesh.
  55867. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55868. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55869. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55870. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55871. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55872. * * 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)
  55873. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55874. * * 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
  55875. * * 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
  55876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55877. * * 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
  55878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55880. * @param name defines the name of the mesh
  55881. * @param options defines the options used to create the mesh
  55882. * @param scene defines the hosting scene
  55883. * @returns the tube mesh
  55884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55885. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55886. */
  55887. static CreateTube(name: string, options: {
  55888. path: Vector3[];
  55889. radius?: number;
  55890. tessellation?: number;
  55891. radiusFunction?: {
  55892. (i: number, distance: number): number;
  55893. };
  55894. cap?: number;
  55895. arc?: number;
  55896. updatable?: boolean;
  55897. sideOrientation?: number;
  55898. frontUVs?: Vector4;
  55899. backUVs?: Vector4;
  55900. instance?: Mesh;
  55901. invertUV?: boolean;
  55902. }, scene?: Nullable<Scene>): Mesh;
  55903. }
  55904. }
  55905. declare module BABYLON {
  55906. /**
  55907. * Class containing static functions to help procedurally build meshes
  55908. */
  55909. export class IcoSphereBuilder {
  55910. /**
  55911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55913. * * 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`)
  55914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55915. * * 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
  55916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55917. * * 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
  55918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55919. * @param name defines the name of the mesh
  55920. * @param options defines the options used to create the mesh
  55921. * @param scene defines the hosting scene
  55922. * @returns the icosahedron mesh
  55923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55924. */
  55925. static CreateIcoSphere(name: string, options: {
  55926. radius?: number;
  55927. radiusX?: number;
  55928. radiusY?: number;
  55929. radiusZ?: number;
  55930. flat?: boolean;
  55931. subdivisions?: number;
  55932. sideOrientation?: number;
  55933. frontUVs?: Vector4;
  55934. backUVs?: Vector4;
  55935. updatable?: boolean;
  55936. }, scene?: Nullable<Scene>): Mesh;
  55937. }
  55938. }
  55939. declare module BABYLON {
  55940. /**
  55941. * Class containing static functions to help procedurally build meshes
  55942. */
  55943. export class DecalBuilder {
  55944. /**
  55945. * Creates a decal mesh.
  55946. * 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
  55947. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55948. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55949. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55950. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55951. * @param name defines the name of the mesh
  55952. * @param sourceMesh defines the mesh where the decal must be applied
  55953. * @param options defines the options used to create the mesh
  55954. * @param scene defines the hosting scene
  55955. * @returns the decal mesh
  55956. * @see https://doc.babylonjs.com/how_to/decals
  55957. */
  55958. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55959. position?: Vector3;
  55960. normal?: Vector3;
  55961. size?: Vector3;
  55962. angle?: number;
  55963. }): Mesh;
  55964. }
  55965. }
  55966. declare module BABYLON {
  55967. /**
  55968. * Class containing static functions to help procedurally build meshes
  55969. */
  55970. export class MeshBuilder {
  55971. /**
  55972. * Creates a box mesh
  55973. * * The parameter `size` sets the size (float) of each box side (default 1)
  55974. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55975. * * 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)
  55976. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55978. * * 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
  55979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55980. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55981. * @param name defines the name of the mesh
  55982. * @param options defines the options used to create the mesh
  55983. * @param scene defines the hosting scene
  55984. * @returns the box mesh
  55985. */
  55986. static CreateBox(name: string, options: {
  55987. size?: number;
  55988. width?: number;
  55989. height?: number;
  55990. depth?: number;
  55991. faceUV?: Vector4[];
  55992. faceColors?: Color4[];
  55993. sideOrientation?: number;
  55994. frontUVs?: Vector4;
  55995. backUVs?: Vector4;
  55996. updatable?: boolean;
  55997. }, scene?: Nullable<Scene>): Mesh;
  55998. /**
  55999. * Creates a tiled box mesh
  56000. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56002. * @param name defines the name of the mesh
  56003. * @param options defines the options used to create the mesh
  56004. * @param scene defines the hosting scene
  56005. * @returns the tiled box mesh
  56006. */
  56007. static CreateTiledBox(name: string, options: {
  56008. pattern?: number;
  56009. size?: number;
  56010. width?: number;
  56011. height?: number;
  56012. depth: number;
  56013. tileSize?: number;
  56014. tileWidth?: number;
  56015. tileHeight?: number;
  56016. faceUV?: Vector4[];
  56017. faceColors?: Color4[];
  56018. alignHorizontal?: number;
  56019. alignVertical?: number;
  56020. sideOrientation?: number;
  56021. updatable?: boolean;
  56022. }, scene?: Nullable<Scene>): Mesh;
  56023. /**
  56024. * Creates a sphere mesh
  56025. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56026. * * 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`)
  56027. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56028. * * 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
  56029. * * 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)
  56030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56031. * * 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
  56032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56033. * @param name defines the name of the mesh
  56034. * @param options defines the options used to create the mesh
  56035. * @param scene defines the hosting scene
  56036. * @returns the sphere mesh
  56037. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56038. */
  56039. static CreateSphere(name: string, options: {
  56040. segments?: number;
  56041. diameter?: number;
  56042. diameterX?: number;
  56043. diameterY?: number;
  56044. diameterZ?: number;
  56045. arc?: number;
  56046. slice?: number;
  56047. sideOrientation?: number;
  56048. frontUVs?: Vector4;
  56049. backUVs?: Vector4;
  56050. updatable?: boolean;
  56051. }, scene?: Nullable<Scene>): Mesh;
  56052. /**
  56053. * Creates a plane polygonal mesh. By default, this is a disc
  56054. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56055. * * 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
  56056. * * 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
  56057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56058. * * 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
  56059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56060. * @param name defines the name of the mesh
  56061. * @param options defines the options used to create the mesh
  56062. * @param scene defines the hosting scene
  56063. * @returns the plane polygonal mesh
  56064. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56065. */
  56066. static CreateDisc(name: string, options: {
  56067. radius?: number;
  56068. tessellation?: number;
  56069. arc?: number;
  56070. updatable?: boolean;
  56071. sideOrientation?: number;
  56072. frontUVs?: Vector4;
  56073. backUVs?: Vector4;
  56074. }, scene?: Nullable<Scene>): Mesh;
  56075. /**
  56076. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56077. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56078. * * 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`)
  56079. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56080. * * 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
  56081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56082. * * 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
  56083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56084. * @param name defines the name of the mesh
  56085. * @param options defines the options used to create the mesh
  56086. * @param scene defines the hosting scene
  56087. * @returns the icosahedron mesh
  56088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56089. */
  56090. static CreateIcoSphere(name: string, options: {
  56091. radius?: number;
  56092. radiusX?: number;
  56093. radiusY?: number;
  56094. radiusZ?: number;
  56095. flat?: boolean;
  56096. subdivisions?: number;
  56097. sideOrientation?: number;
  56098. frontUVs?: Vector4;
  56099. backUVs?: Vector4;
  56100. updatable?: boolean;
  56101. }, scene?: Nullable<Scene>): Mesh;
  56102. /**
  56103. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56104. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56105. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56106. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56107. * * 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
  56108. * * 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
  56109. * * 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
  56110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56111. * * 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
  56112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56113. * * 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
  56114. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56115. * * 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
  56116. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56118. * @param name defines the name of the mesh
  56119. * @param options defines the options used to create the mesh
  56120. * @param scene defines the hosting scene
  56121. * @returns the ribbon mesh
  56122. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56124. */
  56125. static CreateRibbon(name: string, options: {
  56126. pathArray: Vector3[][];
  56127. closeArray?: boolean;
  56128. closePath?: boolean;
  56129. offset?: number;
  56130. updatable?: boolean;
  56131. sideOrientation?: number;
  56132. frontUVs?: Vector4;
  56133. backUVs?: Vector4;
  56134. instance?: Mesh;
  56135. invertUV?: boolean;
  56136. uvs?: Vector2[];
  56137. colors?: Color4[];
  56138. }, scene?: Nullable<Scene>): Mesh;
  56139. /**
  56140. * Creates a cylinder or a cone mesh
  56141. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56142. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56143. * * 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.
  56144. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56145. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56146. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56147. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56148. * * 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).
  56149. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56150. * * 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).
  56151. * * 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
  56152. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56153. * * 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
  56154. * * 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.
  56155. * * If `enclose` is false, a ring surface is one element.
  56156. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56157. * * 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
  56158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56159. * * 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
  56160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56161. * @param name defines the name of the mesh
  56162. * @param options defines the options used to create the mesh
  56163. * @param scene defines the hosting scene
  56164. * @returns the cylinder mesh
  56165. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56166. */
  56167. static CreateCylinder(name: string, options: {
  56168. height?: number;
  56169. diameterTop?: number;
  56170. diameterBottom?: number;
  56171. diameter?: number;
  56172. tessellation?: number;
  56173. subdivisions?: number;
  56174. arc?: number;
  56175. faceColors?: Color4[];
  56176. faceUV?: Vector4[];
  56177. updatable?: boolean;
  56178. hasRings?: boolean;
  56179. enclose?: boolean;
  56180. cap?: number;
  56181. sideOrientation?: number;
  56182. frontUVs?: Vector4;
  56183. backUVs?: Vector4;
  56184. }, scene?: Nullable<Scene>): Mesh;
  56185. /**
  56186. * Creates a torus mesh
  56187. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56188. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56189. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56191. * * 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
  56192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56193. * @param name defines the name of the mesh
  56194. * @param options defines the options used to create the mesh
  56195. * @param scene defines the hosting scene
  56196. * @returns the torus mesh
  56197. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56198. */
  56199. static CreateTorus(name: string, options: {
  56200. diameter?: number;
  56201. thickness?: number;
  56202. tessellation?: number;
  56203. updatable?: boolean;
  56204. sideOrientation?: number;
  56205. frontUVs?: Vector4;
  56206. backUVs?: Vector4;
  56207. }, scene?: Nullable<Scene>): Mesh;
  56208. /**
  56209. * Creates a torus knot mesh
  56210. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56211. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56212. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56213. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56215. * * 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
  56216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56217. * @param name defines the name of the mesh
  56218. * @param options defines the options used to create the mesh
  56219. * @param scene defines the hosting scene
  56220. * @returns the torus knot mesh
  56221. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56222. */
  56223. static CreateTorusKnot(name: string, options: {
  56224. radius?: number;
  56225. tube?: number;
  56226. radialSegments?: number;
  56227. tubularSegments?: number;
  56228. p?: number;
  56229. q?: number;
  56230. updatable?: boolean;
  56231. sideOrientation?: number;
  56232. frontUVs?: Vector4;
  56233. backUVs?: Vector4;
  56234. }, scene?: Nullable<Scene>): Mesh;
  56235. /**
  56236. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56237. * * 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
  56238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56239. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56240. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56241. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56243. * * 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
  56244. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56247. * @param name defines the name of the new line system
  56248. * @param options defines the options used to create the line system
  56249. * @param scene defines the hosting scene
  56250. * @returns a new line system mesh
  56251. */
  56252. static CreateLineSystem(name: string, options: {
  56253. lines: Vector3[][];
  56254. updatable?: boolean;
  56255. instance?: Nullable<LinesMesh>;
  56256. colors?: Nullable<Color4[][]>;
  56257. useVertexAlpha?: boolean;
  56258. }, scene: Nullable<Scene>): LinesMesh;
  56259. /**
  56260. * Creates a line mesh
  56261. * 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
  56262. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56263. * * The parameter `points` is an array successive Vector3
  56264. * * 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
  56265. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56266. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56267. * * When updating an instance, remember that only point positions can change, not the number of points
  56268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56270. * @param name defines the name of the new line system
  56271. * @param options defines the options used to create the line system
  56272. * @param scene defines the hosting scene
  56273. * @returns a new line mesh
  56274. */
  56275. static CreateLines(name: string, options: {
  56276. points: Vector3[];
  56277. updatable?: boolean;
  56278. instance?: Nullable<LinesMesh>;
  56279. colors?: Color4[];
  56280. useVertexAlpha?: boolean;
  56281. }, scene?: Nullable<Scene>): LinesMesh;
  56282. /**
  56283. * Creates a dashed line mesh
  56284. * * 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
  56285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56286. * * The parameter `points` is an array successive Vector3
  56287. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56288. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56289. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56290. * * 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
  56291. * * When updating an instance, remember that only point positions can change, not the number of points
  56292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56293. * @param name defines the name of the mesh
  56294. * @param options defines the options used to create the mesh
  56295. * @param scene defines the hosting scene
  56296. * @returns the dashed line mesh
  56297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56298. */
  56299. static CreateDashedLines(name: string, options: {
  56300. points: Vector3[];
  56301. dashSize?: number;
  56302. gapSize?: number;
  56303. dashNb?: number;
  56304. updatable?: boolean;
  56305. instance?: LinesMesh;
  56306. }, scene?: Nullable<Scene>): LinesMesh;
  56307. /**
  56308. * 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.
  56309. * * 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.
  56310. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56311. * * 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.
  56312. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56313. * * 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
  56314. * * 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
  56315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56317. * * 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
  56318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56320. * @param name defines the name of the mesh
  56321. * @param options defines the options used to create the mesh
  56322. * @param scene defines the hosting scene
  56323. * @returns the extruded shape mesh
  56324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56326. */
  56327. static ExtrudeShape(name: string, options: {
  56328. shape: Vector3[];
  56329. path: Vector3[];
  56330. scale?: number;
  56331. rotation?: number;
  56332. cap?: number;
  56333. updatable?: boolean;
  56334. sideOrientation?: number;
  56335. frontUVs?: Vector4;
  56336. backUVs?: Vector4;
  56337. instance?: Mesh;
  56338. invertUV?: boolean;
  56339. }, scene?: Nullable<Scene>): Mesh;
  56340. /**
  56341. * Creates an custom extruded shape mesh.
  56342. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56343. * * 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.
  56344. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56345. * * 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
  56346. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56347. * * 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
  56348. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56349. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56350. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56351. * * 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
  56352. * * 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
  56353. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56355. * * 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
  56356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56358. * @param name defines the name of the mesh
  56359. * @param options defines the options used to create the mesh
  56360. * @param scene defines the hosting scene
  56361. * @returns the custom extruded shape mesh
  56362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56365. */
  56366. static ExtrudeShapeCustom(name: string, options: {
  56367. shape: Vector3[];
  56368. path: Vector3[];
  56369. scaleFunction?: any;
  56370. rotationFunction?: any;
  56371. ribbonCloseArray?: boolean;
  56372. ribbonClosePath?: boolean;
  56373. cap?: number;
  56374. updatable?: boolean;
  56375. sideOrientation?: number;
  56376. frontUVs?: Vector4;
  56377. backUVs?: Vector4;
  56378. instance?: Mesh;
  56379. invertUV?: boolean;
  56380. }, scene?: Nullable<Scene>): Mesh;
  56381. /**
  56382. * Creates lathe mesh.
  56383. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56384. * * 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
  56385. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56386. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56387. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56388. * * 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
  56389. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56390. * * 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
  56391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56392. * * 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
  56393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56395. * @param name defines the name of the mesh
  56396. * @param options defines the options used to create the mesh
  56397. * @param scene defines the hosting scene
  56398. * @returns the lathe mesh
  56399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56400. */
  56401. static CreateLathe(name: string, options: {
  56402. shape: Vector3[];
  56403. radius?: number;
  56404. tessellation?: number;
  56405. clip?: number;
  56406. arc?: number;
  56407. closed?: boolean;
  56408. updatable?: boolean;
  56409. sideOrientation?: number;
  56410. frontUVs?: Vector4;
  56411. backUVs?: Vector4;
  56412. cap?: number;
  56413. invertUV?: boolean;
  56414. }, scene?: Nullable<Scene>): Mesh;
  56415. /**
  56416. * Creates a tiled plane mesh
  56417. * * You can set a limited pattern arrangement with the tiles
  56418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56419. * * 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
  56420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56421. * @param name defines the name of the mesh
  56422. * @param options defines the options used to create the mesh
  56423. * @param scene defines the hosting scene
  56424. * @returns the plane mesh
  56425. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56426. */
  56427. static CreateTiledPlane(name: string, options: {
  56428. pattern?: number;
  56429. tileSize?: number;
  56430. tileWidth?: number;
  56431. tileHeight?: number;
  56432. size?: number;
  56433. width?: number;
  56434. height?: number;
  56435. alignHorizontal?: number;
  56436. alignVertical?: number;
  56437. sideOrientation?: number;
  56438. frontUVs?: Vector4;
  56439. backUVs?: Vector4;
  56440. updatable?: boolean;
  56441. }, scene?: Nullable<Scene>): Mesh;
  56442. /**
  56443. * Creates a plane mesh
  56444. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56445. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56446. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56448. * * 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
  56449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56450. * @param name defines the name of the mesh
  56451. * @param options defines the options used to create the mesh
  56452. * @param scene defines the hosting scene
  56453. * @returns the plane mesh
  56454. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56455. */
  56456. static CreatePlane(name: string, options: {
  56457. size?: number;
  56458. width?: number;
  56459. height?: number;
  56460. sideOrientation?: number;
  56461. frontUVs?: Vector4;
  56462. backUVs?: Vector4;
  56463. updatable?: boolean;
  56464. sourcePlane?: Plane;
  56465. }, scene?: Nullable<Scene>): Mesh;
  56466. /**
  56467. * Creates a ground mesh
  56468. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56469. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56471. * @param name defines the name of the mesh
  56472. * @param options defines the options used to create the mesh
  56473. * @param scene defines the hosting scene
  56474. * @returns the ground mesh
  56475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56476. */
  56477. static CreateGround(name: string, options: {
  56478. width?: number;
  56479. height?: number;
  56480. subdivisions?: number;
  56481. subdivisionsX?: number;
  56482. subdivisionsY?: number;
  56483. updatable?: boolean;
  56484. }, scene?: Nullable<Scene>): Mesh;
  56485. /**
  56486. * Creates a tiled ground mesh
  56487. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56488. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56489. * * 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
  56490. * * 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
  56491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56492. * @param name defines the name of the mesh
  56493. * @param options defines the options used to create the mesh
  56494. * @param scene defines the hosting scene
  56495. * @returns the tiled ground mesh
  56496. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56497. */
  56498. static CreateTiledGround(name: string, options: {
  56499. xmin: number;
  56500. zmin: number;
  56501. xmax: number;
  56502. zmax: number;
  56503. subdivisions?: {
  56504. w: number;
  56505. h: number;
  56506. };
  56507. precision?: {
  56508. w: number;
  56509. h: number;
  56510. };
  56511. updatable?: boolean;
  56512. }, scene?: Nullable<Scene>): Mesh;
  56513. /**
  56514. * Creates a ground mesh from a height map
  56515. * * The parameter `url` sets the URL of the height map image resource.
  56516. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56517. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56518. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56519. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56520. * * 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.
  56521. * * 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).
  56522. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56524. * @param name defines the name of the mesh
  56525. * @param url defines the url to the height map
  56526. * @param options defines the options used to create the mesh
  56527. * @param scene defines the hosting scene
  56528. * @returns the ground mesh
  56529. * @see https://doc.babylonjs.com/babylon101/height_map
  56530. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56531. */
  56532. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56533. width?: number;
  56534. height?: number;
  56535. subdivisions?: number;
  56536. minHeight?: number;
  56537. maxHeight?: number;
  56538. colorFilter?: Color3;
  56539. alphaFilter?: number;
  56540. updatable?: boolean;
  56541. onReady?: (mesh: GroundMesh) => void;
  56542. }, scene?: Nullable<Scene>): GroundMesh;
  56543. /**
  56544. * Creates a polygon mesh
  56545. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56546. * * 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
  56547. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56549. * * 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)
  56550. * * Remember you can only change the shape positions, not their number when updating a polygon
  56551. * @param name defines the name of the mesh
  56552. * @param options defines the options used to create the mesh
  56553. * @param scene defines the hosting scene
  56554. * @param earcutInjection can be used to inject your own earcut reference
  56555. * @returns the polygon mesh
  56556. */
  56557. static CreatePolygon(name: string, options: {
  56558. shape: Vector3[];
  56559. holes?: Vector3[][];
  56560. depth?: number;
  56561. faceUV?: Vector4[];
  56562. faceColors?: Color4[];
  56563. updatable?: boolean;
  56564. sideOrientation?: number;
  56565. frontUVs?: Vector4;
  56566. backUVs?: Vector4;
  56567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56568. /**
  56569. * Creates an extruded polygon mesh, with depth in the Y direction.
  56570. * * 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)
  56571. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56572. * @param name defines the name of the mesh
  56573. * @param options defines the options used to create the mesh
  56574. * @param scene defines the hosting scene
  56575. * @param earcutInjection can be used to inject your own earcut reference
  56576. * @returns the polygon mesh
  56577. */
  56578. static ExtrudePolygon(name: string, options: {
  56579. shape: Vector3[];
  56580. holes?: Vector3[][];
  56581. depth?: number;
  56582. faceUV?: Vector4[];
  56583. faceColors?: Color4[];
  56584. updatable?: boolean;
  56585. sideOrientation?: number;
  56586. frontUVs?: Vector4;
  56587. backUVs?: Vector4;
  56588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56589. /**
  56590. * Creates a tube mesh.
  56591. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56592. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56593. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56594. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56595. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56596. * * 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)
  56597. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56598. * * 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
  56599. * * 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
  56600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56601. * * 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
  56602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56604. * @param name defines the name of the mesh
  56605. * @param options defines the options used to create the mesh
  56606. * @param scene defines the hosting scene
  56607. * @returns the tube mesh
  56608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56609. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56610. */
  56611. static CreateTube(name: string, options: {
  56612. path: Vector3[];
  56613. radius?: number;
  56614. tessellation?: number;
  56615. radiusFunction?: {
  56616. (i: number, distance: number): number;
  56617. };
  56618. cap?: number;
  56619. arc?: number;
  56620. updatable?: boolean;
  56621. sideOrientation?: number;
  56622. frontUVs?: Vector4;
  56623. backUVs?: Vector4;
  56624. instance?: Mesh;
  56625. invertUV?: boolean;
  56626. }, scene?: Nullable<Scene>): Mesh;
  56627. /**
  56628. * Creates a polyhedron mesh
  56629. * * 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
  56630. * * The parameter `size` (positive float, default 1) sets the polygon size
  56631. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56632. * * 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`
  56633. * * 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
  56634. * * 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)`)
  56635. * * 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
  56636. * * 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
  56637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56638. * * 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
  56639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56640. * @param name defines the name of the mesh
  56641. * @param options defines the options used to create the mesh
  56642. * @param scene defines the hosting scene
  56643. * @returns the polyhedron mesh
  56644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56645. */
  56646. static CreatePolyhedron(name: string, options: {
  56647. type?: number;
  56648. size?: number;
  56649. sizeX?: number;
  56650. sizeY?: number;
  56651. sizeZ?: number;
  56652. custom?: any;
  56653. faceUV?: Vector4[];
  56654. faceColors?: Color4[];
  56655. flat?: boolean;
  56656. updatable?: boolean;
  56657. sideOrientation?: number;
  56658. frontUVs?: Vector4;
  56659. backUVs?: Vector4;
  56660. }, scene?: Nullable<Scene>): Mesh;
  56661. /**
  56662. * Creates a decal mesh.
  56663. * 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
  56664. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56665. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56666. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56667. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56668. * @param name defines the name of the mesh
  56669. * @param sourceMesh defines the mesh where the decal must be applied
  56670. * @param options defines the options used to create the mesh
  56671. * @param scene defines the hosting scene
  56672. * @returns the decal mesh
  56673. * @see https://doc.babylonjs.com/how_to/decals
  56674. */
  56675. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56676. position?: Vector3;
  56677. normal?: Vector3;
  56678. size?: Vector3;
  56679. angle?: number;
  56680. }): Mesh;
  56681. }
  56682. }
  56683. declare module BABYLON {
  56684. /**
  56685. * A simplifier interface for future simplification implementations
  56686. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56687. */
  56688. export interface ISimplifier {
  56689. /**
  56690. * Simplification of a given mesh according to the given settings.
  56691. * Since this requires computation, it is assumed that the function runs async.
  56692. * @param settings The settings of the simplification, including quality and distance
  56693. * @param successCallback A callback that will be called after the mesh was simplified.
  56694. * @param errorCallback in case of an error, this callback will be called. optional.
  56695. */
  56696. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56697. }
  56698. /**
  56699. * Expected simplification settings.
  56700. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56701. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56702. */
  56703. export interface ISimplificationSettings {
  56704. /**
  56705. * Gets or sets the expected quality
  56706. */
  56707. quality: number;
  56708. /**
  56709. * Gets or sets the distance when this optimized version should be used
  56710. */
  56711. distance: number;
  56712. /**
  56713. * Gets an already optimized mesh
  56714. */
  56715. optimizeMesh?: boolean;
  56716. }
  56717. /**
  56718. * Class used to specify simplification options
  56719. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56720. */
  56721. export class SimplificationSettings implements ISimplificationSettings {
  56722. /** expected quality */
  56723. quality: number;
  56724. /** distance when this optimized version should be used */
  56725. distance: number;
  56726. /** already optimized mesh */
  56727. optimizeMesh?: boolean | undefined;
  56728. /**
  56729. * Creates a SimplificationSettings
  56730. * @param quality expected quality
  56731. * @param distance distance when this optimized version should be used
  56732. * @param optimizeMesh already optimized mesh
  56733. */
  56734. constructor(
  56735. /** expected quality */
  56736. quality: number,
  56737. /** distance when this optimized version should be used */
  56738. distance: number,
  56739. /** already optimized mesh */
  56740. optimizeMesh?: boolean | undefined);
  56741. }
  56742. /**
  56743. * Interface used to define a simplification task
  56744. */
  56745. export interface ISimplificationTask {
  56746. /**
  56747. * Array of settings
  56748. */
  56749. settings: Array<ISimplificationSettings>;
  56750. /**
  56751. * Simplification type
  56752. */
  56753. simplificationType: SimplificationType;
  56754. /**
  56755. * Mesh to simplify
  56756. */
  56757. mesh: Mesh;
  56758. /**
  56759. * Callback called on success
  56760. */
  56761. successCallback?: () => void;
  56762. /**
  56763. * Defines if parallel processing can be used
  56764. */
  56765. parallelProcessing: boolean;
  56766. }
  56767. /**
  56768. * Queue used to order the simplification tasks
  56769. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56770. */
  56771. export class SimplificationQueue {
  56772. private _simplificationArray;
  56773. /**
  56774. * Gets a boolean indicating that the process is still running
  56775. */
  56776. running: boolean;
  56777. /**
  56778. * Creates a new queue
  56779. */
  56780. constructor();
  56781. /**
  56782. * Adds a new simplification task
  56783. * @param task defines a task to add
  56784. */
  56785. addTask(task: ISimplificationTask): void;
  56786. /**
  56787. * Execute next task
  56788. */
  56789. executeNext(): void;
  56790. /**
  56791. * Execute a simplification task
  56792. * @param task defines the task to run
  56793. */
  56794. runSimplification(task: ISimplificationTask): void;
  56795. private getSimplifier;
  56796. }
  56797. /**
  56798. * The implemented types of simplification
  56799. * At the moment only Quadratic Error Decimation is implemented
  56800. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56801. */
  56802. export enum SimplificationType {
  56803. /** Quadratic error decimation */
  56804. QUADRATIC = 0
  56805. }
  56806. }
  56807. declare module BABYLON {
  56808. interface Scene {
  56809. /** @hidden (Backing field) */
  56810. _simplificationQueue: SimplificationQueue;
  56811. /**
  56812. * Gets or sets the simplification queue attached to the scene
  56813. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56814. */
  56815. simplificationQueue: SimplificationQueue;
  56816. }
  56817. interface Mesh {
  56818. /**
  56819. * Simplify the mesh according to the given array of settings.
  56820. * Function will return immediately and will simplify async
  56821. * @param settings a collection of simplification settings
  56822. * @param parallelProcessing should all levels calculate parallel or one after the other
  56823. * @param simplificationType the type of simplification to run
  56824. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56825. * @returns the current mesh
  56826. */
  56827. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56828. }
  56829. /**
  56830. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56831. * created in a scene
  56832. */
  56833. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56834. /**
  56835. * The component name helpfull to identify the component in the list of scene components.
  56836. */
  56837. readonly name: string;
  56838. /**
  56839. * The scene the component belongs to.
  56840. */
  56841. scene: Scene;
  56842. /**
  56843. * Creates a new instance of the component for the given scene
  56844. * @param scene Defines the scene to register the component in
  56845. */
  56846. constructor(scene: Scene);
  56847. /**
  56848. * Registers the component in a given scene
  56849. */
  56850. register(): void;
  56851. /**
  56852. * Rebuilds the elements related to this component in case of
  56853. * context lost for instance.
  56854. */
  56855. rebuild(): void;
  56856. /**
  56857. * Disposes the component and the associated ressources
  56858. */
  56859. dispose(): void;
  56860. private _beforeCameraUpdate;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /**
  56865. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56866. */
  56867. export interface INavigationEnginePlugin {
  56868. /**
  56869. * plugin name
  56870. */
  56871. name: string;
  56872. /**
  56873. * Creates a navigation mesh
  56874. * @param meshes array of all the geometry used to compute the navigatio mesh
  56875. * @param parameters bunch of parameters used to filter geometry
  56876. */
  56877. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56878. /**
  56879. * Create a navigation mesh debug mesh
  56880. * @param scene is where the mesh will be added
  56881. * @returns debug display mesh
  56882. */
  56883. createDebugNavMesh(scene: Scene): Mesh;
  56884. /**
  56885. * Get a navigation mesh constrained position, closest to the parameter position
  56886. * @param position world position
  56887. * @returns the closest point to position constrained by the navigation mesh
  56888. */
  56889. getClosestPoint(position: Vector3): Vector3;
  56890. /**
  56891. * Get a navigation mesh constrained position, within a particular radius
  56892. * @param position world position
  56893. * @param maxRadius the maximum distance to the constrained world position
  56894. * @returns the closest point to position constrained by the navigation mesh
  56895. */
  56896. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56897. /**
  56898. * Compute the final position from a segment made of destination-position
  56899. * @param position world position
  56900. * @param destination world position
  56901. * @returns the resulting point along the navmesh
  56902. */
  56903. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56904. /**
  56905. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56906. * @param start world position
  56907. * @param end world position
  56908. * @returns array containing world position composing the path
  56909. */
  56910. computePath(start: Vector3, end: Vector3): Vector3[];
  56911. /**
  56912. * If this plugin is supported
  56913. * @returns true if plugin is supported
  56914. */
  56915. isSupported(): boolean;
  56916. /**
  56917. * Create a new Crowd so you can add agents
  56918. * @param maxAgents the maximum agent count in the crowd
  56919. * @param maxAgentRadius the maximum radius an agent can have
  56920. * @param scene to attach the crowd to
  56921. * @returns the crowd you can add agents to
  56922. */
  56923. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56924. /**
  56925. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56926. * The queries will try to find a solution within those bounds
  56927. * default is (1,1,1)
  56928. * @param extent x,y,z value that define the extent around the queries point of reference
  56929. */
  56930. setDefaultQueryExtent(extent: Vector3): void;
  56931. /**
  56932. * Get the Bounding box extent specified by setDefaultQueryExtent
  56933. * @returns the box extent values
  56934. */
  56935. getDefaultQueryExtent(): Vector3;
  56936. /**
  56937. * Release all resources
  56938. */
  56939. dispose(): void;
  56940. }
  56941. /**
  56942. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56943. */
  56944. export interface ICrowd {
  56945. /**
  56946. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56947. * You can attach anything to that node. The node position is updated in the scene update tick.
  56948. * @param pos world position that will be constrained by the navigation mesh
  56949. * @param parameters agent parameters
  56950. * @param transform hooked to the agent that will be update by the scene
  56951. * @returns agent index
  56952. */
  56953. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56954. /**
  56955. * Returns the agent position in world space
  56956. * @param index agent index returned by addAgent
  56957. * @returns world space position
  56958. */
  56959. getAgentPosition(index: number): Vector3;
  56960. /**
  56961. * Gets the agent velocity in world space
  56962. * @param index agent index returned by addAgent
  56963. * @returns world space velocity
  56964. */
  56965. getAgentVelocity(index: number): Vector3;
  56966. /**
  56967. * remove a particular agent previously created
  56968. * @param index agent index returned by addAgent
  56969. */
  56970. removeAgent(index: number): void;
  56971. /**
  56972. * get the list of all agents attached to this crowd
  56973. * @returns list of agent indices
  56974. */
  56975. getAgents(): number[];
  56976. /**
  56977. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56978. * @param deltaTime in seconds
  56979. */
  56980. update(deltaTime: number): void;
  56981. /**
  56982. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56983. * @param index agent index returned by addAgent
  56984. * @param destination targeted world position
  56985. */
  56986. agentGoto(index: number, destination: Vector3): void;
  56987. /**
  56988. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56989. * The queries will try to find a solution within those bounds
  56990. * default is (1,1,1)
  56991. * @param extent x,y,z value that define the extent around the queries point of reference
  56992. */
  56993. setDefaultQueryExtent(extent: Vector3): void;
  56994. /**
  56995. * Get the Bounding box extent specified by setDefaultQueryExtent
  56996. * @returns the box extent values
  56997. */
  56998. getDefaultQueryExtent(): Vector3;
  56999. /**
  57000. * Release all resources
  57001. */
  57002. dispose(): void;
  57003. }
  57004. /**
  57005. * Configures an agent
  57006. */
  57007. export interface IAgentParameters {
  57008. /**
  57009. * Agent radius. [Limit: >= 0]
  57010. */
  57011. radius: number;
  57012. /**
  57013. * Agent height. [Limit: > 0]
  57014. */
  57015. height: number;
  57016. /**
  57017. * Maximum allowed acceleration. [Limit: >= 0]
  57018. */
  57019. maxAcceleration: number;
  57020. /**
  57021. * Maximum allowed speed. [Limit: >= 0]
  57022. */
  57023. maxSpeed: number;
  57024. /**
  57025. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57026. */
  57027. collisionQueryRange: number;
  57028. /**
  57029. * The path visibility optimization range. [Limit: > 0]
  57030. */
  57031. pathOptimizationRange: number;
  57032. /**
  57033. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57034. */
  57035. separationWeight: number;
  57036. }
  57037. /**
  57038. * Configures the navigation mesh creation
  57039. */
  57040. export interface INavMeshParameters {
  57041. /**
  57042. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57043. */
  57044. cs: number;
  57045. /**
  57046. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57047. */
  57048. ch: number;
  57049. /**
  57050. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57051. */
  57052. walkableSlopeAngle: number;
  57053. /**
  57054. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57055. * be considered walkable. [Limit: >= 3] [Units: vx]
  57056. */
  57057. walkableHeight: number;
  57058. /**
  57059. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57060. */
  57061. walkableClimb: number;
  57062. /**
  57063. * The distance to erode/shrink the walkable area of the heightfield away from
  57064. * obstructions. [Limit: >=0] [Units: vx]
  57065. */
  57066. walkableRadius: number;
  57067. /**
  57068. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57069. */
  57070. maxEdgeLen: number;
  57071. /**
  57072. * The maximum distance a simplfied contour's border edges should deviate
  57073. * the original raw contour. [Limit: >=0] [Units: vx]
  57074. */
  57075. maxSimplificationError: number;
  57076. /**
  57077. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57078. */
  57079. minRegionArea: number;
  57080. /**
  57081. * Any regions with a span count smaller than this value will, if possible,
  57082. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57083. */
  57084. mergeRegionArea: number;
  57085. /**
  57086. * The maximum number of vertices allowed for polygons generated during the
  57087. * contour to polygon conversion process. [Limit: >= 3]
  57088. */
  57089. maxVertsPerPoly: number;
  57090. /**
  57091. * Sets the sampling distance to use when generating the detail mesh.
  57092. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57093. */
  57094. detailSampleDist: number;
  57095. /**
  57096. * The maximum distance the detail mesh surface should deviate from heightfield
  57097. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57098. */
  57099. detailSampleMaxError: number;
  57100. }
  57101. }
  57102. declare module BABYLON {
  57103. /**
  57104. * RecastJS navigation plugin
  57105. */
  57106. export class RecastJSPlugin implements INavigationEnginePlugin {
  57107. /**
  57108. * Reference to the Recast library
  57109. */
  57110. bjsRECAST: any;
  57111. /**
  57112. * plugin name
  57113. */
  57114. name: string;
  57115. /**
  57116. * the first navmesh created. We might extend this to support multiple navmeshes
  57117. */
  57118. navMesh: any;
  57119. /**
  57120. * Initializes the recastJS plugin
  57121. * @param recastInjection can be used to inject your own recast reference
  57122. */
  57123. constructor(recastInjection?: any);
  57124. /**
  57125. * Creates a navigation mesh
  57126. * @param meshes array of all the geometry used to compute the navigatio mesh
  57127. * @param parameters bunch of parameters used to filter geometry
  57128. */
  57129. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57130. /**
  57131. * Create a navigation mesh debug mesh
  57132. * @param scene is where the mesh will be added
  57133. * @returns debug display mesh
  57134. */
  57135. createDebugNavMesh(scene: Scene): Mesh;
  57136. /**
  57137. * Get a navigation mesh constrained position, closest to the parameter position
  57138. * @param position world position
  57139. * @returns the closest point to position constrained by the navigation mesh
  57140. */
  57141. getClosestPoint(position: Vector3): Vector3;
  57142. /**
  57143. * Get a navigation mesh constrained position, within a particular radius
  57144. * @param position world position
  57145. * @param maxRadius the maximum distance to the constrained world position
  57146. * @returns the closest point to position constrained by the navigation mesh
  57147. */
  57148. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57149. /**
  57150. * Compute the final position from a segment made of destination-position
  57151. * @param position world position
  57152. * @param destination world position
  57153. * @returns the resulting point along the navmesh
  57154. */
  57155. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57156. /**
  57157. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57158. * @param start world position
  57159. * @param end world position
  57160. * @returns array containing world position composing the path
  57161. */
  57162. computePath(start: Vector3, end: Vector3): Vector3[];
  57163. /**
  57164. * Create a new Crowd so you can add agents
  57165. * @param maxAgents the maximum agent count in the crowd
  57166. * @param maxAgentRadius the maximum radius an agent can have
  57167. * @param scene to attach the crowd to
  57168. * @returns the crowd you can add agents to
  57169. */
  57170. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57171. /**
  57172. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57173. * The queries will try to find a solution within those bounds
  57174. * default is (1,1,1)
  57175. * @param extent x,y,z value that define the extent around the queries point of reference
  57176. */
  57177. setDefaultQueryExtent(extent: Vector3): void;
  57178. /**
  57179. * Get the Bounding box extent specified by setDefaultQueryExtent
  57180. * @returns the box extent values
  57181. */
  57182. getDefaultQueryExtent(): Vector3;
  57183. /**
  57184. * Disposes
  57185. */
  57186. dispose(): void;
  57187. /**
  57188. * If this plugin is supported
  57189. * @returns true if plugin is supported
  57190. */
  57191. isSupported(): boolean;
  57192. }
  57193. /**
  57194. * Recast detour crowd implementation
  57195. */
  57196. export class RecastJSCrowd implements ICrowd {
  57197. /**
  57198. * Recast/detour plugin
  57199. */
  57200. bjsRECASTPlugin: RecastJSPlugin;
  57201. /**
  57202. * Link to the detour crowd
  57203. */
  57204. recastCrowd: any;
  57205. /**
  57206. * One transform per agent
  57207. */
  57208. transforms: TransformNode[];
  57209. /**
  57210. * All agents created
  57211. */
  57212. agents: number[];
  57213. /**
  57214. * Link to the scene is kept to unregister the crowd from the scene
  57215. */
  57216. private _scene;
  57217. /**
  57218. * Observer for crowd updates
  57219. */
  57220. private _onBeforeAnimationsObserver;
  57221. /**
  57222. * Constructor
  57223. * @param plugin recastJS plugin
  57224. * @param maxAgents the maximum agent count in the crowd
  57225. * @param maxAgentRadius the maximum radius an agent can have
  57226. * @param scene to attach the crowd to
  57227. * @returns the crowd you can add agents to
  57228. */
  57229. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57230. /**
  57231. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57232. * You can attach anything to that node. The node position is updated in the scene update tick.
  57233. * @param pos world position that will be constrained by the navigation mesh
  57234. * @param parameters agent parameters
  57235. * @param transform hooked to the agent that will be update by the scene
  57236. * @returns agent index
  57237. */
  57238. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57239. /**
  57240. * Returns the agent position in world space
  57241. * @param index agent index returned by addAgent
  57242. * @returns world space position
  57243. */
  57244. getAgentPosition(index: number): Vector3;
  57245. /**
  57246. * Returns the agent velocity in world space
  57247. * @param index agent index returned by addAgent
  57248. * @returns world space velocity
  57249. */
  57250. getAgentVelocity(index: number): Vector3;
  57251. /**
  57252. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57253. * @param index agent index returned by addAgent
  57254. * @param destination targeted world position
  57255. */
  57256. agentGoto(index: number, destination: Vector3): void;
  57257. /**
  57258. * remove a particular agent previously created
  57259. * @param index agent index returned by addAgent
  57260. */
  57261. removeAgent(index: number): void;
  57262. /**
  57263. * get the list of all agents attached to this crowd
  57264. * @returns list of agent indices
  57265. */
  57266. getAgents(): number[];
  57267. /**
  57268. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57269. * @param deltaTime in seconds
  57270. */
  57271. update(deltaTime: number): void;
  57272. /**
  57273. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57274. * The queries will try to find a solution within those bounds
  57275. * default is (1,1,1)
  57276. * @param extent x,y,z value that define the extent around the queries point of reference
  57277. */
  57278. setDefaultQueryExtent(extent: Vector3): void;
  57279. /**
  57280. * Get the Bounding box extent specified by setDefaultQueryExtent
  57281. * @returns the box extent values
  57282. */
  57283. getDefaultQueryExtent(): Vector3;
  57284. /**
  57285. * Release all resources
  57286. */
  57287. dispose(): void;
  57288. }
  57289. }
  57290. declare module BABYLON {
  57291. /**
  57292. * Class used to enable access to IndexedDB
  57293. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57294. */
  57295. export class Database implements IOfflineProvider {
  57296. private _callbackManifestChecked;
  57297. private _currentSceneUrl;
  57298. private _db;
  57299. private _enableSceneOffline;
  57300. private _enableTexturesOffline;
  57301. private _manifestVersionFound;
  57302. private _mustUpdateRessources;
  57303. private _hasReachedQuota;
  57304. private _isSupported;
  57305. private _idbFactory;
  57306. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57307. private static IsUASupportingBlobStorage;
  57308. /**
  57309. * Gets a boolean indicating if Database storate is enabled (off by default)
  57310. */
  57311. static IDBStorageEnabled: boolean;
  57312. /**
  57313. * Gets a boolean indicating if scene must be saved in the database
  57314. */
  57315. readonly enableSceneOffline: boolean;
  57316. /**
  57317. * Gets a boolean indicating if textures must be saved in the database
  57318. */
  57319. readonly enableTexturesOffline: boolean;
  57320. /**
  57321. * Creates a new Database
  57322. * @param urlToScene defines the url to load the scene
  57323. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57324. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57325. */
  57326. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57327. private static _ParseURL;
  57328. private static _ReturnFullUrlLocation;
  57329. private _checkManifestFile;
  57330. /**
  57331. * Open the database and make it available
  57332. * @param successCallback defines the callback to call on success
  57333. * @param errorCallback defines the callback to call on error
  57334. */
  57335. open(successCallback: () => void, errorCallback: () => void): void;
  57336. /**
  57337. * Loads an image from the database
  57338. * @param url defines the url to load from
  57339. * @param image defines the target DOM image
  57340. */
  57341. loadImage(url: string, image: HTMLImageElement): void;
  57342. private _loadImageFromDBAsync;
  57343. private _saveImageIntoDBAsync;
  57344. private _checkVersionFromDB;
  57345. private _loadVersionFromDBAsync;
  57346. private _saveVersionIntoDBAsync;
  57347. /**
  57348. * Loads a file from database
  57349. * @param url defines the URL to load from
  57350. * @param sceneLoaded defines a callback to call on success
  57351. * @param progressCallBack defines a callback to call when progress changed
  57352. * @param errorCallback defines a callback to call on error
  57353. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57354. */
  57355. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57356. private _loadFileAsync;
  57357. private _saveFileAsync;
  57358. /**
  57359. * Validates if xhr data is correct
  57360. * @param xhr defines the request to validate
  57361. * @param dataType defines the expected data type
  57362. * @returns true if data is correct
  57363. */
  57364. private static _ValidateXHRData;
  57365. }
  57366. }
  57367. declare module BABYLON {
  57368. /** @hidden */
  57369. export var gpuUpdateParticlesPixelShader: {
  57370. name: string;
  57371. shader: string;
  57372. };
  57373. }
  57374. declare module BABYLON {
  57375. /** @hidden */
  57376. export var gpuUpdateParticlesVertexShader: {
  57377. name: string;
  57378. shader: string;
  57379. };
  57380. }
  57381. declare module BABYLON {
  57382. /** @hidden */
  57383. export var clipPlaneFragmentDeclaration2: {
  57384. name: string;
  57385. shader: string;
  57386. };
  57387. }
  57388. declare module BABYLON {
  57389. /** @hidden */
  57390. export var gpuRenderParticlesPixelShader: {
  57391. name: string;
  57392. shader: string;
  57393. };
  57394. }
  57395. declare module BABYLON {
  57396. /** @hidden */
  57397. export var clipPlaneVertexDeclaration2: {
  57398. name: string;
  57399. shader: string;
  57400. };
  57401. }
  57402. declare module BABYLON {
  57403. /** @hidden */
  57404. export var gpuRenderParticlesVertexShader: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module BABYLON {
  57410. /**
  57411. * This represents a GPU particle system in Babylon
  57412. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57413. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57414. */
  57415. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57416. /**
  57417. * The layer mask we are rendering the particles through.
  57418. */
  57419. layerMask: number;
  57420. private _capacity;
  57421. private _activeCount;
  57422. private _currentActiveCount;
  57423. private _accumulatedCount;
  57424. private _renderEffect;
  57425. private _updateEffect;
  57426. private _buffer0;
  57427. private _buffer1;
  57428. private _spriteBuffer;
  57429. private _updateVAO;
  57430. private _renderVAO;
  57431. private _targetIndex;
  57432. private _sourceBuffer;
  57433. private _targetBuffer;
  57434. private _engine;
  57435. private _currentRenderId;
  57436. private _started;
  57437. private _stopped;
  57438. private _timeDelta;
  57439. private _randomTexture;
  57440. private _randomTexture2;
  57441. private _attributesStrideSize;
  57442. private _updateEffectOptions;
  57443. private _randomTextureSize;
  57444. private _actualFrame;
  57445. private readonly _rawTextureWidth;
  57446. /**
  57447. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57448. */
  57449. static readonly IsSupported: boolean;
  57450. /**
  57451. * An event triggered when the system is disposed.
  57452. */
  57453. onDisposeObservable: Observable<GPUParticleSystem>;
  57454. /**
  57455. * Gets the maximum number of particles active at the same time.
  57456. * @returns The max number of active particles.
  57457. */
  57458. getCapacity(): number;
  57459. /**
  57460. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57461. * to override the particles.
  57462. */
  57463. forceDepthWrite: boolean;
  57464. /**
  57465. * Gets or set the number of active particles
  57466. */
  57467. activeParticleCount: number;
  57468. private _preWarmDone;
  57469. /**
  57470. * Is this system ready to be used/rendered
  57471. * @return true if the system is ready
  57472. */
  57473. isReady(): boolean;
  57474. /**
  57475. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57476. * @returns True if it has been started, otherwise false.
  57477. */
  57478. isStarted(): boolean;
  57479. /**
  57480. * Starts the particle system and begins to emit
  57481. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57482. */
  57483. start(delay?: number): void;
  57484. /**
  57485. * Stops the particle system.
  57486. */
  57487. stop(): void;
  57488. /**
  57489. * Remove all active particles
  57490. */
  57491. reset(): void;
  57492. /**
  57493. * Returns the string "GPUParticleSystem"
  57494. * @returns a string containing the class name
  57495. */
  57496. getClassName(): string;
  57497. private _colorGradientsTexture;
  57498. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57499. /**
  57500. * Adds a new color gradient
  57501. * @param gradient defines the gradient to use (between 0 and 1)
  57502. * @param color1 defines the color to affect to the specified gradient
  57503. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57504. * @returns the current particle system
  57505. */
  57506. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57507. /**
  57508. * Remove a specific color gradient
  57509. * @param gradient defines the gradient to remove
  57510. * @returns the current particle system
  57511. */
  57512. removeColorGradient(gradient: number): GPUParticleSystem;
  57513. private _angularSpeedGradientsTexture;
  57514. private _sizeGradientsTexture;
  57515. private _velocityGradientsTexture;
  57516. private _limitVelocityGradientsTexture;
  57517. private _dragGradientsTexture;
  57518. private _addFactorGradient;
  57519. /**
  57520. * Adds a new size gradient
  57521. * @param gradient defines the gradient to use (between 0 and 1)
  57522. * @param factor defines the size factor to affect to the specified gradient
  57523. * @returns the current particle system
  57524. */
  57525. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57526. /**
  57527. * Remove a specific size gradient
  57528. * @param gradient defines the gradient to remove
  57529. * @returns the current particle system
  57530. */
  57531. removeSizeGradient(gradient: number): GPUParticleSystem;
  57532. /**
  57533. * Adds a new angular speed gradient
  57534. * @param gradient defines the gradient to use (between 0 and 1)
  57535. * @param factor defines the angular speed to affect to the specified gradient
  57536. * @returns the current particle system
  57537. */
  57538. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57539. /**
  57540. * Remove a specific angular speed gradient
  57541. * @param gradient defines the gradient to remove
  57542. * @returns the current particle system
  57543. */
  57544. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57545. /**
  57546. * Adds a new velocity gradient
  57547. * @param gradient defines the gradient to use (between 0 and 1)
  57548. * @param factor defines the velocity to affect to the specified gradient
  57549. * @returns the current particle system
  57550. */
  57551. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57552. /**
  57553. * Remove a specific velocity gradient
  57554. * @param gradient defines the gradient to remove
  57555. * @returns the current particle system
  57556. */
  57557. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57558. /**
  57559. * Adds a new limit velocity gradient
  57560. * @param gradient defines the gradient to use (between 0 and 1)
  57561. * @param factor defines the limit velocity value to affect to the specified gradient
  57562. * @returns the current particle system
  57563. */
  57564. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57565. /**
  57566. * Remove a specific limit velocity gradient
  57567. * @param gradient defines the gradient to remove
  57568. * @returns the current particle system
  57569. */
  57570. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57571. /**
  57572. * Adds a new drag gradient
  57573. * @param gradient defines the gradient to use (between 0 and 1)
  57574. * @param factor defines the drag value to affect to the specified gradient
  57575. * @returns the current particle system
  57576. */
  57577. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57578. /**
  57579. * Remove a specific drag gradient
  57580. * @param gradient defines the gradient to remove
  57581. * @returns the current particle system
  57582. */
  57583. removeDragGradient(gradient: number): GPUParticleSystem;
  57584. /**
  57585. * Not supported by GPUParticleSystem
  57586. * @param gradient defines the gradient to use (between 0 and 1)
  57587. * @param factor defines the emit rate value to affect to the specified gradient
  57588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57589. * @returns the current particle system
  57590. */
  57591. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57592. /**
  57593. * Not supported by GPUParticleSystem
  57594. * @param gradient defines the gradient to remove
  57595. * @returns the current particle system
  57596. */
  57597. removeEmitRateGradient(gradient: number): IParticleSystem;
  57598. /**
  57599. * Not supported by GPUParticleSystem
  57600. * @param gradient defines the gradient to use (between 0 and 1)
  57601. * @param factor defines the start size value to affect to the specified gradient
  57602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57603. * @returns the current particle system
  57604. */
  57605. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57606. /**
  57607. * Not supported by GPUParticleSystem
  57608. * @param gradient defines the gradient to remove
  57609. * @returns the current particle system
  57610. */
  57611. removeStartSizeGradient(gradient: number): IParticleSystem;
  57612. /**
  57613. * Not supported by GPUParticleSystem
  57614. * @param gradient defines the gradient to use (between 0 and 1)
  57615. * @param min defines the color remap minimal range
  57616. * @param max defines the color remap maximal range
  57617. * @returns the current particle system
  57618. */
  57619. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57620. /**
  57621. * Not supported by GPUParticleSystem
  57622. * @param gradient defines the gradient to remove
  57623. * @returns the current particle system
  57624. */
  57625. removeColorRemapGradient(): IParticleSystem;
  57626. /**
  57627. * Not supported by GPUParticleSystem
  57628. * @param gradient defines the gradient to use (between 0 and 1)
  57629. * @param min defines the alpha remap minimal range
  57630. * @param max defines the alpha remap maximal range
  57631. * @returns the current particle system
  57632. */
  57633. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57634. /**
  57635. * Not supported by GPUParticleSystem
  57636. * @param gradient defines the gradient to remove
  57637. * @returns the current particle system
  57638. */
  57639. removeAlphaRemapGradient(): IParticleSystem;
  57640. /**
  57641. * Not supported by GPUParticleSystem
  57642. * @param gradient defines the gradient to use (between 0 and 1)
  57643. * @param color defines the color to affect to the specified gradient
  57644. * @returns the current particle system
  57645. */
  57646. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57647. /**
  57648. * Not supported by GPUParticleSystem
  57649. * @param gradient defines the gradient to remove
  57650. * @returns the current particle system
  57651. */
  57652. removeRampGradient(): IParticleSystem;
  57653. /**
  57654. * Not supported by GPUParticleSystem
  57655. * @returns the list of ramp gradients
  57656. */
  57657. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57658. /**
  57659. * Not supported by GPUParticleSystem
  57660. * Gets or sets a boolean indicating that ramp gradients must be used
  57661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57662. */
  57663. useRampGradients: boolean;
  57664. /**
  57665. * Not supported by GPUParticleSystem
  57666. * @param gradient defines the gradient to use (between 0 and 1)
  57667. * @param factor defines the life time factor to affect to the specified gradient
  57668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57669. * @returns the current particle system
  57670. */
  57671. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57672. /**
  57673. * Not supported by GPUParticleSystem
  57674. * @param gradient defines the gradient to remove
  57675. * @returns the current particle system
  57676. */
  57677. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57678. /**
  57679. * Instantiates a GPU particle system.
  57680. * 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.
  57681. * @param name The name of the particle system
  57682. * @param options The options used to create the system
  57683. * @param scene The scene the particle system belongs to
  57684. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57685. */
  57686. constructor(name: string, options: Partial<{
  57687. capacity: number;
  57688. randomTextureSize: number;
  57689. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57690. protected _reset(): void;
  57691. private _createUpdateVAO;
  57692. private _createRenderVAO;
  57693. private _initialize;
  57694. /** @hidden */
  57695. _recreateUpdateEffect(): void;
  57696. /** @hidden */
  57697. _recreateRenderEffect(): void;
  57698. /**
  57699. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57700. * @param preWarm defines if we are in the pre-warmimg phase
  57701. */
  57702. animate(preWarm?: boolean): void;
  57703. private _createFactorGradientTexture;
  57704. private _createSizeGradientTexture;
  57705. private _createAngularSpeedGradientTexture;
  57706. private _createVelocityGradientTexture;
  57707. private _createLimitVelocityGradientTexture;
  57708. private _createDragGradientTexture;
  57709. private _createColorGradientTexture;
  57710. /**
  57711. * Renders the particle system in its current state
  57712. * @param preWarm defines if the system should only update the particles but not render them
  57713. * @returns the current number of particles
  57714. */
  57715. render(preWarm?: boolean): number;
  57716. /**
  57717. * Rebuilds the particle system
  57718. */
  57719. rebuild(): void;
  57720. private _releaseBuffers;
  57721. private _releaseVAOs;
  57722. /**
  57723. * Disposes the particle system and free the associated resources
  57724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57725. */
  57726. dispose(disposeTexture?: boolean): void;
  57727. /**
  57728. * Clones the particle system.
  57729. * @param name The name of the cloned object
  57730. * @param newEmitter The new emitter to use
  57731. * @returns the cloned particle system
  57732. */
  57733. clone(name: string, newEmitter: any): GPUParticleSystem;
  57734. /**
  57735. * Serializes the particle system to a JSON object.
  57736. * @returns the JSON object
  57737. */
  57738. serialize(): any;
  57739. /**
  57740. * Parses a JSON object to create a GPU particle system.
  57741. * @param parsedParticleSystem The JSON object to parse
  57742. * @param scene The scene to create the particle system in
  57743. * @param rootUrl The root url to use to load external dependencies like texture
  57744. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57745. * @returns the parsed GPU particle system
  57746. */
  57747. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57748. }
  57749. }
  57750. declare module BABYLON {
  57751. /**
  57752. * Represents a set of particle systems working together to create a specific effect
  57753. */
  57754. export class ParticleSystemSet implements IDisposable {
  57755. private _emitterCreationOptions;
  57756. private _emitterNode;
  57757. /**
  57758. * Gets the particle system list
  57759. */
  57760. systems: IParticleSystem[];
  57761. /**
  57762. * Gets the emitter node used with this set
  57763. */
  57764. readonly emitterNode: Nullable<TransformNode>;
  57765. /**
  57766. * Creates a new emitter mesh as a sphere
  57767. * @param options defines the options used to create the sphere
  57768. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57769. * @param scene defines the hosting scene
  57770. */
  57771. setEmitterAsSphere(options: {
  57772. diameter: number;
  57773. segments: number;
  57774. color: Color3;
  57775. }, renderingGroupId: number, scene: Scene): void;
  57776. /**
  57777. * Starts all particle systems of the set
  57778. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57779. */
  57780. start(emitter?: AbstractMesh): void;
  57781. /**
  57782. * Release all associated resources
  57783. */
  57784. dispose(): void;
  57785. /**
  57786. * Serialize the set into a JSON compatible object
  57787. * @returns a JSON compatible representation of the set
  57788. */
  57789. serialize(): any;
  57790. /**
  57791. * Parse a new ParticleSystemSet from a serialized source
  57792. * @param data defines a JSON compatible representation of the set
  57793. * @param scene defines the hosting scene
  57794. * @param gpu defines if we want GPU particles or CPU particles
  57795. * @returns a new ParticleSystemSet
  57796. */
  57797. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57798. }
  57799. }
  57800. declare module BABYLON {
  57801. /**
  57802. * This class is made for on one-liner static method to help creating particle system set.
  57803. */
  57804. export class ParticleHelper {
  57805. /**
  57806. * Gets or sets base Assets URL
  57807. */
  57808. static BaseAssetsUrl: string;
  57809. /**
  57810. * Create a default particle system that you can tweak
  57811. * @param emitter defines the emitter to use
  57812. * @param capacity defines the system capacity (default is 500 particles)
  57813. * @param scene defines the hosting scene
  57814. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57815. * @returns the new Particle system
  57816. */
  57817. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57818. /**
  57819. * This is the main static method (one-liner) of this helper to create different particle systems
  57820. * @param type This string represents the type to the particle system to create
  57821. * @param scene The scene where the particle system should live
  57822. * @param gpu If the system will use gpu
  57823. * @returns the ParticleSystemSet created
  57824. */
  57825. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57826. /**
  57827. * Static function used to export a particle system to a ParticleSystemSet variable.
  57828. * Please note that the emitter shape is not exported
  57829. * @param systems defines the particle systems to export
  57830. * @returns the created particle system set
  57831. */
  57832. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57833. }
  57834. }
  57835. declare module BABYLON {
  57836. interface Engine {
  57837. /**
  57838. * Create an effect to use with particle systems.
  57839. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57840. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57841. * @param uniformsNames defines a list of attribute names
  57842. * @param samplers defines an array of string used to represent textures
  57843. * @param defines defines the string containing the defines to use to compile the shaders
  57844. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57845. * @param onCompiled defines a function to call when the effect creation is successful
  57846. * @param onError defines a function to call when the effect creation has failed
  57847. * @returns the new Effect
  57848. */
  57849. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57850. }
  57851. interface Mesh {
  57852. /**
  57853. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57854. * @returns an array of IParticleSystem
  57855. */
  57856. getEmittedParticleSystems(): IParticleSystem[];
  57857. /**
  57858. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57859. * @returns an array of IParticleSystem
  57860. */
  57861. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57862. }
  57863. /**
  57864. * @hidden
  57865. */
  57866. export var _IDoNeedToBeInTheBuild: number;
  57867. }
  57868. declare module BABYLON {
  57869. interface Scene {
  57870. /** @hidden (Backing field) */
  57871. _physicsEngine: Nullable<IPhysicsEngine>;
  57872. /**
  57873. * Gets the current physics engine
  57874. * @returns a IPhysicsEngine or null if none attached
  57875. */
  57876. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57877. /**
  57878. * Enables physics to the current scene
  57879. * @param gravity defines the scene's gravity for the physics engine
  57880. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57881. * @return a boolean indicating if the physics engine was initialized
  57882. */
  57883. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57884. /**
  57885. * Disables and disposes the physics engine associated with the scene
  57886. */
  57887. disablePhysicsEngine(): void;
  57888. /**
  57889. * Gets a boolean indicating if there is an active physics engine
  57890. * @returns a boolean indicating if there is an active physics engine
  57891. */
  57892. isPhysicsEnabled(): boolean;
  57893. /**
  57894. * Deletes a physics compound impostor
  57895. * @param compound defines the compound to delete
  57896. */
  57897. deleteCompoundImpostor(compound: any): void;
  57898. /**
  57899. * An event triggered when physic simulation is about to be run
  57900. */
  57901. onBeforePhysicsObservable: Observable<Scene>;
  57902. /**
  57903. * An event triggered when physic simulation has been done
  57904. */
  57905. onAfterPhysicsObservable: Observable<Scene>;
  57906. }
  57907. interface AbstractMesh {
  57908. /** @hidden */
  57909. _physicsImpostor: Nullable<PhysicsImpostor>;
  57910. /**
  57911. * Gets or sets impostor used for physic simulation
  57912. * @see http://doc.babylonjs.com/features/physics_engine
  57913. */
  57914. physicsImpostor: Nullable<PhysicsImpostor>;
  57915. /**
  57916. * Gets the current physics impostor
  57917. * @see http://doc.babylonjs.com/features/physics_engine
  57918. * @returns a physics impostor or null
  57919. */
  57920. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57921. /** Apply a physic impulse to the mesh
  57922. * @param force defines the force to apply
  57923. * @param contactPoint defines where to apply the force
  57924. * @returns the current mesh
  57925. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57926. */
  57927. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57928. /**
  57929. * Creates a physic joint between two meshes
  57930. * @param otherMesh defines the other mesh to use
  57931. * @param pivot1 defines the pivot to use on this mesh
  57932. * @param pivot2 defines the pivot to use on the other mesh
  57933. * @param options defines additional options (can be plugin dependent)
  57934. * @returns the current mesh
  57935. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57936. */
  57937. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57938. /** @hidden */
  57939. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57940. }
  57941. /**
  57942. * Defines the physics engine scene component responsible to manage a physics engine
  57943. */
  57944. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57945. /**
  57946. * The component name helpful to identify the component in the list of scene components.
  57947. */
  57948. readonly name: string;
  57949. /**
  57950. * The scene the component belongs to.
  57951. */
  57952. scene: Scene;
  57953. /**
  57954. * Creates a new instance of the component for the given scene
  57955. * @param scene Defines the scene to register the component in
  57956. */
  57957. constructor(scene: Scene);
  57958. /**
  57959. * Registers the component in a given scene
  57960. */
  57961. register(): void;
  57962. /**
  57963. * Rebuilds the elements related to this component in case of
  57964. * context lost for instance.
  57965. */
  57966. rebuild(): void;
  57967. /**
  57968. * Disposes the component and the associated ressources
  57969. */
  57970. dispose(): void;
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * A helper for physics simulations
  57976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57977. */
  57978. export class PhysicsHelper {
  57979. private _scene;
  57980. private _physicsEngine;
  57981. /**
  57982. * Initializes the Physics helper
  57983. * @param scene Babylon.js scene
  57984. */
  57985. constructor(scene: Scene);
  57986. /**
  57987. * Applies a radial explosion impulse
  57988. * @param origin the origin of the explosion
  57989. * @param radiusOrEventOptions the radius or the options of radial explosion
  57990. * @param strength the explosion strength
  57991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57992. * @returns A physics radial explosion event, or null
  57993. */
  57994. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57995. /**
  57996. * Applies a radial explosion force
  57997. * @param origin the origin of the explosion
  57998. * @param radiusOrEventOptions the radius or the options of radial explosion
  57999. * @param strength the explosion strength
  58000. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58001. * @returns A physics radial explosion event, or null
  58002. */
  58003. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58004. /**
  58005. * Creates a gravitational field
  58006. * @param origin the origin of the explosion
  58007. * @param radiusOrEventOptions the radius or the options of radial explosion
  58008. * @param strength the explosion strength
  58009. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58010. * @returns A physics gravitational field event, or null
  58011. */
  58012. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58013. /**
  58014. * Creates a physics updraft event
  58015. * @param origin the origin of the updraft
  58016. * @param radiusOrEventOptions the radius or the options of the updraft
  58017. * @param strength the strength of the updraft
  58018. * @param height the height of the updraft
  58019. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58020. * @returns A physics updraft event, or null
  58021. */
  58022. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58023. /**
  58024. * Creates a physics vortex event
  58025. * @param origin the of the vortex
  58026. * @param radiusOrEventOptions the radius or the options of the vortex
  58027. * @param strength the strength of the vortex
  58028. * @param height the height of the vortex
  58029. * @returns a Physics vortex event, or null
  58030. * A physics vortex event or null
  58031. */
  58032. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58033. }
  58034. /**
  58035. * Represents a physics radial explosion event
  58036. */
  58037. class PhysicsRadialExplosionEvent {
  58038. private _scene;
  58039. private _options;
  58040. private _sphere;
  58041. private _dataFetched;
  58042. /**
  58043. * Initializes a radial explosioin event
  58044. * @param _scene BabylonJS scene
  58045. * @param _options The options for the vortex event
  58046. */
  58047. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58048. /**
  58049. * Returns the data related to the radial explosion event (sphere).
  58050. * @returns The radial explosion event data
  58051. */
  58052. getData(): PhysicsRadialExplosionEventData;
  58053. /**
  58054. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58055. * @param impostor A physics imposter
  58056. * @param origin the origin of the explosion
  58057. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58058. */
  58059. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58060. /**
  58061. * Triggers affecterd impostors callbacks
  58062. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58063. */
  58064. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58065. /**
  58066. * Disposes the sphere.
  58067. * @param force Specifies if the sphere should be disposed by force
  58068. */
  58069. dispose(force?: boolean): void;
  58070. /*** Helpers ***/
  58071. private _prepareSphere;
  58072. private _intersectsWithSphere;
  58073. }
  58074. /**
  58075. * Represents a gravitational field event
  58076. */
  58077. class PhysicsGravitationalFieldEvent {
  58078. private _physicsHelper;
  58079. private _scene;
  58080. private _origin;
  58081. private _options;
  58082. private _tickCallback;
  58083. private _sphere;
  58084. private _dataFetched;
  58085. /**
  58086. * Initializes the physics gravitational field event
  58087. * @param _physicsHelper A physics helper
  58088. * @param _scene BabylonJS scene
  58089. * @param _origin The origin position of the gravitational field event
  58090. * @param _options The options for the vortex event
  58091. */
  58092. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58093. /**
  58094. * Returns the data related to the gravitational field event (sphere).
  58095. * @returns A gravitational field event
  58096. */
  58097. getData(): PhysicsGravitationalFieldEventData;
  58098. /**
  58099. * Enables the gravitational field.
  58100. */
  58101. enable(): void;
  58102. /**
  58103. * Disables the gravitational field.
  58104. */
  58105. disable(): void;
  58106. /**
  58107. * Disposes the sphere.
  58108. * @param force The force to dispose from the gravitational field event
  58109. */
  58110. dispose(force?: boolean): void;
  58111. private _tick;
  58112. }
  58113. /**
  58114. * Represents a physics updraft event
  58115. */
  58116. class PhysicsUpdraftEvent {
  58117. private _scene;
  58118. private _origin;
  58119. private _options;
  58120. private _physicsEngine;
  58121. private _originTop;
  58122. private _originDirection;
  58123. private _tickCallback;
  58124. private _cylinder;
  58125. private _cylinderPosition;
  58126. private _dataFetched;
  58127. /**
  58128. * Initializes the physics updraft event
  58129. * @param _scene BabylonJS scene
  58130. * @param _origin The origin position of the updraft
  58131. * @param _options The options for the updraft event
  58132. */
  58133. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58134. /**
  58135. * Returns the data related to the updraft event (cylinder).
  58136. * @returns A physics updraft event
  58137. */
  58138. getData(): PhysicsUpdraftEventData;
  58139. /**
  58140. * Enables the updraft.
  58141. */
  58142. enable(): void;
  58143. /**
  58144. * Disables the updraft.
  58145. */
  58146. disable(): void;
  58147. /**
  58148. * Disposes the cylinder.
  58149. * @param force Specifies if the updraft should be disposed by force
  58150. */
  58151. dispose(force?: boolean): void;
  58152. private getImpostorHitData;
  58153. private _tick;
  58154. /*** Helpers ***/
  58155. private _prepareCylinder;
  58156. private _intersectsWithCylinder;
  58157. }
  58158. /**
  58159. * Represents a physics vortex event
  58160. */
  58161. class PhysicsVortexEvent {
  58162. private _scene;
  58163. private _origin;
  58164. private _options;
  58165. private _physicsEngine;
  58166. private _originTop;
  58167. private _tickCallback;
  58168. private _cylinder;
  58169. private _cylinderPosition;
  58170. private _dataFetched;
  58171. /**
  58172. * Initializes the physics vortex event
  58173. * @param _scene The BabylonJS scene
  58174. * @param _origin The origin position of the vortex
  58175. * @param _options The options for the vortex event
  58176. */
  58177. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58178. /**
  58179. * Returns the data related to the vortex event (cylinder).
  58180. * @returns The physics vortex event data
  58181. */
  58182. getData(): PhysicsVortexEventData;
  58183. /**
  58184. * Enables the vortex.
  58185. */
  58186. enable(): void;
  58187. /**
  58188. * Disables the cortex.
  58189. */
  58190. disable(): void;
  58191. /**
  58192. * Disposes the sphere.
  58193. * @param force
  58194. */
  58195. dispose(force?: boolean): void;
  58196. private getImpostorHitData;
  58197. private _tick;
  58198. /*** Helpers ***/
  58199. private _prepareCylinder;
  58200. private _intersectsWithCylinder;
  58201. }
  58202. /**
  58203. * Options fot the radial explosion event
  58204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58205. */
  58206. export class PhysicsRadialExplosionEventOptions {
  58207. /**
  58208. * The radius of the sphere for the radial explosion.
  58209. */
  58210. radius: number;
  58211. /**
  58212. * The strenth of the explosion.
  58213. */
  58214. strength: number;
  58215. /**
  58216. * The strenght of the force in correspondence to the distance of the affected object
  58217. */
  58218. falloff: PhysicsRadialImpulseFalloff;
  58219. /**
  58220. * Sphere options for the radial explosion.
  58221. */
  58222. sphere: {
  58223. segments: number;
  58224. diameter: number;
  58225. };
  58226. /**
  58227. * Sphere options for the radial explosion.
  58228. */
  58229. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58230. }
  58231. /**
  58232. * Options fot the updraft event
  58233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58234. */
  58235. export class PhysicsUpdraftEventOptions {
  58236. /**
  58237. * The radius of the cylinder for the vortex
  58238. */
  58239. radius: number;
  58240. /**
  58241. * The strenth of the updraft.
  58242. */
  58243. strength: number;
  58244. /**
  58245. * The height of the cylinder for the updraft.
  58246. */
  58247. height: number;
  58248. /**
  58249. * The mode for the the updraft.
  58250. */
  58251. updraftMode: PhysicsUpdraftMode;
  58252. }
  58253. /**
  58254. * Options fot the vortex event
  58255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58256. */
  58257. export class PhysicsVortexEventOptions {
  58258. /**
  58259. * The radius of the cylinder for the vortex
  58260. */
  58261. radius: number;
  58262. /**
  58263. * The strenth of the vortex.
  58264. */
  58265. strength: number;
  58266. /**
  58267. * The height of the cylinder for the vortex.
  58268. */
  58269. height: number;
  58270. /**
  58271. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58272. */
  58273. centripetalForceThreshold: number;
  58274. /**
  58275. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58276. */
  58277. centripetalForceMultiplier: number;
  58278. /**
  58279. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58280. */
  58281. centrifugalForceMultiplier: number;
  58282. /**
  58283. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58284. */
  58285. updraftForceMultiplier: number;
  58286. }
  58287. /**
  58288. * The strenght of the force in correspondence to the distance of the affected object
  58289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58290. */
  58291. export enum PhysicsRadialImpulseFalloff {
  58292. /** Defines that impulse is constant in strength across it's whole radius */
  58293. Constant = 0,
  58294. /** Defines that impulse gets weaker if it's further from the origin */
  58295. Linear = 1
  58296. }
  58297. /**
  58298. * The strength of the force in correspondence to the distance of the affected object
  58299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58300. */
  58301. export enum PhysicsUpdraftMode {
  58302. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58303. Center = 0,
  58304. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58305. Perpendicular = 1
  58306. }
  58307. /**
  58308. * Interface for a physics hit data
  58309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58310. */
  58311. export interface PhysicsHitData {
  58312. /**
  58313. * The force applied at the contact point
  58314. */
  58315. force: Vector3;
  58316. /**
  58317. * The contact point
  58318. */
  58319. contactPoint: Vector3;
  58320. /**
  58321. * The distance from the origin to the contact point
  58322. */
  58323. distanceFromOrigin: number;
  58324. }
  58325. /**
  58326. * Interface for radial explosion event data
  58327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58328. */
  58329. export interface PhysicsRadialExplosionEventData {
  58330. /**
  58331. * A sphere used for the radial explosion event
  58332. */
  58333. sphere: Mesh;
  58334. }
  58335. /**
  58336. * Interface for gravitational field event data
  58337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58338. */
  58339. export interface PhysicsGravitationalFieldEventData {
  58340. /**
  58341. * A sphere mesh used for the gravitational field event
  58342. */
  58343. sphere: Mesh;
  58344. }
  58345. /**
  58346. * Interface for updraft event data
  58347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58348. */
  58349. export interface PhysicsUpdraftEventData {
  58350. /**
  58351. * A cylinder used for the updraft event
  58352. */
  58353. cylinder: Mesh;
  58354. }
  58355. /**
  58356. * Interface for vortex event data
  58357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58358. */
  58359. export interface PhysicsVortexEventData {
  58360. /**
  58361. * A cylinder used for the vortex event
  58362. */
  58363. cylinder: Mesh;
  58364. }
  58365. /**
  58366. * Interface for an affected physics impostor
  58367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58368. */
  58369. export interface PhysicsAffectedImpostorWithData {
  58370. /**
  58371. * The impostor affected by the effect
  58372. */
  58373. impostor: PhysicsImpostor;
  58374. /**
  58375. * The data about the hit/horce from the explosion
  58376. */
  58377. hitData: PhysicsHitData;
  58378. }
  58379. }
  58380. declare module BABYLON {
  58381. /** @hidden */
  58382. export var blackAndWhitePixelShader: {
  58383. name: string;
  58384. shader: string;
  58385. };
  58386. }
  58387. declare module BABYLON {
  58388. /**
  58389. * Post process used to render in black and white
  58390. */
  58391. export class BlackAndWhitePostProcess extends PostProcess {
  58392. /**
  58393. * Linear about to convert he result to black and white (default: 1)
  58394. */
  58395. degree: number;
  58396. /**
  58397. * Creates a black and white post process
  58398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58399. * @param name The name of the effect.
  58400. * @param options The required width/height ratio to downsize to before computing the render pass.
  58401. * @param camera The camera to apply the render pass to.
  58402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58403. * @param engine The engine which the post process will be applied. (default: current engine)
  58404. * @param reusable If the post process can be reused on the same frame. (default: false)
  58405. */
  58406. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58407. }
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * This represents a set of one or more post processes in Babylon.
  58412. * A post process can be used to apply a shader to a texture after it is rendered.
  58413. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58414. */
  58415. export class PostProcessRenderEffect {
  58416. private _postProcesses;
  58417. private _getPostProcesses;
  58418. private _singleInstance;
  58419. private _cameras;
  58420. private _indicesForCamera;
  58421. /**
  58422. * Name of the effect
  58423. * @hidden
  58424. */
  58425. _name: string;
  58426. /**
  58427. * Instantiates a post process render effect.
  58428. * A post process can be used to apply a shader to a texture after it is rendered.
  58429. * @param engine The engine the effect is tied to
  58430. * @param name The name of the effect
  58431. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58432. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58433. */
  58434. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58435. /**
  58436. * Checks if all the post processes in the effect are supported.
  58437. */
  58438. readonly isSupported: boolean;
  58439. /**
  58440. * Updates the current state of the effect
  58441. * @hidden
  58442. */
  58443. _update(): void;
  58444. /**
  58445. * Attaches the effect on cameras
  58446. * @param cameras The camera to attach to.
  58447. * @hidden
  58448. */
  58449. _attachCameras(cameras: Camera): void;
  58450. /**
  58451. * Attaches the effect on cameras
  58452. * @param cameras The camera to attach to.
  58453. * @hidden
  58454. */
  58455. _attachCameras(cameras: Camera[]): void;
  58456. /**
  58457. * Detaches the effect on cameras
  58458. * @param cameras The camera to detatch from.
  58459. * @hidden
  58460. */
  58461. _detachCameras(cameras: Camera): void;
  58462. /**
  58463. * Detatches the effect on cameras
  58464. * @param cameras The camera to detatch from.
  58465. * @hidden
  58466. */
  58467. _detachCameras(cameras: Camera[]): void;
  58468. /**
  58469. * Enables the effect on given cameras
  58470. * @param cameras The camera to enable.
  58471. * @hidden
  58472. */
  58473. _enable(cameras: Camera): void;
  58474. /**
  58475. * Enables the effect on given cameras
  58476. * @param cameras The camera to enable.
  58477. * @hidden
  58478. */
  58479. _enable(cameras: Nullable<Camera[]>): void;
  58480. /**
  58481. * Disables the effect on the given cameras
  58482. * @param cameras The camera to disable.
  58483. * @hidden
  58484. */
  58485. _disable(cameras: Camera): void;
  58486. /**
  58487. * Disables the effect on the given cameras
  58488. * @param cameras The camera to disable.
  58489. * @hidden
  58490. */
  58491. _disable(cameras: Nullable<Camera[]>): void;
  58492. /**
  58493. * Gets a list of the post processes contained in the effect.
  58494. * @param camera The camera to get the post processes on.
  58495. * @returns The list of the post processes in the effect.
  58496. */
  58497. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58498. }
  58499. }
  58500. declare module BABYLON {
  58501. /** @hidden */
  58502. export var extractHighlightsPixelShader: {
  58503. name: string;
  58504. shader: string;
  58505. };
  58506. }
  58507. declare module BABYLON {
  58508. /**
  58509. * 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.
  58510. */
  58511. export class ExtractHighlightsPostProcess extends PostProcess {
  58512. /**
  58513. * The luminance threshold, pixels below this value will be set to black.
  58514. */
  58515. threshold: number;
  58516. /** @hidden */
  58517. _exposure: number;
  58518. /**
  58519. * Post process which has the input texture to be used when performing highlight extraction
  58520. * @hidden
  58521. */
  58522. _inputPostProcess: Nullable<PostProcess>;
  58523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58524. }
  58525. }
  58526. declare module BABYLON {
  58527. /** @hidden */
  58528. export var bloomMergePixelShader: {
  58529. name: string;
  58530. shader: string;
  58531. };
  58532. }
  58533. declare module BABYLON {
  58534. /**
  58535. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58536. */
  58537. export class BloomMergePostProcess extends PostProcess {
  58538. /** Weight of the bloom to be added to the original input. */
  58539. weight: number;
  58540. /**
  58541. * Creates a new instance of @see BloomMergePostProcess
  58542. * @param name The name of the effect.
  58543. * @param originalFromInput Post process which's input will be used for the merge.
  58544. * @param blurred Blurred highlights post process which's output will be used.
  58545. * @param weight Weight of the bloom to be added to the original input.
  58546. * @param options The required width/height ratio to downsize to before computing the render pass.
  58547. * @param camera The camera to apply the render pass to.
  58548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58549. * @param engine The engine which the post process will be applied. (default: current engine)
  58550. * @param reusable If the post process can be reused on the same frame. (default: false)
  58551. * @param textureType Type of textures used when performing the post process. (default: 0)
  58552. * @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)
  58553. */
  58554. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58555. /** Weight of the bloom to be added to the original input. */
  58556. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58557. }
  58558. }
  58559. declare module BABYLON {
  58560. /**
  58561. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58562. */
  58563. export class BloomEffect extends PostProcessRenderEffect {
  58564. private bloomScale;
  58565. /**
  58566. * @hidden Internal
  58567. */
  58568. _effects: Array<PostProcess>;
  58569. /**
  58570. * @hidden Internal
  58571. */
  58572. _downscale: ExtractHighlightsPostProcess;
  58573. private _blurX;
  58574. private _blurY;
  58575. private _merge;
  58576. /**
  58577. * The luminance threshold to find bright areas of the image to bloom.
  58578. */
  58579. threshold: number;
  58580. /**
  58581. * The strength of the bloom.
  58582. */
  58583. weight: number;
  58584. /**
  58585. * Specifies the size of the bloom blur kernel, relative to the final output size
  58586. */
  58587. kernel: number;
  58588. /**
  58589. * Creates a new instance of @see BloomEffect
  58590. * @param scene The scene the effect belongs to.
  58591. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58592. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58593. * @param bloomWeight The the strength of bloom.
  58594. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58595. * @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)
  58596. */
  58597. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58598. /**
  58599. * Disposes each of the internal effects for a given camera.
  58600. * @param camera The camera to dispose the effect on.
  58601. */
  58602. disposeEffects(camera: Camera): void;
  58603. /**
  58604. * @hidden Internal
  58605. */
  58606. _updateEffects(): void;
  58607. /**
  58608. * Internal
  58609. * @returns if all the contained post processes are ready.
  58610. * @hidden
  58611. */
  58612. _isReady(): boolean;
  58613. }
  58614. }
  58615. declare module BABYLON {
  58616. /** @hidden */
  58617. export var chromaticAberrationPixelShader: {
  58618. name: string;
  58619. shader: string;
  58620. };
  58621. }
  58622. declare module BABYLON {
  58623. /**
  58624. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58625. */
  58626. export class ChromaticAberrationPostProcess extends PostProcess {
  58627. /**
  58628. * The amount of seperation of rgb channels (default: 30)
  58629. */
  58630. aberrationAmount: number;
  58631. /**
  58632. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58633. */
  58634. radialIntensity: number;
  58635. /**
  58636. * 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))
  58637. */
  58638. direction: Vector2;
  58639. /**
  58640. * 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))
  58641. */
  58642. centerPosition: Vector2;
  58643. /**
  58644. * Creates a new instance ChromaticAberrationPostProcess
  58645. * @param name The name of the effect.
  58646. * @param screenWidth The width of the screen to apply the effect on.
  58647. * @param screenHeight The height of the screen to apply the effect on.
  58648. * @param options The required width/height ratio to downsize to before computing the render pass.
  58649. * @param camera The camera to apply the render pass to.
  58650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58651. * @param engine The engine which the post process will be applied. (default: current engine)
  58652. * @param reusable If the post process can be reused on the same frame. (default: false)
  58653. * @param textureType Type of textures used when performing the post process. (default: 0)
  58654. * @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)
  58655. */
  58656. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. /** @hidden */
  58661. export var circleOfConfusionPixelShader: {
  58662. name: string;
  58663. shader: string;
  58664. };
  58665. }
  58666. declare module BABYLON {
  58667. /**
  58668. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58669. */
  58670. export class CircleOfConfusionPostProcess extends PostProcess {
  58671. /**
  58672. * 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.
  58673. */
  58674. lensSize: number;
  58675. /**
  58676. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58677. */
  58678. fStop: number;
  58679. /**
  58680. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58681. */
  58682. focusDistance: number;
  58683. /**
  58684. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58685. */
  58686. focalLength: number;
  58687. private _depthTexture;
  58688. /**
  58689. * Creates a new instance CircleOfConfusionPostProcess
  58690. * @param name The name of the effect.
  58691. * @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.
  58692. * @param options The required width/height ratio to downsize to before computing the render pass.
  58693. * @param camera The camera to apply the render pass to.
  58694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58695. * @param engine The engine which the post process will be applied. (default: current engine)
  58696. * @param reusable If the post process can be reused on the same frame. (default: false)
  58697. * @param textureType Type of textures used when performing the post process. (default: 0)
  58698. * @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)
  58699. */
  58700. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58701. /**
  58702. * 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.
  58703. */
  58704. depthTexture: RenderTargetTexture;
  58705. }
  58706. }
  58707. declare module BABYLON {
  58708. /** @hidden */
  58709. export var colorCorrectionPixelShader: {
  58710. name: string;
  58711. shader: string;
  58712. };
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. *
  58717. * This post-process allows the modification of rendered colors by using
  58718. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58719. *
  58720. * The object needs to be provided an url to a texture containing the color
  58721. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58722. * Use an image editing software to tweak the LUT to match your needs.
  58723. *
  58724. * For an example of a color LUT, see here:
  58725. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58726. * For explanations on color grading, see here:
  58727. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58728. *
  58729. */
  58730. export class ColorCorrectionPostProcess extends PostProcess {
  58731. private _colorTableTexture;
  58732. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /** @hidden */
  58737. export var convolutionPixelShader: {
  58738. name: string;
  58739. shader: string;
  58740. };
  58741. }
  58742. declare module BABYLON {
  58743. /**
  58744. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58745. * input texture to perform effects such as edge detection or sharpening
  58746. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58747. */
  58748. export class ConvolutionPostProcess extends PostProcess {
  58749. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58750. kernel: number[];
  58751. /**
  58752. * Creates a new instance ConvolutionPostProcess
  58753. * @param name The name of the effect.
  58754. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58755. * @param options The required width/height ratio to downsize to before computing the render pass.
  58756. * @param camera The camera to apply the render pass to.
  58757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58758. * @param engine The engine which the post process will be applied. (default: current engine)
  58759. * @param reusable If the post process can be reused on the same frame. (default: false)
  58760. * @param textureType Type of textures used when performing the post process. (default: 0)
  58761. */
  58762. constructor(name: string,
  58763. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58764. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58765. /**
  58766. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58767. */
  58768. static EdgeDetect0Kernel: number[];
  58769. /**
  58770. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58771. */
  58772. static EdgeDetect1Kernel: number[];
  58773. /**
  58774. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58775. */
  58776. static EdgeDetect2Kernel: number[];
  58777. /**
  58778. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58779. */
  58780. static SharpenKernel: number[];
  58781. /**
  58782. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58783. */
  58784. static EmbossKernel: number[];
  58785. /**
  58786. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58787. */
  58788. static GaussianKernel: number[];
  58789. }
  58790. }
  58791. declare module BABYLON {
  58792. /**
  58793. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58794. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58795. * based on samples that have a large difference in distance than the center pixel.
  58796. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58797. */
  58798. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58799. direction: Vector2;
  58800. /**
  58801. * Creates a new instance CircleOfConfusionPostProcess
  58802. * @param name The name of the effect.
  58803. * @param scene The scene the effect belongs to.
  58804. * @param direction The direction the blur should be applied.
  58805. * @param kernel The size of the kernel used to blur.
  58806. * @param options The required width/height ratio to downsize to before computing the render pass.
  58807. * @param camera The camera to apply the render pass to.
  58808. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58809. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58811. * @param engine The engine which the post process will be applied. (default: current engine)
  58812. * @param reusable If the post process can be reused on the same frame. (default: false)
  58813. * @param textureType Type of textures used when performing the post process. (default: 0)
  58814. * @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)
  58815. */
  58816. 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);
  58817. }
  58818. }
  58819. declare module BABYLON {
  58820. /** @hidden */
  58821. export var depthOfFieldMergePixelShader: {
  58822. name: string;
  58823. shader: string;
  58824. };
  58825. }
  58826. declare module BABYLON {
  58827. /**
  58828. * Options to be set when merging outputs from the default pipeline.
  58829. */
  58830. export class DepthOfFieldMergePostProcessOptions {
  58831. /**
  58832. * The original image to merge on top of
  58833. */
  58834. originalFromInput: PostProcess;
  58835. /**
  58836. * Parameters to perform the merge of the depth of field effect
  58837. */
  58838. depthOfField?: {
  58839. circleOfConfusion: PostProcess;
  58840. blurSteps: Array<PostProcess>;
  58841. };
  58842. /**
  58843. * Parameters to perform the merge of bloom effect
  58844. */
  58845. bloom?: {
  58846. blurred: PostProcess;
  58847. weight: number;
  58848. };
  58849. }
  58850. /**
  58851. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58852. */
  58853. export class DepthOfFieldMergePostProcess extends PostProcess {
  58854. private blurSteps;
  58855. /**
  58856. * Creates a new instance of DepthOfFieldMergePostProcess
  58857. * @param name The name of the effect.
  58858. * @param originalFromInput Post process which's input will be used for the merge.
  58859. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58860. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58861. * @param options The required width/height ratio to downsize to before computing the render pass.
  58862. * @param camera The camera to apply the render pass to.
  58863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58864. * @param engine The engine which the post process will be applied. (default: current engine)
  58865. * @param reusable If the post process can be reused on the same frame. (default: false)
  58866. * @param textureType Type of textures used when performing the post process. (default: 0)
  58867. * @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)
  58868. */
  58869. 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);
  58870. /**
  58871. * Updates the effect with the current post process compile time values and recompiles the shader.
  58872. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58873. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58874. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58875. * @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
  58876. * @param onCompiled Called when the shader has been compiled.
  58877. * @param onError Called if there is an error when compiling a shader.
  58878. */
  58879. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58880. }
  58881. }
  58882. declare module BABYLON {
  58883. /**
  58884. * Specifies the level of max blur that should be applied when using the depth of field effect
  58885. */
  58886. export enum DepthOfFieldEffectBlurLevel {
  58887. /**
  58888. * Subtle blur
  58889. */
  58890. Low = 0,
  58891. /**
  58892. * Medium blur
  58893. */
  58894. Medium = 1,
  58895. /**
  58896. * Large blur
  58897. */
  58898. High = 2
  58899. }
  58900. /**
  58901. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58902. */
  58903. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58904. private _circleOfConfusion;
  58905. /**
  58906. * @hidden Internal, blurs from high to low
  58907. */
  58908. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58909. private _depthOfFieldBlurY;
  58910. private _dofMerge;
  58911. /**
  58912. * @hidden Internal post processes in depth of field effect
  58913. */
  58914. _effects: Array<PostProcess>;
  58915. /**
  58916. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58917. */
  58918. focalLength: number;
  58919. /**
  58920. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58921. */
  58922. fStop: number;
  58923. /**
  58924. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58925. */
  58926. focusDistance: number;
  58927. /**
  58928. * 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.
  58929. */
  58930. lensSize: number;
  58931. /**
  58932. * Creates a new instance DepthOfFieldEffect
  58933. * @param scene The scene the effect belongs to.
  58934. * @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.
  58935. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58936. * @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)
  58937. */
  58938. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58939. /**
  58940. * Get the current class name of the current effet
  58941. * @returns "DepthOfFieldEffect"
  58942. */
  58943. getClassName(): string;
  58944. /**
  58945. * 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.
  58946. */
  58947. depthTexture: RenderTargetTexture;
  58948. /**
  58949. * Disposes each of the internal effects for a given camera.
  58950. * @param camera The camera to dispose the effect on.
  58951. */
  58952. disposeEffects(camera: Camera): void;
  58953. /**
  58954. * @hidden Internal
  58955. */
  58956. _updateEffects(): void;
  58957. /**
  58958. * Internal
  58959. * @returns if all the contained post processes are ready.
  58960. * @hidden
  58961. */
  58962. _isReady(): boolean;
  58963. }
  58964. }
  58965. declare module BABYLON {
  58966. /** @hidden */
  58967. export var displayPassPixelShader: {
  58968. name: string;
  58969. shader: string;
  58970. };
  58971. }
  58972. declare module BABYLON {
  58973. /**
  58974. * DisplayPassPostProcess which produces an output the same as it's input
  58975. */
  58976. export class DisplayPassPostProcess extends PostProcess {
  58977. /**
  58978. * Creates the DisplayPassPostProcess
  58979. * @param name The name of the effect.
  58980. * @param options The required width/height ratio to downsize to before computing the render pass.
  58981. * @param camera The camera to apply the render pass to.
  58982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58983. * @param engine The engine which the post process will be applied. (default: current engine)
  58984. * @param reusable If the post process can be reused on the same frame. (default: false)
  58985. */
  58986. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58987. }
  58988. }
  58989. declare module BABYLON {
  58990. /** @hidden */
  58991. export var filterPixelShader: {
  58992. name: string;
  58993. shader: string;
  58994. };
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * Applies a kernel filter to the image
  58999. */
  59000. export class FilterPostProcess extends PostProcess {
  59001. /** The matrix to be applied to the image */
  59002. kernelMatrix: Matrix;
  59003. /**
  59004. *
  59005. * @param name The name of the effect.
  59006. * @param kernelMatrix The matrix to be applied to the image
  59007. * @param options The required width/height ratio to downsize to before computing the render pass.
  59008. * @param camera The camera to apply the render pass to.
  59009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59010. * @param engine The engine which the post process will be applied. (default: current engine)
  59011. * @param reusable If the post process can be reused on the same frame. (default: false)
  59012. */
  59013. constructor(name: string,
  59014. /** The matrix to be applied to the image */
  59015. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59016. }
  59017. }
  59018. declare module BABYLON {
  59019. /** @hidden */
  59020. export var fxaaPixelShader: {
  59021. name: string;
  59022. shader: string;
  59023. };
  59024. }
  59025. declare module BABYLON {
  59026. /** @hidden */
  59027. export var fxaaVertexShader: {
  59028. name: string;
  59029. shader: string;
  59030. };
  59031. }
  59032. declare module BABYLON {
  59033. /**
  59034. * Fxaa post process
  59035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59036. */
  59037. export class FxaaPostProcess extends PostProcess {
  59038. /** @hidden */
  59039. texelWidth: number;
  59040. /** @hidden */
  59041. texelHeight: number;
  59042. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59043. private _getDefines;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /** @hidden */
  59048. export var grainPixelShader: {
  59049. name: string;
  59050. shader: string;
  59051. };
  59052. }
  59053. declare module BABYLON {
  59054. /**
  59055. * The GrainPostProcess adds noise to the image at mid luminance levels
  59056. */
  59057. export class GrainPostProcess extends PostProcess {
  59058. /**
  59059. * The intensity of the grain added (default: 30)
  59060. */
  59061. intensity: number;
  59062. /**
  59063. * If the grain should be randomized on every frame
  59064. */
  59065. animated: boolean;
  59066. /**
  59067. * Creates a new instance of @see GrainPostProcess
  59068. * @param name The name of the effect.
  59069. * @param options The required width/height ratio to downsize to before computing the render pass.
  59070. * @param camera The camera to apply the render pass to.
  59071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59072. * @param engine The engine which the post process will be applied. (default: current engine)
  59073. * @param reusable If the post process can be reused on the same frame. (default: false)
  59074. * @param textureType Type of textures used when performing the post process. (default: 0)
  59075. * @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)
  59076. */
  59077. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59078. }
  59079. }
  59080. declare module BABYLON {
  59081. /** @hidden */
  59082. export var highlightsPixelShader: {
  59083. name: string;
  59084. shader: string;
  59085. };
  59086. }
  59087. declare module BABYLON {
  59088. /**
  59089. * Extracts highlights from the image
  59090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59091. */
  59092. export class HighlightsPostProcess extends PostProcess {
  59093. /**
  59094. * Extracts highlights from the image
  59095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59096. * @param name The name of the effect.
  59097. * @param options The required width/height ratio to downsize to before computing the render pass.
  59098. * @param camera The camera to apply the render pass to.
  59099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59100. * @param engine The engine which the post process will be applied. (default: current engine)
  59101. * @param reusable If the post process can be reused on the same frame. (default: false)
  59102. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59103. */
  59104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59105. }
  59106. }
  59107. declare module BABYLON {
  59108. /** @hidden */
  59109. export var mrtFragmentDeclaration: {
  59110. name: string;
  59111. shader: string;
  59112. };
  59113. }
  59114. declare module BABYLON {
  59115. /** @hidden */
  59116. export var geometryPixelShader: {
  59117. name: string;
  59118. shader: string;
  59119. };
  59120. }
  59121. declare module BABYLON {
  59122. /** @hidden */
  59123. export var geometryVertexShader: {
  59124. name: string;
  59125. shader: string;
  59126. };
  59127. }
  59128. declare module BABYLON {
  59129. /** @hidden */
  59130. interface ISavedTransformationMatrix {
  59131. world: Matrix;
  59132. viewProjection: Matrix;
  59133. }
  59134. /**
  59135. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59136. */
  59137. export class GeometryBufferRenderer {
  59138. /**
  59139. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59140. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59141. */
  59142. static readonly POSITION_TEXTURE_TYPE: number;
  59143. /**
  59144. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59145. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59146. */
  59147. static readonly VELOCITY_TEXTURE_TYPE: number;
  59148. /**
  59149. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59150. * in order to compute objects velocities when enableVelocity is set to "true"
  59151. * @hidden
  59152. */
  59153. _previousTransformationMatrices: {
  59154. [index: number]: ISavedTransformationMatrix;
  59155. };
  59156. /**
  59157. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59158. * in order to compute objects velocities when enableVelocity is set to "true"
  59159. * @hidden
  59160. */
  59161. _previousBonesTransformationMatrices: {
  59162. [index: number]: Float32Array;
  59163. };
  59164. /**
  59165. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59166. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59167. */
  59168. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59169. private _scene;
  59170. private _multiRenderTarget;
  59171. private _ratio;
  59172. private _enablePosition;
  59173. private _enableVelocity;
  59174. private _positionIndex;
  59175. private _velocityIndex;
  59176. protected _effect: Effect;
  59177. protected _cachedDefines: string;
  59178. /**
  59179. * Set the render list (meshes to be rendered) used in the G buffer.
  59180. */
  59181. renderList: Mesh[];
  59182. /**
  59183. * Gets wether or not G buffer are supported by the running hardware.
  59184. * This requires draw buffer supports
  59185. */
  59186. readonly isSupported: boolean;
  59187. /**
  59188. * Returns the index of the given texture type in the G-Buffer textures array
  59189. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59190. * @returns the index of the given texture type in the G-Buffer textures array
  59191. */
  59192. getTextureIndex(textureType: number): number;
  59193. /**
  59194. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59195. */
  59196. /**
  59197. * Sets whether or not objects positions are enabled for the G buffer.
  59198. */
  59199. enablePosition: boolean;
  59200. /**
  59201. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59202. */
  59203. /**
  59204. * Sets wether or not objects velocities are enabled for the G buffer.
  59205. */
  59206. enableVelocity: boolean;
  59207. /**
  59208. * Gets the scene associated with the buffer.
  59209. */
  59210. readonly scene: Scene;
  59211. /**
  59212. * Gets the ratio used by the buffer during its creation.
  59213. * How big is the buffer related to the main canvas.
  59214. */
  59215. readonly ratio: number;
  59216. /** @hidden */
  59217. static _SceneComponentInitialization: (scene: Scene) => void;
  59218. /**
  59219. * Creates a new G Buffer for the scene
  59220. * @param scene The scene the buffer belongs to
  59221. * @param ratio How big is the buffer related to the main canvas.
  59222. */
  59223. constructor(scene: Scene, ratio?: number);
  59224. /**
  59225. * Checks wether everything is ready to render a submesh to the G buffer.
  59226. * @param subMesh the submesh to check readiness for
  59227. * @param useInstances is the mesh drawn using instance or not
  59228. * @returns true if ready otherwise false
  59229. */
  59230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59231. /**
  59232. * Gets the current underlying G Buffer.
  59233. * @returns the buffer
  59234. */
  59235. getGBuffer(): MultiRenderTarget;
  59236. /**
  59237. * Gets the number of samples used to render the buffer (anti aliasing).
  59238. */
  59239. /**
  59240. * Sets the number of samples used to render the buffer (anti aliasing).
  59241. */
  59242. samples: number;
  59243. /**
  59244. * Disposes the renderer and frees up associated resources.
  59245. */
  59246. dispose(): void;
  59247. protected _createRenderTargets(): void;
  59248. private _copyBonesTransformationMatrices;
  59249. }
  59250. }
  59251. declare module BABYLON {
  59252. interface Scene {
  59253. /** @hidden (Backing field) */
  59254. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59255. /**
  59256. * Gets or Sets the current geometry buffer associated to the scene.
  59257. */
  59258. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59259. /**
  59260. * Enables a GeometryBufferRender and associates it with the scene
  59261. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59262. * @returns the GeometryBufferRenderer
  59263. */
  59264. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59265. /**
  59266. * Disables the GeometryBufferRender associated with the scene
  59267. */
  59268. disableGeometryBufferRenderer(): void;
  59269. }
  59270. /**
  59271. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59272. * in several rendering techniques.
  59273. */
  59274. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59275. /**
  59276. * The component name helpful to identify the component in the list of scene components.
  59277. */
  59278. readonly name: string;
  59279. /**
  59280. * The scene the component belongs to.
  59281. */
  59282. scene: Scene;
  59283. /**
  59284. * Creates a new instance of the component for the given scene
  59285. * @param scene Defines the scene to register the component in
  59286. */
  59287. constructor(scene: Scene);
  59288. /**
  59289. * Registers the component in a given scene
  59290. */
  59291. register(): void;
  59292. /**
  59293. * Rebuilds the elements related to this component in case of
  59294. * context lost for instance.
  59295. */
  59296. rebuild(): void;
  59297. /**
  59298. * Disposes the component and the associated ressources
  59299. */
  59300. dispose(): void;
  59301. private _gatherRenderTargets;
  59302. }
  59303. }
  59304. declare module BABYLON {
  59305. /** @hidden */
  59306. export var motionBlurPixelShader: {
  59307. name: string;
  59308. shader: string;
  59309. };
  59310. }
  59311. declare module BABYLON {
  59312. /**
  59313. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59314. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59315. * As an example, all you have to do is to create the post-process:
  59316. * var mb = new BABYLON.MotionBlurPostProcess(
  59317. * 'mb', // The name of the effect.
  59318. * scene, // The scene containing the objects to blur according to their velocity.
  59319. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59320. * camera // The camera to apply the render pass to.
  59321. * );
  59322. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59323. */
  59324. export class MotionBlurPostProcess extends PostProcess {
  59325. /**
  59326. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59327. */
  59328. motionStrength: number;
  59329. /**
  59330. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59331. */
  59332. /**
  59333. * Sets the number of iterations to be used for motion blur quality
  59334. */
  59335. motionBlurSamples: number;
  59336. private _motionBlurSamples;
  59337. private _geometryBufferRenderer;
  59338. /**
  59339. * Creates a new instance MotionBlurPostProcess
  59340. * @param name The name of the effect.
  59341. * @param scene The scene containing the objects to blur according to their velocity.
  59342. * @param options The required width/height ratio to downsize to before computing the render pass.
  59343. * @param camera The camera to apply the render pass to.
  59344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59345. * @param engine The engine which the post process will be applied. (default: current engine)
  59346. * @param reusable If the post process can be reused on the same frame. (default: false)
  59347. * @param textureType Type of textures used when performing the post process. (default: 0)
  59348. * @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)
  59349. */
  59350. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59351. /**
  59352. * Excludes the given skinned mesh from computing bones velocities.
  59353. * 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.
  59354. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59355. */
  59356. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59357. /**
  59358. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59359. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59360. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59361. */
  59362. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59363. /**
  59364. * Disposes the post process.
  59365. * @param camera The camera to dispose the post process on.
  59366. */
  59367. dispose(camera?: Camera): void;
  59368. }
  59369. }
  59370. declare module BABYLON {
  59371. /** @hidden */
  59372. export var refractionPixelShader: {
  59373. name: string;
  59374. shader: string;
  59375. };
  59376. }
  59377. declare module BABYLON {
  59378. /**
  59379. * Post process which applies a refractin texture
  59380. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59381. */
  59382. export class RefractionPostProcess extends PostProcess {
  59383. /** the base color of the refraction (used to taint the rendering) */
  59384. color: Color3;
  59385. /** simulated refraction depth */
  59386. depth: number;
  59387. /** the coefficient of the base color (0 to remove base color tainting) */
  59388. colorLevel: number;
  59389. private _refTexture;
  59390. private _ownRefractionTexture;
  59391. /**
  59392. * Gets or sets the refraction texture
  59393. * Please note that you are responsible for disposing the texture if you set it manually
  59394. */
  59395. refractionTexture: Texture;
  59396. /**
  59397. * Initializes the RefractionPostProcess
  59398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59399. * @param name The name of the effect.
  59400. * @param refractionTextureUrl Url of the refraction texture to use
  59401. * @param color the base color of the refraction (used to taint the rendering)
  59402. * @param depth simulated refraction depth
  59403. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59404. * @param camera The camera to apply the render pass to.
  59405. * @param options The required width/height ratio to downsize to before computing the render pass.
  59406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59407. * @param engine The engine which the post process will be applied. (default: current engine)
  59408. * @param reusable If the post process can be reused on the same frame. (default: false)
  59409. */
  59410. constructor(name: string, refractionTextureUrl: string,
  59411. /** the base color of the refraction (used to taint the rendering) */
  59412. color: Color3,
  59413. /** simulated refraction depth */
  59414. depth: number,
  59415. /** the coefficient of the base color (0 to remove base color tainting) */
  59416. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59417. /**
  59418. * Disposes of the post process
  59419. * @param camera Camera to dispose post process on
  59420. */
  59421. dispose(camera: Camera): void;
  59422. }
  59423. }
  59424. declare module BABYLON {
  59425. /** @hidden */
  59426. export var sharpenPixelShader: {
  59427. name: string;
  59428. shader: string;
  59429. };
  59430. }
  59431. declare module BABYLON {
  59432. /**
  59433. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59434. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59435. */
  59436. export class SharpenPostProcess extends PostProcess {
  59437. /**
  59438. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59439. */
  59440. colorAmount: number;
  59441. /**
  59442. * How much sharpness should be applied (default: 0.3)
  59443. */
  59444. edgeAmount: number;
  59445. /**
  59446. * Creates a new instance ConvolutionPostProcess
  59447. * @param name The name of the effect.
  59448. * @param options The required width/height ratio to downsize to before computing the render pass.
  59449. * @param camera The camera to apply the render pass to.
  59450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59451. * @param engine The engine which the post process will be applied. (default: current engine)
  59452. * @param reusable If the post process can be reused on the same frame. (default: false)
  59453. * @param textureType Type of textures used when performing the post process. (default: 0)
  59454. * @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)
  59455. */
  59456. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59457. }
  59458. }
  59459. declare module BABYLON {
  59460. /**
  59461. * PostProcessRenderPipeline
  59462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59463. */
  59464. export class PostProcessRenderPipeline {
  59465. private engine;
  59466. private _renderEffects;
  59467. private _renderEffectsForIsolatedPass;
  59468. /**
  59469. * List of inspectable custom properties (used by the Inspector)
  59470. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59471. */
  59472. inspectableCustomProperties: IInspectable[];
  59473. /**
  59474. * @hidden
  59475. */
  59476. protected _cameras: Camera[];
  59477. /** @hidden */
  59478. _name: string;
  59479. /**
  59480. * Gets pipeline name
  59481. */
  59482. readonly name: string;
  59483. /**
  59484. * Initializes a PostProcessRenderPipeline
  59485. * @param engine engine to add the pipeline to
  59486. * @param name name of the pipeline
  59487. */
  59488. constructor(engine: Engine, name: string);
  59489. /**
  59490. * Gets the class name
  59491. * @returns "PostProcessRenderPipeline"
  59492. */
  59493. getClassName(): string;
  59494. /**
  59495. * If all the render effects in the pipeline are supported
  59496. */
  59497. readonly isSupported: boolean;
  59498. /**
  59499. * Adds an effect to the pipeline
  59500. * @param renderEffect the effect to add
  59501. */
  59502. addEffect(renderEffect: PostProcessRenderEffect): void;
  59503. /** @hidden */
  59504. _rebuild(): void;
  59505. /** @hidden */
  59506. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59507. /** @hidden */
  59508. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59509. /** @hidden */
  59510. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59511. /** @hidden */
  59512. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59513. /** @hidden */
  59514. _attachCameras(cameras: Camera, unique: boolean): void;
  59515. /** @hidden */
  59516. _attachCameras(cameras: Camera[], unique: boolean): void;
  59517. /** @hidden */
  59518. _detachCameras(cameras: Camera): void;
  59519. /** @hidden */
  59520. _detachCameras(cameras: Nullable<Camera[]>): void;
  59521. /** @hidden */
  59522. _update(): void;
  59523. /** @hidden */
  59524. _reset(): void;
  59525. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59526. /**
  59527. * Disposes of the pipeline
  59528. */
  59529. dispose(): void;
  59530. }
  59531. }
  59532. declare module BABYLON {
  59533. /**
  59534. * PostProcessRenderPipelineManager class
  59535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59536. */
  59537. export class PostProcessRenderPipelineManager {
  59538. private _renderPipelines;
  59539. /**
  59540. * Initializes a PostProcessRenderPipelineManager
  59541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59542. */
  59543. constructor();
  59544. /**
  59545. * Gets the list of supported render pipelines
  59546. */
  59547. readonly supportedPipelines: PostProcessRenderPipeline[];
  59548. /**
  59549. * Adds a pipeline to the manager
  59550. * @param renderPipeline The pipeline to add
  59551. */
  59552. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59553. /**
  59554. * Attaches a camera to the pipeline
  59555. * @param renderPipelineName The name of the pipeline to attach to
  59556. * @param cameras the camera to attach
  59557. * @param unique if the camera can be attached multiple times to the pipeline
  59558. */
  59559. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59560. /**
  59561. * Detaches a camera from the pipeline
  59562. * @param renderPipelineName The name of the pipeline to detach from
  59563. * @param cameras the camera to detach
  59564. */
  59565. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59566. /**
  59567. * Enables an effect by name on a pipeline
  59568. * @param renderPipelineName the name of the pipeline to enable the effect in
  59569. * @param renderEffectName the name of the effect to enable
  59570. * @param cameras the cameras that the effect should be enabled on
  59571. */
  59572. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59573. /**
  59574. * Disables an effect by name on a pipeline
  59575. * @param renderPipelineName the name of the pipeline to disable the effect in
  59576. * @param renderEffectName the name of the effect to disable
  59577. * @param cameras the cameras that the effect should be disabled on
  59578. */
  59579. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59580. /**
  59581. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59582. */
  59583. update(): void;
  59584. /** @hidden */
  59585. _rebuild(): void;
  59586. /**
  59587. * Disposes of the manager and pipelines
  59588. */
  59589. dispose(): void;
  59590. }
  59591. }
  59592. declare module BABYLON {
  59593. interface Scene {
  59594. /** @hidden (Backing field) */
  59595. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59596. /**
  59597. * Gets the postprocess render pipeline manager
  59598. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59599. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59600. */
  59601. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59602. }
  59603. /**
  59604. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59605. */
  59606. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59607. /**
  59608. * The component name helpfull to identify the component in the list of scene components.
  59609. */
  59610. readonly name: string;
  59611. /**
  59612. * The scene the component belongs to.
  59613. */
  59614. scene: Scene;
  59615. /**
  59616. * Creates a new instance of the component for the given scene
  59617. * @param scene Defines the scene to register the component in
  59618. */
  59619. constructor(scene: Scene);
  59620. /**
  59621. * Registers the component in a given scene
  59622. */
  59623. register(): void;
  59624. /**
  59625. * Rebuilds the elements related to this component in case of
  59626. * context lost for instance.
  59627. */
  59628. rebuild(): void;
  59629. /**
  59630. * Disposes the component and the associated ressources
  59631. */
  59632. dispose(): void;
  59633. private _gatherRenderTargets;
  59634. }
  59635. }
  59636. declare module BABYLON {
  59637. /**
  59638. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59639. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59640. */
  59641. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59642. private _scene;
  59643. private _camerasToBeAttached;
  59644. /**
  59645. * ID of the sharpen post process,
  59646. */
  59647. private readonly SharpenPostProcessId;
  59648. /**
  59649. * @ignore
  59650. * ID of the image processing post process;
  59651. */
  59652. readonly ImageProcessingPostProcessId: string;
  59653. /**
  59654. * @ignore
  59655. * ID of the Fast Approximate Anti-Aliasing post process;
  59656. */
  59657. readonly FxaaPostProcessId: string;
  59658. /**
  59659. * ID of the chromatic aberration post process,
  59660. */
  59661. private readonly ChromaticAberrationPostProcessId;
  59662. /**
  59663. * ID of the grain post process
  59664. */
  59665. private readonly GrainPostProcessId;
  59666. /**
  59667. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59668. */
  59669. sharpen: SharpenPostProcess;
  59670. private _sharpenEffect;
  59671. private bloom;
  59672. /**
  59673. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59674. */
  59675. depthOfField: DepthOfFieldEffect;
  59676. /**
  59677. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59678. */
  59679. fxaa: FxaaPostProcess;
  59680. /**
  59681. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59682. */
  59683. imageProcessing: ImageProcessingPostProcess;
  59684. /**
  59685. * Chromatic aberration post process which will shift rgb colors in the image
  59686. */
  59687. chromaticAberration: ChromaticAberrationPostProcess;
  59688. private _chromaticAberrationEffect;
  59689. /**
  59690. * Grain post process which add noise to the image
  59691. */
  59692. grain: GrainPostProcess;
  59693. private _grainEffect;
  59694. /**
  59695. * Glow post process which adds a glow to emissive areas of the image
  59696. */
  59697. private _glowLayer;
  59698. /**
  59699. * Animations which can be used to tweak settings over a period of time
  59700. */
  59701. animations: Animation[];
  59702. private _imageProcessingConfigurationObserver;
  59703. private _sharpenEnabled;
  59704. private _bloomEnabled;
  59705. private _depthOfFieldEnabled;
  59706. private _depthOfFieldBlurLevel;
  59707. private _fxaaEnabled;
  59708. private _imageProcessingEnabled;
  59709. private _defaultPipelineTextureType;
  59710. private _bloomScale;
  59711. private _chromaticAberrationEnabled;
  59712. private _grainEnabled;
  59713. private _buildAllowed;
  59714. /**
  59715. * Gets active scene
  59716. */
  59717. readonly scene: Scene;
  59718. /**
  59719. * Enable or disable the sharpen process from the pipeline
  59720. */
  59721. sharpenEnabled: boolean;
  59722. private _resizeObserver;
  59723. private _hardwareScaleLevel;
  59724. private _bloomKernel;
  59725. /**
  59726. * Specifies the size of the bloom blur kernel, relative to the final output size
  59727. */
  59728. bloomKernel: number;
  59729. /**
  59730. * Specifies the weight of the bloom in the final rendering
  59731. */
  59732. private _bloomWeight;
  59733. /**
  59734. * Specifies the luma threshold for the area that will be blurred by the bloom
  59735. */
  59736. private _bloomThreshold;
  59737. private _hdr;
  59738. /**
  59739. * The strength of the bloom.
  59740. */
  59741. bloomWeight: number;
  59742. /**
  59743. * The strength of the bloom.
  59744. */
  59745. bloomThreshold: number;
  59746. /**
  59747. * The scale of the bloom, lower value will provide better performance.
  59748. */
  59749. bloomScale: number;
  59750. /**
  59751. * Enable or disable the bloom from the pipeline
  59752. */
  59753. bloomEnabled: boolean;
  59754. private _rebuildBloom;
  59755. /**
  59756. * If the depth of field is enabled.
  59757. */
  59758. depthOfFieldEnabled: boolean;
  59759. /**
  59760. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59761. */
  59762. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59763. /**
  59764. * If the anti aliasing is enabled.
  59765. */
  59766. fxaaEnabled: boolean;
  59767. private _samples;
  59768. /**
  59769. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59770. */
  59771. samples: number;
  59772. /**
  59773. * If image processing is enabled.
  59774. */
  59775. imageProcessingEnabled: boolean;
  59776. /**
  59777. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59778. */
  59779. glowLayerEnabled: boolean;
  59780. /**
  59781. * Gets the glow layer (or null if not defined)
  59782. */
  59783. readonly glowLayer: Nullable<GlowLayer>;
  59784. /**
  59785. * Enable or disable the chromaticAberration process from the pipeline
  59786. */
  59787. chromaticAberrationEnabled: boolean;
  59788. /**
  59789. * Enable or disable the grain process from the pipeline
  59790. */
  59791. grainEnabled: boolean;
  59792. /**
  59793. * @constructor
  59794. * @param name - The rendering pipeline name (default: "")
  59795. * @param hdr - If high dynamic range textures should be used (default: true)
  59796. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59797. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59798. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59799. */
  59800. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59801. /**
  59802. * Get the class name
  59803. * @returns "DefaultRenderingPipeline"
  59804. */
  59805. getClassName(): string;
  59806. /**
  59807. * Force the compilation of the entire pipeline.
  59808. */
  59809. prepare(): void;
  59810. private _hasCleared;
  59811. private _prevPostProcess;
  59812. private _prevPrevPostProcess;
  59813. private _setAutoClearAndTextureSharing;
  59814. private _depthOfFieldSceneObserver;
  59815. private _buildPipeline;
  59816. private _disposePostProcesses;
  59817. /**
  59818. * Adds a camera to the pipeline
  59819. * @param camera the camera to be added
  59820. */
  59821. addCamera(camera: Camera): void;
  59822. /**
  59823. * Removes a camera from the pipeline
  59824. * @param camera the camera to remove
  59825. */
  59826. removeCamera(camera: Camera): void;
  59827. /**
  59828. * Dispose of the pipeline and stop all post processes
  59829. */
  59830. dispose(): void;
  59831. /**
  59832. * Serialize the rendering pipeline (Used when exporting)
  59833. * @returns the serialized object
  59834. */
  59835. serialize(): any;
  59836. /**
  59837. * Parse the serialized pipeline
  59838. * @param source Source pipeline.
  59839. * @param scene The scene to load the pipeline to.
  59840. * @param rootUrl The URL of the serialized pipeline.
  59841. * @returns An instantiated pipeline from the serialized object.
  59842. */
  59843. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59844. }
  59845. }
  59846. declare module BABYLON {
  59847. /** @hidden */
  59848. export var lensHighlightsPixelShader: {
  59849. name: string;
  59850. shader: string;
  59851. };
  59852. }
  59853. declare module BABYLON {
  59854. /** @hidden */
  59855. export var depthOfFieldPixelShader: {
  59856. name: string;
  59857. shader: string;
  59858. };
  59859. }
  59860. declare module BABYLON {
  59861. /**
  59862. * BABYLON.JS Chromatic Aberration GLSL Shader
  59863. * Author: Olivier Guyot
  59864. * Separates very slightly R, G and B colors on the edges of the screen
  59865. * Inspired by Francois Tarlier & Martins Upitis
  59866. */
  59867. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59868. /**
  59869. * @ignore
  59870. * The chromatic aberration PostProcess id in the pipeline
  59871. */
  59872. LensChromaticAberrationEffect: string;
  59873. /**
  59874. * @ignore
  59875. * The highlights enhancing PostProcess id in the pipeline
  59876. */
  59877. HighlightsEnhancingEffect: string;
  59878. /**
  59879. * @ignore
  59880. * The depth-of-field PostProcess id in the pipeline
  59881. */
  59882. LensDepthOfFieldEffect: string;
  59883. private _scene;
  59884. private _depthTexture;
  59885. private _grainTexture;
  59886. private _chromaticAberrationPostProcess;
  59887. private _highlightsPostProcess;
  59888. private _depthOfFieldPostProcess;
  59889. private _edgeBlur;
  59890. private _grainAmount;
  59891. private _chromaticAberration;
  59892. private _distortion;
  59893. private _highlightsGain;
  59894. private _highlightsThreshold;
  59895. private _dofDistance;
  59896. private _dofAperture;
  59897. private _dofDarken;
  59898. private _dofPentagon;
  59899. private _blurNoise;
  59900. /**
  59901. * @constructor
  59902. *
  59903. * Effect parameters are as follow:
  59904. * {
  59905. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59906. * edge_blur: number; // from 0 to x (1 for realism)
  59907. * distortion: number; // from 0 to x (1 for realism)
  59908. * grain_amount: number; // from 0 to 1
  59909. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59910. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59911. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59912. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59913. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59914. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59915. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59916. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59917. * }
  59918. * Note: if an effect parameter is unset, effect is disabled
  59919. *
  59920. * @param name The rendering pipeline name
  59921. * @param parameters - An object containing all parameters (see above)
  59922. * @param scene The scene linked to this pipeline
  59923. * @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)
  59924. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59925. */
  59926. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59927. /**
  59928. * Get the class name
  59929. * @returns "LensRenderingPipeline"
  59930. */
  59931. getClassName(): string;
  59932. /**
  59933. * Gets associated scene
  59934. */
  59935. readonly scene: Scene;
  59936. /**
  59937. * Gets or sets the edge blur
  59938. */
  59939. edgeBlur: number;
  59940. /**
  59941. * Gets or sets the grain amount
  59942. */
  59943. grainAmount: number;
  59944. /**
  59945. * Gets or sets the chromatic aberration amount
  59946. */
  59947. chromaticAberration: number;
  59948. /**
  59949. * Gets or sets the depth of field aperture
  59950. */
  59951. dofAperture: number;
  59952. /**
  59953. * Gets or sets the edge distortion
  59954. */
  59955. edgeDistortion: number;
  59956. /**
  59957. * Gets or sets the depth of field distortion
  59958. */
  59959. dofDistortion: number;
  59960. /**
  59961. * Gets or sets the darken out of focus amount
  59962. */
  59963. darkenOutOfFocus: number;
  59964. /**
  59965. * Gets or sets a boolean indicating if blur noise is enabled
  59966. */
  59967. blurNoise: boolean;
  59968. /**
  59969. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59970. */
  59971. pentagonBokeh: boolean;
  59972. /**
  59973. * Gets or sets the highlight grain amount
  59974. */
  59975. highlightsGain: number;
  59976. /**
  59977. * Gets or sets the highlight threshold
  59978. */
  59979. highlightsThreshold: number;
  59980. /**
  59981. * Sets the amount of blur at the edges
  59982. * @param amount blur amount
  59983. */
  59984. setEdgeBlur(amount: number): void;
  59985. /**
  59986. * Sets edge blur to 0
  59987. */
  59988. disableEdgeBlur(): void;
  59989. /**
  59990. * Sets the amout of grain
  59991. * @param amount Amount of grain
  59992. */
  59993. setGrainAmount(amount: number): void;
  59994. /**
  59995. * Set grain amount to 0
  59996. */
  59997. disableGrain(): void;
  59998. /**
  59999. * Sets the chromatic aberration amount
  60000. * @param amount amount of chromatic aberration
  60001. */
  60002. setChromaticAberration(amount: number): void;
  60003. /**
  60004. * Sets chromatic aberration amount to 0
  60005. */
  60006. disableChromaticAberration(): void;
  60007. /**
  60008. * Sets the EdgeDistortion amount
  60009. * @param amount amount of EdgeDistortion
  60010. */
  60011. setEdgeDistortion(amount: number): void;
  60012. /**
  60013. * Sets edge distortion to 0
  60014. */
  60015. disableEdgeDistortion(): void;
  60016. /**
  60017. * Sets the FocusDistance amount
  60018. * @param amount amount of FocusDistance
  60019. */
  60020. setFocusDistance(amount: number): void;
  60021. /**
  60022. * Disables depth of field
  60023. */
  60024. disableDepthOfField(): void;
  60025. /**
  60026. * Sets the Aperture amount
  60027. * @param amount amount of Aperture
  60028. */
  60029. setAperture(amount: number): void;
  60030. /**
  60031. * Sets the DarkenOutOfFocus amount
  60032. * @param amount amount of DarkenOutOfFocus
  60033. */
  60034. setDarkenOutOfFocus(amount: number): void;
  60035. private _pentagonBokehIsEnabled;
  60036. /**
  60037. * Creates a pentagon bokeh effect
  60038. */
  60039. enablePentagonBokeh(): void;
  60040. /**
  60041. * Disables the pentagon bokeh effect
  60042. */
  60043. disablePentagonBokeh(): void;
  60044. /**
  60045. * Enables noise blur
  60046. */
  60047. enableNoiseBlur(): void;
  60048. /**
  60049. * Disables noise blur
  60050. */
  60051. disableNoiseBlur(): void;
  60052. /**
  60053. * Sets the HighlightsGain amount
  60054. * @param amount amount of HighlightsGain
  60055. */
  60056. setHighlightsGain(amount: number): void;
  60057. /**
  60058. * Sets the HighlightsThreshold amount
  60059. * @param amount amount of HighlightsThreshold
  60060. */
  60061. setHighlightsThreshold(amount: number): void;
  60062. /**
  60063. * Disables highlights
  60064. */
  60065. disableHighlights(): void;
  60066. /**
  60067. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60068. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60069. */
  60070. dispose(disableDepthRender?: boolean): void;
  60071. private _createChromaticAberrationPostProcess;
  60072. private _createHighlightsPostProcess;
  60073. private _createDepthOfFieldPostProcess;
  60074. private _createGrainTexture;
  60075. }
  60076. }
  60077. declare module BABYLON {
  60078. /** @hidden */
  60079. export var ssao2PixelShader: {
  60080. name: string;
  60081. shader: string;
  60082. };
  60083. }
  60084. declare module BABYLON {
  60085. /** @hidden */
  60086. export var ssaoCombinePixelShader: {
  60087. name: string;
  60088. shader: string;
  60089. };
  60090. }
  60091. declare module BABYLON {
  60092. /**
  60093. * Render pipeline to produce ssao effect
  60094. */
  60095. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60096. /**
  60097. * @ignore
  60098. * The PassPostProcess id in the pipeline that contains the original scene color
  60099. */
  60100. SSAOOriginalSceneColorEffect: string;
  60101. /**
  60102. * @ignore
  60103. * The SSAO PostProcess id in the pipeline
  60104. */
  60105. SSAORenderEffect: string;
  60106. /**
  60107. * @ignore
  60108. * The horizontal blur PostProcess id in the pipeline
  60109. */
  60110. SSAOBlurHRenderEffect: string;
  60111. /**
  60112. * @ignore
  60113. * The vertical blur PostProcess id in the pipeline
  60114. */
  60115. SSAOBlurVRenderEffect: string;
  60116. /**
  60117. * @ignore
  60118. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60119. */
  60120. SSAOCombineRenderEffect: string;
  60121. /**
  60122. * The output strength of the SSAO post-process. Default value is 1.0.
  60123. */
  60124. totalStrength: number;
  60125. /**
  60126. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60127. */
  60128. maxZ: number;
  60129. /**
  60130. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60131. */
  60132. minZAspect: number;
  60133. private _samples;
  60134. /**
  60135. * Number of samples used for the SSAO calculations. Default value is 8
  60136. */
  60137. samples: number;
  60138. private _textureSamples;
  60139. /**
  60140. * Number of samples to use for antialiasing
  60141. */
  60142. textureSamples: number;
  60143. /**
  60144. * Ratio object used for SSAO ratio and blur ratio
  60145. */
  60146. private _ratio;
  60147. /**
  60148. * Dynamically generated sphere sampler.
  60149. */
  60150. private _sampleSphere;
  60151. /**
  60152. * Blur filter offsets
  60153. */
  60154. private _samplerOffsets;
  60155. private _expensiveBlur;
  60156. /**
  60157. * If bilateral blur should be used
  60158. */
  60159. expensiveBlur: boolean;
  60160. /**
  60161. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60162. */
  60163. radius: number;
  60164. /**
  60165. * The base color of the SSAO post-process
  60166. * The final result is "base + ssao" between [0, 1]
  60167. */
  60168. base: number;
  60169. /**
  60170. * Support test.
  60171. */
  60172. static readonly IsSupported: boolean;
  60173. private _scene;
  60174. private _depthTexture;
  60175. private _normalTexture;
  60176. private _randomTexture;
  60177. private _originalColorPostProcess;
  60178. private _ssaoPostProcess;
  60179. private _blurHPostProcess;
  60180. private _blurVPostProcess;
  60181. private _ssaoCombinePostProcess;
  60182. private _firstUpdate;
  60183. /**
  60184. * Gets active scene
  60185. */
  60186. readonly scene: Scene;
  60187. /**
  60188. * @constructor
  60189. * @param name The rendering pipeline name
  60190. * @param scene The scene linked to this pipeline
  60191. * @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 }
  60192. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60193. */
  60194. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60195. /**
  60196. * Get the class name
  60197. * @returns "SSAO2RenderingPipeline"
  60198. */
  60199. getClassName(): string;
  60200. /**
  60201. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60202. */
  60203. dispose(disableGeometryBufferRenderer?: boolean): void;
  60204. private _createBlurPostProcess;
  60205. /** @hidden */
  60206. _rebuild(): void;
  60207. private _bits;
  60208. private _radicalInverse_VdC;
  60209. private _hammersley;
  60210. private _hemisphereSample_uniform;
  60211. private _generateHemisphere;
  60212. private _createSSAOPostProcess;
  60213. private _createSSAOCombinePostProcess;
  60214. private _createRandomTexture;
  60215. /**
  60216. * Serialize the rendering pipeline (Used when exporting)
  60217. * @returns the serialized object
  60218. */
  60219. serialize(): any;
  60220. /**
  60221. * Parse the serialized pipeline
  60222. * @param source Source pipeline.
  60223. * @param scene The scene to load the pipeline to.
  60224. * @param rootUrl The URL of the serialized pipeline.
  60225. * @returns An instantiated pipeline from the serialized object.
  60226. */
  60227. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60228. }
  60229. }
  60230. declare module BABYLON {
  60231. /** @hidden */
  60232. export var ssaoPixelShader: {
  60233. name: string;
  60234. shader: string;
  60235. };
  60236. }
  60237. declare module BABYLON {
  60238. /**
  60239. * Render pipeline to produce ssao effect
  60240. */
  60241. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60242. /**
  60243. * @ignore
  60244. * The PassPostProcess id in the pipeline that contains the original scene color
  60245. */
  60246. SSAOOriginalSceneColorEffect: string;
  60247. /**
  60248. * @ignore
  60249. * The SSAO PostProcess id in the pipeline
  60250. */
  60251. SSAORenderEffect: string;
  60252. /**
  60253. * @ignore
  60254. * The horizontal blur PostProcess id in the pipeline
  60255. */
  60256. SSAOBlurHRenderEffect: string;
  60257. /**
  60258. * @ignore
  60259. * The vertical blur PostProcess id in the pipeline
  60260. */
  60261. SSAOBlurVRenderEffect: string;
  60262. /**
  60263. * @ignore
  60264. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60265. */
  60266. SSAOCombineRenderEffect: string;
  60267. /**
  60268. * The output strength of the SSAO post-process. Default value is 1.0.
  60269. */
  60270. totalStrength: number;
  60271. /**
  60272. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60273. */
  60274. radius: number;
  60275. /**
  60276. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60277. * Must not be equal to fallOff and superior to fallOff.
  60278. * Default value is 0.0075
  60279. */
  60280. area: number;
  60281. /**
  60282. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60283. * Must not be equal to area and inferior to area.
  60284. * Default value is 0.000001
  60285. */
  60286. fallOff: number;
  60287. /**
  60288. * The base color of the SSAO post-process
  60289. * The final result is "base + ssao" between [0, 1]
  60290. */
  60291. base: number;
  60292. private _scene;
  60293. private _depthTexture;
  60294. private _randomTexture;
  60295. private _originalColorPostProcess;
  60296. private _ssaoPostProcess;
  60297. private _blurHPostProcess;
  60298. private _blurVPostProcess;
  60299. private _ssaoCombinePostProcess;
  60300. private _firstUpdate;
  60301. /**
  60302. * Gets active scene
  60303. */
  60304. readonly scene: Scene;
  60305. /**
  60306. * @constructor
  60307. * @param name - The rendering pipeline name
  60308. * @param scene - The scene linked to this pipeline
  60309. * @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 }
  60310. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60311. */
  60312. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60313. /**
  60314. * Get the class name
  60315. * @returns "SSAORenderingPipeline"
  60316. */
  60317. getClassName(): string;
  60318. /**
  60319. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60320. */
  60321. dispose(disableDepthRender?: boolean): void;
  60322. private _createBlurPostProcess;
  60323. /** @hidden */
  60324. _rebuild(): void;
  60325. private _createSSAOPostProcess;
  60326. private _createSSAOCombinePostProcess;
  60327. private _createRandomTexture;
  60328. }
  60329. }
  60330. declare module BABYLON {
  60331. /** @hidden */
  60332. export var standardPixelShader: {
  60333. name: string;
  60334. shader: string;
  60335. };
  60336. }
  60337. declare module BABYLON {
  60338. /**
  60339. * Standard rendering pipeline
  60340. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60341. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60342. */
  60343. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60344. /**
  60345. * Public members
  60346. */
  60347. /**
  60348. * Post-process which contains the original scene color before the pipeline applies all the effects
  60349. */
  60350. originalPostProcess: Nullable<PostProcess>;
  60351. /**
  60352. * Post-process used to down scale an image x4
  60353. */
  60354. downSampleX4PostProcess: Nullable<PostProcess>;
  60355. /**
  60356. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60357. */
  60358. brightPassPostProcess: Nullable<PostProcess>;
  60359. /**
  60360. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60361. */
  60362. blurHPostProcesses: PostProcess[];
  60363. /**
  60364. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60365. */
  60366. blurVPostProcesses: PostProcess[];
  60367. /**
  60368. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60369. */
  60370. textureAdderPostProcess: Nullable<PostProcess>;
  60371. /**
  60372. * Post-process used to create volumetric lighting effect
  60373. */
  60374. volumetricLightPostProcess: Nullable<PostProcess>;
  60375. /**
  60376. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60377. */
  60378. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60379. /**
  60380. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60381. */
  60382. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60383. /**
  60384. * Post-process used to merge the volumetric light effect and the real scene color
  60385. */
  60386. volumetricLightMergePostProces: Nullable<PostProcess>;
  60387. /**
  60388. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60389. */
  60390. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60391. /**
  60392. * Base post-process used to calculate the average luminance of the final image for HDR
  60393. */
  60394. luminancePostProcess: Nullable<PostProcess>;
  60395. /**
  60396. * Post-processes used to create down sample post-processes in order to get
  60397. * the average luminance of the final image for HDR
  60398. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60399. */
  60400. luminanceDownSamplePostProcesses: PostProcess[];
  60401. /**
  60402. * Post-process used to create a HDR effect (light adaptation)
  60403. */
  60404. hdrPostProcess: Nullable<PostProcess>;
  60405. /**
  60406. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60407. */
  60408. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60409. /**
  60410. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60411. */
  60412. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60413. /**
  60414. * Post-process used to merge the final HDR post-process and the real scene color
  60415. */
  60416. hdrFinalPostProcess: Nullable<PostProcess>;
  60417. /**
  60418. * Post-process used to create a lens flare effect
  60419. */
  60420. lensFlarePostProcess: Nullable<PostProcess>;
  60421. /**
  60422. * Post-process that merges the result of the lens flare post-process and the real scene color
  60423. */
  60424. lensFlareComposePostProcess: Nullable<PostProcess>;
  60425. /**
  60426. * Post-process used to create a motion blur effect
  60427. */
  60428. motionBlurPostProcess: Nullable<PostProcess>;
  60429. /**
  60430. * Post-process used to create a depth of field effect
  60431. */
  60432. depthOfFieldPostProcess: Nullable<PostProcess>;
  60433. /**
  60434. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60435. */
  60436. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60437. /**
  60438. * Represents the brightness threshold in order to configure the illuminated surfaces
  60439. */
  60440. brightThreshold: number;
  60441. /**
  60442. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60443. */
  60444. blurWidth: number;
  60445. /**
  60446. * Sets if the blur for highlighted surfaces must be only horizontal
  60447. */
  60448. horizontalBlur: boolean;
  60449. /**
  60450. * Gets the overall exposure used by the pipeline
  60451. */
  60452. /**
  60453. * Sets the overall exposure used by the pipeline
  60454. */
  60455. exposure: number;
  60456. /**
  60457. * Texture used typically to simulate "dirty" on camera lens
  60458. */
  60459. lensTexture: Nullable<Texture>;
  60460. /**
  60461. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60462. */
  60463. volumetricLightCoefficient: number;
  60464. /**
  60465. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60466. */
  60467. volumetricLightPower: number;
  60468. /**
  60469. * Used the set the blur intensity to smooth the volumetric lights
  60470. */
  60471. volumetricLightBlurScale: number;
  60472. /**
  60473. * Light (spot or directional) used to generate the volumetric lights rays
  60474. * The source light must have a shadow generate so the pipeline can get its
  60475. * depth map
  60476. */
  60477. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60478. /**
  60479. * For eye adaptation, represents the minimum luminance the eye can see
  60480. */
  60481. hdrMinimumLuminance: number;
  60482. /**
  60483. * For eye adaptation, represents the decrease luminance speed
  60484. */
  60485. hdrDecreaseRate: number;
  60486. /**
  60487. * For eye adaptation, represents the increase luminance speed
  60488. */
  60489. hdrIncreaseRate: number;
  60490. /**
  60491. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60492. */
  60493. /**
  60494. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60495. */
  60496. hdrAutoExposure: boolean;
  60497. /**
  60498. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60499. */
  60500. lensColorTexture: Nullable<Texture>;
  60501. /**
  60502. * The overall strengh for the lens flare effect
  60503. */
  60504. lensFlareStrength: number;
  60505. /**
  60506. * Dispersion coefficient for lens flare ghosts
  60507. */
  60508. lensFlareGhostDispersal: number;
  60509. /**
  60510. * Main lens flare halo width
  60511. */
  60512. lensFlareHaloWidth: number;
  60513. /**
  60514. * Based on the lens distortion effect, defines how much the lens flare result
  60515. * is distorted
  60516. */
  60517. lensFlareDistortionStrength: number;
  60518. /**
  60519. * Configures the blur intensity used for for lens flare (halo)
  60520. */
  60521. lensFlareBlurWidth: number;
  60522. /**
  60523. * Lens star texture must be used to simulate rays on the flares and is available
  60524. * in the documentation
  60525. */
  60526. lensStarTexture: Nullable<Texture>;
  60527. /**
  60528. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60529. * flare effect by taking account of the dirt texture
  60530. */
  60531. lensFlareDirtTexture: Nullable<Texture>;
  60532. /**
  60533. * Represents the focal length for the depth of field effect
  60534. */
  60535. depthOfFieldDistance: number;
  60536. /**
  60537. * Represents the blur intensity for the blurred part of the depth of field effect
  60538. */
  60539. depthOfFieldBlurWidth: number;
  60540. /**
  60541. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60542. */
  60543. /**
  60544. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60545. */
  60546. motionStrength: number;
  60547. /**
  60548. * Gets wether or not the motion blur post-process is object based or screen based.
  60549. */
  60550. /**
  60551. * Sets wether or not the motion blur post-process should be object based or screen based
  60552. */
  60553. objectBasedMotionBlur: boolean;
  60554. /**
  60555. * List of animations for the pipeline (IAnimatable implementation)
  60556. */
  60557. animations: Animation[];
  60558. /**
  60559. * Private members
  60560. */
  60561. private _scene;
  60562. private _currentDepthOfFieldSource;
  60563. private _basePostProcess;
  60564. private _fixedExposure;
  60565. private _currentExposure;
  60566. private _hdrAutoExposure;
  60567. private _hdrCurrentLuminance;
  60568. private _motionStrength;
  60569. private _isObjectBasedMotionBlur;
  60570. private _floatTextureType;
  60571. private _camerasToBeAttached;
  60572. private _ratio;
  60573. private _bloomEnabled;
  60574. private _depthOfFieldEnabled;
  60575. private _vlsEnabled;
  60576. private _lensFlareEnabled;
  60577. private _hdrEnabled;
  60578. private _motionBlurEnabled;
  60579. private _fxaaEnabled;
  60580. private _motionBlurSamples;
  60581. private _volumetricLightStepsCount;
  60582. private _samples;
  60583. /**
  60584. * @ignore
  60585. * Specifies if the bloom pipeline is enabled
  60586. */
  60587. BloomEnabled: boolean;
  60588. /**
  60589. * @ignore
  60590. * Specifies if the depth of field pipeline is enabed
  60591. */
  60592. DepthOfFieldEnabled: boolean;
  60593. /**
  60594. * @ignore
  60595. * Specifies if the lens flare pipeline is enabed
  60596. */
  60597. LensFlareEnabled: boolean;
  60598. /**
  60599. * @ignore
  60600. * Specifies if the HDR pipeline is enabled
  60601. */
  60602. HDREnabled: boolean;
  60603. /**
  60604. * @ignore
  60605. * Specifies if the volumetric lights scattering effect is enabled
  60606. */
  60607. VLSEnabled: boolean;
  60608. /**
  60609. * @ignore
  60610. * Specifies if the motion blur effect is enabled
  60611. */
  60612. MotionBlurEnabled: boolean;
  60613. /**
  60614. * Specifies if anti-aliasing is enabled
  60615. */
  60616. fxaaEnabled: boolean;
  60617. /**
  60618. * Specifies the number of steps used to calculate the volumetric lights
  60619. * Typically in interval [50, 200]
  60620. */
  60621. volumetricLightStepsCount: number;
  60622. /**
  60623. * Specifies the number of samples used for the motion blur effect
  60624. * Typically in interval [16, 64]
  60625. */
  60626. motionBlurSamples: number;
  60627. /**
  60628. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60629. */
  60630. samples: number;
  60631. /**
  60632. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60633. * @constructor
  60634. * @param name The rendering pipeline name
  60635. * @param scene The scene linked to this pipeline
  60636. * @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)
  60637. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60638. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60639. */
  60640. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60641. private _buildPipeline;
  60642. private _createDownSampleX4PostProcess;
  60643. private _createBrightPassPostProcess;
  60644. private _createBlurPostProcesses;
  60645. private _createTextureAdderPostProcess;
  60646. private _createVolumetricLightPostProcess;
  60647. private _createLuminancePostProcesses;
  60648. private _createHdrPostProcess;
  60649. private _createLensFlarePostProcess;
  60650. private _createDepthOfFieldPostProcess;
  60651. private _createMotionBlurPostProcess;
  60652. private _getDepthTexture;
  60653. private _disposePostProcesses;
  60654. /**
  60655. * Dispose of the pipeline and stop all post processes
  60656. */
  60657. dispose(): void;
  60658. /**
  60659. * Serialize the rendering pipeline (Used when exporting)
  60660. * @returns the serialized object
  60661. */
  60662. serialize(): any;
  60663. /**
  60664. * Parse the serialized pipeline
  60665. * @param source Source pipeline.
  60666. * @param scene The scene to load the pipeline to.
  60667. * @param rootUrl The URL of the serialized pipeline.
  60668. * @returns An instantiated pipeline from the serialized object.
  60669. */
  60670. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60671. /**
  60672. * Luminance steps
  60673. */
  60674. static LuminanceSteps: number;
  60675. }
  60676. }
  60677. declare module BABYLON {
  60678. /** @hidden */
  60679. export var tonemapPixelShader: {
  60680. name: string;
  60681. shader: string;
  60682. };
  60683. }
  60684. declare module BABYLON {
  60685. /** Defines operator used for tonemapping */
  60686. export enum TonemappingOperator {
  60687. /** Hable */
  60688. Hable = 0,
  60689. /** Reinhard */
  60690. Reinhard = 1,
  60691. /** HejiDawson */
  60692. HejiDawson = 2,
  60693. /** Photographic */
  60694. Photographic = 3
  60695. }
  60696. /**
  60697. * Defines a post process to apply tone mapping
  60698. */
  60699. export class TonemapPostProcess extends PostProcess {
  60700. private _operator;
  60701. /** Defines the required exposure adjustement */
  60702. exposureAdjustment: number;
  60703. /**
  60704. * Creates a new TonemapPostProcess
  60705. * @param name defines the name of the postprocess
  60706. * @param _operator defines the operator to use
  60707. * @param exposureAdjustment defines the required exposure adjustement
  60708. * @param camera defines the camera to use (can be null)
  60709. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60710. * @param engine defines the hosting engine (can be ignore if camera is set)
  60711. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60712. */
  60713. constructor(name: string, _operator: TonemappingOperator,
  60714. /** Defines the required exposure adjustement */
  60715. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60716. }
  60717. }
  60718. declare module BABYLON {
  60719. /** @hidden */
  60720. export var depthVertexShader: {
  60721. name: string;
  60722. shader: string;
  60723. };
  60724. }
  60725. declare module BABYLON {
  60726. /** @hidden */
  60727. export var volumetricLightScatteringPixelShader: {
  60728. name: string;
  60729. shader: string;
  60730. };
  60731. }
  60732. declare module BABYLON {
  60733. /** @hidden */
  60734. export var volumetricLightScatteringPassVertexShader: {
  60735. name: string;
  60736. shader: string;
  60737. };
  60738. }
  60739. declare module BABYLON {
  60740. /** @hidden */
  60741. export var volumetricLightScatteringPassPixelShader: {
  60742. name: string;
  60743. shader: string;
  60744. };
  60745. }
  60746. declare module BABYLON {
  60747. /**
  60748. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60749. */
  60750. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60751. private _volumetricLightScatteringPass;
  60752. private _volumetricLightScatteringRTT;
  60753. private _viewPort;
  60754. private _screenCoordinates;
  60755. private _cachedDefines;
  60756. /**
  60757. * If not undefined, the mesh position is computed from the attached node position
  60758. */
  60759. attachedNode: {
  60760. position: Vector3;
  60761. };
  60762. /**
  60763. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60764. */
  60765. customMeshPosition: Vector3;
  60766. /**
  60767. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60768. */
  60769. useCustomMeshPosition: boolean;
  60770. /**
  60771. * If the post-process should inverse the light scattering direction
  60772. */
  60773. invert: boolean;
  60774. /**
  60775. * The internal mesh used by the post-process
  60776. */
  60777. mesh: Mesh;
  60778. /**
  60779. * @hidden
  60780. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60781. */
  60782. useDiffuseColor: boolean;
  60783. /**
  60784. * Array containing the excluded meshes not rendered in the internal pass
  60785. */
  60786. excludedMeshes: AbstractMesh[];
  60787. /**
  60788. * Controls the overall intensity of the post-process
  60789. */
  60790. exposure: number;
  60791. /**
  60792. * Dissipates each sample's contribution in range [0, 1]
  60793. */
  60794. decay: number;
  60795. /**
  60796. * Controls the overall intensity of each sample
  60797. */
  60798. weight: number;
  60799. /**
  60800. * Controls the density of each sample
  60801. */
  60802. density: number;
  60803. /**
  60804. * @constructor
  60805. * @param name The post-process name
  60806. * @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)
  60807. * @param camera The camera that the post-process will be attached to
  60808. * @param mesh The mesh used to create the light scattering
  60809. * @param samples The post-process quality, default 100
  60810. * @param samplingModeThe post-process filtering mode
  60811. * @param engine The babylon engine
  60812. * @param reusable If the post-process is reusable
  60813. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60814. */
  60815. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60816. /**
  60817. * Returns the string "VolumetricLightScatteringPostProcess"
  60818. * @returns "VolumetricLightScatteringPostProcess"
  60819. */
  60820. getClassName(): string;
  60821. private _isReady;
  60822. /**
  60823. * Sets the new light position for light scattering effect
  60824. * @param position The new custom light position
  60825. */
  60826. setCustomMeshPosition(position: Vector3): void;
  60827. /**
  60828. * Returns the light position for light scattering effect
  60829. * @return Vector3 The custom light position
  60830. */
  60831. getCustomMeshPosition(): Vector3;
  60832. /**
  60833. * Disposes the internal assets and detaches the post-process from the camera
  60834. */
  60835. dispose(camera: Camera): void;
  60836. /**
  60837. * Returns the render target texture used by the post-process
  60838. * @return the render target texture used by the post-process
  60839. */
  60840. getPass(): RenderTargetTexture;
  60841. private _meshExcluded;
  60842. private _createPass;
  60843. private _updateMeshScreenCoordinates;
  60844. /**
  60845. * Creates a default mesh for the Volumeric Light Scattering post-process
  60846. * @param name The mesh name
  60847. * @param scene The scene where to create the mesh
  60848. * @return the default mesh
  60849. */
  60850. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60851. }
  60852. }
  60853. declare module BABYLON {
  60854. interface Scene {
  60855. /** @hidden (Backing field) */
  60856. _boundingBoxRenderer: BoundingBoxRenderer;
  60857. /** @hidden (Backing field) */
  60858. _forceShowBoundingBoxes: boolean;
  60859. /**
  60860. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60861. */
  60862. forceShowBoundingBoxes: boolean;
  60863. /**
  60864. * Gets the bounding box renderer associated with the scene
  60865. * @returns a BoundingBoxRenderer
  60866. */
  60867. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60868. }
  60869. interface AbstractMesh {
  60870. /** @hidden (Backing field) */
  60871. _showBoundingBox: boolean;
  60872. /**
  60873. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60874. */
  60875. showBoundingBox: boolean;
  60876. }
  60877. /**
  60878. * Component responsible of rendering the bounding box of the meshes in a scene.
  60879. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60880. */
  60881. export class BoundingBoxRenderer implements ISceneComponent {
  60882. /**
  60883. * The component name helpfull to identify the component in the list of scene components.
  60884. */
  60885. readonly name: string;
  60886. /**
  60887. * The scene the component belongs to.
  60888. */
  60889. scene: Scene;
  60890. /**
  60891. * Color of the bounding box lines placed in front of an object
  60892. */
  60893. frontColor: Color3;
  60894. /**
  60895. * Color of the bounding box lines placed behind an object
  60896. */
  60897. backColor: Color3;
  60898. /**
  60899. * Defines if the renderer should show the back lines or not
  60900. */
  60901. showBackLines: boolean;
  60902. /**
  60903. * @hidden
  60904. */
  60905. renderList: SmartArray<BoundingBox>;
  60906. private _colorShader;
  60907. private _vertexBuffers;
  60908. private _indexBuffer;
  60909. private _fillIndexBuffer;
  60910. private _fillIndexData;
  60911. /**
  60912. * Instantiates a new bounding box renderer in a scene.
  60913. * @param scene the scene the renderer renders in
  60914. */
  60915. constructor(scene: Scene);
  60916. /**
  60917. * Registers the component in a given scene
  60918. */
  60919. register(): void;
  60920. private _evaluateSubMesh;
  60921. private _activeMesh;
  60922. private _prepareRessources;
  60923. private _createIndexBuffer;
  60924. /**
  60925. * Rebuilds the elements related to this component in case of
  60926. * context lost for instance.
  60927. */
  60928. rebuild(): void;
  60929. /**
  60930. * @hidden
  60931. */
  60932. reset(): void;
  60933. /**
  60934. * Render the bounding boxes of a specific rendering group
  60935. * @param renderingGroupId defines the rendering group to render
  60936. */
  60937. render(renderingGroupId: number): void;
  60938. /**
  60939. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60940. * @param mesh Define the mesh to render the occlusion bounding box for
  60941. */
  60942. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60943. /**
  60944. * Dispose and release the resources attached to this renderer.
  60945. */
  60946. dispose(): void;
  60947. }
  60948. }
  60949. declare module BABYLON {
  60950. /** @hidden */
  60951. export var depthPixelShader: {
  60952. name: string;
  60953. shader: string;
  60954. };
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * This represents a depth renderer in Babylon.
  60959. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60960. */
  60961. export class DepthRenderer {
  60962. private _scene;
  60963. private _depthMap;
  60964. private _effect;
  60965. private readonly _storeNonLinearDepth;
  60966. private readonly _clearColor;
  60967. /** Get if the depth renderer is using packed depth or not */
  60968. readonly isPacked: boolean;
  60969. private _cachedDefines;
  60970. private _camera;
  60971. /**
  60972. * Specifiess that the depth renderer will only be used within
  60973. * the camera it is created for.
  60974. * This can help forcing its rendering during the camera processing.
  60975. */
  60976. useOnlyInActiveCamera: boolean;
  60977. /** @hidden */
  60978. static _SceneComponentInitialization: (scene: Scene) => void;
  60979. /**
  60980. * Instantiates a depth renderer
  60981. * @param scene The scene the renderer belongs to
  60982. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60983. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60984. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60985. */
  60986. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60987. /**
  60988. * Creates the depth rendering effect and checks if the effect is ready.
  60989. * @param subMesh The submesh to be used to render the depth map of
  60990. * @param useInstances If multiple world instances should be used
  60991. * @returns if the depth renderer is ready to render the depth map
  60992. */
  60993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60994. /**
  60995. * Gets the texture which the depth map will be written to.
  60996. * @returns The depth map texture
  60997. */
  60998. getDepthMap(): RenderTargetTexture;
  60999. /**
  61000. * Disposes of the depth renderer.
  61001. */
  61002. dispose(): void;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. interface Scene {
  61007. /** @hidden (Backing field) */
  61008. _depthRenderer: {
  61009. [id: string]: DepthRenderer;
  61010. };
  61011. /**
  61012. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61013. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61014. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61015. * @returns the created depth renderer
  61016. */
  61017. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61018. /**
  61019. * Disables a depth renderer for a given camera
  61020. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61021. */
  61022. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61023. }
  61024. /**
  61025. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61026. * in several rendering techniques.
  61027. */
  61028. export class DepthRendererSceneComponent implements ISceneComponent {
  61029. /**
  61030. * The component name helpfull to identify the component in the list of scene components.
  61031. */
  61032. readonly name: string;
  61033. /**
  61034. * The scene the component belongs to.
  61035. */
  61036. scene: Scene;
  61037. /**
  61038. * Creates a new instance of the component for the given scene
  61039. * @param scene Defines the scene to register the component in
  61040. */
  61041. constructor(scene: Scene);
  61042. /**
  61043. * Registers the component in a given scene
  61044. */
  61045. register(): void;
  61046. /**
  61047. * Rebuilds the elements related to this component in case of
  61048. * context lost for instance.
  61049. */
  61050. rebuild(): void;
  61051. /**
  61052. * Disposes the component and the associated ressources
  61053. */
  61054. dispose(): void;
  61055. private _gatherRenderTargets;
  61056. private _gatherActiveCameraRenderTargets;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /** @hidden */
  61061. export var outlinePixelShader: {
  61062. name: string;
  61063. shader: string;
  61064. };
  61065. }
  61066. declare module BABYLON {
  61067. /** @hidden */
  61068. export var outlineVertexShader: {
  61069. name: string;
  61070. shader: string;
  61071. };
  61072. }
  61073. declare module BABYLON {
  61074. interface Scene {
  61075. /** @hidden */
  61076. _outlineRenderer: OutlineRenderer;
  61077. /**
  61078. * Gets the outline renderer associated with the scene
  61079. * @returns a OutlineRenderer
  61080. */
  61081. getOutlineRenderer(): OutlineRenderer;
  61082. }
  61083. interface AbstractMesh {
  61084. /** @hidden (Backing field) */
  61085. _renderOutline: boolean;
  61086. /**
  61087. * Gets or sets a boolean indicating if the outline must be rendered as well
  61088. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61089. */
  61090. renderOutline: boolean;
  61091. /** @hidden (Backing field) */
  61092. _renderOverlay: boolean;
  61093. /**
  61094. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61095. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61096. */
  61097. renderOverlay: boolean;
  61098. }
  61099. /**
  61100. * This class is responsible to draw bothe outline/overlay of meshes.
  61101. * It should not be used directly but through the available method on mesh.
  61102. */
  61103. export class OutlineRenderer implements ISceneComponent {
  61104. /**
  61105. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61106. */
  61107. private static _StencilReference;
  61108. /**
  61109. * The name of the component. Each component must have a unique name.
  61110. */
  61111. name: string;
  61112. /**
  61113. * The scene the component belongs to.
  61114. */
  61115. scene: Scene;
  61116. /**
  61117. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61118. */
  61119. zOffset: number;
  61120. private _engine;
  61121. private _effect;
  61122. private _cachedDefines;
  61123. private _savedDepthWrite;
  61124. /**
  61125. * Instantiates a new outline renderer. (There could be only one per scene).
  61126. * @param scene Defines the scene it belongs to
  61127. */
  61128. constructor(scene: Scene);
  61129. /**
  61130. * Register the component to one instance of a scene.
  61131. */
  61132. register(): void;
  61133. /**
  61134. * Rebuilds the elements related to this component in case of
  61135. * context lost for instance.
  61136. */
  61137. rebuild(): void;
  61138. /**
  61139. * Disposes the component and the associated ressources.
  61140. */
  61141. dispose(): void;
  61142. /**
  61143. * Renders the outline in the canvas.
  61144. * @param subMesh Defines the sumesh to render
  61145. * @param batch Defines the batch of meshes in case of instances
  61146. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61147. */
  61148. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61149. /**
  61150. * Returns whether or not the outline renderer is ready for a given submesh.
  61151. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61152. * @param subMesh Defines the submesh to check readyness for
  61153. * @param useInstances Defines wheter wee are trying to render instances or not
  61154. * @returns true if ready otherwise false
  61155. */
  61156. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61157. private _beforeRenderingMesh;
  61158. private _afterRenderingMesh;
  61159. }
  61160. }
  61161. declare module BABYLON {
  61162. /**
  61163. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61164. * @see http://doc.babylonjs.com/babylon101/sprites
  61165. */
  61166. export class SpritePackedManager extends SpriteManager {
  61167. /** defines the packed manager's name */
  61168. name: string;
  61169. /**
  61170. * Creates a new sprite manager from a packed sprite sheet
  61171. * @param name defines the manager's name
  61172. * @param imgUrl defines the sprite sheet url
  61173. * @param capacity defines the maximum allowed number of sprites
  61174. * @param scene defines the hosting scene
  61175. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61176. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61177. * @param samplingMode defines the smapling mode to use with spritesheet
  61178. * @param fromPacked set to true; do not alter
  61179. */
  61180. constructor(
  61181. /** defines the packed manager's name */
  61182. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61183. }
  61184. }
  61185. declare module BABYLON {
  61186. /**
  61187. * Defines the list of states available for a task inside a AssetsManager
  61188. */
  61189. export enum AssetTaskState {
  61190. /**
  61191. * Initialization
  61192. */
  61193. INIT = 0,
  61194. /**
  61195. * Running
  61196. */
  61197. RUNNING = 1,
  61198. /**
  61199. * Done
  61200. */
  61201. DONE = 2,
  61202. /**
  61203. * Error
  61204. */
  61205. ERROR = 3
  61206. }
  61207. /**
  61208. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61209. */
  61210. export abstract class AbstractAssetTask {
  61211. /**
  61212. * Task name
  61213. */ name: string;
  61214. /**
  61215. * Callback called when the task is successful
  61216. */
  61217. onSuccess: (task: any) => void;
  61218. /**
  61219. * Callback called when the task is not successful
  61220. */
  61221. onError: (task: any, message?: string, exception?: any) => void;
  61222. /**
  61223. * Creates a new AssetsManager
  61224. * @param name defines the name of the task
  61225. */
  61226. constructor(
  61227. /**
  61228. * Task name
  61229. */ name: string);
  61230. private _isCompleted;
  61231. private _taskState;
  61232. private _errorObject;
  61233. /**
  61234. * Get if the task is completed
  61235. */
  61236. readonly isCompleted: boolean;
  61237. /**
  61238. * Gets the current state of the task
  61239. */
  61240. readonly taskState: AssetTaskState;
  61241. /**
  61242. * Gets the current error object (if task is in error)
  61243. */
  61244. readonly errorObject: {
  61245. message?: string;
  61246. exception?: any;
  61247. };
  61248. /**
  61249. * Internal only
  61250. * @hidden
  61251. */
  61252. _setErrorObject(message?: string, exception?: any): void;
  61253. /**
  61254. * Execute the current task
  61255. * @param scene defines the scene where you want your assets to be loaded
  61256. * @param onSuccess is a callback called when the task is successfully executed
  61257. * @param onError is a callback called if an error occurs
  61258. */
  61259. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61260. /**
  61261. * Execute the current task
  61262. * @param scene defines the scene where you want your assets to be loaded
  61263. * @param onSuccess is a callback called when the task is successfully executed
  61264. * @param onError is a callback called if an error occurs
  61265. */
  61266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61267. /**
  61268. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61269. * This can be used with failed tasks that have the reason for failure fixed.
  61270. */
  61271. reset(): void;
  61272. private onErrorCallback;
  61273. private onDoneCallback;
  61274. }
  61275. /**
  61276. * Define the interface used by progress events raised during assets loading
  61277. */
  61278. export interface IAssetsProgressEvent {
  61279. /**
  61280. * Defines the number of remaining tasks to process
  61281. */
  61282. remainingCount: number;
  61283. /**
  61284. * Defines the total number of tasks
  61285. */
  61286. totalCount: number;
  61287. /**
  61288. * Defines the task that was just processed
  61289. */
  61290. task: AbstractAssetTask;
  61291. }
  61292. /**
  61293. * Class used to share progress information about assets loading
  61294. */
  61295. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61296. /**
  61297. * Defines the number of remaining tasks to process
  61298. */
  61299. remainingCount: number;
  61300. /**
  61301. * Defines the total number of tasks
  61302. */
  61303. totalCount: number;
  61304. /**
  61305. * Defines the task that was just processed
  61306. */
  61307. task: AbstractAssetTask;
  61308. /**
  61309. * Creates a AssetsProgressEvent
  61310. * @param remainingCount defines the number of remaining tasks to process
  61311. * @param totalCount defines the total number of tasks
  61312. * @param task defines the task that was just processed
  61313. */
  61314. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61315. }
  61316. /**
  61317. * Define a task used by AssetsManager to load meshes
  61318. */
  61319. export class MeshAssetTask extends AbstractAssetTask {
  61320. /**
  61321. * Defines the name of the task
  61322. */
  61323. name: string;
  61324. /**
  61325. * Defines the list of mesh's names you want to load
  61326. */
  61327. meshesNames: any;
  61328. /**
  61329. * Defines the root url to use as a base to load your meshes and associated resources
  61330. */
  61331. rootUrl: string;
  61332. /**
  61333. * Defines the filename of the scene to load from
  61334. */
  61335. sceneFilename: string;
  61336. /**
  61337. * Gets the list of loaded meshes
  61338. */
  61339. loadedMeshes: Array<AbstractMesh>;
  61340. /**
  61341. * Gets the list of loaded particle systems
  61342. */
  61343. loadedParticleSystems: Array<IParticleSystem>;
  61344. /**
  61345. * Gets the list of loaded skeletons
  61346. */
  61347. loadedSkeletons: Array<Skeleton>;
  61348. /**
  61349. * Gets the list of loaded animation groups
  61350. */
  61351. loadedAnimationGroups: Array<AnimationGroup>;
  61352. /**
  61353. * Callback called when the task is successful
  61354. */
  61355. onSuccess: (task: MeshAssetTask) => void;
  61356. /**
  61357. * Callback called when the task is successful
  61358. */
  61359. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61360. /**
  61361. * Creates a new MeshAssetTask
  61362. * @param name defines the name of the task
  61363. * @param meshesNames defines the list of mesh's names you want to load
  61364. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61365. * @param sceneFilename defines the filename of the scene to load from
  61366. */
  61367. constructor(
  61368. /**
  61369. * Defines the name of the task
  61370. */
  61371. name: string,
  61372. /**
  61373. * Defines the list of mesh's names you want to load
  61374. */
  61375. meshesNames: any,
  61376. /**
  61377. * Defines the root url to use as a base to load your meshes and associated resources
  61378. */
  61379. rootUrl: string,
  61380. /**
  61381. * Defines the filename of the scene to load from
  61382. */
  61383. sceneFilename: string);
  61384. /**
  61385. * Execute the current task
  61386. * @param scene defines the scene where you want your assets to be loaded
  61387. * @param onSuccess is a callback called when the task is successfully executed
  61388. * @param onError is a callback called if an error occurs
  61389. */
  61390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61391. }
  61392. /**
  61393. * Define a task used by AssetsManager to load text content
  61394. */
  61395. export class TextFileAssetTask extends AbstractAssetTask {
  61396. /**
  61397. * Defines the name of the task
  61398. */
  61399. name: string;
  61400. /**
  61401. * Defines the location of the file to load
  61402. */
  61403. url: string;
  61404. /**
  61405. * Gets the loaded text string
  61406. */
  61407. text: string;
  61408. /**
  61409. * Callback called when the task is successful
  61410. */
  61411. onSuccess: (task: TextFileAssetTask) => void;
  61412. /**
  61413. * Callback called when the task is successful
  61414. */
  61415. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61416. /**
  61417. * Creates a new TextFileAssetTask object
  61418. * @param name defines the name of the task
  61419. * @param url defines the location of the file to load
  61420. */
  61421. constructor(
  61422. /**
  61423. * Defines the name of the task
  61424. */
  61425. name: string,
  61426. /**
  61427. * Defines the location of the file to load
  61428. */
  61429. url: string);
  61430. /**
  61431. * Execute the current task
  61432. * @param scene defines the scene where you want your assets to be loaded
  61433. * @param onSuccess is a callback called when the task is successfully executed
  61434. * @param onError is a callback called if an error occurs
  61435. */
  61436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61437. }
  61438. /**
  61439. * Define a task used by AssetsManager to load binary data
  61440. */
  61441. export class BinaryFileAssetTask extends AbstractAssetTask {
  61442. /**
  61443. * Defines the name of the task
  61444. */
  61445. name: string;
  61446. /**
  61447. * Defines the location of the file to load
  61448. */
  61449. url: string;
  61450. /**
  61451. * Gets the lodaded data (as an array buffer)
  61452. */
  61453. data: ArrayBuffer;
  61454. /**
  61455. * Callback called when the task is successful
  61456. */
  61457. onSuccess: (task: BinaryFileAssetTask) => void;
  61458. /**
  61459. * Callback called when the task is successful
  61460. */
  61461. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61462. /**
  61463. * Creates a new BinaryFileAssetTask object
  61464. * @param name defines the name of the new task
  61465. * @param url defines the location of the file to load
  61466. */
  61467. constructor(
  61468. /**
  61469. * Defines the name of the task
  61470. */
  61471. name: string,
  61472. /**
  61473. * Defines the location of the file to load
  61474. */
  61475. url: string);
  61476. /**
  61477. * Execute the current task
  61478. * @param scene defines the scene where you want your assets to be loaded
  61479. * @param onSuccess is a callback called when the task is successfully executed
  61480. * @param onError is a callback called if an error occurs
  61481. */
  61482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61483. }
  61484. /**
  61485. * Define a task used by AssetsManager to load images
  61486. */
  61487. export class ImageAssetTask extends AbstractAssetTask {
  61488. /**
  61489. * Defines the name of the task
  61490. */
  61491. name: string;
  61492. /**
  61493. * Defines the location of the image to load
  61494. */
  61495. url: string;
  61496. /**
  61497. * Gets the loaded images
  61498. */
  61499. image: HTMLImageElement;
  61500. /**
  61501. * Callback called when the task is successful
  61502. */
  61503. onSuccess: (task: ImageAssetTask) => void;
  61504. /**
  61505. * Callback called when the task is successful
  61506. */
  61507. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61508. /**
  61509. * Creates a new ImageAssetTask
  61510. * @param name defines the name of the task
  61511. * @param url defines the location of the image to load
  61512. */
  61513. constructor(
  61514. /**
  61515. * Defines the name of the task
  61516. */
  61517. name: string,
  61518. /**
  61519. * Defines the location of the image to load
  61520. */
  61521. url: string);
  61522. /**
  61523. * Execute the current task
  61524. * @param scene defines the scene where you want your assets to be loaded
  61525. * @param onSuccess is a callback called when the task is successfully executed
  61526. * @param onError is a callback called if an error occurs
  61527. */
  61528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61529. }
  61530. /**
  61531. * Defines the interface used by texture loading tasks
  61532. */
  61533. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61534. /**
  61535. * Gets the loaded texture
  61536. */
  61537. texture: TEX;
  61538. }
  61539. /**
  61540. * Define a task used by AssetsManager to load 2D textures
  61541. */
  61542. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61543. /**
  61544. * Defines the name of the task
  61545. */
  61546. name: string;
  61547. /**
  61548. * Defines the location of the file to load
  61549. */
  61550. url: string;
  61551. /**
  61552. * Defines if mipmap should not be generated (default is false)
  61553. */
  61554. noMipmap?: boolean | undefined;
  61555. /**
  61556. * Defines if texture must be inverted on Y axis (default is false)
  61557. */
  61558. invertY?: boolean | undefined;
  61559. /**
  61560. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61561. */
  61562. samplingMode: number;
  61563. /**
  61564. * Gets the loaded texture
  61565. */
  61566. texture: Texture;
  61567. /**
  61568. * Callback called when the task is successful
  61569. */
  61570. onSuccess: (task: TextureAssetTask) => void;
  61571. /**
  61572. * Callback called when the task is successful
  61573. */
  61574. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61575. /**
  61576. * Creates a new TextureAssetTask object
  61577. * @param name defines the name of the task
  61578. * @param url defines the location of the file to load
  61579. * @param noMipmap defines if mipmap should not be generated (default is false)
  61580. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61581. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61582. */
  61583. constructor(
  61584. /**
  61585. * Defines the name of the task
  61586. */
  61587. name: string,
  61588. /**
  61589. * Defines the location of the file to load
  61590. */
  61591. url: string,
  61592. /**
  61593. * Defines if mipmap should not be generated (default is false)
  61594. */
  61595. noMipmap?: boolean | undefined,
  61596. /**
  61597. * Defines if texture must be inverted on Y axis (default is false)
  61598. */
  61599. invertY?: boolean | undefined,
  61600. /**
  61601. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61602. */
  61603. samplingMode?: number);
  61604. /**
  61605. * Execute the current task
  61606. * @param scene defines the scene where you want your assets to be loaded
  61607. * @param onSuccess is a callback called when the task is successfully executed
  61608. * @param onError is a callback called if an error occurs
  61609. */
  61610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61611. }
  61612. /**
  61613. * Define a task used by AssetsManager to load cube textures
  61614. */
  61615. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61616. /**
  61617. * Defines the name of the task
  61618. */
  61619. name: string;
  61620. /**
  61621. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61622. */
  61623. url: string;
  61624. /**
  61625. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61626. */
  61627. extensions?: string[] | undefined;
  61628. /**
  61629. * Defines if mipmaps should not be generated (default is false)
  61630. */
  61631. noMipmap?: boolean | undefined;
  61632. /**
  61633. * Defines the explicit list of files (undefined by default)
  61634. */
  61635. files?: string[] | undefined;
  61636. /**
  61637. * Gets the loaded texture
  61638. */
  61639. texture: CubeTexture;
  61640. /**
  61641. * Callback called when the task is successful
  61642. */
  61643. onSuccess: (task: CubeTextureAssetTask) => void;
  61644. /**
  61645. * Callback called when the task is successful
  61646. */
  61647. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61648. /**
  61649. * Creates a new CubeTextureAssetTask
  61650. * @param name defines the name of the task
  61651. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61652. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61653. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61654. * @param files defines the explicit list of files (undefined by default)
  61655. */
  61656. constructor(
  61657. /**
  61658. * Defines the name of the task
  61659. */
  61660. name: string,
  61661. /**
  61662. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61663. */
  61664. url: string,
  61665. /**
  61666. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61667. */
  61668. extensions?: string[] | undefined,
  61669. /**
  61670. * Defines if mipmaps should not be generated (default is false)
  61671. */
  61672. noMipmap?: boolean | undefined,
  61673. /**
  61674. * Defines the explicit list of files (undefined by default)
  61675. */
  61676. files?: string[] | undefined);
  61677. /**
  61678. * Execute the current task
  61679. * @param scene defines the scene where you want your assets to be loaded
  61680. * @param onSuccess is a callback called when the task is successfully executed
  61681. * @param onError is a callback called if an error occurs
  61682. */
  61683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61684. }
  61685. /**
  61686. * Define a task used by AssetsManager to load HDR cube textures
  61687. */
  61688. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61689. /**
  61690. * Defines the name of the task
  61691. */
  61692. name: string;
  61693. /**
  61694. * Defines the location of the file to load
  61695. */
  61696. url: string;
  61697. /**
  61698. * Defines the desired size (the more it increases the longer the generation will be)
  61699. */
  61700. size: number;
  61701. /**
  61702. * Defines if mipmaps should not be generated (default is false)
  61703. */
  61704. noMipmap: boolean;
  61705. /**
  61706. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61707. */
  61708. generateHarmonics: boolean;
  61709. /**
  61710. * 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)
  61711. */
  61712. gammaSpace: boolean;
  61713. /**
  61714. * Internal Use Only
  61715. */
  61716. reserved: boolean;
  61717. /**
  61718. * Gets the loaded texture
  61719. */
  61720. texture: HDRCubeTexture;
  61721. /**
  61722. * Callback called when the task is successful
  61723. */
  61724. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61725. /**
  61726. * Callback called when the task is successful
  61727. */
  61728. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61729. /**
  61730. * Creates a new HDRCubeTextureAssetTask object
  61731. * @param name defines the name of the task
  61732. * @param url defines the location of the file to load
  61733. * @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.
  61734. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61735. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61736. * @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)
  61737. * @param reserved Internal use only
  61738. */
  61739. constructor(
  61740. /**
  61741. * Defines the name of the task
  61742. */
  61743. name: string,
  61744. /**
  61745. * Defines the location of the file to load
  61746. */
  61747. url: string,
  61748. /**
  61749. * Defines the desired size (the more it increases the longer the generation will be)
  61750. */
  61751. size: number,
  61752. /**
  61753. * Defines if mipmaps should not be generated (default is false)
  61754. */
  61755. noMipmap?: boolean,
  61756. /**
  61757. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61758. */
  61759. generateHarmonics?: boolean,
  61760. /**
  61761. * 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)
  61762. */
  61763. gammaSpace?: boolean,
  61764. /**
  61765. * Internal Use Only
  61766. */
  61767. reserved?: boolean);
  61768. /**
  61769. * Execute the current task
  61770. * @param scene defines the scene where you want your assets to be loaded
  61771. * @param onSuccess is a callback called when the task is successfully executed
  61772. * @param onError is a callback called if an error occurs
  61773. */
  61774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61775. }
  61776. /**
  61777. * Define a task used by AssetsManager to load Equirectangular cube textures
  61778. */
  61779. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61780. /**
  61781. * Defines the name of the task
  61782. */
  61783. name: string;
  61784. /**
  61785. * Defines the location of the file to load
  61786. */
  61787. url: string;
  61788. /**
  61789. * Defines the desired size (the more it increases the longer the generation will be)
  61790. */
  61791. size: number;
  61792. /**
  61793. * Defines if mipmaps should not be generated (default is false)
  61794. */
  61795. noMipmap: boolean;
  61796. /**
  61797. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61798. * but the standard material would require them in Gamma space) (default is true)
  61799. */
  61800. gammaSpace: boolean;
  61801. /**
  61802. * Gets the loaded texture
  61803. */
  61804. texture: EquiRectangularCubeTexture;
  61805. /**
  61806. * Callback called when the task is successful
  61807. */
  61808. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61809. /**
  61810. * Callback called when the task is successful
  61811. */
  61812. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61813. /**
  61814. * Creates a new EquiRectangularCubeTextureAssetTask object
  61815. * @param name defines the name of the task
  61816. * @param url defines the location of the file to load
  61817. * @param size defines the desired size (the more it increases the longer the generation will be)
  61818. * If the size is omitted this implies you are using a preprocessed cubemap.
  61819. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61820. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61821. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61822. * (default is true)
  61823. */
  61824. constructor(
  61825. /**
  61826. * Defines the name of the task
  61827. */
  61828. name: string,
  61829. /**
  61830. * Defines the location of the file to load
  61831. */
  61832. url: string,
  61833. /**
  61834. * Defines the desired size (the more it increases the longer the generation will be)
  61835. */
  61836. size: number,
  61837. /**
  61838. * Defines if mipmaps should not be generated (default is false)
  61839. */
  61840. noMipmap?: boolean,
  61841. /**
  61842. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61843. * but the standard material would require them in Gamma space) (default is true)
  61844. */
  61845. gammaSpace?: boolean);
  61846. /**
  61847. * Execute the current task
  61848. * @param scene defines the scene where you want your assets to be loaded
  61849. * @param onSuccess is a callback called when the task is successfully executed
  61850. * @param onError is a callback called if an error occurs
  61851. */
  61852. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61853. }
  61854. /**
  61855. * This class can be used to easily import assets into a scene
  61856. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61857. */
  61858. export class AssetsManager {
  61859. private _scene;
  61860. private _isLoading;
  61861. protected _tasks: AbstractAssetTask[];
  61862. protected _waitingTasksCount: number;
  61863. protected _totalTasksCount: number;
  61864. /**
  61865. * Callback called when all tasks are processed
  61866. */
  61867. onFinish: (tasks: AbstractAssetTask[]) => void;
  61868. /**
  61869. * Callback called when a task is successful
  61870. */
  61871. onTaskSuccess: (task: AbstractAssetTask) => void;
  61872. /**
  61873. * Callback called when a task had an error
  61874. */
  61875. onTaskError: (task: AbstractAssetTask) => void;
  61876. /**
  61877. * Callback called when a task is done (whatever the result is)
  61878. */
  61879. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61880. /**
  61881. * Observable called when all tasks are processed
  61882. */
  61883. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61884. /**
  61885. * Observable called when a task had an error
  61886. */
  61887. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61888. /**
  61889. * Observable called when all tasks were executed
  61890. */
  61891. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61892. /**
  61893. * Observable called when a task is done (whatever the result is)
  61894. */
  61895. onProgressObservable: Observable<IAssetsProgressEvent>;
  61896. /**
  61897. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61898. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61899. */
  61900. useDefaultLoadingScreen: boolean;
  61901. /**
  61902. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61903. * when all assets have been downloaded.
  61904. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61905. */
  61906. autoHideLoadingUI: boolean;
  61907. /**
  61908. * Creates a new AssetsManager
  61909. * @param scene defines the scene to work on
  61910. */
  61911. constructor(scene: Scene);
  61912. /**
  61913. * Add a MeshAssetTask to the list of active tasks
  61914. * @param taskName defines the name of the new task
  61915. * @param meshesNames defines the name of meshes to load
  61916. * @param rootUrl defines the root url to use to locate files
  61917. * @param sceneFilename defines the filename of the scene file
  61918. * @returns a new MeshAssetTask object
  61919. */
  61920. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61921. /**
  61922. * Add a TextFileAssetTask to the list of active tasks
  61923. * @param taskName defines the name of the new task
  61924. * @param url defines the url of the file to load
  61925. * @returns a new TextFileAssetTask object
  61926. */
  61927. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61928. /**
  61929. * Add a BinaryFileAssetTask to the list of active tasks
  61930. * @param taskName defines the name of the new task
  61931. * @param url defines the url of the file to load
  61932. * @returns a new BinaryFileAssetTask object
  61933. */
  61934. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61935. /**
  61936. * Add a ImageAssetTask to the list of active tasks
  61937. * @param taskName defines the name of the new task
  61938. * @param url defines the url of the file to load
  61939. * @returns a new ImageAssetTask object
  61940. */
  61941. addImageTask(taskName: string, url: string): ImageAssetTask;
  61942. /**
  61943. * Add a TextureAssetTask to the list of active tasks
  61944. * @param taskName defines the name of the new task
  61945. * @param url defines the url of the file to load
  61946. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61947. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61948. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61949. * @returns a new TextureAssetTask object
  61950. */
  61951. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61952. /**
  61953. * Add a CubeTextureAssetTask to the list of active tasks
  61954. * @param taskName defines the name of the new task
  61955. * @param url defines the url of the file to load
  61956. * @param extensions defines the extension to use to load the cube map (can be null)
  61957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61958. * @param files defines the list of files to load (can be null)
  61959. * @returns a new CubeTextureAssetTask object
  61960. */
  61961. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61962. /**
  61963. *
  61964. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61965. * @param taskName defines the name of the new task
  61966. * @param url defines the url of the file to load
  61967. * @param size defines the size you want for the cubemap (can be null)
  61968. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61969. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61970. * @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)
  61971. * @param reserved Internal use only
  61972. * @returns a new HDRCubeTextureAssetTask object
  61973. */
  61974. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61975. /**
  61976. *
  61977. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61978. * @param taskName defines the name of the new task
  61979. * @param url defines the url of the file to load
  61980. * @param size defines the size you want for the cubemap (can be null)
  61981. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61982. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61983. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61984. * @returns a new EquiRectangularCubeTextureAssetTask object
  61985. */
  61986. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61987. /**
  61988. * Remove a task from the assets manager.
  61989. * @param task the task to remove
  61990. */
  61991. removeTask(task: AbstractAssetTask): void;
  61992. private _decreaseWaitingTasksCount;
  61993. private _runTask;
  61994. /**
  61995. * Reset the AssetsManager and remove all tasks
  61996. * @return the current instance of the AssetsManager
  61997. */
  61998. reset(): AssetsManager;
  61999. /**
  62000. * Start the loading process
  62001. * @return the current instance of the AssetsManager
  62002. */
  62003. load(): AssetsManager;
  62004. /**
  62005. * Start the loading process as an async operation
  62006. * @return a promise returning the list of failed tasks
  62007. */
  62008. loadAsync(): Promise<void>;
  62009. }
  62010. }
  62011. declare module BABYLON {
  62012. /**
  62013. * Wrapper class for promise with external resolve and reject.
  62014. */
  62015. export class Deferred<T> {
  62016. /**
  62017. * The promise associated with this deferred object.
  62018. */
  62019. readonly promise: Promise<T>;
  62020. private _resolve;
  62021. private _reject;
  62022. /**
  62023. * The resolve method of the promise associated with this deferred object.
  62024. */
  62025. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62026. /**
  62027. * The reject method of the promise associated with this deferred object.
  62028. */
  62029. readonly reject: (reason?: any) => void;
  62030. /**
  62031. * Constructor for this deferred object.
  62032. */
  62033. constructor();
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62039. */
  62040. export class MeshExploder {
  62041. private _centerMesh;
  62042. private _meshes;
  62043. private _meshesOrigins;
  62044. private _toCenterVectors;
  62045. private _scaledDirection;
  62046. private _newPosition;
  62047. private _centerPosition;
  62048. /**
  62049. * Explodes meshes from a center mesh.
  62050. * @param meshes The meshes to explode.
  62051. * @param centerMesh The mesh to be center of explosion.
  62052. */
  62053. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62054. private _setCenterMesh;
  62055. /**
  62056. * Get class name
  62057. * @returns "MeshExploder"
  62058. */
  62059. getClassName(): string;
  62060. /**
  62061. * "Exploded meshes"
  62062. * @returns Array of meshes with the centerMesh at index 0.
  62063. */
  62064. getMeshes(): Array<Mesh>;
  62065. /**
  62066. * Explodes meshes giving a specific direction
  62067. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62068. */
  62069. explode(direction?: number): void;
  62070. }
  62071. }
  62072. declare module BABYLON {
  62073. /**
  62074. * Class used to help managing file picking and drag'n'drop
  62075. */
  62076. export class FilesInput {
  62077. /**
  62078. * List of files ready to be loaded
  62079. */
  62080. static readonly FilesToLoad: {
  62081. [key: string]: File;
  62082. };
  62083. /**
  62084. * Callback called when a file is processed
  62085. */
  62086. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62087. private _engine;
  62088. private _currentScene;
  62089. private _sceneLoadedCallback;
  62090. private _progressCallback;
  62091. private _additionalRenderLoopLogicCallback;
  62092. private _textureLoadingCallback;
  62093. private _startingProcessingFilesCallback;
  62094. private _onReloadCallback;
  62095. private _errorCallback;
  62096. private _elementToMonitor;
  62097. private _sceneFileToLoad;
  62098. private _filesToLoad;
  62099. /**
  62100. * Creates a new FilesInput
  62101. * @param engine defines the rendering engine
  62102. * @param scene defines the hosting scene
  62103. * @param sceneLoadedCallback callback called when scene is loaded
  62104. * @param progressCallback callback called to track progress
  62105. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62106. * @param textureLoadingCallback callback called when a texture is loading
  62107. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62108. * @param onReloadCallback callback called when a reload is requested
  62109. * @param errorCallback callback call if an error occurs
  62110. */
  62111. 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);
  62112. private _dragEnterHandler;
  62113. private _dragOverHandler;
  62114. private _dropHandler;
  62115. /**
  62116. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62117. * @param elementToMonitor defines the DOM element to track
  62118. */
  62119. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62120. /**
  62121. * Release all associated resources
  62122. */
  62123. dispose(): void;
  62124. private renderFunction;
  62125. private drag;
  62126. private drop;
  62127. private _traverseFolder;
  62128. private _processFiles;
  62129. /**
  62130. * Load files from a drop event
  62131. * @param event defines the drop event to use as source
  62132. */
  62133. loadFiles(event: any): void;
  62134. private _processReload;
  62135. /**
  62136. * Reload the current scene from the loaded files
  62137. */
  62138. reload(): void;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62145. */
  62146. export class SceneOptimization {
  62147. /**
  62148. * Defines the priority of this optimization (0 by default which means first in the list)
  62149. */
  62150. priority: number;
  62151. /**
  62152. * Gets a string describing the action executed by the current optimization
  62153. * @returns description string
  62154. */
  62155. getDescription(): string;
  62156. /**
  62157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62158. * @param scene defines the current scene where to apply this optimization
  62159. * @param optimizer defines the current optimizer
  62160. * @returns true if everything that can be done was applied
  62161. */
  62162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62163. /**
  62164. * Creates the SceneOptimization object
  62165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62166. * @param desc defines the description associated with the optimization
  62167. */
  62168. constructor(
  62169. /**
  62170. * Defines the priority of this optimization (0 by default which means first in the list)
  62171. */
  62172. priority?: number);
  62173. }
  62174. /**
  62175. * Defines an optimization used to reduce the size of render target textures
  62176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62177. */
  62178. export class TextureOptimization extends SceneOptimization {
  62179. /**
  62180. * Defines the priority of this optimization (0 by default which means first in the list)
  62181. */
  62182. priority: number;
  62183. /**
  62184. * 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
  62185. */
  62186. maximumSize: number;
  62187. /**
  62188. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62189. */
  62190. step: number;
  62191. /**
  62192. * Gets a string describing the action executed by the current optimization
  62193. * @returns description string
  62194. */
  62195. getDescription(): string;
  62196. /**
  62197. * Creates the TextureOptimization object
  62198. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62199. * @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
  62200. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62201. */
  62202. constructor(
  62203. /**
  62204. * Defines the priority of this optimization (0 by default which means first in the list)
  62205. */
  62206. priority?: number,
  62207. /**
  62208. * 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
  62209. */
  62210. maximumSize?: number,
  62211. /**
  62212. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62213. */
  62214. step?: number);
  62215. /**
  62216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62217. * @param scene defines the current scene where to apply this optimization
  62218. * @param optimizer defines the current optimizer
  62219. * @returns true if everything that can be done was applied
  62220. */
  62221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62222. }
  62223. /**
  62224. * Defines an optimization used to increase or decrease the rendering resolution
  62225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62226. */
  62227. export class HardwareScalingOptimization extends SceneOptimization {
  62228. /**
  62229. * Defines the priority of this optimization (0 by default which means first in the list)
  62230. */
  62231. priority: number;
  62232. /**
  62233. * Defines the maximum scale to use (2 by default)
  62234. */
  62235. maximumScale: number;
  62236. /**
  62237. * Defines the step to use between two passes (0.5 by default)
  62238. */
  62239. step: number;
  62240. private _currentScale;
  62241. private _directionOffset;
  62242. /**
  62243. * Gets a string describing the action executed by the current optimization
  62244. * @return description string
  62245. */
  62246. getDescription(): string;
  62247. /**
  62248. * Creates the HardwareScalingOptimization object
  62249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62250. * @param maximumScale defines the maximum scale to use (2 by default)
  62251. * @param step defines the step to use between two passes (0.5 by default)
  62252. */
  62253. constructor(
  62254. /**
  62255. * Defines the priority of this optimization (0 by default which means first in the list)
  62256. */
  62257. priority?: number,
  62258. /**
  62259. * Defines the maximum scale to use (2 by default)
  62260. */
  62261. maximumScale?: number,
  62262. /**
  62263. * Defines the step to use between two passes (0.5 by default)
  62264. */
  62265. step?: number);
  62266. /**
  62267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62268. * @param scene defines the current scene where to apply this optimization
  62269. * @param optimizer defines the current optimizer
  62270. * @returns true if everything that can be done was applied
  62271. */
  62272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62273. }
  62274. /**
  62275. * Defines an optimization used to remove shadows
  62276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62277. */
  62278. export class ShadowsOptimization extends SceneOptimization {
  62279. /**
  62280. * Gets a string describing the action executed by the current optimization
  62281. * @return description string
  62282. */
  62283. getDescription(): string;
  62284. /**
  62285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62286. * @param scene defines the current scene where to apply this optimization
  62287. * @param optimizer defines the current optimizer
  62288. * @returns true if everything that can be done was applied
  62289. */
  62290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62291. }
  62292. /**
  62293. * Defines an optimization used to turn post-processes off
  62294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62295. */
  62296. export class PostProcessesOptimization extends SceneOptimization {
  62297. /**
  62298. * Gets a string describing the action executed by the current optimization
  62299. * @return description string
  62300. */
  62301. getDescription(): string;
  62302. /**
  62303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62304. * @param scene defines the current scene where to apply this optimization
  62305. * @param optimizer defines the current optimizer
  62306. * @returns true if everything that can be done was applied
  62307. */
  62308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62309. }
  62310. /**
  62311. * Defines an optimization used to turn lens flares off
  62312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62313. */
  62314. export class LensFlaresOptimization extends SceneOptimization {
  62315. /**
  62316. * Gets a string describing the action executed by the current optimization
  62317. * @return description string
  62318. */
  62319. getDescription(): string;
  62320. /**
  62321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62322. * @param scene defines the current scene where to apply this optimization
  62323. * @param optimizer defines the current optimizer
  62324. * @returns true if everything that can be done was applied
  62325. */
  62326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62327. }
  62328. /**
  62329. * Defines an optimization based on user defined callback.
  62330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62331. */
  62332. export class CustomOptimization extends SceneOptimization {
  62333. /**
  62334. * Callback called to apply the custom optimization.
  62335. */
  62336. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62337. /**
  62338. * Callback called to get custom description
  62339. */
  62340. onGetDescription: () => string;
  62341. /**
  62342. * Gets a string describing the action executed by the current optimization
  62343. * @returns description string
  62344. */
  62345. getDescription(): string;
  62346. /**
  62347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62348. * @param scene defines the current scene where to apply this optimization
  62349. * @param optimizer defines the current optimizer
  62350. * @returns true if everything that can be done was applied
  62351. */
  62352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62353. }
  62354. /**
  62355. * Defines an optimization used to turn particles off
  62356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62357. */
  62358. export class ParticlesOptimization extends SceneOptimization {
  62359. /**
  62360. * Gets a string describing the action executed by the current optimization
  62361. * @return description string
  62362. */
  62363. getDescription(): string;
  62364. /**
  62365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62366. * @param scene defines the current scene where to apply this optimization
  62367. * @param optimizer defines the current optimizer
  62368. * @returns true if everything that can be done was applied
  62369. */
  62370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62371. }
  62372. /**
  62373. * Defines an optimization used to turn render targets off
  62374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62375. */
  62376. export class RenderTargetsOptimization extends SceneOptimization {
  62377. /**
  62378. * Gets a string describing the action executed by the current optimization
  62379. * @return description string
  62380. */
  62381. getDescription(): string;
  62382. /**
  62383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62384. * @param scene defines the current scene where to apply this optimization
  62385. * @param optimizer defines the current optimizer
  62386. * @returns true if everything that can be done was applied
  62387. */
  62388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62389. }
  62390. /**
  62391. * Defines an optimization used to merge meshes with compatible materials
  62392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62393. */
  62394. export class MergeMeshesOptimization extends SceneOptimization {
  62395. private static _UpdateSelectionTree;
  62396. /**
  62397. * Gets or sets a boolean which defines if optimization octree has to be updated
  62398. */
  62399. /**
  62400. * Gets or sets a boolean which defines if optimization octree has to be updated
  62401. */
  62402. static UpdateSelectionTree: boolean;
  62403. /**
  62404. * Gets a string describing the action executed by the current optimization
  62405. * @return description string
  62406. */
  62407. getDescription(): string;
  62408. private _canBeMerged;
  62409. /**
  62410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62411. * @param scene defines the current scene where to apply this optimization
  62412. * @param optimizer defines the current optimizer
  62413. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62414. * @returns true if everything that can be done was applied
  62415. */
  62416. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62417. }
  62418. /**
  62419. * Defines a list of options used by SceneOptimizer
  62420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62421. */
  62422. export class SceneOptimizerOptions {
  62423. /**
  62424. * Defines the target frame rate to reach (60 by default)
  62425. */
  62426. targetFrameRate: number;
  62427. /**
  62428. * Defines the interval between two checkes (2000ms by default)
  62429. */
  62430. trackerDuration: number;
  62431. /**
  62432. * Gets the list of optimizations to apply
  62433. */
  62434. optimizations: SceneOptimization[];
  62435. /**
  62436. * Creates a new list of options used by SceneOptimizer
  62437. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62438. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62439. */
  62440. constructor(
  62441. /**
  62442. * Defines the target frame rate to reach (60 by default)
  62443. */
  62444. targetFrameRate?: number,
  62445. /**
  62446. * Defines the interval between two checkes (2000ms by default)
  62447. */
  62448. trackerDuration?: number);
  62449. /**
  62450. * Add a new optimization
  62451. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62452. * @returns the current SceneOptimizerOptions
  62453. */
  62454. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62455. /**
  62456. * Add a new custom optimization
  62457. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62458. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62460. * @returns the current SceneOptimizerOptions
  62461. */
  62462. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62463. /**
  62464. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62465. * @param targetFrameRate defines the target frame rate (60 by default)
  62466. * @returns a SceneOptimizerOptions object
  62467. */
  62468. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62469. /**
  62470. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62471. * @param targetFrameRate defines the target frame rate (60 by default)
  62472. * @returns a SceneOptimizerOptions object
  62473. */
  62474. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62475. /**
  62476. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62477. * @param targetFrameRate defines the target frame rate (60 by default)
  62478. * @returns a SceneOptimizerOptions object
  62479. */
  62480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62481. }
  62482. /**
  62483. * Class used to run optimizations in order to reach a target frame rate
  62484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62485. */
  62486. export class SceneOptimizer implements IDisposable {
  62487. private _isRunning;
  62488. private _options;
  62489. private _scene;
  62490. private _currentPriorityLevel;
  62491. private _targetFrameRate;
  62492. private _trackerDuration;
  62493. private _currentFrameRate;
  62494. private _sceneDisposeObserver;
  62495. private _improvementMode;
  62496. /**
  62497. * Defines an observable called when the optimizer reaches the target frame rate
  62498. */
  62499. onSuccessObservable: Observable<SceneOptimizer>;
  62500. /**
  62501. * Defines an observable called when the optimizer enables an optimization
  62502. */
  62503. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62504. /**
  62505. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62506. */
  62507. onFailureObservable: Observable<SceneOptimizer>;
  62508. /**
  62509. * Gets a boolean indicating if the optimizer is in improvement mode
  62510. */
  62511. readonly isInImprovementMode: boolean;
  62512. /**
  62513. * Gets the current priority level (0 at start)
  62514. */
  62515. readonly currentPriorityLevel: number;
  62516. /**
  62517. * Gets the current frame rate checked by the SceneOptimizer
  62518. */
  62519. readonly currentFrameRate: number;
  62520. /**
  62521. * Gets or sets the current target frame rate (60 by default)
  62522. */
  62523. /**
  62524. * Gets or sets the current target frame rate (60 by default)
  62525. */
  62526. targetFrameRate: number;
  62527. /**
  62528. * Gets or sets the current interval between two checks (every 2000ms by default)
  62529. */
  62530. /**
  62531. * Gets or sets the current interval between two checks (every 2000ms by default)
  62532. */
  62533. trackerDuration: number;
  62534. /**
  62535. * Gets the list of active optimizations
  62536. */
  62537. readonly optimizations: SceneOptimization[];
  62538. /**
  62539. * Creates a new SceneOptimizer
  62540. * @param scene defines the scene to work on
  62541. * @param options defines the options to use with the SceneOptimizer
  62542. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62543. * @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)
  62544. */
  62545. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62546. /**
  62547. * Stops the current optimizer
  62548. */
  62549. stop(): void;
  62550. /**
  62551. * Reset the optimizer to initial step (current priority level = 0)
  62552. */
  62553. reset(): void;
  62554. /**
  62555. * Start the optimizer. By default it will try to reach a specific framerate
  62556. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62557. */
  62558. start(): void;
  62559. private _checkCurrentState;
  62560. /**
  62561. * Release all resources
  62562. */
  62563. dispose(): void;
  62564. /**
  62565. * Helper function to create a SceneOptimizer with one single line of code
  62566. * @param scene defines the scene to work on
  62567. * @param options defines the options to use with the SceneOptimizer
  62568. * @param onSuccess defines a callback to call on success
  62569. * @param onFailure defines a callback to call on failure
  62570. * @returns the new SceneOptimizer object
  62571. */
  62572. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62573. }
  62574. }
  62575. declare module BABYLON {
  62576. /**
  62577. * Class used to serialize a scene into a string
  62578. */
  62579. export class SceneSerializer {
  62580. /**
  62581. * Clear cache used by a previous serialization
  62582. */
  62583. static ClearCache(): void;
  62584. /**
  62585. * Serialize a scene into a JSON compatible object
  62586. * @param scene defines the scene to serialize
  62587. * @returns a JSON compatible object
  62588. */
  62589. static Serialize(scene: Scene): any;
  62590. /**
  62591. * Serialize a mesh into a JSON compatible object
  62592. * @param toSerialize defines the mesh to serialize
  62593. * @param withParents defines if parents must be serialized as well
  62594. * @param withChildren defines if children must be serialized as well
  62595. * @returns a JSON compatible object
  62596. */
  62597. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62598. }
  62599. }
  62600. declare module BABYLON {
  62601. /**
  62602. * Class used to host texture specific utilities
  62603. */
  62604. export class TextureTools {
  62605. /**
  62606. * Uses the GPU to create a copy texture rescaled at a given size
  62607. * @param texture Texture to copy from
  62608. * @param width defines the desired width
  62609. * @param height defines the desired height
  62610. * @param useBilinearMode defines if bilinear mode has to be used
  62611. * @return the generated texture
  62612. */
  62613. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62614. }
  62615. }
  62616. declare module BABYLON {
  62617. /**
  62618. * This represents the different options available for the video capture.
  62619. */
  62620. export interface VideoRecorderOptions {
  62621. /** Defines the mime type of the video. */
  62622. mimeType: string;
  62623. /** Defines the FPS the video should be recorded at. */
  62624. fps: number;
  62625. /** Defines the chunk size for the recording data. */
  62626. recordChunckSize: number;
  62627. /** The audio tracks to attach to the recording. */
  62628. audioTracks?: MediaStreamTrack[];
  62629. }
  62630. /**
  62631. * This can help with recording videos from BabylonJS.
  62632. * This is based on the available WebRTC functionalities of the browser.
  62633. *
  62634. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62635. */
  62636. export class VideoRecorder {
  62637. private static readonly _defaultOptions;
  62638. /**
  62639. * Returns whether or not the VideoRecorder is available in your browser.
  62640. * @param engine Defines the Babylon Engine.
  62641. * @returns true if supported otherwise false.
  62642. */
  62643. static IsSupported(engine: Engine): boolean;
  62644. private readonly _options;
  62645. private _canvas;
  62646. private _mediaRecorder;
  62647. private _recordedChunks;
  62648. private _fileName;
  62649. private _resolve;
  62650. private _reject;
  62651. /**
  62652. * True when a recording is already in progress.
  62653. */
  62654. readonly isRecording: boolean;
  62655. /**
  62656. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62657. * @param engine Defines the BabylonJS Engine you wish to record.
  62658. * @param options Defines options that can be used to customize the capture.
  62659. */
  62660. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62661. /**
  62662. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62663. */
  62664. stopRecording(): void;
  62665. /**
  62666. * Starts recording the canvas for a max duration specified in parameters.
  62667. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62668. * If null no automatic download will start and you can rely on the promise to get the data back.
  62669. * @param maxDuration Defines the maximum recording time in seconds.
  62670. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62671. * @return A promise callback at the end of the recording with the video data in Blob.
  62672. */
  62673. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62674. /**
  62675. * Releases internal resources used during the recording.
  62676. */
  62677. dispose(): void;
  62678. private _handleDataAvailable;
  62679. private _handleError;
  62680. private _handleStop;
  62681. }
  62682. }
  62683. declare module BABYLON {
  62684. /**
  62685. * Class containing a set of static utilities functions for screenshots
  62686. */
  62687. export class ScreenshotTools {
  62688. /**
  62689. * Captures a screenshot of the current rendering
  62690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62691. * @param engine defines the rendering engine
  62692. * @param camera defines the source camera
  62693. * @param size This parameter can be set to a single number or to an object with the
  62694. * following (optional) properties: precision, width, height. If a single number is passed,
  62695. * it will be used for both width and height. If an object is passed, the screenshot size
  62696. * will be derived from the parameters. The precision property is a multiplier allowing
  62697. * rendering at a higher or lower resolution
  62698. * @param successCallback defines the callback receives a single parameter which contains the
  62699. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62700. * src parameter of an <img> to display it
  62701. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62702. * Check your browser for supported MIME types
  62703. */
  62704. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62705. /**
  62706. * Captures a screenshot of the current rendering
  62707. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62708. * @param engine defines the rendering engine
  62709. * @param camera defines the source camera
  62710. * @param size This parameter can be set to a single number or to an object with the
  62711. * following (optional) properties: precision, width, height. If a single number is passed,
  62712. * it will be used for both width and height. If an object is passed, the screenshot size
  62713. * will be derived from the parameters. The precision property is a multiplier allowing
  62714. * rendering at a higher or lower resolution
  62715. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62716. * Check your browser for supported MIME types
  62717. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62718. * to the src parameter of an <img> to display it
  62719. */
  62720. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62721. /**
  62722. * Generates an image screenshot from the specified camera.
  62723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62724. * @param engine The engine to use for rendering
  62725. * @param camera The camera to use for rendering
  62726. * @param size This parameter can be set to a single number or to an object with the
  62727. * following (optional) properties: precision, width, height. If a single number is passed,
  62728. * it will be used for both width and height. If an object is passed, the screenshot size
  62729. * will be derived from the parameters. The precision property is a multiplier allowing
  62730. * rendering at a higher or lower resolution
  62731. * @param successCallback The callback receives a single parameter which contains the
  62732. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62733. * src parameter of an <img> to display it
  62734. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62735. * Check your browser for supported MIME types
  62736. * @param samples Texture samples (default: 1)
  62737. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62738. * @param fileName A name for for the downloaded file.
  62739. */
  62740. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62741. /**
  62742. * Generates an image screenshot from the specified camera.
  62743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62744. * @param engine The engine to use for rendering
  62745. * @param camera The camera to use for rendering
  62746. * @param size This parameter can be set to a single number or to an object with the
  62747. * following (optional) properties: precision, width, height. If a single number is passed,
  62748. * it will be used for both width and height. If an object is passed, the screenshot size
  62749. * will be derived from the parameters. The precision property is a multiplier allowing
  62750. * rendering at a higher or lower resolution
  62751. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62752. * Check your browser for supported MIME types
  62753. * @param samples Texture samples (default: 1)
  62754. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62755. * @param fileName A name for for the downloaded file.
  62756. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62757. * to the src parameter of an <img> to display it
  62758. */
  62759. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62760. /**
  62761. * Gets height and width for screenshot size
  62762. * @private
  62763. */
  62764. private static _getScreenshotSize;
  62765. }
  62766. }
  62767. declare module BABYLON {
  62768. /**
  62769. * A cursor which tracks a point on a path
  62770. */
  62771. export class PathCursor {
  62772. private path;
  62773. /**
  62774. * Stores path cursor callbacks for when an onchange event is triggered
  62775. */
  62776. private _onchange;
  62777. /**
  62778. * The value of the path cursor
  62779. */
  62780. value: number;
  62781. /**
  62782. * The animation array of the path cursor
  62783. */
  62784. animations: Animation[];
  62785. /**
  62786. * Initializes the path cursor
  62787. * @param path The path to track
  62788. */
  62789. constructor(path: Path2);
  62790. /**
  62791. * Gets the cursor point on the path
  62792. * @returns A point on the path cursor at the cursor location
  62793. */
  62794. getPoint(): Vector3;
  62795. /**
  62796. * Moves the cursor ahead by the step amount
  62797. * @param step The amount to move the cursor forward
  62798. * @returns This path cursor
  62799. */
  62800. moveAhead(step?: number): PathCursor;
  62801. /**
  62802. * Moves the cursor behind by the step amount
  62803. * @param step The amount to move the cursor back
  62804. * @returns This path cursor
  62805. */
  62806. moveBack(step?: number): PathCursor;
  62807. /**
  62808. * Moves the cursor by the step amount
  62809. * If the step amount is greater than one, an exception is thrown
  62810. * @param step The amount to move the cursor
  62811. * @returns This path cursor
  62812. */
  62813. move(step: number): PathCursor;
  62814. /**
  62815. * Ensures that the value is limited between zero and one
  62816. * @returns This path cursor
  62817. */
  62818. private ensureLimits;
  62819. /**
  62820. * Runs onchange callbacks on change (used by the animation engine)
  62821. * @returns This path cursor
  62822. */
  62823. private raiseOnChange;
  62824. /**
  62825. * Executes a function on change
  62826. * @param f A path cursor onchange callback
  62827. * @returns This path cursor
  62828. */
  62829. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62830. }
  62831. }
  62832. declare module BABYLON {
  62833. /** @hidden */
  62834. export var blurPixelShader: {
  62835. name: string;
  62836. shader: string;
  62837. };
  62838. }
  62839. declare module BABYLON {
  62840. /** @hidden */
  62841. export var pointCloudVertexDeclaration: {
  62842. name: string;
  62843. shader: string;
  62844. };
  62845. }
  62846. // Mixins
  62847. interface Window {
  62848. mozIndexedDB: IDBFactory;
  62849. webkitIndexedDB: IDBFactory;
  62850. msIndexedDB: IDBFactory;
  62851. webkitURL: typeof URL;
  62852. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62853. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62854. WebGLRenderingContext: WebGLRenderingContext;
  62855. MSGesture: MSGesture;
  62856. CANNON: any;
  62857. AudioContext: AudioContext;
  62858. webkitAudioContext: AudioContext;
  62859. PointerEvent: any;
  62860. Math: Math;
  62861. Uint8Array: Uint8ArrayConstructor;
  62862. Float32Array: Float32ArrayConstructor;
  62863. mozURL: typeof URL;
  62864. msURL: typeof URL;
  62865. VRFrameData: any; // WebVR, from specs 1.1
  62866. DracoDecoderModule: any;
  62867. setImmediate(handler: (...args: any[]) => void): number;
  62868. }
  62869. interface HTMLCanvasElement {
  62870. requestPointerLock(): void;
  62871. msRequestPointerLock?(): void;
  62872. mozRequestPointerLock?(): void;
  62873. webkitRequestPointerLock?(): void;
  62874. /** Track wether a record is in progress */
  62875. isRecording: boolean;
  62876. /** Capture Stream method defined by some browsers */
  62877. captureStream(fps?: number): MediaStream;
  62878. }
  62879. interface CanvasRenderingContext2D {
  62880. msImageSmoothingEnabled: boolean;
  62881. }
  62882. interface MouseEvent {
  62883. mozMovementX: number;
  62884. mozMovementY: number;
  62885. webkitMovementX: number;
  62886. webkitMovementY: number;
  62887. msMovementX: number;
  62888. msMovementY: number;
  62889. }
  62890. interface Navigator {
  62891. mozGetVRDevices: (any: any) => any;
  62892. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62893. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62894. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62895. webkitGetGamepads(): Gamepad[];
  62896. msGetGamepads(): Gamepad[];
  62897. webkitGamepads(): Gamepad[];
  62898. }
  62899. interface HTMLVideoElement {
  62900. mozSrcObject: any;
  62901. }
  62902. interface Math {
  62903. fround(x: number): number;
  62904. imul(a: number, b: number): number;
  62905. }
  62906. interface WebGLRenderingContext {
  62907. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62908. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62909. vertexAttribDivisor(index: number, divisor: number): void;
  62910. createVertexArray(): any;
  62911. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62912. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62913. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62914. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62915. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62916. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62917. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62918. // Queries
  62919. createQuery(): WebGLQuery;
  62920. deleteQuery(query: WebGLQuery): void;
  62921. beginQuery(target: number, query: WebGLQuery): void;
  62922. endQuery(target: number): void;
  62923. getQueryParameter(query: WebGLQuery, pname: number): any;
  62924. getQuery(target: number, pname: number): any;
  62925. MAX_SAMPLES: number;
  62926. RGBA8: number;
  62927. READ_FRAMEBUFFER: number;
  62928. DRAW_FRAMEBUFFER: number;
  62929. UNIFORM_BUFFER: number;
  62930. HALF_FLOAT_OES: number;
  62931. RGBA16F: number;
  62932. RGBA32F: number;
  62933. R32F: number;
  62934. RG32F: number;
  62935. RGB32F: number;
  62936. R16F: number;
  62937. RG16F: number;
  62938. RGB16F: number;
  62939. RED: number;
  62940. RG: number;
  62941. R8: number;
  62942. RG8: number;
  62943. UNSIGNED_INT_24_8: number;
  62944. DEPTH24_STENCIL8: number;
  62945. MIN: number;
  62946. MAX: number;
  62947. /* Multiple Render Targets */
  62948. drawBuffers(buffers: number[]): void;
  62949. readBuffer(src: number): void;
  62950. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62951. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62952. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62953. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62954. // Occlusion Query
  62955. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62956. ANY_SAMPLES_PASSED: number;
  62957. QUERY_RESULT_AVAILABLE: number;
  62958. QUERY_RESULT: number;
  62959. }
  62960. interface WebGLProgram {
  62961. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62962. }
  62963. interface EXT_disjoint_timer_query {
  62964. QUERY_COUNTER_BITS_EXT: number;
  62965. TIME_ELAPSED_EXT: number;
  62966. TIMESTAMP_EXT: number;
  62967. GPU_DISJOINT_EXT: number;
  62968. QUERY_RESULT_EXT: number;
  62969. QUERY_RESULT_AVAILABLE_EXT: number;
  62970. queryCounterEXT(query: WebGLQuery, target: number): void;
  62971. createQueryEXT(): WebGLQuery;
  62972. beginQueryEXT(target: number, query: WebGLQuery): void;
  62973. endQueryEXT(target: number): void;
  62974. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62975. deleteQueryEXT(query: WebGLQuery): void;
  62976. }
  62977. interface WebGLUniformLocation {
  62978. _currentState: any;
  62979. }
  62980. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62981. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62982. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62983. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62984. interface WebGLRenderingContext {
  62985. readonly RASTERIZER_DISCARD: number;
  62986. readonly DEPTH_COMPONENT24: number;
  62987. readonly TEXTURE_3D: number;
  62988. readonly TEXTURE_2D_ARRAY: number;
  62989. readonly TEXTURE_COMPARE_FUNC: number;
  62990. readonly TEXTURE_COMPARE_MODE: number;
  62991. readonly COMPARE_REF_TO_TEXTURE: number;
  62992. readonly TEXTURE_WRAP_R: number;
  62993. readonly HALF_FLOAT: number;
  62994. readonly RGB8: number;
  62995. readonly RED_INTEGER: number;
  62996. readonly RG_INTEGER: number;
  62997. readonly RGB_INTEGER: number;
  62998. readonly RGBA_INTEGER: number;
  62999. readonly R8_SNORM: number;
  63000. readonly RG8_SNORM: number;
  63001. readonly RGB8_SNORM: number;
  63002. readonly RGBA8_SNORM: number;
  63003. readonly R8I: number;
  63004. readonly RG8I: number;
  63005. readonly RGB8I: number;
  63006. readonly RGBA8I: number;
  63007. readonly R8UI: number;
  63008. readonly RG8UI: number;
  63009. readonly RGB8UI: number;
  63010. readonly RGBA8UI: number;
  63011. readonly R16I: number;
  63012. readonly RG16I: number;
  63013. readonly RGB16I: number;
  63014. readonly RGBA16I: number;
  63015. readonly R16UI: number;
  63016. readonly RG16UI: number;
  63017. readonly RGB16UI: number;
  63018. readonly RGBA16UI: number;
  63019. readonly R32I: number;
  63020. readonly RG32I: number;
  63021. readonly RGB32I: number;
  63022. readonly RGBA32I: number;
  63023. readonly R32UI: number;
  63024. readonly RG32UI: number;
  63025. readonly RGB32UI: number;
  63026. readonly RGBA32UI: number;
  63027. readonly RGB10_A2UI: number;
  63028. readonly R11F_G11F_B10F: number;
  63029. readonly RGB9_E5: number;
  63030. readonly RGB10_A2: number;
  63031. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63032. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63033. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63034. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63035. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63036. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63037. 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;
  63038. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63039. readonly TRANSFORM_FEEDBACK: number;
  63040. readonly INTERLEAVED_ATTRIBS: number;
  63041. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63042. createTransformFeedback(): WebGLTransformFeedback;
  63043. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63044. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63045. beginTransformFeedback(primitiveMode: number): void;
  63046. endTransformFeedback(): void;
  63047. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63048. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63049. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63050. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63051. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63052. }
  63053. interface ImageBitmap {
  63054. readonly width: number;
  63055. readonly height: number;
  63056. close(): void;
  63057. }
  63058. interface WebGLQuery extends WebGLObject {
  63059. }
  63060. declare var WebGLQuery: {
  63061. prototype: WebGLQuery;
  63062. new(): WebGLQuery;
  63063. };
  63064. interface WebGLSampler extends WebGLObject {
  63065. }
  63066. declare var WebGLSampler: {
  63067. prototype: WebGLSampler;
  63068. new(): WebGLSampler;
  63069. };
  63070. interface WebGLSync extends WebGLObject {
  63071. }
  63072. declare var WebGLSync: {
  63073. prototype: WebGLSync;
  63074. new(): WebGLSync;
  63075. };
  63076. interface WebGLTransformFeedback extends WebGLObject {
  63077. }
  63078. declare var WebGLTransformFeedback: {
  63079. prototype: WebGLTransformFeedback;
  63080. new(): WebGLTransformFeedback;
  63081. };
  63082. interface WebGLVertexArrayObject extends WebGLObject {
  63083. }
  63084. declare var WebGLVertexArrayObject: {
  63085. prototype: WebGLVertexArrayObject;
  63086. new(): WebGLVertexArrayObject;
  63087. };
  63088. // Type definitions for WebVR API
  63089. // Project: https://w3c.github.io/webvr/
  63090. // Definitions by: six a <https://github.com/lostfictions>
  63091. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63092. interface VRDisplay extends EventTarget {
  63093. /**
  63094. * Dictionary of capabilities describing the VRDisplay.
  63095. */
  63096. readonly capabilities: VRDisplayCapabilities;
  63097. /**
  63098. * z-depth defining the far plane of the eye view frustum
  63099. * enables mapping of values in the render target depth
  63100. * attachment to scene coordinates. Initially set to 10000.0.
  63101. */
  63102. depthFar: number;
  63103. /**
  63104. * z-depth defining the near plane of the eye view frustum
  63105. * enables mapping of values in the render target depth
  63106. * attachment to scene coordinates. Initially set to 0.01.
  63107. */
  63108. depthNear: number;
  63109. /**
  63110. * An identifier for this distinct VRDisplay. Used as an
  63111. * association point in the Gamepad API.
  63112. */
  63113. readonly displayId: number;
  63114. /**
  63115. * A display name, a user-readable name identifying it.
  63116. */
  63117. readonly displayName: string;
  63118. readonly isConnected: boolean;
  63119. readonly isPresenting: boolean;
  63120. /**
  63121. * If this VRDisplay supports room-scale experiences, the optional
  63122. * stage attribute contains details on the room-scale parameters.
  63123. */
  63124. readonly stageParameters: VRStageParameters | null;
  63125. /**
  63126. * Passing the value returned by `requestAnimationFrame` to
  63127. * `cancelAnimationFrame` will unregister the callback.
  63128. * @param handle Define the hanle of the request to cancel
  63129. */
  63130. cancelAnimationFrame(handle: number): void;
  63131. /**
  63132. * Stops presenting to the VRDisplay.
  63133. * @returns a promise to know when it stopped
  63134. */
  63135. exitPresent(): Promise<void>;
  63136. /**
  63137. * Return the current VREyeParameters for the given eye.
  63138. * @param whichEye Define the eye we want the parameter for
  63139. * @returns the eye parameters
  63140. */
  63141. getEyeParameters(whichEye: string): VREyeParameters;
  63142. /**
  63143. * Populates the passed VRFrameData with the information required to render
  63144. * the current frame.
  63145. * @param frameData Define the data structure to populate
  63146. * @returns true if ok otherwise false
  63147. */
  63148. getFrameData(frameData: VRFrameData): boolean;
  63149. /**
  63150. * Get the layers currently being presented.
  63151. * @returns the list of VR layers
  63152. */
  63153. getLayers(): VRLayer[];
  63154. /**
  63155. * Return a VRPose containing the future predicted pose of the VRDisplay
  63156. * when the current frame will be presented. The value returned will not
  63157. * change until JavaScript has returned control to the browser.
  63158. *
  63159. * The VRPose will contain the position, orientation, velocity,
  63160. * and acceleration of each of these properties.
  63161. * @returns the pose object
  63162. */
  63163. getPose(): VRPose;
  63164. /**
  63165. * Return the current instantaneous pose of the VRDisplay, with no
  63166. * prediction applied.
  63167. * @returns the current instantaneous pose
  63168. */
  63169. getImmediatePose(): VRPose;
  63170. /**
  63171. * The callback passed to `requestAnimationFrame` will be called
  63172. * any time a new frame should be rendered. When the VRDisplay is
  63173. * presenting the callback will be called at the native refresh
  63174. * rate of the HMD. When not presenting this function acts
  63175. * identically to how window.requestAnimationFrame acts. Content should
  63176. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63177. * asynchronously from other displays and at differing refresh rates.
  63178. * @param callback Define the eaction to run next frame
  63179. * @returns the request handle it
  63180. */
  63181. requestAnimationFrame(callback: FrameRequestCallback): number;
  63182. /**
  63183. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63184. * Repeat calls while already presenting will update the VRLayers being displayed.
  63185. * @param layers Define the list of layer to present
  63186. * @returns a promise to know when the request has been fulfilled
  63187. */
  63188. requestPresent(layers: VRLayer[]): Promise<void>;
  63189. /**
  63190. * Reset the pose for this display, treating its current position and
  63191. * orientation as the "origin/zero" values. VRPose.position,
  63192. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63193. * updated when calling resetPose(). This should be called in only
  63194. * sitting-space experiences.
  63195. */
  63196. resetPose(): void;
  63197. /**
  63198. * The VRLayer provided to the VRDisplay will be captured and presented
  63199. * in the HMD. Calling this function has the same effect on the source
  63200. * canvas as any other operation that uses its source image, and canvases
  63201. * created without preserveDrawingBuffer set to true will be cleared.
  63202. * @param pose Define the pose to submit
  63203. */
  63204. submitFrame(pose?: VRPose): void;
  63205. }
  63206. declare var VRDisplay: {
  63207. prototype: VRDisplay;
  63208. new(): VRDisplay;
  63209. };
  63210. interface VRLayer {
  63211. leftBounds?: number[] | Float32Array | null;
  63212. rightBounds?: number[] | Float32Array | null;
  63213. source?: HTMLCanvasElement | null;
  63214. }
  63215. interface VRDisplayCapabilities {
  63216. readonly canPresent: boolean;
  63217. readonly hasExternalDisplay: boolean;
  63218. readonly hasOrientation: boolean;
  63219. readonly hasPosition: boolean;
  63220. readonly maxLayers: number;
  63221. }
  63222. interface VREyeParameters {
  63223. /** @deprecated */
  63224. readonly fieldOfView: VRFieldOfView;
  63225. readonly offset: Float32Array;
  63226. readonly renderHeight: number;
  63227. readonly renderWidth: number;
  63228. }
  63229. interface VRFieldOfView {
  63230. readonly downDegrees: number;
  63231. readonly leftDegrees: number;
  63232. readonly rightDegrees: number;
  63233. readonly upDegrees: number;
  63234. }
  63235. interface VRFrameData {
  63236. readonly leftProjectionMatrix: Float32Array;
  63237. readonly leftViewMatrix: Float32Array;
  63238. readonly pose: VRPose;
  63239. readonly rightProjectionMatrix: Float32Array;
  63240. readonly rightViewMatrix: Float32Array;
  63241. readonly timestamp: number;
  63242. }
  63243. interface VRPose {
  63244. readonly angularAcceleration: Float32Array | null;
  63245. readonly angularVelocity: Float32Array | null;
  63246. readonly linearAcceleration: Float32Array | null;
  63247. readonly linearVelocity: Float32Array | null;
  63248. readonly orientation: Float32Array | null;
  63249. readonly position: Float32Array | null;
  63250. readonly timestamp: number;
  63251. }
  63252. interface VRStageParameters {
  63253. sittingToStandingTransform?: Float32Array;
  63254. sizeX?: number;
  63255. sizeY?: number;
  63256. }
  63257. interface Navigator {
  63258. getVRDisplays(): Promise<VRDisplay[]>;
  63259. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63260. }
  63261. interface Window {
  63262. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63263. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63264. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63265. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63266. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63267. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63268. }
  63269. interface Gamepad {
  63270. readonly displayId: number;
  63271. }
  63272. type XRSessionMode =
  63273. | "inline"
  63274. | "immersive-vr"
  63275. | "immersive-ar";
  63276. type XRReferenceSpaceType =
  63277. | "viewer"
  63278. | "local"
  63279. | "local-floor"
  63280. | "bounded-floor"
  63281. | "unbounded";
  63282. type XREnvironmentBlendMode =
  63283. | "opaque"
  63284. | "additive"
  63285. | "alpha-blend";
  63286. type XRVisibilityState =
  63287. | "visible"
  63288. | "visible-blurred"
  63289. | "hidden";
  63290. type XRHandedness =
  63291. | "none"
  63292. | "left"
  63293. | "right";
  63294. type XRTargetRayMode =
  63295. | "gaze"
  63296. | "tracked-pointer"
  63297. | "screen";
  63298. type XREye =
  63299. | "none"
  63300. | "left"
  63301. | "right";
  63302. interface XRSpace extends EventTarget {
  63303. }
  63304. interface XRRenderState {
  63305. depthNear?: number;
  63306. depthFar?: number;
  63307. inlineVerticalFieldOfView?: number;
  63308. baseLayer?: XRWebGLLayer;
  63309. }
  63310. interface XRInputSource {
  63311. handedness: XRHandedness;
  63312. targetRayMode: XRTargetRayMode;
  63313. targetRaySpace: XRSpace;
  63314. gripSpace: XRSpace | undefined;
  63315. gamepad: Gamepad | undefined;
  63316. profiles: Array<string>;
  63317. }
  63318. interface XRSession {
  63319. addEventListener: Function;
  63320. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63321. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63322. requestAnimationFrame: Function;
  63323. end(): Promise<void>;
  63324. renderState: XRRenderState;
  63325. inputSources: Array<XRInputSource>;
  63326. }
  63327. interface XRReferenceSpace extends XRSpace {
  63328. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63329. onreset: any;
  63330. }
  63331. interface XRFrame {
  63332. session: XRSession;
  63333. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63334. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63335. }
  63336. interface XRViewerPose extends XRPose {
  63337. views: Array<XRView>;
  63338. }
  63339. interface XRPose {
  63340. transform: XRRigidTransform;
  63341. emulatedPosition: boolean;
  63342. }
  63343. declare var XRWebGLLayer: {
  63344. prototype: XRWebGLLayer;
  63345. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63346. };
  63347. interface XRWebGLLayer {
  63348. framebuffer: WebGLFramebuffer;
  63349. framebufferWidth: number;
  63350. framebufferHeight: number;
  63351. getViewport: Function;
  63352. }
  63353. interface XRRigidTransform {
  63354. position: DOMPointReadOnly;
  63355. orientation: DOMPointReadOnly;
  63356. matrix: Float32Array;
  63357. inverse: XRRigidTransform;
  63358. }
  63359. interface XRView {
  63360. eye: XREye;
  63361. projectionMatrix: Float32Array;
  63362. transform: XRRigidTransform;
  63363. }
  63364. interface XRInputSourceChangeEvent {
  63365. session: XRSession;
  63366. removed: Array<XRInputSource>;
  63367. added: Array<XRInputSource>;
  63368. }
  63369. /**
  63370. * @ignore
  63371. */
  63372. declare module BABYLON.GLTF2.Exporter {
  63373. }
  63374. /**
  63375. * @ignore
  63376. */
  63377. declare module BABYLON.GLTF1 {
  63378. }
  63379. declare module BABYLON.GUI {
  63380. /**
  63381. * Class used to specific a value and its associated unit
  63382. */
  63383. export class ValueAndUnit {
  63384. /** defines the unit to store */
  63385. unit: number;
  63386. /** defines a boolean indicating if the value can be negative */
  63387. negativeValueAllowed: boolean;
  63388. private _value;
  63389. private _originalUnit;
  63390. /**
  63391. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63392. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63393. */
  63394. ignoreAdaptiveScaling: boolean;
  63395. /**
  63396. * Creates a new ValueAndUnit
  63397. * @param value defines the value to store
  63398. * @param unit defines the unit to store
  63399. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63400. */
  63401. constructor(value: number,
  63402. /** defines the unit to store */
  63403. unit?: number,
  63404. /** defines a boolean indicating if the value can be negative */
  63405. negativeValueAllowed?: boolean);
  63406. /** Gets a boolean indicating if the value is a percentage */
  63407. readonly isPercentage: boolean;
  63408. /** Gets a boolean indicating if the value is store as pixel */
  63409. readonly isPixel: boolean;
  63410. /** Gets direct internal value */
  63411. readonly internalValue: number;
  63412. /**
  63413. * Gets value as pixel
  63414. * @param host defines the root host
  63415. * @param refValue defines the reference value for percentages
  63416. * @returns the value as pixel
  63417. */
  63418. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63419. /**
  63420. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63421. * @param value defines the value to store
  63422. * @param unit defines the unit to store
  63423. * @returns the current ValueAndUnit
  63424. */
  63425. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63426. /**
  63427. * Gets the value accordingly to its unit
  63428. * @param host defines the root host
  63429. * @returns the value
  63430. */
  63431. getValue(host: AdvancedDynamicTexture): number;
  63432. /**
  63433. * Gets a string representation of the value
  63434. * @param host defines the root host
  63435. * @param decimals defines an optional number of decimals to display
  63436. * @returns a string
  63437. */
  63438. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63439. /**
  63440. * Store a value parsed from a string
  63441. * @param source defines the source string
  63442. * @returns true if the value was successfully parsed
  63443. */
  63444. fromString(source: string | number): boolean;
  63445. private static _Regex;
  63446. private static _UNITMODE_PERCENTAGE;
  63447. private static _UNITMODE_PIXEL;
  63448. /** UNITMODE_PERCENTAGE */
  63449. static readonly UNITMODE_PERCENTAGE: number;
  63450. /** UNITMODE_PIXEL */
  63451. static readonly UNITMODE_PIXEL: number;
  63452. }
  63453. }
  63454. declare module BABYLON.GUI {
  63455. /**
  63456. * Define a style used by control to automatically setup properties based on a template.
  63457. * Only support font related properties so far
  63458. */
  63459. export class Style implements BABYLON.IDisposable {
  63460. private _fontFamily;
  63461. private _fontStyle;
  63462. private _fontWeight;
  63463. /** @hidden */
  63464. _host: AdvancedDynamicTexture;
  63465. /** @hidden */
  63466. _fontSize: ValueAndUnit;
  63467. /**
  63468. * BABYLON.Observable raised when the style values are changed
  63469. */
  63470. onChangedObservable: BABYLON.Observable<Style>;
  63471. /**
  63472. * Creates a new style object
  63473. * @param host defines the AdvancedDynamicTexture which hosts this style
  63474. */
  63475. constructor(host: AdvancedDynamicTexture);
  63476. /**
  63477. * Gets or sets the font size
  63478. */
  63479. fontSize: string | number;
  63480. /**
  63481. * Gets or sets the font family
  63482. */
  63483. fontFamily: string;
  63484. /**
  63485. * Gets or sets the font style
  63486. */
  63487. fontStyle: string;
  63488. /** Gets or sets font weight */
  63489. fontWeight: string;
  63490. /** Dispose all associated resources */
  63491. dispose(): void;
  63492. }
  63493. }
  63494. declare module BABYLON.GUI {
  63495. /**
  63496. * Class used to transport BABYLON.Vector2 information for pointer events
  63497. */
  63498. export class Vector2WithInfo extends BABYLON.Vector2 {
  63499. /** defines the current mouse button index */
  63500. buttonIndex: number;
  63501. /**
  63502. * Creates a new Vector2WithInfo
  63503. * @param source defines the vector2 data to transport
  63504. * @param buttonIndex defines the current mouse button index
  63505. */
  63506. constructor(source: BABYLON.Vector2,
  63507. /** defines the current mouse button index */
  63508. buttonIndex?: number);
  63509. }
  63510. /** Class used to provide 2D matrix features */
  63511. export class Matrix2D {
  63512. /** Gets the internal array of 6 floats used to store matrix data */
  63513. m: Float32Array;
  63514. /**
  63515. * Creates a new matrix
  63516. * @param m00 defines value for (0, 0)
  63517. * @param m01 defines value for (0, 1)
  63518. * @param m10 defines value for (1, 0)
  63519. * @param m11 defines value for (1, 1)
  63520. * @param m20 defines value for (2, 0)
  63521. * @param m21 defines value for (2, 1)
  63522. */
  63523. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63524. /**
  63525. * Fills the matrix from direct values
  63526. * @param m00 defines value for (0, 0)
  63527. * @param m01 defines value for (0, 1)
  63528. * @param m10 defines value for (1, 0)
  63529. * @param m11 defines value for (1, 1)
  63530. * @param m20 defines value for (2, 0)
  63531. * @param m21 defines value for (2, 1)
  63532. * @returns the current modified matrix
  63533. */
  63534. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63535. /**
  63536. * Gets matrix determinant
  63537. * @returns the determinant
  63538. */
  63539. determinant(): number;
  63540. /**
  63541. * Inverses the matrix and stores it in a target matrix
  63542. * @param result defines the target matrix
  63543. * @returns the current matrix
  63544. */
  63545. invertToRef(result: Matrix2D): Matrix2D;
  63546. /**
  63547. * Multiplies the current matrix with another one
  63548. * @param other defines the second operand
  63549. * @param result defines the target matrix
  63550. * @returns the current matrix
  63551. */
  63552. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63553. /**
  63554. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63555. * @param x defines the x coordinate to transform
  63556. * @param y defines the x coordinate to transform
  63557. * @param result defines the target vector2
  63558. * @returns the current matrix
  63559. */
  63560. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63561. /**
  63562. * Creates an identity matrix
  63563. * @returns a new matrix
  63564. */
  63565. static Identity(): Matrix2D;
  63566. /**
  63567. * Creates a translation matrix and stores it in a target matrix
  63568. * @param x defines the x coordinate of the translation
  63569. * @param y defines the y coordinate of the translation
  63570. * @param result defines the target matrix
  63571. */
  63572. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63573. /**
  63574. * Creates a scaling matrix and stores it in a target matrix
  63575. * @param x defines the x coordinate of the scaling
  63576. * @param y defines the y coordinate of the scaling
  63577. * @param result defines the target matrix
  63578. */
  63579. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63580. /**
  63581. * Creates a rotation matrix and stores it in a target matrix
  63582. * @param angle defines the rotation angle
  63583. * @param result defines the target matrix
  63584. */
  63585. static RotationToRef(angle: number, result: Matrix2D): void;
  63586. private static _TempPreTranslationMatrix;
  63587. private static _TempPostTranslationMatrix;
  63588. private static _TempRotationMatrix;
  63589. private static _TempScalingMatrix;
  63590. private static _TempCompose0;
  63591. private static _TempCompose1;
  63592. private static _TempCompose2;
  63593. /**
  63594. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63595. * @param tx defines the x coordinate of the translation
  63596. * @param ty defines the y coordinate of the translation
  63597. * @param angle defines the rotation angle
  63598. * @param scaleX defines the x coordinate of the scaling
  63599. * @param scaleY defines the y coordinate of the scaling
  63600. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63601. * @param result defines the target matrix
  63602. */
  63603. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63604. }
  63605. }
  63606. declare module BABYLON.GUI {
  63607. /**
  63608. * Class used to store 2D control sizes
  63609. */
  63610. export class Measure {
  63611. /** defines left coordinate */
  63612. left: number;
  63613. /** defines top coordinate */
  63614. top: number;
  63615. /** defines width dimension */
  63616. width: number;
  63617. /** defines height dimension */
  63618. height: number;
  63619. /**
  63620. * Creates a new measure
  63621. * @param left defines left coordinate
  63622. * @param top defines top coordinate
  63623. * @param width defines width dimension
  63624. * @param height defines height dimension
  63625. */
  63626. constructor(
  63627. /** defines left coordinate */
  63628. left: number,
  63629. /** defines top coordinate */
  63630. top: number,
  63631. /** defines width dimension */
  63632. width: number,
  63633. /** defines height dimension */
  63634. height: number);
  63635. /**
  63636. * Copy from another measure
  63637. * @param other defines the other measure to copy from
  63638. */
  63639. copyFrom(other: Measure): void;
  63640. /**
  63641. * Copy from a group of 4 floats
  63642. * @param left defines left coordinate
  63643. * @param top defines top coordinate
  63644. * @param width defines width dimension
  63645. * @param height defines height dimension
  63646. */
  63647. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63648. /**
  63649. * Computes the axis aligned bounding box measure for two given measures
  63650. * @param a Input measure
  63651. * @param b Input measure
  63652. * @param result the resulting bounding measure
  63653. */
  63654. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63655. /**
  63656. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63657. * @param transform the matrix to transform the measure before computing the AABB
  63658. * @param result the resulting AABB
  63659. */
  63660. transformToRef(transform: Matrix2D, result: Measure): void;
  63661. /**
  63662. * Check equality between this measure and another one
  63663. * @param other defines the other measures
  63664. * @returns true if both measures are equals
  63665. */
  63666. isEqualsTo(other: Measure): boolean;
  63667. /**
  63668. * Creates an empty measure
  63669. * @returns a new measure
  63670. */
  63671. static Empty(): Measure;
  63672. }
  63673. }
  63674. declare module BABYLON.GUI {
  63675. /**
  63676. * Interface used to define a control that can receive focus
  63677. */
  63678. export interface IFocusableControl {
  63679. /**
  63680. * Function called when the control receives the focus
  63681. */
  63682. onFocus(): void;
  63683. /**
  63684. * Function called when the control loses the focus
  63685. */
  63686. onBlur(): void;
  63687. /**
  63688. * Function called to let the control handle keyboard events
  63689. * @param evt defines the current keyboard event
  63690. */
  63691. processKeyboard(evt: KeyboardEvent): void;
  63692. /**
  63693. * Function called to get the list of controls that should not steal the focus from this control
  63694. * @returns an array of controls
  63695. */
  63696. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63697. }
  63698. /**
  63699. * Class used to create texture to support 2D GUI elements
  63700. * @see http://doc.babylonjs.com/how_to/gui
  63701. */
  63702. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63703. private _isDirty;
  63704. private _renderObserver;
  63705. private _resizeObserver;
  63706. private _preKeyboardObserver;
  63707. private _pointerMoveObserver;
  63708. private _pointerObserver;
  63709. private _canvasPointerOutObserver;
  63710. private _background;
  63711. /** @hidden */
  63712. _rootContainer: Container;
  63713. /** @hidden */
  63714. _lastPickedControl: Control;
  63715. /** @hidden */
  63716. _lastControlOver: {
  63717. [pointerId: number]: Control;
  63718. };
  63719. /** @hidden */
  63720. _lastControlDown: {
  63721. [pointerId: number]: Control;
  63722. };
  63723. /** @hidden */
  63724. _capturingControl: {
  63725. [pointerId: number]: Control;
  63726. };
  63727. /** @hidden */
  63728. _shouldBlockPointer: boolean;
  63729. /** @hidden */
  63730. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63731. /** @hidden */
  63732. _linkedControls: Control[];
  63733. private _isFullscreen;
  63734. private _fullscreenViewport;
  63735. private _idealWidth;
  63736. private _idealHeight;
  63737. private _useSmallestIdeal;
  63738. private _renderAtIdealSize;
  63739. private _focusedControl;
  63740. private _blockNextFocusCheck;
  63741. private _renderScale;
  63742. private _rootCanvas;
  63743. private _cursorChanged;
  63744. /**
  63745. * Define type to string to ensure compatibility across browsers
  63746. * Safari doesn't support DataTransfer constructor
  63747. */
  63748. private _clipboardData;
  63749. /**
  63750. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63751. */
  63752. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63753. /**
  63754. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63755. */
  63756. onControlPickedObservable: BABYLON.Observable<Control>;
  63757. /**
  63758. * BABYLON.Observable event triggered before layout is evaluated
  63759. */
  63760. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63761. /**
  63762. * BABYLON.Observable event triggered after the layout was evaluated
  63763. */
  63764. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63765. /**
  63766. * BABYLON.Observable event triggered before the texture is rendered
  63767. */
  63768. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63769. /**
  63770. * BABYLON.Observable event triggered after the texture was rendered
  63771. */
  63772. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63773. /**
  63774. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63775. */
  63776. premulAlpha: boolean;
  63777. /**
  63778. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63779. * Useful when you want more antialiasing
  63780. */
  63781. renderScale: number;
  63782. /** Gets or sets the background color */
  63783. background: string;
  63784. /**
  63785. * Gets or sets the ideal width used to design controls.
  63786. * The GUI will then rescale everything accordingly
  63787. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63788. */
  63789. idealWidth: number;
  63790. /**
  63791. * Gets or sets the ideal height used to design controls.
  63792. * The GUI will then rescale everything accordingly
  63793. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63794. */
  63795. idealHeight: number;
  63796. /**
  63797. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63798. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63799. */
  63800. useSmallestIdeal: boolean;
  63801. /**
  63802. * Gets or sets a boolean indicating if adaptive scaling must be used
  63803. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63804. */
  63805. renderAtIdealSize: boolean;
  63806. /**
  63807. * Gets the underlying layer used to render the texture when in fullscreen mode
  63808. */
  63809. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63810. /**
  63811. * Gets the root container control
  63812. */
  63813. readonly rootContainer: Container;
  63814. /**
  63815. * Returns an array containing the root container.
  63816. * This is mostly used to let the Inspector introspects the ADT
  63817. * @returns an array containing the rootContainer
  63818. */
  63819. getChildren(): Array<Container>;
  63820. /**
  63821. * Will return all controls that are inside this texture
  63822. * @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
  63823. * @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
  63824. * @return all child controls
  63825. */
  63826. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63827. /**
  63828. * Gets or sets the current focused control
  63829. */
  63830. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63831. /**
  63832. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63833. */
  63834. isForeground: boolean;
  63835. /**
  63836. * Gets or set information about clipboardData
  63837. */
  63838. clipboardData: string;
  63839. /**
  63840. * Creates a new AdvancedDynamicTexture
  63841. * @param name defines the name of the texture
  63842. * @param width defines the width of the texture
  63843. * @param height defines the height of the texture
  63844. * @param scene defines the hosting scene
  63845. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63846. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63847. */
  63848. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63849. /**
  63850. * Get the current class name of the texture useful for serialization or dynamic coding.
  63851. * @returns "AdvancedDynamicTexture"
  63852. */
  63853. getClassName(): string;
  63854. /**
  63855. * Function used to execute a function on all controls
  63856. * @param func defines the function to execute
  63857. * @param container defines the container where controls belong. If null the root container will be used
  63858. */
  63859. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63860. private _useInvalidateRectOptimization;
  63861. /**
  63862. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63863. */
  63864. useInvalidateRectOptimization: boolean;
  63865. private _invalidatedRectangle;
  63866. /**
  63867. * Invalidates a rectangle area on the gui texture
  63868. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63869. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63870. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63871. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63872. */
  63873. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63874. /**
  63875. * Marks the texture as dirty forcing a complete update
  63876. */
  63877. markAsDirty(): void;
  63878. /**
  63879. * Helper function used to create a new style
  63880. * @returns a new style
  63881. * @see http://doc.babylonjs.com/how_to/gui#styles
  63882. */
  63883. createStyle(): Style;
  63884. /**
  63885. * Adds a new control to the root container
  63886. * @param control defines the control to add
  63887. * @returns the current texture
  63888. */
  63889. addControl(control: Control): AdvancedDynamicTexture;
  63890. /**
  63891. * Removes a control from the root container
  63892. * @param control defines the control to remove
  63893. * @returns the current texture
  63894. */
  63895. removeControl(control: Control): AdvancedDynamicTexture;
  63896. /**
  63897. * Release all resources
  63898. */
  63899. dispose(): void;
  63900. private _onResize;
  63901. /** @hidden */
  63902. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63903. /**
  63904. * Get screen coordinates for a vector3
  63905. * @param position defines the position to project
  63906. * @param worldMatrix defines the world matrix to use
  63907. * @returns the projected position
  63908. */
  63909. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63910. private _checkUpdate;
  63911. private _clearMeasure;
  63912. private _render;
  63913. /** @hidden */
  63914. _changeCursor(cursor: string): void;
  63915. /** @hidden */
  63916. _registerLastControlDown(control: Control, pointerId: number): void;
  63917. private _doPicking;
  63918. /** @hidden */
  63919. _cleanControlAfterRemovalFromList(list: {
  63920. [pointerId: number]: Control;
  63921. }, control: Control): void;
  63922. /** @hidden */
  63923. _cleanControlAfterRemoval(control: Control): void;
  63924. /** Attach to all scene events required to support pointer events */
  63925. attach(): void;
  63926. /** @hidden */
  63927. private onClipboardCopy;
  63928. /** @hidden */
  63929. private onClipboardCut;
  63930. /** @hidden */
  63931. private onClipboardPaste;
  63932. /**
  63933. * Register the clipboard Events onto the canvas
  63934. */
  63935. registerClipboardEvents(): void;
  63936. /**
  63937. * Unregister the clipboard Events from the canvas
  63938. */
  63939. unRegisterClipboardEvents(): void;
  63940. /**
  63941. * Connect the texture to a hosting mesh to enable interactions
  63942. * @param mesh defines the mesh to attach to
  63943. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63944. */
  63945. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63946. /**
  63947. * Move the focus to a specific control
  63948. * @param control defines the control which will receive the focus
  63949. */
  63950. moveFocusToControl(control: IFocusableControl): void;
  63951. private _manageFocus;
  63952. private _attachToOnPointerOut;
  63953. /**
  63954. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63955. * @param mesh defines the mesh which will receive the texture
  63956. * @param width defines the texture width (1024 by default)
  63957. * @param height defines the texture height (1024 by default)
  63958. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63959. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63960. * @returns a new AdvancedDynamicTexture
  63961. */
  63962. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63963. /**
  63964. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63965. * In this mode the texture will rely on a layer for its rendering.
  63966. * This allows it to be treated like any other layer.
  63967. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63968. * LayerMask is set through advancedTexture.layer.layerMask
  63969. * @param name defines name for the texture
  63970. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63971. * @param scene defines the hsoting scene
  63972. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63973. * @returns a new AdvancedDynamicTexture
  63974. */
  63975. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63976. }
  63977. }
  63978. declare module BABYLON.GUI {
  63979. /**
  63980. * Root class used for all 2D controls
  63981. * @see http://doc.babylonjs.com/how_to/gui#controls
  63982. */
  63983. export class Control {
  63984. /** defines the name of the control */
  63985. name?: string | undefined;
  63986. /**
  63987. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63988. */
  63989. static AllowAlphaInheritance: boolean;
  63990. private _alpha;
  63991. private _alphaSet;
  63992. private _zIndex;
  63993. /** @hidden */
  63994. _host: AdvancedDynamicTexture;
  63995. /** Gets or sets the control parent */
  63996. parent: BABYLON.Nullable<Container>;
  63997. /** @hidden */
  63998. _currentMeasure: Measure;
  63999. private _fontFamily;
  64000. private _fontStyle;
  64001. private _fontWeight;
  64002. private _fontSize;
  64003. private _font;
  64004. /** @hidden */
  64005. _width: ValueAndUnit;
  64006. /** @hidden */
  64007. _height: ValueAndUnit;
  64008. /** @hidden */
  64009. protected _fontOffset: {
  64010. ascent: number;
  64011. height: number;
  64012. descent: number;
  64013. };
  64014. private _color;
  64015. private _style;
  64016. private _styleObserver;
  64017. /** @hidden */
  64018. protected _horizontalAlignment: number;
  64019. /** @hidden */
  64020. protected _verticalAlignment: number;
  64021. /** @hidden */
  64022. protected _isDirty: boolean;
  64023. /** @hidden */
  64024. protected _wasDirty: boolean;
  64025. /** @hidden */
  64026. _tempParentMeasure: Measure;
  64027. /** @hidden */
  64028. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64029. /** @hidden */
  64030. protected _cachedParentMeasure: Measure;
  64031. private _paddingLeft;
  64032. private _paddingRight;
  64033. private _paddingTop;
  64034. private _paddingBottom;
  64035. /** @hidden */
  64036. _left: ValueAndUnit;
  64037. /** @hidden */
  64038. _top: ValueAndUnit;
  64039. private _scaleX;
  64040. private _scaleY;
  64041. private _rotation;
  64042. private _transformCenterX;
  64043. private _transformCenterY;
  64044. /** @hidden */
  64045. _transformMatrix: Matrix2D;
  64046. /** @hidden */
  64047. protected _invertTransformMatrix: Matrix2D;
  64048. /** @hidden */
  64049. protected _transformedPosition: BABYLON.Vector2;
  64050. private _isMatrixDirty;
  64051. private _cachedOffsetX;
  64052. private _cachedOffsetY;
  64053. private _isVisible;
  64054. private _isHighlighted;
  64055. /** @hidden */
  64056. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64057. private _fontSet;
  64058. private _dummyVector2;
  64059. private _downCount;
  64060. private _enterCount;
  64061. private _doNotRender;
  64062. private _downPointerIds;
  64063. protected _isEnabled: boolean;
  64064. protected _disabledColor: string;
  64065. /** @hidden */
  64066. protected _rebuildLayout: boolean;
  64067. /** @hidden */
  64068. _isClipped: boolean;
  64069. /** @hidden */
  64070. _tag: any;
  64071. /**
  64072. * 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
  64073. */
  64074. uniqueId: number;
  64075. /**
  64076. * Gets or sets an object used to store user defined information for the node
  64077. */
  64078. metadata: any;
  64079. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64080. isHitTestVisible: boolean;
  64081. /** Gets or sets a boolean indicating if the control can block pointer events */
  64082. isPointerBlocker: boolean;
  64083. /** Gets or sets a boolean indicating if the control can be focusable */
  64084. isFocusInvisible: boolean;
  64085. /**
  64086. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64087. * 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
  64088. */
  64089. clipChildren: boolean;
  64090. /**
  64091. * Gets or sets a boolean indicating that control content must be clipped
  64092. * 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
  64093. */
  64094. clipContent: boolean;
  64095. /**
  64096. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64097. */
  64098. useBitmapCache: boolean;
  64099. private _cacheData;
  64100. private _shadowOffsetX;
  64101. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64102. shadowOffsetX: number;
  64103. private _shadowOffsetY;
  64104. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64105. shadowOffsetY: number;
  64106. private _shadowBlur;
  64107. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64108. shadowBlur: number;
  64109. private _shadowColor;
  64110. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64111. shadowColor: string;
  64112. /** Gets or sets the cursor to use when the control is hovered */
  64113. hoverCursor: string;
  64114. /** @hidden */
  64115. protected _linkOffsetX: ValueAndUnit;
  64116. /** @hidden */
  64117. protected _linkOffsetY: ValueAndUnit;
  64118. /** Gets the control type name */
  64119. readonly typeName: string;
  64120. /**
  64121. * Get the current class name of the control.
  64122. * @returns current class name
  64123. */
  64124. getClassName(): string;
  64125. /**
  64126. * An event triggered when the pointer move over the control.
  64127. */
  64128. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64129. /**
  64130. * An event triggered when the pointer move out of the control.
  64131. */
  64132. onPointerOutObservable: BABYLON.Observable<Control>;
  64133. /**
  64134. * An event triggered when the pointer taps the control
  64135. */
  64136. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64137. /**
  64138. * An event triggered when pointer up
  64139. */
  64140. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64141. /**
  64142. * An event triggered when a control is clicked on
  64143. */
  64144. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64145. /**
  64146. * An event triggered when pointer enters the control
  64147. */
  64148. onPointerEnterObservable: BABYLON.Observable<Control>;
  64149. /**
  64150. * An event triggered when the control is marked as dirty
  64151. */
  64152. onDirtyObservable: BABYLON.Observable<Control>;
  64153. /**
  64154. * An event triggered before drawing the control
  64155. */
  64156. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64157. /**
  64158. * An event triggered after the control was drawn
  64159. */
  64160. onAfterDrawObservable: BABYLON.Observable<Control>;
  64161. /**
  64162. * Get the hosting AdvancedDynamicTexture
  64163. */
  64164. readonly host: AdvancedDynamicTexture;
  64165. /** Gets or set information about font offsets (used to render and align text) */
  64166. fontOffset: {
  64167. ascent: number;
  64168. height: number;
  64169. descent: number;
  64170. };
  64171. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64172. alpha: number;
  64173. /**
  64174. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64175. */
  64176. isHighlighted: boolean;
  64177. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64178. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64179. */
  64180. scaleX: number;
  64181. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64182. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64183. */
  64184. scaleY: number;
  64185. /** Gets or sets the rotation angle (0 by default)
  64186. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64187. */
  64188. rotation: number;
  64189. /** Gets or sets the transformation center on Y axis (0 by default)
  64190. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64191. */
  64192. transformCenterY: number;
  64193. /** Gets or sets the transformation center on X axis (0 by default)
  64194. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64195. */
  64196. transformCenterX: number;
  64197. /**
  64198. * Gets or sets the horizontal alignment
  64199. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64200. */
  64201. horizontalAlignment: number;
  64202. /**
  64203. * Gets or sets the vertical alignment
  64204. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64205. */
  64206. verticalAlignment: number;
  64207. /**
  64208. * Gets or sets control width
  64209. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64210. */
  64211. width: string | number;
  64212. /**
  64213. * Gets or sets the control width in pixel
  64214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64215. */
  64216. widthInPixels: number;
  64217. /**
  64218. * Gets or sets control height
  64219. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64220. */
  64221. height: string | number;
  64222. /**
  64223. * Gets or sets control height in pixel
  64224. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64225. */
  64226. heightInPixels: number;
  64227. /** Gets or set font family */
  64228. fontFamily: string;
  64229. /** Gets or sets font style */
  64230. fontStyle: string;
  64231. /** Gets or sets font weight */
  64232. fontWeight: string;
  64233. /**
  64234. * Gets or sets style
  64235. * @see http://doc.babylonjs.com/how_to/gui#styles
  64236. */
  64237. style: BABYLON.Nullable<Style>;
  64238. /** @hidden */
  64239. readonly _isFontSizeInPercentage: boolean;
  64240. /** Gets or sets font size in pixels */
  64241. fontSizeInPixels: number;
  64242. /** Gets or sets font size */
  64243. fontSize: string | number;
  64244. /** Gets or sets foreground color */
  64245. color: string;
  64246. /** Gets or sets z index which is used to reorder controls on the z axis */
  64247. zIndex: number;
  64248. /** Gets or sets a boolean indicating if the control can be rendered */
  64249. notRenderable: boolean;
  64250. /** Gets or sets a boolean indicating if the control is visible */
  64251. isVisible: boolean;
  64252. /** Gets a boolean indicating that the control needs to update its rendering */
  64253. readonly isDirty: boolean;
  64254. /**
  64255. * Gets the current linked mesh (or null if none)
  64256. */
  64257. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64258. /**
  64259. * Gets or sets a value indicating the padding to use on the left of the control
  64260. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64261. */
  64262. paddingLeft: string | number;
  64263. /**
  64264. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64265. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64266. */
  64267. paddingLeftInPixels: number;
  64268. /**
  64269. * Gets or sets a value indicating the padding to use on the right of the control
  64270. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64271. */
  64272. paddingRight: string | number;
  64273. /**
  64274. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64275. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64276. */
  64277. paddingRightInPixels: number;
  64278. /**
  64279. * Gets or sets a value indicating the padding to use on the top of the control
  64280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64281. */
  64282. paddingTop: string | number;
  64283. /**
  64284. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64285. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64286. */
  64287. paddingTopInPixels: number;
  64288. /**
  64289. * Gets or sets a value indicating the padding to use on the bottom of the control
  64290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64291. */
  64292. paddingBottom: string | number;
  64293. /**
  64294. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64295. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64296. */
  64297. paddingBottomInPixels: number;
  64298. /**
  64299. * Gets or sets a value indicating the left coordinate of the control
  64300. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64301. */
  64302. left: string | number;
  64303. /**
  64304. * Gets or sets a value indicating the left coordinate in pixels of the control
  64305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64306. */
  64307. leftInPixels: number;
  64308. /**
  64309. * Gets or sets a value indicating the top coordinate of the control
  64310. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64311. */
  64312. top: string | number;
  64313. /**
  64314. * Gets or sets a value indicating the top coordinate in pixels of the control
  64315. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64316. */
  64317. topInPixels: number;
  64318. /**
  64319. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64320. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64321. */
  64322. linkOffsetX: string | number;
  64323. /**
  64324. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64325. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64326. */
  64327. linkOffsetXInPixels: number;
  64328. /**
  64329. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64330. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64331. */
  64332. linkOffsetY: string | number;
  64333. /**
  64334. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64335. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64336. */
  64337. linkOffsetYInPixels: number;
  64338. /** Gets the center coordinate on X axis */
  64339. readonly centerX: number;
  64340. /** Gets the center coordinate on Y axis */
  64341. readonly centerY: number;
  64342. /** Gets or sets if control is Enabled*/
  64343. isEnabled: boolean;
  64344. /** Gets or sets background color of control if it's disabled*/
  64345. disabledColor: string;
  64346. /**
  64347. * Creates a new control
  64348. * @param name defines the name of the control
  64349. */
  64350. constructor(
  64351. /** defines the name of the control */
  64352. name?: string | undefined);
  64353. /** @hidden */
  64354. protected _getTypeName(): string;
  64355. /**
  64356. * Gets the first ascendant in the hierarchy of the given type
  64357. * @param className defines the required type
  64358. * @returns the ascendant or null if not found
  64359. */
  64360. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64361. /** @hidden */
  64362. _resetFontCache(): void;
  64363. /**
  64364. * Determines if a container is an ascendant of the current control
  64365. * @param container defines the container to look for
  64366. * @returns true if the container is one of the ascendant of the control
  64367. */
  64368. isAscendant(container: Control): boolean;
  64369. /**
  64370. * Gets coordinates in local control space
  64371. * @param globalCoordinates defines the coordinates to transform
  64372. * @returns the new coordinates in local space
  64373. */
  64374. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64375. /**
  64376. * Gets coordinates in local control space
  64377. * @param globalCoordinates defines the coordinates to transform
  64378. * @param result defines the target vector2 where to store the result
  64379. * @returns the current control
  64380. */
  64381. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64382. /**
  64383. * Gets coordinates in parent local control space
  64384. * @param globalCoordinates defines the coordinates to transform
  64385. * @returns the new coordinates in parent local space
  64386. */
  64387. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64388. /**
  64389. * Move the current control to a vector3 position projected onto the screen.
  64390. * @param position defines the target position
  64391. * @param scene defines the hosting scene
  64392. */
  64393. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64394. /** @hidden */
  64395. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64396. /**
  64397. * Will return all controls that have this control as ascendant
  64398. * @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
  64399. * @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
  64400. * @return all child controls
  64401. */
  64402. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64403. /**
  64404. * Link current control with a target mesh
  64405. * @param mesh defines the mesh to link with
  64406. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64407. */
  64408. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64409. /** @hidden */
  64410. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64411. /** @hidden */
  64412. _offsetLeft(offset: number): void;
  64413. /** @hidden */
  64414. _offsetTop(offset: number): void;
  64415. /** @hidden */
  64416. _markMatrixAsDirty(): void;
  64417. /** @hidden */
  64418. _flagDescendantsAsMatrixDirty(): void;
  64419. /** @hidden */
  64420. _intersectsRect(rect: Measure): boolean;
  64421. /** @hidden */
  64422. protected invalidateRect(): void;
  64423. /** @hidden */
  64424. _markAsDirty(force?: boolean): void;
  64425. /** @hidden */
  64426. _markAllAsDirty(): void;
  64427. /** @hidden */
  64428. _link(host: AdvancedDynamicTexture): void;
  64429. /** @hidden */
  64430. protected _transform(context?: CanvasRenderingContext2D): void;
  64431. /** @hidden */
  64432. _renderHighlight(context: CanvasRenderingContext2D): void;
  64433. /** @hidden */
  64434. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64435. /** @hidden */
  64436. protected _applyStates(context: CanvasRenderingContext2D): void;
  64437. /** @hidden */
  64438. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64439. /** @hidden */
  64440. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64441. protected _evaluateClippingState(parentMeasure: Measure): void;
  64442. /** @hidden */
  64443. _measure(): void;
  64444. /** @hidden */
  64445. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64446. /** @hidden */
  64447. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64448. /** @hidden */
  64449. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64450. /** @hidden */
  64451. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64452. private static _ClipMeasure;
  64453. private _tmpMeasureA;
  64454. private _clip;
  64455. /** @hidden */
  64456. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64457. /** @hidden */
  64458. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64459. /**
  64460. * Tests if a given coordinates belong to the current control
  64461. * @param x defines x coordinate to test
  64462. * @param y defines y coordinate to test
  64463. * @returns true if the coordinates are inside the control
  64464. */
  64465. contains(x: number, y: number): boolean;
  64466. /** @hidden */
  64467. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64468. /** @hidden */
  64469. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64470. /** @hidden */
  64471. _onPointerEnter(target: Control): boolean;
  64472. /** @hidden */
  64473. _onPointerOut(target: Control, force?: boolean): void;
  64474. /** @hidden */
  64475. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64476. /** @hidden */
  64477. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64478. /** @hidden */
  64479. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64480. /** @hidden */
  64481. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64482. private _prepareFont;
  64483. /** Releases associated resources */
  64484. dispose(): void;
  64485. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64486. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64487. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64488. private static _VERTICAL_ALIGNMENT_TOP;
  64489. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64490. private static _VERTICAL_ALIGNMENT_CENTER;
  64491. /** HORIZONTAL_ALIGNMENT_LEFT */
  64492. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64493. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64494. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64495. /** HORIZONTAL_ALIGNMENT_CENTER */
  64496. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64497. /** VERTICAL_ALIGNMENT_TOP */
  64498. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64499. /** VERTICAL_ALIGNMENT_BOTTOM */
  64500. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64501. /** VERTICAL_ALIGNMENT_CENTER */
  64502. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64503. private static _FontHeightSizes;
  64504. /** @hidden */
  64505. static _GetFontOffset(font: string): {
  64506. ascent: number;
  64507. height: number;
  64508. descent: number;
  64509. };
  64510. /**
  64511. * Creates a stack panel that can be used to render headers
  64512. * @param control defines the control to associate with the header
  64513. * @param text defines the text of the header
  64514. * @param size defines the size of the header
  64515. * @param options defines options used to configure the header
  64516. * @returns a new StackPanel
  64517. * @ignore
  64518. * @hidden
  64519. */
  64520. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64521. isHorizontal: boolean;
  64522. controlFirst: boolean;
  64523. }) => any;
  64524. /** @hidden */
  64525. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64526. }
  64527. }
  64528. declare module BABYLON.GUI {
  64529. /**
  64530. * Root class for 2D containers
  64531. * @see http://doc.babylonjs.com/how_to/gui#containers
  64532. */
  64533. export class Container extends Control {
  64534. name?: string | undefined;
  64535. /** @hidden */
  64536. protected _children: Control[];
  64537. /** @hidden */
  64538. protected _measureForChildren: Measure;
  64539. /** @hidden */
  64540. protected _background: string;
  64541. /** @hidden */
  64542. protected _adaptWidthToChildren: boolean;
  64543. /** @hidden */
  64544. protected _adaptHeightToChildren: boolean;
  64545. /**
  64546. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64547. */
  64548. logLayoutCycleErrors: boolean;
  64549. /**
  64550. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64551. */
  64552. maxLayoutCycle: number;
  64553. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64554. adaptHeightToChildren: boolean;
  64555. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64556. adaptWidthToChildren: boolean;
  64557. /** Gets or sets background color */
  64558. background: string;
  64559. /** Gets the list of children */
  64560. readonly children: Control[];
  64561. /**
  64562. * Creates a new Container
  64563. * @param name defines the name of the container
  64564. */
  64565. constructor(name?: string | undefined);
  64566. protected _getTypeName(): string;
  64567. _flagDescendantsAsMatrixDirty(): void;
  64568. /**
  64569. * Gets a child using its name
  64570. * @param name defines the child name to look for
  64571. * @returns the child control if found
  64572. */
  64573. getChildByName(name: string): BABYLON.Nullable<Control>;
  64574. /**
  64575. * Gets a child using its type and its name
  64576. * @param name defines the child name to look for
  64577. * @param type defines the child type to look for
  64578. * @returns the child control if found
  64579. */
  64580. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64581. /**
  64582. * Search for a specific control in children
  64583. * @param control defines the control to look for
  64584. * @returns true if the control is in child list
  64585. */
  64586. containsControl(control: Control): boolean;
  64587. /**
  64588. * Adds a new control to the current container
  64589. * @param control defines the control to add
  64590. * @returns the current container
  64591. */
  64592. addControl(control: BABYLON.Nullable<Control>): Container;
  64593. /**
  64594. * Removes all controls from the current container
  64595. * @returns the current container
  64596. */
  64597. clearControls(): Container;
  64598. /**
  64599. * Removes a control from the current container
  64600. * @param control defines the control to remove
  64601. * @returns the current container
  64602. */
  64603. removeControl(control: Control): Container;
  64604. /** @hidden */
  64605. _reOrderControl(control: Control): void;
  64606. /** @hidden */
  64607. _offsetLeft(offset: number): void;
  64608. /** @hidden */
  64609. _offsetTop(offset: number): void;
  64610. /** @hidden */
  64611. _markAllAsDirty(): void;
  64612. /** @hidden */
  64613. protected _localDraw(context: CanvasRenderingContext2D): void;
  64614. /** @hidden */
  64615. _link(host: AdvancedDynamicTexture): void;
  64616. /** @hidden */
  64617. protected _beforeLayout(): void;
  64618. /** @hidden */
  64619. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64620. /** @hidden */
  64621. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64622. protected _postMeasure(): void;
  64623. /** @hidden */
  64624. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64625. /** @hidden */
  64626. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64627. /** @hidden */
  64628. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64629. /** @hidden */
  64630. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64631. /** Releases associated resources */
  64632. dispose(): void;
  64633. }
  64634. }
  64635. declare module BABYLON.GUI {
  64636. /** Class used to create rectangle container */
  64637. export class Rectangle extends Container {
  64638. name?: string | undefined;
  64639. private _thickness;
  64640. private _cornerRadius;
  64641. /** Gets or sets border thickness */
  64642. thickness: number;
  64643. /** Gets or sets the corner radius angle */
  64644. cornerRadius: number;
  64645. /**
  64646. * Creates a new Rectangle
  64647. * @param name defines the control name
  64648. */
  64649. constructor(name?: string | undefined);
  64650. protected _getTypeName(): string;
  64651. protected _localDraw(context: CanvasRenderingContext2D): void;
  64652. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64653. private _drawRoundedRect;
  64654. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64655. }
  64656. }
  64657. declare module BABYLON.GUI {
  64658. /**
  64659. * Enum that determines the text-wrapping mode to use.
  64660. */
  64661. export enum TextWrapping {
  64662. /**
  64663. * Clip the text when it's larger than Control.width; this is the default mode.
  64664. */
  64665. Clip = 0,
  64666. /**
  64667. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64668. */
  64669. WordWrap = 1,
  64670. /**
  64671. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64672. */
  64673. Ellipsis = 2
  64674. }
  64675. /**
  64676. * Class used to create text block control
  64677. */
  64678. export class TextBlock extends Control {
  64679. /**
  64680. * Defines the name of the control
  64681. */
  64682. name?: string | undefined;
  64683. private _text;
  64684. private _textWrapping;
  64685. private _textHorizontalAlignment;
  64686. private _textVerticalAlignment;
  64687. private _lines;
  64688. private _resizeToFit;
  64689. private _lineSpacing;
  64690. private _outlineWidth;
  64691. private _outlineColor;
  64692. /**
  64693. * An event triggered after the text is changed
  64694. */
  64695. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64696. /**
  64697. * An event triggered after the text was broken up into lines
  64698. */
  64699. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64700. /**
  64701. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64702. */
  64703. readonly lines: any[];
  64704. /**
  64705. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64706. */
  64707. /**
  64708. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64709. */
  64710. resizeToFit: boolean;
  64711. /**
  64712. * Gets or sets a boolean indicating if text must be wrapped
  64713. */
  64714. /**
  64715. * Gets or sets a boolean indicating if text must be wrapped
  64716. */
  64717. textWrapping: TextWrapping | boolean;
  64718. /**
  64719. * Gets or sets text to display
  64720. */
  64721. /**
  64722. * Gets or sets text to display
  64723. */
  64724. text: string;
  64725. /**
  64726. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64727. */
  64728. /**
  64729. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64730. */
  64731. textHorizontalAlignment: number;
  64732. /**
  64733. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64734. */
  64735. /**
  64736. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64737. */
  64738. textVerticalAlignment: number;
  64739. /**
  64740. * Gets or sets line spacing value
  64741. */
  64742. /**
  64743. * Gets or sets line spacing value
  64744. */
  64745. lineSpacing: string | number;
  64746. /**
  64747. * Gets or sets outlineWidth of the text to display
  64748. */
  64749. /**
  64750. * Gets or sets outlineWidth of the text to display
  64751. */
  64752. outlineWidth: number;
  64753. /**
  64754. * Gets or sets outlineColor of the text to display
  64755. */
  64756. /**
  64757. * Gets or sets outlineColor of the text to display
  64758. */
  64759. outlineColor: string;
  64760. /**
  64761. * Creates a new TextBlock object
  64762. * @param name defines the name of the control
  64763. * @param text defines the text to display (emptry string by default)
  64764. */
  64765. constructor(
  64766. /**
  64767. * Defines the name of the control
  64768. */
  64769. name?: string | undefined, text?: string);
  64770. protected _getTypeName(): string;
  64771. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64772. private _drawText;
  64773. /** @hidden */
  64774. _draw(context: CanvasRenderingContext2D): void;
  64775. protected _applyStates(context: CanvasRenderingContext2D): void;
  64776. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64777. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64778. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64779. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64780. protected _renderLines(context: CanvasRenderingContext2D): void;
  64781. /**
  64782. * Given a width constraint applied on the text block, find the expected height
  64783. * @returns expected height
  64784. */
  64785. computeExpectedHeight(): number;
  64786. dispose(): void;
  64787. }
  64788. }
  64789. declare module BABYLON.GUI {
  64790. /**
  64791. * Class used to create 2D images
  64792. */
  64793. export class Image extends Control {
  64794. name?: string | undefined;
  64795. private static _WorkingCanvas;
  64796. private _domImage;
  64797. private _imageWidth;
  64798. private _imageHeight;
  64799. private _loaded;
  64800. private _stretch;
  64801. private _source;
  64802. private _autoScale;
  64803. private _sourceLeft;
  64804. private _sourceTop;
  64805. private _sourceWidth;
  64806. private _sourceHeight;
  64807. private _cellWidth;
  64808. private _cellHeight;
  64809. private _cellId;
  64810. private _populateNinePatchSlicesFromImage;
  64811. private _sliceLeft;
  64812. private _sliceRight;
  64813. private _sliceTop;
  64814. private _sliceBottom;
  64815. private _detectPointerOnOpaqueOnly;
  64816. /**
  64817. * BABYLON.Observable notified when the content is loaded
  64818. */
  64819. onImageLoadedObservable: BABYLON.Observable<Image>;
  64820. /**
  64821. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64822. */
  64823. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64824. /**
  64825. * Gets a boolean indicating that the content is loaded
  64826. */
  64827. readonly isLoaded: boolean;
  64828. /**
  64829. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64830. */
  64831. populateNinePatchSlicesFromImage: boolean;
  64832. /**
  64833. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64834. * Beware using this as this will comsume more memory as the image has to be stored twice
  64835. */
  64836. detectPointerOnOpaqueOnly: boolean;
  64837. /**
  64838. * Gets or sets the left value for slicing (9-patch)
  64839. */
  64840. sliceLeft: number;
  64841. /**
  64842. * Gets or sets the right value for slicing (9-patch)
  64843. */
  64844. sliceRight: number;
  64845. /**
  64846. * Gets or sets the top value for slicing (9-patch)
  64847. */
  64848. sliceTop: number;
  64849. /**
  64850. * Gets or sets the bottom value for slicing (9-patch)
  64851. */
  64852. sliceBottom: number;
  64853. /**
  64854. * Gets or sets the left coordinate in the source image
  64855. */
  64856. sourceLeft: number;
  64857. /**
  64858. * Gets or sets the top coordinate in the source image
  64859. */
  64860. sourceTop: number;
  64861. /**
  64862. * Gets or sets the width to capture in the source image
  64863. */
  64864. sourceWidth: number;
  64865. /**
  64866. * Gets or sets the height to capture in the source image
  64867. */
  64868. sourceHeight: number;
  64869. /**
  64870. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64871. * @see http://doc.babylonjs.com/how_to/gui#image
  64872. */
  64873. autoScale: boolean;
  64874. /** Gets or sets the streching mode used by the image */
  64875. stretch: number;
  64876. /**
  64877. * Gets or sets the internal DOM image used to render the control
  64878. */
  64879. domImage: HTMLImageElement;
  64880. private _onImageLoaded;
  64881. private _extractNinePatchSliceDataFromImage;
  64882. /**
  64883. * Gets or sets image source url
  64884. */
  64885. source: BABYLON.Nullable<string>;
  64886. /**
  64887. * Checks for svg document with icon id present
  64888. */
  64889. private _svgCheck;
  64890. /**
  64891. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64892. * given external svg file and icon id
  64893. */
  64894. private _getSVGAttribs;
  64895. /**
  64896. * Gets or sets the cell width to use when animation sheet is enabled
  64897. * @see http://doc.babylonjs.com/how_to/gui#image
  64898. */
  64899. cellWidth: number;
  64900. /**
  64901. * Gets or sets the cell height to use when animation sheet is enabled
  64902. * @see http://doc.babylonjs.com/how_to/gui#image
  64903. */
  64904. cellHeight: number;
  64905. /**
  64906. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64907. * @see http://doc.babylonjs.com/how_to/gui#image
  64908. */
  64909. cellId: number;
  64910. /**
  64911. * Creates a new Image
  64912. * @param name defines the control name
  64913. * @param url defines the image url
  64914. */
  64915. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64916. /**
  64917. * Tests if a given coordinates belong to the current control
  64918. * @param x defines x coordinate to test
  64919. * @param y defines y coordinate to test
  64920. * @returns true if the coordinates are inside the control
  64921. */
  64922. contains(x: number, y: number): boolean;
  64923. protected _getTypeName(): string;
  64924. /** Force the control to synchronize with its content */
  64925. synchronizeSizeWithContent(): void;
  64926. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64927. private _prepareWorkingCanvasForOpaqueDetection;
  64928. private _drawImage;
  64929. _draw(context: CanvasRenderingContext2D): void;
  64930. private _renderCornerPatch;
  64931. private _renderNinePatch;
  64932. dispose(): void;
  64933. /** STRETCH_NONE */
  64934. static readonly STRETCH_NONE: number;
  64935. /** STRETCH_FILL */
  64936. static readonly STRETCH_FILL: number;
  64937. /** STRETCH_UNIFORM */
  64938. static readonly STRETCH_UNIFORM: number;
  64939. /** STRETCH_EXTEND */
  64940. static readonly STRETCH_EXTEND: number;
  64941. /** NINE_PATCH */
  64942. static readonly STRETCH_NINE_PATCH: number;
  64943. }
  64944. }
  64945. declare module BABYLON.GUI {
  64946. /**
  64947. * Class used to create 2D buttons
  64948. */
  64949. export class Button extends Rectangle {
  64950. name?: string | undefined;
  64951. /**
  64952. * Function called to generate a pointer enter animation
  64953. */
  64954. pointerEnterAnimation: () => void;
  64955. /**
  64956. * Function called to generate a pointer out animation
  64957. */
  64958. pointerOutAnimation: () => void;
  64959. /**
  64960. * Function called to generate a pointer down animation
  64961. */
  64962. pointerDownAnimation: () => void;
  64963. /**
  64964. * Function called to generate a pointer up animation
  64965. */
  64966. pointerUpAnimation: () => void;
  64967. /**
  64968. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64969. */
  64970. delegatePickingToChildren: boolean;
  64971. private _image;
  64972. /**
  64973. * Returns the image part of the button (if any)
  64974. */
  64975. readonly image: BABYLON.Nullable<Image>;
  64976. private _textBlock;
  64977. /**
  64978. * Returns the image part of the button (if any)
  64979. */
  64980. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64981. /**
  64982. * Creates a new Button
  64983. * @param name defines the name of the button
  64984. */
  64985. constructor(name?: string | undefined);
  64986. protected _getTypeName(): string;
  64987. /** @hidden */
  64988. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64989. /** @hidden */
  64990. _onPointerEnter(target: Control): boolean;
  64991. /** @hidden */
  64992. _onPointerOut(target: Control, force?: boolean): void;
  64993. /** @hidden */
  64994. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64995. /** @hidden */
  64996. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64997. /**
  64998. * Creates a new button made with an image and a text
  64999. * @param name defines the name of the button
  65000. * @param text defines the text of the button
  65001. * @param imageUrl defines the url of the image
  65002. * @returns a new Button
  65003. */
  65004. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65005. /**
  65006. * Creates a new button made with an image
  65007. * @param name defines the name of the button
  65008. * @param imageUrl defines the url of the image
  65009. * @returns a new Button
  65010. */
  65011. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65012. /**
  65013. * Creates a new button made with a text
  65014. * @param name defines the name of the button
  65015. * @param text defines the text of the button
  65016. * @returns a new Button
  65017. */
  65018. static CreateSimpleButton(name: string, text: string): Button;
  65019. /**
  65020. * Creates a new button made with an image and a centered text
  65021. * @param name defines the name of the button
  65022. * @param text defines the text of the button
  65023. * @param imageUrl defines the url of the image
  65024. * @returns a new Button
  65025. */
  65026. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65027. }
  65028. }
  65029. declare module BABYLON.GUI {
  65030. /**
  65031. * Class used to create a 2D stack panel container
  65032. */
  65033. export class StackPanel extends Container {
  65034. name?: string | undefined;
  65035. private _isVertical;
  65036. private _manualWidth;
  65037. private _manualHeight;
  65038. private _doNotTrackManualChanges;
  65039. /**
  65040. * Gets or sets a boolean indicating that layou warnings should be ignored
  65041. */
  65042. ignoreLayoutWarnings: boolean;
  65043. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65044. isVertical: boolean;
  65045. /**
  65046. * Gets or sets panel width.
  65047. * This value should not be set when in horizontal mode as it will be computed automatically
  65048. */
  65049. width: string | number;
  65050. /**
  65051. * Gets or sets panel height.
  65052. * This value should not be set when in vertical mode as it will be computed automatically
  65053. */
  65054. height: string | number;
  65055. /**
  65056. * Creates a new StackPanel
  65057. * @param name defines control name
  65058. */
  65059. constructor(name?: string | undefined);
  65060. protected _getTypeName(): string;
  65061. /** @hidden */
  65062. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65063. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65064. protected _postMeasure(): void;
  65065. }
  65066. }
  65067. declare module BABYLON.GUI {
  65068. /**
  65069. * Class used to represent a 2D checkbox
  65070. */
  65071. export class Checkbox extends Control {
  65072. name?: string | undefined;
  65073. private _isChecked;
  65074. private _background;
  65075. private _checkSizeRatio;
  65076. private _thickness;
  65077. /** Gets or sets border thickness */
  65078. thickness: number;
  65079. /**
  65080. * BABYLON.Observable raised when isChecked property changes
  65081. */
  65082. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65083. /** Gets or sets a value indicating the ratio between overall size and check size */
  65084. checkSizeRatio: number;
  65085. /** Gets or sets background color */
  65086. background: string;
  65087. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65088. isChecked: boolean;
  65089. /**
  65090. * Creates a new CheckBox
  65091. * @param name defines the control name
  65092. */
  65093. constructor(name?: string | undefined);
  65094. protected _getTypeName(): string;
  65095. /** @hidden */
  65096. _draw(context: CanvasRenderingContext2D): void;
  65097. /** @hidden */
  65098. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65099. /**
  65100. * Utility function to easily create a checkbox with a header
  65101. * @param title defines the label to use for the header
  65102. * @param onValueChanged defines the callback to call when value changes
  65103. * @returns a StackPanel containing the checkbox and a textBlock
  65104. */
  65105. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65106. }
  65107. }
  65108. declare module BABYLON.GUI {
  65109. /**
  65110. * Class used to store key control properties
  65111. */
  65112. export class KeyPropertySet {
  65113. /** Width */
  65114. width?: string;
  65115. /** Height */
  65116. height?: string;
  65117. /** Left padding */
  65118. paddingLeft?: string;
  65119. /** Right padding */
  65120. paddingRight?: string;
  65121. /** Top padding */
  65122. paddingTop?: string;
  65123. /** Bottom padding */
  65124. paddingBottom?: string;
  65125. /** Foreground color */
  65126. color?: string;
  65127. /** Background color */
  65128. background?: string;
  65129. }
  65130. /**
  65131. * Class used to create virtual keyboard
  65132. */
  65133. export class VirtualKeyboard extends StackPanel {
  65134. /** BABYLON.Observable raised when a key is pressed */
  65135. onKeyPressObservable: BABYLON.Observable<string>;
  65136. /** Gets or sets default key button width */
  65137. defaultButtonWidth: string;
  65138. /** Gets or sets default key button height */
  65139. defaultButtonHeight: string;
  65140. /** Gets or sets default key button left padding */
  65141. defaultButtonPaddingLeft: string;
  65142. /** Gets or sets default key button right padding */
  65143. defaultButtonPaddingRight: string;
  65144. /** Gets or sets default key button top padding */
  65145. defaultButtonPaddingTop: string;
  65146. /** Gets or sets default key button bottom padding */
  65147. defaultButtonPaddingBottom: string;
  65148. /** Gets or sets default key button foreground color */
  65149. defaultButtonColor: string;
  65150. /** Gets or sets default key button background color */
  65151. defaultButtonBackground: string;
  65152. /** Gets or sets shift button foreground color */
  65153. shiftButtonColor: string;
  65154. /** Gets or sets shift button thickness*/
  65155. selectedShiftThickness: number;
  65156. /** Gets shift key state */
  65157. shiftState: number;
  65158. protected _getTypeName(): string;
  65159. private _createKey;
  65160. /**
  65161. * Adds a new row of keys
  65162. * @param keys defines the list of keys to add
  65163. * @param propertySets defines the associated property sets
  65164. */
  65165. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65166. /**
  65167. * Set the shift key to a specific state
  65168. * @param shiftState defines the new shift state
  65169. */
  65170. applyShiftState(shiftState: number): void;
  65171. private _currentlyConnectedInputText;
  65172. private _connectedInputTexts;
  65173. private _onKeyPressObserver;
  65174. /** Gets the input text control currently attached to the keyboard */
  65175. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65176. /**
  65177. * Connects the keyboard with an input text control
  65178. *
  65179. * @param input defines the target control
  65180. */
  65181. connect(input: InputText): void;
  65182. /**
  65183. * Disconnects the keyboard from connected InputText controls
  65184. *
  65185. * @param input optionally defines a target control, otherwise all are disconnected
  65186. */
  65187. disconnect(input?: InputText): void;
  65188. private _removeConnectedInputObservables;
  65189. /**
  65190. * Release all resources
  65191. */
  65192. dispose(): void;
  65193. /**
  65194. * Creates a new keyboard using a default layout
  65195. *
  65196. * @param name defines control name
  65197. * @returns a new VirtualKeyboard
  65198. */
  65199. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65200. }
  65201. }
  65202. declare module BABYLON.GUI {
  65203. /**
  65204. * Class used to create input text control
  65205. */
  65206. export class InputText extends Control implements IFocusableControl {
  65207. name?: string | undefined;
  65208. private _text;
  65209. private _placeholderText;
  65210. private _background;
  65211. private _focusedBackground;
  65212. private _focusedColor;
  65213. private _placeholderColor;
  65214. private _thickness;
  65215. private _margin;
  65216. private _autoStretchWidth;
  65217. private _maxWidth;
  65218. private _isFocused;
  65219. private _blinkTimeout;
  65220. private _blinkIsEven;
  65221. private _cursorOffset;
  65222. private _scrollLeft;
  65223. private _textWidth;
  65224. private _clickedCoordinate;
  65225. private _deadKey;
  65226. private _addKey;
  65227. private _currentKey;
  65228. private _isTextHighlightOn;
  65229. private _textHighlightColor;
  65230. private _highligherOpacity;
  65231. private _highlightedText;
  65232. private _startHighlightIndex;
  65233. private _endHighlightIndex;
  65234. private _cursorIndex;
  65235. private _onFocusSelectAll;
  65236. private _isPointerDown;
  65237. private _onClipboardObserver;
  65238. private _onPointerDblTapObserver;
  65239. /** @hidden */
  65240. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65241. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65242. promptMessage: string;
  65243. /** Force disable prompt on mobile device */
  65244. disableMobilePrompt: boolean;
  65245. /** BABYLON.Observable raised when the text changes */
  65246. onTextChangedObservable: BABYLON.Observable<InputText>;
  65247. /** BABYLON.Observable raised just before an entered character is to be added */
  65248. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65249. /** BABYLON.Observable raised when the control gets the focus */
  65250. onFocusObservable: BABYLON.Observable<InputText>;
  65251. /** BABYLON.Observable raised when the control loses the focus */
  65252. onBlurObservable: BABYLON.Observable<InputText>;
  65253. /**Observable raised when the text is highlighted */
  65254. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65255. /**Observable raised when copy event is triggered */
  65256. onTextCopyObservable: BABYLON.Observable<InputText>;
  65257. /** BABYLON.Observable raised when cut event is triggered */
  65258. onTextCutObservable: BABYLON.Observable<InputText>;
  65259. /** BABYLON.Observable raised when paste event is triggered */
  65260. onTextPasteObservable: BABYLON.Observable<InputText>;
  65261. /** BABYLON.Observable raised when a key event was processed */
  65262. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65263. /** Gets or sets the maximum width allowed by the control */
  65264. maxWidth: string | number;
  65265. /** Gets the maximum width allowed by the control in pixels */
  65266. readonly maxWidthInPixels: number;
  65267. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65268. highligherOpacity: number;
  65269. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65270. onFocusSelectAll: boolean;
  65271. /** Gets or sets the text hightlight color */
  65272. textHighlightColor: string;
  65273. /** Gets or sets control margin */
  65274. margin: string;
  65275. /** Gets control margin in pixels */
  65276. readonly marginInPixels: number;
  65277. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65278. autoStretchWidth: boolean;
  65279. /** Gets or sets border thickness */
  65280. thickness: number;
  65281. /** Gets or sets the background color when focused */
  65282. focusedBackground: string;
  65283. /** Gets or sets the background color when focused */
  65284. focusedColor: string;
  65285. /** Gets or sets the background color */
  65286. background: string;
  65287. /** Gets or sets the placeholder color */
  65288. placeholderColor: string;
  65289. /** Gets or sets the text displayed when the control is empty */
  65290. placeholderText: string;
  65291. /** Gets or sets the dead key flag */
  65292. deadKey: boolean;
  65293. /** Gets or sets the highlight text */
  65294. highlightedText: string;
  65295. /** Gets or sets if the current key should be added */
  65296. addKey: boolean;
  65297. /** Gets or sets the value of the current key being entered */
  65298. currentKey: string;
  65299. /** Gets or sets the text displayed in the control */
  65300. text: string;
  65301. /** Gets or sets control width */
  65302. width: string | number;
  65303. /**
  65304. * Creates a new InputText
  65305. * @param name defines the control name
  65306. * @param text defines the text of the control
  65307. */
  65308. constructor(name?: string | undefined, text?: string);
  65309. /** @hidden */
  65310. onBlur(): void;
  65311. /** @hidden */
  65312. onFocus(): void;
  65313. protected _getTypeName(): string;
  65314. /**
  65315. * Function called to get the list of controls that should not steal the focus from this control
  65316. * @returns an array of controls
  65317. */
  65318. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65319. /** @hidden */
  65320. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65321. /** @hidden */
  65322. private _updateValueFromCursorIndex;
  65323. /** @hidden */
  65324. private _processDblClick;
  65325. /** @hidden */
  65326. private _selectAllText;
  65327. /**
  65328. * Handles the keyboard event
  65329. * @param evt Defines the KeyboardEvent
  65330. */
  65331. processKeyboard(evt: KeyboardEvent): void;
  65332. /** @hidden */
  65333. private _onCopyText;
  65334. /** @hidden */
  65335. private _onCutText;
  65336. /** @hidden */
  65337. private _onPasteText;
  65338. _draw(context: CanvasRenderingContext2D): void;
  65339. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65340. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65341. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65342. protected _beforeRenderText(text: string): string;
  65343. dispose(): void;
  65344. }
  65345. }
  65346. declare module BABYLON.GUI {
  65347. /**
  65348. * Class used to create a 2D grid container
  65349. */
  65350. export class Grid extends Container {
  65351. name?: string | undefined;
  65352. private _rowDefinitions;
  65353. private _columnDefinitions;
  65354. private _cells;
  65355. private _childControls;
  65356. /**
  65357. * Gets the number of columns
  65358. */
  65359. readonly columnCount: number;
  65360. /**
  65361. * Gets the number of rows
  65362. */
  65363. readonly rowCount: number;
  65364. /** Gets the list of children */
  65365. readonly children: Control[];
  65366. /** Gets the list of cells (e.g. the containers) */
  65367. readonly cells: {
  65368. [key: string]: Container;
  65369. };
  65370. /**
  65371. * Gets the definition of a specific row
  65372. * @param index defines the index of the row
  65373. * @returns the row definition
  65374. */
  65375. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65376. /**
  65377. * Gets the definition of a specific column
  65378. * @param index defines the index of the column
  65379. * @returns the column definition
  65380. */
  65381. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65382. /**
  65383. * Adds a new row to the grid
  65384. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65385. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65386. * @returns the current grid
  65387. */
  65388. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65389. /**
  65390. * Adds a new column to the grid
  65391. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65392. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65393. * @returns the current grid
  65394. */
  65395. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65396. /**
  65397. * Update a row definition
  65398. * @param index defines the index of the row to update
  65399. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65400. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65401. * @returns the current grid
  65402. */
  65403. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65404. /**
  65405. * Update a column definition
  65406. * @param index defines the index of the column to update
  65407. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65408. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65409. * @returns the current grid
  65410. */
  65411. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65412. /**
  65413. * Gets the list of children stored in a specific cell
  65414. * @param row defines the row to check
  65415. * @param column defines the column to check
  65416. * @returns the list of controls
  65417. */
  65418. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65419. /**
  65420. * Gets a string representing the child cell info (row x column)
  65421. * @param child defines the control to get info from
  65422. * @returns a string containing the child cell info (row x column)
  65423. */
  65424. getChildCellInfo(child: Control): string;
  65425. private _removeCell;
  65426. private _offsetCell;
  65427. /**
  65428. * Remove a column definition at specified index
  65429. * @param index defines the index of the column to remove
  65430. * @returns the current grid
  65431. */
  65432. removeColumnDefinition(index: number): Grid;
  65433. /**
  65434. * Remove a row definition at specified index
  65435. * @param index defines the index of the row to remove
  65436. * @returns the current grid
  65437. */
  65438. removeRowDefinition(index: number): Grid;
  65439. /**
  65440. * Adds a new control to the current grid
  65441. * @param control defines the control to add
  65442. * @param row defines the row where to add the control (0 by default)
  65443. * @param column defines the column where to add the control (0 by default)
  65444. * @returns the current grid
  65445. */
  65446. addControl(control: Control, row?: number, column?: number): Grid;
  65447. /**
  65448. * Removes a control from the current container
  65449. * @param control defines the control to remove
  65450. * @returns the current container
  65451. */
  65452. removeControl(control: Control): Container;
  65453. /**
  65454. * Creates a new Grid
  65455. * @param name defines control name
  65456. */
  65457. constructor(name?: string | undefined);
  65458. protected _getTypeName(): string;
  65459. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65461. _flagDescendantsAsMatrixDirty(): void;
  65462. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65463. /** Releases associated resources */
  65464. dispose(): void;
  65465. }
  65466. }
  65467. declare module BABYLON.GUI {
  65468. /** Class used to create color pickers */
  65469. export class ColorPicker extends Control {
  65470. name?: string | undefined;
  65471. private static _Epsilon;
  65472. private _colorWheelCanvas;
  65473. private _value;
  65474. private _tmpColor;
  65475. private _pointerStartedOnSquare;
  65476. private _pointerStartedOnWheel;
  65477. private _squareLeft;
  65478. private _squareTop;
  65479. private _squareSize;
  65480. private _h;
  65481. private _s;
  65482. private _v;
  65483. private _lastPointerDownID;
  65484. /**
  65485. * BABYLON.Observable raised when the value changes
  65486. */
  65487. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65488. /** Gets or sets the color of the color picker */
  65489. value: BABYLON.Color3;
  65490. /**
  65491. * Gets or sets control width
  65492. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65493. */
  65494. width: string | number;
  65495. /**
  65496. * Gets or sets control height
  65497. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65498. */
  65499. /** Gets or sets control height */
  65500. height: string | number;
  65501. /** Gets or sets control size */
  65502. size: string | number;
  65503. /**
  65504. * Creates a new ColorPicker
  65505. * @param name defines the control name
  65506. */
  65507. constructor(name?: string | undefined);
  65508. protected _getTypeName(): string;
  65509. /** @hidden */
  65510. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65511. private _updateSquareProps;
  65512. private _drawGradientSquare;
  65513. private _drawCircle;
  65514. private _createColorWheelCanvas;
  65515. /** @hidden */
  65516. _draw(context: CanvasRenderingContext2D): void;
  65517. private _pointerIsDown;
  65518. private _updateValueFromPointer;
  65519. private _isPointOnSquare;
  65520. private _isPointOnWheel;
  65521. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65522. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65523. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65524. /**
  65525. * This function expands the color picker by creating a color picker dialog with manual
  65526. * color value input and the ability to save colors into an array to be used later in
  65527. * subsequent launches of the dialogue.
  65528. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65529. * @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.
  65530. * @returns picked color as a hex string and the saved colors array as hex strings.
  65531. */
  65532. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65533. pickerWidth?: string;
  65534. pickerHeight?: string;
  65535. headerHeight?: string;
  65536. lastColor?: string;
  65537. swatchLimit?: number;
  65538. numSwatchesPerLine?: number;
  65539. savedColors?: Array<string>;
  65540. }): Promise<{
  65541. savedColors?: string[];
  65542. pickedColor: string;
  65543. }>;
  65544. }
  65545. }
  65546. declare module BABYLON.GUI {
  65547. /** Class used to create 2D ellipse containers */
  65548. export class Ellipse extends Container {
  65549. name?: string | undefined;
  65550. private _thickness;
  65551. /** Gets or sets border thickness */
  65552. thickness: number;
  65553. /**
  65554. * Creates a new Ellipse
  65555. * @param name defines the control name
  65556. */
  65557. constructor(name?: string | undefined);
  65558. protected _getTypeName(): string;
  65559. protected _localDraw(context: CanvasRenderingContext2D): void;
  65560. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65561. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65562. }
  65563. }
  65564. declare module BABYLON.GUI {
  65565. /**
  65566. * Class used to create a password control
  65567. */
  65568. export class InputPassword extends InputText {
  65569. protected _beforeRenderText(text: string): string;
  65570. }
  65571. }
  65572. declare module BABYLON.GUI {
  65573. /** Class used to render 2D lines */
  65574. export class Line extends Control {
  65575. name?: string | undefined;
  65576. private _lineWidth;
  65577. private _x1;
  65578. private _y1;
  65579. private _x2;
  65580. private _y2;
  65581. private _dash;
  65582. private _connectedControl;
  65583. private _connectedControlDirtyObserver;
  65584. /** Gets or sets the dash pattern */
  65585. dash: Array<number>;
  65586. /** Gets or sets the control connected with the line end */
  65587. connectedControl: Control;
  65588. /** Gets or sets start coordinates on X axis */
  65589. x1: string | number;
  65590. /** Gets or sets start coordinates on Y axis */
  65591. y1: string | number;
  65592. /** Gets or sets end coordinates on X axis */
  65593. x2: string | number;
  65594. /** Gets or sets end coordinates on Y axis */
  65595. y2: string | number;
  65596. /** Gets or sets line width */
  65597. lineWidth: number;
  65598. /** Gets or sets horizontal alignment */
  65599. horizontalAlignment: number;
  65600. /** Gets or sets vertical alignment */
  65601. verticalAlignment: number;
  65602. private readonly _effectiveX2;
  65603. private readonly _effectiveY2;
  65604. /**
  65605. * Creates a new Line
  65606. * @param name defines the control name
  65607. */
  65608. constructor(name?: string | undefined);
  65609. protected _getTypeName(): string;
  65610. _draw(context: CanvasRenderingContext2D): void;
  65611. _measure(): void;
  65612. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65613. /**
  65614. * Move one end of the line given 3D cartesian coordinates.
  65615. * @param position Targeted world position
  65616. * @param scene BABYLON.Scene
  65617. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65618. */
  65619. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65620. /**
  65621. * Move one end of the line to a position in screen absolute space.
  65622. * @param projectedPosition Position in screen absolute space (X, Y)
  65623. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65624. */
  65625. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65626. }
  65627. }
  65628. declare module BABYLON.GUI {
  65629. /**
  65630. * Class used to store a point for a MultiLine object.
  65631. * The point can be pure 2D coordinates, a mesh or a control
  65632. */
  65633. export class MultiLinePoint {
  65634. private _multiLine;
  65635. private _x;
  65636. private _y;
  65637. private _control;
  65638. private _mesh;
  65639. private _controlObserver;
  65640. private _meshObserver;
  65641. /** @hidden */
  65642. _point: BABYLON.Vector2;
  65643. /**
  65644. * Creates a new MultiLinePoint
  65645. * @param multiLine defines the source MultiLine object
  65646. */
  65647. constructor(multiLine: MultiLine);
  65648. /** Gets or sets x coordinate */
  65649. x: string | number;
  65650. /** Gets or sets y coordinate */
  65651. y: string | number;
  65652. /** Gets or sets the control associated with this point */
  65653. control: BABYLON.Nullable<Control>;
  65654. /** Gets or sets the mesh associated with this point */
  65655. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65656. /** Resets links */
  65657. resetLinks(): void;
  65658. /**
  65659. * Gets a translation vector
  65660. * @returns the translation vector
  65661. */
  65662. translate(): BABYLON.Vector2;
  65663. private _translatePoint;
  65664. /** Release associated resources */
  65665. dispose(): void;
  65666. }
  65667. }
  65668. declare module BABYLON.GUI {
  65669. /**
  65670. * Class used to create multi line control
  65671. */
  65672. export class MultiLine extends Control {
  65673. name?: string | undefined;
  65674. private _lineWidth;
  65675. private _dash;
  65676. private _points;
  65677. private _minX;
  65678. private _minY;
  65679. private _maxX;
  65680. private _maxY;
  65681. /**
  65682. * Creates a new MultiLine
  65683. * @param name defines the control name
  65684. */
  65685. constructor(name?: string | undefined);
  65686. /** Gets or sets dash pattern */
  65687. dash: Array<number>;
  65688. /**
  65689. * Gets point stored at specified index
  65690. * @param index defines the index to look for
  65691. * @returns the requested point if found
  65692. */
  65693. getAt(index: number): MultiLinePoint;
  65694. /** Function called when a point is updated */
  65695. onPointUpdate: () => void;
  65696. /**
  65697. * Adds new points to the point collection
  65698. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65699. * @returns the list of created MultiLinePoint
  65700. */
  65701. add(...items: (AbstractMesh | Control | {
  65702. x: string | number;
  65703. y: string | number;
  65704. })[]): MultiLinePoint[];
  65705. /**
  65706. * Adds a new point to the point collection
  65707. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65708. * @returns the created MultiLinePoint
  65709. */
  65710. push(item?: (AbstractMesh | Control | {
  65711. x: string | number;
  65712. y: string | number;
  65713. })): MultiLinePoint;
  65714. /**
  65715. * Remove a specific value or point from the active point collection
  65716. * @param value defines the value or point to remove
  65717. */
  65718. remove(value: number | MultiLinePoint): void;
  65719. /**
  65720. * Resets this object to initial state (no point)
  65721. */
  65722. reset(): void;
  65723. /**
  65724. * Resets all links
  65725. */
  65726. resetLinks(): void;
  65727. /** Gets or sets line width */
  65728. lineWidth: number;
  65729. horizontalAlignment: number;
  65730. verticalAlignment: number;
  65731. protected _getTypeName(): string;
  65732. _draw(context: CanvasRenderingContext2D): void;
  65733. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65734. _measure(): void;
  65735. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65736. dispose(): void;
  65737. }
  65738. }
  65739. declare module BABYLON.GUI {
  65740. /**
  65741. * Class used to create radio button controls
  65742. */
  65743. export class RadioButton extends Control {
  65744. name?: string | undefined;
  65745. private _isChecked;
  65746. private _background;
  65747. private _checkSizeRatio;
  65748. private _thickness;
  65749. /** Gets or sets border thickness */
  65750. thickness: number;
  65751. /** Gets or sets group name */
  65752. group: string;
  65753. /** BABYLON.Observable raised when isChecked is changed */
  65754. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65755. /** Gets or sets a value indicating the ratio between overall size and check size */
  65756. checkSizeRatio: number;
  65757. /** Gets or sets background color */
  65758. background: string;
  65759. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65760. isChecked: boolean;
  65761. /**
  65762. * Creates a new RadioButton
  65763. * @param name defines the control name
  65764. */
  65765. constructor(name?: string | undefined);
  65766. protected _getTypeName(): string;
  65767. _draw(context: CanvasRenderingContext2D): void;
  65768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65769. /**
  65770. * Utility function to easily create a radio button with a header
  65771. * @param title defines the label to use for the header
  65772. * @param group defines the group to use for the radio button
  65773. * @param isChecked defines the initial state of the radio button
  65774. * @param onValueChanged defines the callback to call when value changes
  65775. * @returns a StackPanel containing the radio button and a textBlock
  65776. */
  65777. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65778. }
  65779. }
  65780. declare module BABYLON.GUI {
  65781. /**
  65782. * Class used to create slider controls
  65783. */
  65784. export class BaseSlider extends Control {
  65785. name?: string | undefined;
  65786. protected _thumbWidth: ValueAndUnit;
  65787. private _minimum;
  65788. private _maximum;
  65789. private _value;
  65790. private _isVertical;
  65791. protected _barOffset: ValueAndUnit;
  65792. private _isThumbClamped;
  65793. protected _displayThumb: boolean;
  65794. private _step;
  65795. private _lastPointerDownID;
  65796. protected _effectiveBarOffset: number;
  65797. protected _renderLeft: number;
  65798. protected _renderTop: number;
  65799. protected _renderWidth: number;
  65800. protected _renderHeight: number;
  65801. protected _backgroundBoxLength: number;
  65802. protected _backgroundBoxThickness: number;
  65803. protected _effectiveThumbThickness: number;
  65804. /** BABYLON.Observable raised when the sldier value changes */
  65805. onValueChangedObservable: BABYLON.Observable<number>;
  65806. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65807. displayThumb: boolean;
  65808. /** Gets or sets a step to apply to values (0 by default) */
  65809. step: number;
  65810. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65811. barOffset: string | number;
  65812. /** Gets main bar offset in pixels*/
  65813. readonly barOffsetInPixels: number;
  65814. /** Gets or sets thumb width */
  65815. thumbWidth: string | number;
  65816. /** Gets thumb width in pixels */
  65817. readonly thumbWidthInPixels: number;
  65818. /** Gets or sets minimum value */
  65819. minimum: number;
  65820. /** Gets or sets maximum value */
  65821. maximum: number;
  65822. /** Gets or sets current value */
  65823. value: number;
  65824. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65825. isVertical: boolean;
  65826. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65827. isThumbClamped: boolean;
  65828. /**
  65829. * Creates a new BaseSlider
  65830. * @param name defines the control name
  65831. */
  65832. constructor(name?: string | undefined);
  65833. protected _getTypeName(): string;
  65834. protected _getThumbPosition(): number;
  65835. protected _getThumbThickness(type: string): number;
  65836. protected _prepareRenderingData(type: string): void;
  65837. private _pointerIsDown;
  65838. /** @hidden */
  65839. protected _updateValueFromPointer(x: number, y: number): void;
  65840. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65841. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65842. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65843. }
  65844. }
  65845. declare module BABYLON.GUI {
  65846. /**
  65847. * Class used to create slider controls
  65848. */
  65849. export class Slider extends BaseSlider {
  65850. name?: string | undefined;
  65851. private _background;
  65852. private _borderColor;
  65853. private _isThumbCircle;
  65854. protected _displayValueBar: boolean;
  65855. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65856. displayValueBar: boolean;
  65857. /** Gets or sets border color */
  65858. borderColor: string;
  65859. /** Gets or sets background color */
  65860. background: string;
  65861. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65862. isThumbCircle: boolean;
  65863. /**
  65864. * Creates a new Slider
  65865. * @param name defines the control name
  65866. */
  65867. constructor(name?: string | undefined);
  65868. protected _getTypeName(): string;
  65869. _draw(context: CanvasRenderingContext2D): void;
  65870. }
  65871. }
  65872. declare module BABYLON.GUI {
  65873. /** Class used to create a RadioGroup
  65874. * which contains groups of radio buttons
  65875. */
  65876. export class SelectorGroup {
  65877. /** name of SelectorGroup */
  65878. name: string;
  65879. private _groupPanel;
  65880. private _selectors;
  65881. private _groupHeader;
  65882. /**
  65883. * Creates a new SelectorGroup
  65884. * @param name of group, used as a group heading
  65885. */
  65886. constructor(
  65887. /** name of SelectorGroup */
  65888. name: string);
  65889. /** Gets the groupPanel of the SelectorGroup */
  65890. readonly groupPanel: StackPanel;
  65891. /** Gets the selectors array */
  65892. readonly selectors: StackPanel[];
  65893. /** Gets and sets the group header */
  65894. header: string;
  65895. /** @hidden */
  65896. private _addGroupHeader;
  65897. /** @hidden*/
  65898. _getSelector(selectorNb: number): StackPanel | undefined;
  65899. /** Removes the selector at the given position
  65900. * @param selectorNb the position of the selector within the group
  65901. */
  65902. removeSelector(selectorNb: number): void;
  65903. }
  65904. /** Class used to create a CheckboxGroup
  65905. * which contains groups of checkbox buttons
  65906. */
  65907. export class CheckboxGroup extends SelectorGroup {
  65908. /** Adds a checkbox as a control
  65909. * @param text is the label for the selector
  65910. * @param func is the function called when the Selector is checked
  65911. * @param checked is true when Selector is checked
  65912. */
  65913. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65914. /** @hidden */
  65915. _setSelectorLabel(selectorNb: number, label: string): void;
  65916. /** @hidden */
  65917. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65918. /** @hidden */
  65919. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65920. /** @hidden */
  65921. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65922. }
  65923. /** Class used to create a RadioGroup
  65924. * which contains groups of radio buttons
  65925. */
  65926. export class RadioGroup extends SelectorGroup {
  65927. private _selectNb;
  65928. /** Adds a radio button as a control
  65929. * @param label is the label for the selector
  65930. * @param func is the function called when the Selector is checked
  65931. * @param checked is true when Selector is checked
  65932. */
  65933. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65934. /** @hidden */
  65935. _setSelectorLabel(selectorNb: number, label: string): void;
  65936. /** @hidden */
  65937. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65938. /** @hidden */
  65939. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65940. /** @hidden */
  65941. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65942. }
  65943. /** Class used to create a SliderGroup
  65944. * which contains groups of slider buttons
  65945. */
  65946. export class SliderGroup extends SelectorGroup {
  65947. /**
  65948. * Adds a slider to the SelectorGroup
  65949. * @param label is the label for the SliderBar
  65950. * @param func is the function called when the Slider moves
  65951. * @param unit is a string describing the units used, eg degrees or metres
  65952. * @param min is the minimum value for the Slider
  65953. * @param max is the maximum value for the Slider
  65954. * @param value is the start value for the Slider between min and max
  65955. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65956. */
  65957. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65958. /** @hidden */
  65959. _setSelectorLabel(selectorNb: number, label: string): void;
  65960. /** @hidden */
  65961. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65962. /** @hidden */
  65963. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65964. /** @hidden */
  65965. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65966. }
  65967. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65968. * @see http://doc.babylonjs.com/how_to/selector
  65969. */
  65970. export class SelectionPanel extends Rectangle {
  65971. /** name of SelectionPanel */
  65972. name: string;
  65973. /** an array of SelectionGroups */
  65974. groups: SelectorGroup[];
  65975. private _panel;
  65976. private _buttonColor;
  65977. private _buttonBackground;
  65978. private _headerColor;
  65979. private _barColor;
  65980. private _barHeight;
  65981. private _spacerHeight;
  65982. private _labelColor;
  65983. private _groups;
  65984. private _bars;
  65985. /**
  65986. * Creates a new SelectionPanel
  65987. * @param name of SelectionPanel
  65988. * @param groups is an array of SelectionGroups
  65989. */
  65990. constructor(
  65991. /** name of SelectionPanel */
  65992. name: string,
  65993. /** an array of SelectionGroups */
  65994. groups?: SelectorGroup[]);
  65995. protected _getTypeName(): string;
  65996. /** Gets or sets the headerColor */
  65997. headerColor: string;
  65998. private _setHeaderColor;
  65999. /** Gets or sets the button color */
  66000. buttonColor: string;
  66001. private _setbuttonColor;
  66002. /** Gets or sets the label color */
  66003. labelColor: string;
  66004. private _setLabelColor;
  66005. /** Gets or sets the button background */
  66006. buttonBackground: string;
  66007. private _setButtonBackground;
  66008. /** Gets or sets the color of separator bar */
  66009. barColor: string;
  66010. private _setBarColor;
  66011. /** Gets or sets the height of separator bar */
  66012. barHeight: string;
  66013. private _setBarHeight;
  66014. /** Gets or sets the height of spacers*/
  66015. spacerHeight: string;
  66016. private _setSpacerHeight;
  66017. /** Adds a bar between groups */
  66018. private _addSpacer;
  66019. /** Add a group to the selection panel
  66020. * @param group is the selector group to add
  66021. */
  66022. addGroup(group: SelectorGroup): void;
  66023. /** Remove the group from the given position
  66024. * @param groupNb is the position of the group in the list
  66025. */
  66026. removeGroup(groupNb: number): void;
  66027. /** Change a group header label
  66028. * @param label is the new group header label
  66029. * @param groupNb is the number of the group to relabel
  66030. * */
  66031. setHeaderName(label: string, groupNb: number): void;
  66032. /** Change selector label to the one given
  66033. * @param label is the new selector label
  66034. * @param groupNb is the number of the groupcontaining the selector
  66035. * @param selectorNb is the number of the selector within a group to relabel
  66036. * */
  66037. relabel(label: string, groupNb: number, selectorNb: number): void;
  66038. /** For a given group position remove the selector at the given position
  66039. * @param groupNb is the number of the group to remove the selector from
  66040. * @param selectorNb is the number of the selector within the group
  66041. */
  66042. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66043. /** For a given group position of correct type add a checkbox button
  66044. * @param groupNb is the number of the group to remove the selector from
  66045. * @param label is the label for the selector
  66046. * @param func is the function called when the Selector is checked
  66047. * @param checked is true when Selector is checked
  66048. */
  66049. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66050. /** For a given group position of correct type add a radio button
  66051. * @param groupNb is the number of the group to remove the selector from
  66052. * @param label is the label for the selector
  66053. * @param func is the function called when the Selector is checked
  66054. * @param checked is true when Selector is checked
  66055. */
  66056. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66057. /**
  66058. * For a given slider group add a slider
  66059. * @param groupNb is the number of the group to add the slider to
  66060. * @param label is the label for the Slider
  66061. * @param func is the function called when the Slider moves
  66062. * @param unit is a string describing the units used, eg degrees or metres
  66063. * @param min is the minimum value for the Slider
  66064. * @param max is the maximum value for the Slider
  66065. * @param value is the start value for the Slider between min and max
  66066. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66067. */
  66068. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66069. }
  66070. }
  66071. declare module BABYLON.GUI {
  66072. /**
  66073. * Class used to hold a the container for ScrollViewer
  66074. * @hidden
  66075. */
  66076. export class _ScrollViewerWindow extends Container {
  66077. parentClientWidth: number;
  66078. parentClientHeight: number;
  66079. /**
  66080. * Creates a new ScrollViewerWindow
  66081. * @param name of ScrollViewerWindow
  66082. */
  66083. constructor(name?: string);
  66084. protected _getTypeName(): string;
  66085. /** @hidden */
  66086. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66087. protected _postMeasure(): void;
  66088. }
  66089. }
  66090. declare module BABYLON.GUI {
  66091. /**
  66092. * Class used to create slider controls
  66093. */
  66094. export class ScrollBar extends BaseSlider {
  66095. name?: string | undefined;
  66096. private _background;
  66097. private _borderColor;
  66098. private _thumbMeasure;
  66099. /** Gets or sets border color */
  66100. borderColor: string;
  66101. /** Gets or sets background color */
  66102. background: string;
  66103. /**
  66104. * Creates a new Slider
  66105. * @param name defines the control name
  66106. */
  66107. constructor(name?: string | undefined);
  66108. protected _getTypeName(): string;
  66109. protected _getThumbThickness(): number;
  66110. _draw(context: CanvasRenderingContext2D): void;
  66111. private _first;
  66112. private _originX;
  66113. private _originY;
  66114. /** @hidden */
  66115. protected _updateValueFromPointer(x: number, y: number): void;
  66116. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66117. }
  66118. }
  66119. declare module BABYLON.GUI {
  66120. /**
  66121. * Class used to hold a viewer window and sliders in a grid
  66122. */
  66123. export class ScrollViewer extends Rectangle {
  66124. private _grid;
  66125. private _horizontalBarSpace;
  66126. private _verticalBarSpace;
  66127. private _dragSpace;
  66128. private _horizontalBar;
  66129. private _verticalBar;
  66130. private _barColor;
  66131. private _barBackground;
  66132. private _barSize;
  66133. private _endLeft;
  66134. private _endTop;
  66135. private _window;
  66136. private _pointerIsOver;
  66137. private _wheelPrecision;
  66138. private _onPointerObserver;
  66139. private _clientWidth;
  66140. private _clientHeight;
  66141. /**
  66142. * Gets the horizontal scrollbar
  66143. */
  66144. readonly horizontalBar: ScrollBar;
  66145. /**
  66146. * Gets the vertical scrollbar
  66147. */
  66148. readonly verticalBar: ScrollBar;
  66149. /**
  66150. * Adds a new control to the current container
  66151. * @param control defines the control to add
  66152. * @returns the current container
  66153. */
  66154. addControl(control: BABYLON.Nullable<Control>): Container;
  66155. /**
  66156. * Removes a control from the current container
  66157. * @param control defines the control to remove
  66158. * @returns the current container
  66159. */
  66160. removeControl(control: Control): Container;
  66161. /** Gets the list of children */
  66162. readonly children: Control[];
  66163. _flagDescendantsAsMatrixDirty(): void;
  66164. /**
  66165. * Creates a new ScrollViewer
  66166. * @param name of ScrollViewer
  66167. */
  66168. constructor(name?: string);
  66169. /** Reset the scroll viewer window to initial size */
  66170. resetWindow(): void;
  66171. protected _getTypeName(): string;
  66172. private _buildClientSizes;
  66173. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66174. protected _postMeasure(): void;
  66175. /**
  66176. * Gets or sets the mouse wheel precision
  66177. * from 0 to 1 with a default value of 0.05
  66178. * */
  66179. wheelPrecision: number;
  66180. /** Gets or sets the bar color */
  66181. barColor: string;
  66182. /** Gets or sets the size of the bar */
  66183. barSize: number;
  66184. /** Gets or sets the bar background */
  66185. barBackground: string;
  66186. /** @hidden */
  66187. private _updateScroller;
  66188. _link(host: AdvancedDynamicTexture): void;
  66189. /** @hidden */
  66190. private _attachWheel;
  66191. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66192. /** Releases associated resources */
  66193. dispose(): void;
  66194. }
  66195. }
  66196. declare module BABYLON.GUI {
  66197. /** Class used to render a grid */
  66198. export class DisplayGrid extends Control {
  66199. name?: string | undefined;
  66200. private _cellWidth;
  66201. private _cellHeight;
  66202. private _minorLineTickness;
  66203. private _minorLineColor;
  66204. private _majorLineTickness;
  66205. private _majorLineColor;
  66206. private _majorLineFrequency;
  66207. private _background;
  66208. private _displayMajorLines;
  66209. private _displayMinorLines;
  66210. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66211. displayMinorLines: boolean;
  66212. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66213. displayMajorLines: boolean;
  66214. /** Gets or sets background color (Black by default) */
  66215. background: string;
  66216. /** Gets or sets the width of each cell (20 by default) */
  66217. cellWidth: number;
  66218. /** Gets or sets the height of each cell (20 by default) */
  66219. cellHeight: number;
  66220. /** Gets or sets the tickness of minor lines (1 by default) */
  66221. minorLineTickness: number;
  66222. /** Gets or sets the color of minor lines (DarkGray by default) */
  66223. minorLineColor: string;
  66224. /** Gets or sets the tickness of major lines (2 by default) */
  66225. majorLineTickness: number;
  66226. /** Gets or sets the color of major lines (White by default) */
  66227. majorLineColor: string;
  66228. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66229. majorLineFrequency: number;
  66230. /**
  66231. * Creates a new GridDisplayRectangle
  66232. * @param name defines the control name
  66233. */
  66234. constructor(name?: string | undefined);
  66235. _draw(context: CanvasRenderingContext2D): void;
  66236. protected _getTypeName(): string;
  66237. }
  66238. }
  66239. declare module BABYLON.GUI {
  66240. /**
  66241. * Class used to create slider controls based on images
  66242. */
  66243. export class ImageBasedSlider extends BaseSlider {
  66244. name?: string | undefined;
  66245. private _backgroundImage;
  66246. private _thumbImage;
  66247. private _valueBarImage;
  66248. private _tempMeasure;
  66249. displayThumb: boolean;
  66250. /**
  66251. * Gets or sets the image used to render the background
  66252. */
  66253. backgroundImage: Image;
  66254. /**
  66255. * Gets or sets the image used to render the value bar
  66256. */
  66257. valueBarImage: Image;
  66258. /**
  66259. * Gets or sets the image used to render the thumb
  66260. */
  66261. thumbImage: Image;
  66262. /**
  66263. * Creates a new ImageBasedSlider
  66264. * @param name defines the control name
  66265. */
  66266. constructor(name?: string | undefined);
  66267. protected _getTypeName(): string;
  66268. _draw(context: CanvasRenderingContext2D): void;
  66269. }
  66270. }
  66271. declare module BABYLON.GUI {
  66272. /**
  66273. * Forcing an export so that this code will execute
  66274. * @hidden
  66275. */
  66276. const name = "Statics";
  66277. }
  66278. declare module BABYLON.GUI {
  66279. /**
  66280. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66281. */
  66282. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66283. /**
  66284. * Define the instrumented AdvancedDynamicTexture.
  66285. */
  66286. texture: AdvancedDynamicTexture;
  66287. private _captureRenderTime;
  66288. private _renderTime;
  66289. private _captureLayoutTime;
  66290. private _layoutTime;
  66291. private _onBeginRenderObserver;
  66292. private _onEndRenderObserver;
  66293. private _onBeginLayoutObserver;
  66294. private _onEndLayoutObserver;
  66295. /**
  66296. * Gets the perf counter used to capture render time
  66297. */
  66298. readonly renderTimeCounter: BABYLON.PerfCounter;
  66299. /**
  66300. * Gets the perf counter used to capture layout time
  66301. */
  66302. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66303. /**
  66304. * Enable or disable the render time capture
  66305. */
  66306. captureRenderTime: boolean;
  66307. /**
  66308. * Enable or disable the layout time capture
  66309. */
  66310. captureLayoutTime: boolean;
  66311. /**
  66312. * Instantiates a new advanced dynamic texture instrumentation.
  66313. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66314. * @param texture Defines the AdvancedDynamicTexture to instrument
  66315. */
  66316. constructor(
  66317. /**
  66318. * Define the instrumented AdvancedDynamicTexture.
  66319. */
  66320. texture: AdvancedDynamicTexture);
  66321. /**
  66322. * Dispose and release associated resources.
  66323. */
  66324. dispose(): void;
  66325. }
  66326. }
  66327. declare module BABYLON.GUI {
  66328. /**
  66329. * Class used to load GUI via XML.
  66330. */
  66331. export class XmlLoader {
  66332. private _nodes;
  66333. private _nodeTypes;
  66334. private _isLoaded;
  66335. private _objectAttributes;
  66336. private _parentClass;
  66337. /**
  66338. * Create a new xml loader
  66339. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66340. */
  66341. constructor(parentClass?: null);
  66342. private _getChainElement;
  66343. private _getClassAttribute;
  66344. private _createGuiElement;
  66345. private _parseGrid;
  66346. private _parseElement;
  66347. private _prepareSourceElement;
  66348. private _parseElementsFromSource;
  66349. private _parseXml;
  66350. /**
  66351. * Gets if the loading has finished.
  66352. * @returns whether the loading has finished or not
  66353. */
  66354. isLoaded(): boolean;
  66355. /**
  66356. * Gets a loaded node / control by id.
  66357. * @param id the Controls id set in the xml
  66358. * @returns element of type Control
  66359. */
  66360. getNodeById(id: string): any;
  66361. /**
  66362. * Gets all loaded nodes / controls
  66363. * @returns Array of controls
  66364. */
  66365. getNodes(): any;
  66366. /**
  66367. * Initiates the xml layout loading
  66368. * @param xmlFile defines the xml layout to load
  66369. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66370. * @param callback defines the callback called on layout load.
  66371. */
  66372. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66373. }
  66374. }
  66375. declare module BABYLON.GUI {
  66376. /**
  66377. * Class used to create containers for controls
  66378. */
  66379. export class Container3D extends Control3D {
  66380. private _blockLayout;
  66381. /**
  66382. * Gets the list of child controls
  66383. */
  66384. protected _children: Control3D[];
  66385. /**
  66386. * Gets the list of child controls
  66387. */
  66388. readonly children: Array<Control3D>;
  66389. /**
  66390. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66391. * This is helpful to optimize layout operation when adding multiple children in a row
  66392. */
  66393. blockLayout: boolean;
  66394. /**
  66395. * Creates a new container
  66396. * @param name defines the container name
  66397. */
  66398. constructor(name?: string);
  66399. /**
  66400. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66401. * @returns the current container
  66402. */
  66403. updateLayout(): Container3D;
  66404. /**
  66405. * Gets a boolean indicating if the given control is in the children of this control
  66406. * @param control defines the control to check
  66407. * @returns true if the control is in the child list
  66408. */
  66409. containsControl(control: Control3D): boolean;
  66410. /**
  66411. * Adds a control to the children of this control
  66412. * @param control defines the control to add
  66413. * @returns the current container
  66414. */
  66415. addControl(control: Control3D): Container3D;
  66416. /**
  66417. * This function will be called everytime a new control is added
  66418. */
  66419. protected _arrangeChildren(): void;
  66420. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66421. /**
  66422. * Removes a control from the children of this control
  66423. * @param control defines the control to remove
  66424. * @returns the current container
  66425. */
  66426. removeControl(control: Control3D): Container3D;
  66427. protected _getTypeName(): string;
  66428. /**
  66429. * Releases all associated resources
  66430. */
  66431. dispose(): void;
  66432. /** Control rotation will remain unchanged */
  66433. static readonly UNSET_ORIENTATION: number;
  66434. /** Control will rotate to make it look at sphere central axis */
  66435. static readonly FACEORIGIN_ORIENTATION: number;
  66436. /** Control will rotate to make it look back at sphere central axis */
  66437. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66438. /** Control will rotate to look at z axis (0, 0, 1) */
  66439. static readonly FACEFORWARD_ORIENTATION: number;
  66440. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66441. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66442. }
  66443. }
  66444. declare module BABYLON.GUI {
  66445. /**
  66446. * Class used to manage 3D user interface
  66447. * @see http://doc.babylonjs.com/how_to/gui3d
  66448. */
  66449. export class GUI3DManager implements BABYLON.IDisposable {
  66450. private _scene;
  66451. private _sceneDisposeObserver;
  66452. private _utilityLayer;
  66453. private _rootContainer;
  66454. private _pointerObserver;
  66455. private _pointerOutObserver;
  66456. /** @hidden */
  66457. _lastPickedControl: Control3D;
  66458. /** @hidden */
  66459. _lastControlOver: {
  66460. [pointerId: number]: Control3D;
  66461. };
  66462. /** @hidden */
  66463. _lastControlDown: {
  66464. [pointerId: number]: Control3D;
  66465. };
  66466. /**
  66467. * BABYLON.Observable raised when the point picked by the pointer events changed
  66468. */
  66469. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66470. /** @hidden */
  66471. _sharedMaterials: {
  66472. [key: string]: BABYLON.Material;
  66473. };
  66474. /** Gets the hosting scene */
  66475. readonly scene: BABYLON.Scene;
  66476. /** Gets associated utility layer */
  66477. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66478. /**
  66479. * Creates a new GUI3DManager
  66480. * @param scene
  66481. */
  66482. constructor(scene?: BABYLON.Scene);
  66483. private _handlePointerOut;
  66484. private _doPicking;
  66485. /**
  66486. * Gets the root container
  66487. */
  66488. readonly rootContainer: Container3D;
  66489. /**
  66490. * Gets a boolean indicating if the given control is in the root child list
  66491. * @param control defines the control to check
  66492. * @returns true if the control is in the root child list
  66493. */
  66494. containsControl(control: Control3D): boolean;
  66495. /**
  66496. * Adds a control to the root child list
  66497. * @param control defines the control to add
  66498. * @returns the current manager
  66499. */
  66500. addControl(control: Control3D): GUI3DManager;
  66501. /**
  66502. * Removes a control from the root child list
  66503. * @param control defines the control to remove
  66504. * @returns the current container
  66505. */
  66506. removeControl(control: Control3D): GUI3DManager;
  66507. /**
  66508. * Releases all associated resources
  66509. */
  66510. dispose(): void;
  66511. }
  66512. }
  66513. declare module BABYLON.GUI {
  66514. /**
  66515. * Class used to transport BABYLON.Vector3 information for pointer events
  66516. */
  66517. export class Vector3WithInfo extends BABYLON.Vector3 {
  66518. /** defines the current mouse button index */
  66519. buttonIndex: number;
  66520. /**
  66521. * Creates a new Vector3WithInfo
  66522. * @param source defines the vector3 data to transport
  66523. * @param buttonIndex defines the current mouse button index
  66524. */
  66525. constructor(source: BABYLON.Vector3,
  66526. /** defines the current mouse button index */
  66527. buttonIndex?: number);
  66528. }
  66529. }
  66530. declare module BABYLON.GUI {
  66531. /**
  66532. * Class used as base class for controls
  66533. */
  66534. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66535. /** Defines the control name */
  66536. name?: string | undefined;
  66537. /** @hidden */
  66538. _host: GUI3DManager;
  66539. private _node;
  66540. private _downCount;
  66541. private _enterCount;
  66542. private _downPointerIds;
  66543. private _isVisible;
  66544. /** Gets or sets the control position in world space */
  66545. position: BABYLON.Vector3;
  66546. /** Gets or sets the control scaling in world space */
  66547. scaling: BABYLON.Vector3;
  66548. /** Callback used to start pointer enter animation */
  66549. pointerEnterAnimation: () => void;
  66550. /** Callback used to start pointer out animation */
  66551. pointerOutAnimation: () => void;
  66552. /** Callback used to start pointer down animation */
  66553. pointerDownAnimation: () => void;
  66554. /** Callback used to start pointer up animation */
  66555. pointerUpAnimation: () => void;
  66556. /**
  66557. * An event triggered when the pointer move over the control
  66558. */
  66559. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66560. /**
  66561. * An event triggered when the pointer move out of the control
  66562. */
  66563. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66564. /**
  66565. * An event triggered when the pointer taps the control
  66566. */
  66567. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66568. /**
  66569. * An event triggered when pointer is up
  66570. */
  66571. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66572. /**
  66573. * An event triggered when a control is clicked on (with a mouse)
  66574. */
  66575. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66576. /**
  66577. * An event triggered when pointer enters the control
  66578. */
  66579. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66580. /**
  66581. * Gets or sets the parent container
  66582. */
  66583. parent: BABYLON.Nullable<Container3D>;
  66584. private _behaviors;
  66585. /**
  66586. * Gets the list of attached behaviors
  66587. * @see http://doc.babylonjs.com/features/behaviour
  66588. */
  66589. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66590. /**
  66591. * Attach a behavior to the control
  66592. * @see http://doc.babylonjs.com/features/behaviour
  66593. * @param behavior defines the behavior to attach
  66594. * @returns the current control
  66595. */
  66596. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66597. /**
  66598. * Remove an attached behavior
  66599. * @see http://doc.babylonjs.com/features/behaviour
  66600. * @param behavior defines the behavior to attach
  66601. * @returns the current control
  66602. */
  66603. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66604. /**
  66605. * Gets an attached behavior by name
  66606. * @param name defines the name of the behavior to look for
  66607. * @see http://doc.babylonjs.com/features/behaviour
  66608. * @returns null if behavior was not found else the requested behavior
  66609. */
  66610. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66611. /** Gets or sets a boolean indicating if the control is visible */
  66612. isVisible: boolean;
  66613. /**
  66614. * Creates a new control
  66615. * @param name defines the control name
  66616. */
  66617. constructor(
  66618. /** Defines the control name */
  66619. name?: string | undefined);
  66620. /**
  66621. * Gets a string representing the class name
  66622. */
  66623. readonly typeName: string;
  66624. /**
  66625. * Get the current class name of the control.
  66626. * @returns current class name
  66627. */
  66628. getClassName(): string;
  66629. protected _getTypeName(): string;
  66630. /**
  66631. * Gets the transform node used by this control
  66632. */
  66633. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66634. /**
  66635. * Gets the mesh used to render this control
  66636. */
  66637. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66638. /**
  66639. * Link the control as child of the given node
  66640. * @param node defines the node to link to. Use null to unlink the control
  66641. * @returns the current control
  66642. */
  66643. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66644. /** @hidden **/
  66645. _prepareNode(scene: BABYLON.Scene): void;
  66646. /**
  66647. * Node creation.
  66648. * Can be overriden by children
  66649. * @param scene defines the scene where the node must be attached
  66650. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66651. */
  66652. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66653. /**
  66654. * Affect a material to the given mesh
  66655. * @param mesh defines the mesh which will represent the control
  66656. */
  66657. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66658. /** @hidden */
  66659. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66660. /** @hidden */
  66661. _onPointerEnter(target: Control3D): boolean;
  66662. /** @hidden */
  66663. _onPointerOut(target: Control3D): void;
  66664. /** @hidden */
  66665. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66666. /** @hidden */
  66667. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66668. /** @hidden */
  66669. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66670. /** @hidden */
  66671. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66672. /** @hidden */
  66673. _disposeNode(): void;
  66674. /**
  66675. * Releases all associated resources
  66676. */
  66677. dispose(): void;
  66678. }
  66679. }
  66680. declare module BABYLON.GUI {
  66681. /**
  66682. * Class used as a root to all buttons
  66683. */
  66684. export class AbstractButton3D extends Control3D {
  66685. /**
  66686. * Creates a new button
  66687. * @param name defines the control name
  66688. */
  66689. constructor(name?: string);
  66690. protected _getTypeName(): string;
  66691. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66692. }
  66693. }
  66694. declare module BABYLON.GUI {
  66695. /**
  66696. * Class used to create a button in 3D
  66697. */
  66698. export class Button3D extends AbstractButton3D {
  66699. /** @hidden */
  66700. protected _currentMaterial: BABYLON.Material;
  66701. private _facadeTexture;
  66702. private _content;
  66703. private _contentResolution;
  66704. private _contentScaleRatio;
  66705. /**
  66706. * Gets or sets the texture resolution used to render content (512 by default)
  66707. */
  66708. contentResolution: BABYLON.int;
  66709. /**
  66710. * Gets or sets the texture scale ratio used to render content (2 by default)
  66711. */
  66712. contentScaleRatio: number;
  66713. protected _disposeFacadeTexture(): void;
  66714. protected _resetContent(): void;
  66715. /**
  66716. * Creates a new button
  66717. * @param name defines the control name
  66718. */
  66719. constructor(name?: string);
  66720. /**
  66721. * Gets or sets the GUI 2D content used to display the button's facade
  66722. */
  66723. content: Control;
  66724. /**
  66725. * Apply the facade texture (created from the content property).
  66726. * This function can be overloaded by child classes
  66727. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66728. */
  66729. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66730. protected _getTypeName(): string;
  66731. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66732. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66733. /**
  66734. * Releases all associated resources
  66735. */
  66736. dispose(): void;
  66737. }
  66738. }
  66739. declare module BABYLON.GUI {
  66740. /**
  66741. * Abstract class used to create a container panel deployed on the surface of a volume
  66742. */
  66743. export abstract class VolumeBasedPanel extends Container3D {
  66744. private _columns;
  66745. private _rows;
  66746. private _rowThenColum;
  66747. private _orientation;
  66748. protected _cellWidth: number;
  66749. protected _cellHeight: number;
  66750. /**
  66751. * Gets or sets the distance between elements
  66752. */
  66753. margin: number;
  66754. /**
  66755. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66756. * | Value | Type | Description |
  66757. * | ----- | ----------------------------------- | ----------- |
  66758. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66759. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66760. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66761. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66762. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66763. */
  66764. orientation: number;
  66765. /**
  66766. * Gets or sets the number of columns requested (10 by default).
  66767. * The panel will automatically compute the number of rows based on number of child controls.
  66768. */
  66769. columns: BABYLON.int;
  66770. /**
  66771. * Gets or sets a the number of rows requested.
  66772. * The panel will automatically compute the number of columns based on number of child controls.
  66773. */
  66774. rows: BABYLON.int;
  66775. /**
  66776. * Creates new VolumeBasedPanel
  66777. */
  66778. constructor();
  66779. protected _arrangeChildren(): void;
  66780. /** Child classes must implement this function to provide correct control positioning */
  66781. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66782. /** Child classes can implement this function to provide additional processing */
  66783. protected _finalProcessing(): void;
  66784. }
  66785. }
  66786. declare module BABYLON.GUI {
  66787. /**
  66788. * Class used to create a container panel deployed on the surface of a cylinder
  66789. */
  66790. export class CylinderPanel extends VolumeBasedPanel {
  66791. private _radius;
  66792. /**
  66793. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66794. */
  66795. radius: BABYLON.float;
  66796. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66797. private _cylindricalMapping;
  66798. }
  66799. }
  66800. declare module BABYLON.GUI {
  66801. /** @hidden */
  66802. export var fluentVertexShader: {
  66803. name: string;
  66804. shader: string;
  66805. };
  66806. }
  66807. declare module BABYLON.GUI {
  66808. /** @hidden */
  66809. export var fluentPixelShader: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module BABYLON.GUI {
  66815. /** @hidden */
  66816. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66817. INNERGLOW: boolean;
  66818. BORDER: boolean;
  66819. HOVERLIGHT: boolean;
  66820. TEXTURE: boolean;
  66821. constructor();
  66822. }
  66823. /**
  66824. * Class used to render controls with fluent desgin
  66825. */
  66826. export class FluentMaterial extends BABYLON.PushMaterial {
  66827. /**
  66828. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66829. */
  66830. innerGlowColorIntensity: number;
  66831. /**
  66832. * Gets or sets the inner glow color (white by default)
  66833. */
  66834. innerGlowColor: BABYLON.Color3;
  66835. /**
  66836. * Gets or sets alpha value (default is 1.0)
  66837. */
  66838. alpha: number;
  66839. /**
  66840. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66841. */
  66842. albedoColor: BABYLON.Color3;
  66843. /**
  66844. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66845. */
  66846. renderBorders: boolean;
  66847. /**
  66848. * Gets or sets border width (default is 0.5)
  66849. */
  66850. borderWidth: number;
  66851. /**
  66852. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66853. */
  66854. edgeSmoothingValue: number;
  66855. /**
  66856. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66857. */
  66858. borderMinValue: number;
  66859. /**
  66860. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66861. */
  66862. renderHoverLight: boolean;
  66863. /**
  66864. * Gets or sets the radius used to render the hover light (default is 1.0)
  66865. */
  66866. hoverRadius: number;
  66867. /**
  66868. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66869. */
  66870. hoverColor: BABYLON.Color4;
  66871. /**
  66872. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66873. */
  66874. hoverPosition: BABYLON.Vector3;
  66875. private _albedoTexture;
  66876. /** Gets or sets the texture to use for albedo color */
  66877. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66878. /**
  66879. * Creates a new Fluent material
  66880. * @param name defines the name of the material
  66881. * @param scene defines the hosting scene
  66882. */
  66883. constructor(name: string, scene: BABYLON.Scene);
  66884. needAlphaBlending(): boolean;
  66885. needAlphaTesting(): boolean;
  66886. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66887. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66888. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66889. getActiveTextures(): BABYLON.BaseTexture[];
  66890. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66891. dispose(forceDisposeEffect?: boolean): void;
  66892. clone(name: string): FluentMaterial;
  66893. serialize(): any;
  66894. getClassName(): string;
  66895. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66896. }
  66897. }
  66898. declare module BABYLON.GUI {
  66899. /**
  66900. * Class used to create a holographic button in 3D
  66901. */
  66902. export class HolographicButton extends Button3D {
  66903. private _backPlate;
  66904. private _textPlate;
  66905. private _frontPlate;
  66906. private _text;
  66907. private _imageUrl;
  66908. private _shareMaterials;
  66909. private _frontMaterial;
  66910. private _backMaterial;
  66911. private _plateMaterial;
  66912. private _pickedPointObserver;
  66913. private _tooltipFade;
  66914. private _tooltipTextBlock;
  66915. private _tooltipTexture;
  66916. private _tooltipMesh;
  66917. private _tooltipHoverObserver;
  66918. private _tooltipOutObserver;
  66919. private _disposeTooltip;
  66920. /**
  66921. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66922. */
  66923. tooltipText: BABYLON.Nullable<string>;
  66924. /**
  66925. * Gets or sets text for the button
  66926. */
  66927. text: string;
  66928. /**
  66929. * Gets or sets the image url for the button
  66930. */
  66931. imageUrl: string;
  66932. /**
  66933. * Gets the back material used by this button
  66934. */
  66935. readonly backMaterial: FluentMaterial;
  66936. /**
  66937. * Gets the front material used by this button
  66938. */
  66939. readonly frontMaterial: FluentMaterial;
  66940. /**
  66941. * Gets the plate material used by this button
  66942. */
  66943. readonly plateMaterial: BABYLON.StandardMaterial;
  66944. /**
  66945. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66946. */
  66947. readonly shareMaterials: boolean;
  66948. /**
  66949. * Creates a new button
  66950. * @param name defines the control name
  66951. */
  66952. constructor(name?: string, shareMaterials?: boolean);
  66953. protected _getTypeName(): string;
  66954. private _rebuildContent;
  66955. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66956. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66957. private _createBackMaterial;
  66958. private _createFrontMaterial;
  66959. private _createPlateMaterial;
  66960. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66961. /**
  66962. * Releases all associated resources
  66963. */
  66964. dispose(): void;
  66965. }
  66966. }
  66967. declare module BABYLON.GUI {
  66968. /**
  66969. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66970. */
  66971. export class MeshButton3D extends Button3D {
  66972. /** @hidden */
  66973. protected _currentMesh: BABYLON.Mesh;
  66974. /**
  66975. * Creates a new 3D button based on a mesh
  66976. * @param mesh mesh to become a 3D button
  66977. * @param name defines the control name
  66978. */
  66979. constructor(mesh: BABYLON.Mesh, name?: string);
  66980. protected _getTypeName(): string;
  66981. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66982. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66983. }
  66984. }
  66985. declare module BABYLON.GUI {
  66986. /**
  66987. * Class used to create a container panel deployed on the surface of a plane
  66988. */
  66989. export class PlanePanel extends VolumeBasedPanel {
  66990. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66991. }
  66992. }
  66993. declare module BABYLON.GUI {
  66994. /**
  66995. * Class used to create a container panel where items get randomized planar mapping
  66996. */
  66997. export class ScatterPanel extends VolumeBasedPanel {
  66998. private _iteration;
  66999. /**
  67000. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67001. */
  67002. iteration: BABYLON.float;
  67003. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67004. private _scatterMapping;
  67005. protected _finalProcessing(): void;
  67006. }
  67007. }
  67008. declare module BABYLON.GUI {
  67009. /**
  67010. * Class used to create a container panel deployed on the surface of a sphere
  67011. */
  67012. export class SpherePanel extends VolumeBasedPanel {
  67013. private _radius;
  67014. /**
  67015. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67016. */
  67017. radius: BABYLON.float;
  67018. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67019. private _sphericalMapping;
  67020. }
  67021. }
  67022. declare module BABYLON.GUI {
  67023. /**
  67024. * Class used to create a stack panel in 3D on XY plane
  67025. */
  67026. export class StackPanel3D extends Container3D {
  67027. private _isVertical;
  67028. /**
  67029. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67030. */
  67031. isVertical: boolean;
  67032. /**
  67033. * Gets or sets the distance between elements
  67034. */
  67035. margin: number;
  67036. /**
  67037. * Creates new StackPanel
  67038. * @param isVertical
  67039. */
  67040. constructor(isVertical?: boolean);
  67041. protected _arrangeChildren(): void;
  67042. }
  67043. }
  67044. declare module BABYLON {
  67045. /**
  67046. * Mode that determines the coordinate system to use.
  67047. */
  67048. export enum GLTFLoaderCoordinateSystemMode {
  67049. /**
  67050. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67051. */
  67052. AUTO = 0,
  67053. /**
  67054. * Sets the useRightHandedSystem flag on the scene.
  67055. */
  67056. FORCE_RIGHT_HANDED = 1
  67057. }
  67058. /**
  67059. * Mode that determines what animations will start.
  67060. */
  67061. export enum GLTFLoaderAnimationStartMode {
  67062. /**
  67063. * No animation will start.
  67064. */
  67065. NONE = 0,
  67066. /**
  67067. * The first animation will start.
  67068. */
  67069. FIRST = 1,
  67070. /**
  67071. * All animations will start.
  67072. */
  67073. ALL = 2
  67074. }
  67075. /**
  67076. * Interface that contains the data for the glTF asset.
  67077. */
  67078. export interface IGLTFLoaderData {
  67079. /**
  67080. * Object that represents the glTF JSON.
  67081. */
  67082. json: Object;
  67083. /**
  67084. * The BIN chunk of a binary glTF.
  67085. */
  67086. bin: Nullable<ArrayBufferView>;
  67087. }
  67088. /**
  67089. * Interface for extending the loader.
  67090. */
  67091. export interface IGLTFLoaderExtension {
  67092. /**
  67093. * The name of this extension.
  67094. */
  67095. readonly name: string;
  67096. /**
  67097. * Defines whether this extension is enabled.
  67098. */
  67099. enabled: boolean;
  67100. }
  67101. /**
  67102. * Loader state.
  67103. */
  67104. export enum GLTFLoaderState {
  67105. /**
  67106. * The asset is loading.
  67107. */
  67108. LOADING = 0,
  67109. /**
  67110. * The asset is ready for rendering.
  67111. */
  67112. READY = 1,
  67113. /**
  67114. * The asset is completely loaded.
  67115. */
  67116. COMPLETE = 2
  67117. }
  67118. /** @hidden */
  67119. export interface IGLTFLoader extends IDisposable {
  67120. readonly state: Nullable<GLTFLoaderState>;
  67121. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67122. meshes: AbstractMesh[];
  67123. particleSystems: IParticleSystem[];
  67124. skeletons: Skeleton[];
  67125. animationGroups: AnimationGroup[];
  67126. }>;
  67127. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67128. }
  67129. /**
  67130. * File loader for loading glTF files into a scene.
  67131. */
  67132. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67133. /** @hidden */
  67134. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67135. /** @hidden */
  67136. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67137. /**
  67138. * Raised when the asset has been parsed
  67139. */
  67140. onParsedObservable: Observable<IGLTFLoaderData>;
  67141. private _onParsedObserver;
  67142. /**
  67143. * Raised when the asset has been parsed
  67144. */
  67145. onParsed: (loaderData: IGLTFLoaderData) => void;
  67146. /**
  67147. * 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.
  67148. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67149. * Defaults to true.
  67150. * @hidden
  67151. */
  67152. static IncrementalLoading: boolean;
  67153. /**
  67154. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67155. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67156. * @hidden
  67157. */
  67158. static HomogeneousCoordinates: boolean;
  67159. /**
  67160. * The coordinate system mode. Defaults to AUTO.
  67161. */
  67162. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67163. /**
  67164. * The animation start mode. Defaults to FIRST.
  67165. */
  67166. animationStartMode: GLTFLoaderAnimationStartMode;
  67167. /**
  67168. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67169. */
  67170. compileMaterials: boolean;
  67171. /**
  67172. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67173. */
  67174. useClipPlane: boolean;
  67175. /**
  67176. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67177. */
  67178. compileShadowGenerators: boolean;
  67179. /**
  67180. * Defines if the Alpha blended materials are only applied as coverage.
  67181. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67182. * If true, no extra effects are applied to transparent pixels.
  67183. */
  67184. transparencyAsCoverage: boolean;
  67185. /**
  67186. * Function called before loading a url referenced by the asset.
  67187. */
  67188. preprocessUrlAsync: (url: string) => Promise<string>;
  67189. /**
  67190. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67191. */
  67192. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67193. private _onMeshLoadedObserver;
  67194. /**
  67195. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67196. */
  67197. onMeshLoaded: (mesh: AbstractMesh) => void;
  67198. /**
  67199. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67200. */
  67201. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67202. private _onTextureLoadedObserver;
  67203. /**
  67204. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67205. */
  67206. onTextureLoaded: (texture: BaseTexture) => void;
  67207. /**
  67208. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67209. */
  67210. readonly onMaterialLoadedObservable: Observable<Material>;
  67211. private _onMaterialLoadedObserver;
  67212. /**
  67213. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67214. */
  67215. onMaterialLoaded: (material: Material) => void;
  67216. /**
  67217. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67218. */
  67219. readonly onCameraLoadedObservable: Observable<Camera>;
  67220. private _onCameraLoadedObserver;
  67221. /**
  67222. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67223. */
  67224. onCameraLoaded: (camera: Camera) => void;
  67225. /**
  67226. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67227. * For assets with LODs, raised when all of the LODs are complete.
  67228. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67229. */
  67230. readonly onCompleteObservable: Observable<void>;
  67231. private _onCompleteObserver;
  67232. /**
  67233. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67234. * For assets with LODs, raised when all of the LODs are complete.
  67235. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67236. */
  67237. onComplete: () => void;
  67238. /**
  67239. * Observable raised when an error occurs.
  67240. */
  67241. readonly onErrorObservable: Observable<any>;
  67242. private _onErrorObserver;
  67243. /**
  67244. * Callback raised when an error occurs.
  67245. */
  67246. onError: (reason: any) => void;
  67247. /**
  67248. * Observable raised after the loader is disposed.
  67249. */
  67250. readonly onDisposeObservable: Observable<void>;
  67251. private _onDisposeObserver;
  67252. /**
  67253. * Callback raised after the loader is disposed.
  67254. */
  67255. onDispose: () => void;
  67256. /**
  67257. * Observable raised after a loader extension is created.
  67258. * Set additional options for a loader extension in this event.
  67259. */
  67260. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67261. private _onExtensionLoadedObserver;
  67262. /**
  67263. * Callback raised after a loader extension is created.
  67264. */
  67265. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67266. /**
  67267. * Defines if the loader logging is enabled.
  67268. */
  67269. loggingEnabled: boolean;
  67270. /**
  67271. * Defines if the loader should capture performance counters.
  67272. */
  67273. capturePerformanceCounters: boolean;
  67274. /**
  67275. * Defines if the loader should validate the asset.
  67276. */
  67277. validate: boolean;
  67278. /**
  67279. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67280. */
  67281. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67282. private _onValidatedObserver;
  67283. /**
  67284. * Callback raised after a loader extension is created.
  67285. */
  67286. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67287. private _loader;
  67288. /**
  67289. * Name of the loader ("gltf")
  67290. */
  67291. name: string;
  67292. /**
  67293. * Supported file extensions of the loader (.gltf, .glb)
  67294. */
  67295. extensions: ISceneLoaderPluginExtensions;
  67296. /**
  67297. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67298. */
  67299. dispose(): void;
  67300. /** @hidden */
  67301. _clear(): void;
  67302. /**
  67303. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67304. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67305. * @param scene the scene the meshes should be added to
  67306. * @param data the glTF data to load
  67307. * @param rootUrl root url to load from
  67308. * @param onProgress event that fires when loading progress has occured
  67309. * @param fileName Defines the name of the file to load
  67310. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67311. */
  67312. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67313. meshes: AbstractMesh[];
  67314. particleSystems: IParticleSystem[];
  67315. skeletons: Skeleton[];
  67316. animationGroups: AnimationGroup[];
  67317. }>;
  67318. /**
  67319. * Imports all objects from the loaded glTF data and adds them to the scene
  67320. * @param scene the scene the objects should be added to
  67321. * @param data the glTF data to load
  67322. * @param rootUrl root url to load from
  67323. * @param onProgress event that fires when loading progress has occured
  67324. * @param fileName Defines the name of the file to load
  67325. * @returns a promise which completes when objects have been loaded to the scene
  67326. */
  67327. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67328. /**
  67329. * Load into an asset container.
  67330. * @param scene The scene to load into
  67331. * @param data The data to import
  67332. * @param rootUrl The root url for scene and resources
  67333. * @param onProgress The callback when the load progresses
  67334. * @param fileName Defines the name of the file to load
  67335. * @returns The loaded asset container
  67336. */
  67337. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67338. /**
  67339. * If the data string can be loaded directly.
  67340. * @param data string contianing the file data
  67341. * @returns if the data can be loaded directly
  67342. */
  67343. canDirectLoad(data: string): boolean;
  67344. /**
  67345. * Rewrites a url by combining a root url and response url.
  67346. */
  67347. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67348. /**
  67349. * Instantiates a glTF file loader plugin.
  67350. * @returns the created plugin
  67351. */
  67352. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67353. /**
  67354. * The loader state or null if the loader is not active.
  67355. */
  67356. readonly loaderState: Nullable<GLTFLoaderState>;
  67357. /**
  67358. * Returns a promise that resolves when the asset is completely loaded.
  67359. * @returns a promise that resolves when the asset is completely loaded.
  67360. */
  67361. whenCompleteAsync(): Promise<void>;
  67362. private _parseAsync;
  67363. private _validateAsync;
  67364. private _getLoader;
  67365. private _unpackBinary;
  67366. private _unpackBinaryV1;
  67367. private _unpackBinaryV2;
  67368. private static _parseVersion;
  67369. private static _compareVersion;
  67370. private static _decodeBufferToText;
  67371. private static readonly _logSpaces;
  67372. private _logIndentLevel;
  67373. private _loggingEnabled;
  67374. /** @hidden */
  67375. _log: (message: string) => void;
  67376. /** @hidden */
  67377. _logOpen(message: string): void;
  67378. /** @hidden */
  67379. _logClose(): void;
  67380. private _logEnabled;
  67381. private _logDisabled;
  67382. private _capturePerformanceCounters;
  67383. /** @hidden */
  67384. _startPerformanceCounter: (counterName: string) => void;
  67385. /** @hidden */
  67386. _endPerformanceCounter: (counterName: string) => void;
  67387. private _startPerformanceCounterEnabled;
  67388. private _startPerformanceCounterDisabled;
  67389. private _endPerformanceCounterEnabled;
  67390. private _endPerformanceCounterDisabled;
  67391. }
  67392. }
  67393. declare module BABYLON.GLTF1 {
  67394. /**
  67395. * Enums
  67396. * @hidden
  67397. */
  67398. export enum EComponentType {
  67399. BYTE = 5120,
  67400. UNSIGNED_BYTE = 5121,
  67401. SHORT = 5122,
  67402. UNSIGNED_SHORT = 5123,
  67403. FLOAT = 5126
  67404. }
  67405. /** @hidden */
  67406. export enum EShaderType {
  67407. FRAGMENT = 35632,
  67408. VERTEX = 35633
  67409. }
  67410. /** @hidden */
  67411. export enum EParameterType {
  67412. BYTE = 5120,
  67413. UNSIGNED_BYTE = 5121,
  67414. SHORT = 5122,
  67415. UNSIGNED_SHORT = 5123,
  67416. INT = 5124,
  67417. UNSIGNED_INT = 5125,
  67418. FLOAT = 5126,
  67419. FLOAT_VEC2 = 35664,
  67420. FLOAT_VEC3 = 35665,
  67421. FLOAT_VEC4 = 35666,
  67422. INT_VEC2 = 35667,
  67423. INT_VEC3 = 35668,
  67424. INT_VEC4 = 35669,
  67425. BOOL = 35670,
  67426. BOOL_VEC2 = 35671,
  67427. BOOL_VEC3 = 35672,
  67428. BOOL_VEC4 = 35673,
  67429. FLOAT_MAT2 = 35674,
  67430. FLOAT_MAT3 = 35675,
  67431. FLOAT_MAT4 = 35676,
  67432. SAMPLER_2D = 35678
  67433. }
  67434. /** @hidden */
  67435. export enum ETextureWrapMode {
  67436. CLAMP_TO_EDGE = 33071,
  67437. MIRRORED_REPEAT = 33648,
  67438. REPEAT = 10497
  67439. }
  67440. /** @hidden */
  67441. export enum ETextureFilterType {
  67442. NEAREST = 9728,
  67443. LINEAR = 9728,
  67444. NEAREST_MIPMAP_NEAREST = 9984,
  67445. LINEAR_MIPMAP_NEAREST = 9985,
  67446. NEAREST_MIPMAP_LINEAR = 9986,
  67447. LINEAR_MIPMAP_LINEAR = 9987
  67448. }
  67449. /** @hidden */
  67450. export enum ETextureFormat {
  67451. ALPHA = 6406,
  67452. RGB = 6407,
  67453. RGBA = 6408,
  67454. LUMINANCE = 6409,
  67455. LUMINANCE_ALPHA = 6410
  67456. }
  67457. /** @hidden */
  67458. export enum ECullingType {
  67459. FRONT = 1028,
  67460. BACK = 1029,
  67461. FRONT_AND_BACK = 1032
  67462. }
  67463. /** @hidden */
  67464. export enum EBlendingFunction {
  67465. ZERO = 0,
  67466. ONE = 1,
  67467. SRC_COLOR = 768,
  67468. ONE_MINUS_SRC_COLOR = 769,
  67469. DST_COLOR = 774,
  67470. ONE_MINUS_DST_COLOR = 775,
  67471. SRC_ALPHA = 770,
  67472. ONE_MINUS_SRC_ALPHA = 771,
  67473. DST_ALPHA = 772,
  67474. ONE_MINUS_DST_ALPHA = 773,
  67475. CONSTANT_COLOR = 32769,
  67476. ONE_MINUS_CONSTANT_COLOR = 32770,
  67477. CONSTANT_ALPHA = 32771,
  67478. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67479. SRC_ALPHA_SATURATE = 776
  67480. }
  67481. /** @hidden */
  67482. export interface IGLTFProperty {
  67483. extensions?: {
  67484. [key: string]: any;
  67485. };
  67486. extras?: Object;
  67487. }
  67488. /** @hidden */
  67489. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67490. name?: string;
  67491. }
  67492. /** @hidden */
  67493. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67494. bufferView: string;
  67495. byteOffset: number;
  67496. byteStride: number;
  67497. count: number;
  67498. type: string;
  67499. componentType: EComponentType;
  67500. max?: number[];
  67501. min?: number[];
  67502. name?: string;
  67503. }
  67504. /** @hidden */
  67505. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67506. buffer: string;
  67507. byteOffset: number;
  67508. byteLength: number;
  67509. byteStride: number;
  67510. target?: number;
  67511. }
  67512. /** @hidden */
  67513. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67514. uri: string;
  67515. byteLength?: number;
  67516. type?: string;
  67517. }
  67518. /** @hidden */
  67519. export interface IGLTFShader extends IGLTFChildRootProperty {
  67520. uri: string;
  67521. type: EShaderType;
  67522. }
  67523. /** @hidden */
  67524. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67525. attributes: string[];
  67526. fragmentShader: string;
  67527. vertexShader: string;
  67528. }
  67529. /** @hidden */
  67530. export interface IGLTFTechniqueParameter {
  67531. type: number;
  67532. count?: number;
  67533. semantic?: string;
  67534. node?: string;
  67535. value?: number | boolean | string | Array<any>;
  67536. source?: string;
  67537. babylonValue?: any;
  67538. }
  67539. /** @hidden */
  67540. export interface IGLTFTechniqueCommonProfile {
  67541. lightingModel: string;
  67542. texcoordBindings: Object;
  67543. parameters?: Array<any>;
  67544. }
  67545. /** @hidden */
  67546. export interface IGLTFTechniqueStatesFunctions {
  67547. blendColor?: number[];
  67548. blendEquationSeparate?: number[];
  67549. blendFuncSeparate?: number[];
  67550. colorMask: boolean[];
  67551. cullFace: number[];
  67552. }
  67553. /** @hidden */
  67554. export interface IGLTFTechniqueStates {
  67555. enable: number[];
  67556. functions: IGLTFTechniqueStatesFunctions;
  67557. }
  67558. /** @hidden */
  67559. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67560. parameters: {
  67561. [key: string]: IGLTFTechniqueParameter;
  67562. };
  67563. program: string;
  67564. attributes: {
  67565. [key: string]: string;
  67566. };
  67567. uniforms: {
  67568. [key: string]: string;
  67569. };
  67570. states: IGLTFTechniqueStates;
  67571. }
  67572. /** @hidden */
  67573. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67574. technique?: string;
  67575. values: string[];
  67576. }
  67577. /** @hidden */
  67578. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67579. attributes: {
  67580. [key: string]: string;
  67581. };
  67582. indices: string;
  67583. material: string;
  67584. mode?: number;
  67585. }
  67586. /** @hidden */
  67587. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67588. primitives: IGLTFMeshPrimitive[];
  67589. }
  67590. /** @hidden */
  67591. export interface IGLTFImage extends IGLTFChildRootProperty {
  67592. uri: string;
  67593. }
  67594. /** @hidden */
  67595. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67596. magFilter?: number;
  67597. minFilter?: number;
  67598. wrapS?: number;
  67599. wrapT?: number;
  67600. }
  67601. /** @hidden */
  67602. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67603. sampler: string;
  67604. source: string;
  67605. format?: ETextureFormat;
  67606. internalFormat?: ETextureFormat;
  67607. target?: number;
  67608. type?: number;
  67609. babylonTexture?: Texture;
  67610. }
  67611. /** @hidden */
  67612. export interface IGLTFAmbienLight {
  67613. color?: number[];
  67614. }
  67615. /** @hidden */
  67616. export interface IGLTFDirectionalLight {
  67617. color?: number[];
  67618. }
  67619. /** @hidden */
  67620. export interface IGLTFPointLight {
  67621. color?: number[];
  67622. constantAttenuation?: number;
  67623. linearAttenuation?: number;
  67624. quadraticAttenuation?: number;
  67625. }
  67626. /** @hidden */
  67627. export interface IGLTFSpotLight {
  67628. color?: number[];
  67629. constantAttenuation?: number;
  67630. fallOfAngle?: number;
  67631. fallOffExponent?: number;
  67632. linearAttenuation?: number;
  67633. quadraticAttenuation?: number;
  67634. }
  67635. /** @hidden */
  67636. export interface IGLTFLight extends IGLTFChildRootProperty {
  67637. type: string;
  67638. }
  67639. /** @hidden */
  67640. export interface IGLTFCameraOrthographic {
  67641. xmag: number;
  67642. ymag: number;
  67643. zfar: number;
  67644. znear: number;
  67645. }
  67646. /** @hidden */
  67647. export interface IGLTFCameraPerspective {
  67648. aspectRatio: number;
  67649. yfov: number;
  67650. zfar: number;
  67651. znear: number;
  67652. }
  67653. /** @hidden */
  67654. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67655. type: string;
  67656. }
  67657. /** @hidden */
  67658. export interface IGLTFAnimationChannelTarget {
  67659. id: string;
  67660. path: string;
  67661. }
  67662. /** @hidden */
  67663. export interface IGLTFAnimationChannel {
  67664. sampler: string;
  67665. target: IGLTFAnimationChannelTarget;
  67666. }
  67667. /** @hidden */
  67668. export interface IGLTFAnimationSampler {
  67669. input: string;
  67670. output: string;
  67671. interpolation?: string;
  67672. }
  67673. /** @hidden */
  67674. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67675. channels?: IGLTFAnimationChannel[];
  67676. parameters?: {
  67677. [key: string]: string;
  67678. };
  67679. samplers?: {
  67680. [key: string]: IGLTFAnimationSampler;
  67681. };
  67682. }
  67683. /** @hidden */
  67684. export interface IGLTFNodeInstanceSkin {
  67685. skeletons: string[];
  67686. skin: string;
  67687. meshes: string[];
  67688. }
  67689. /** @hidden */
  67690. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67691. bindShapeMatrix: number[];
  67692. inverseBindMatrices: string;
  67693. jointNames: string[];
  67694. babylonSkeleton?: Skeleton;
  67695. }
  67696. /** @hidden */
  67697. export interface IGLTFNode extends IGLTFChildRootProperty {
  67698. camera?: string;
  67699. children: string[];
  67700. skin?: string;
  67701. jointName?: string;
  67702. light?: string;
  67703. matrix: number[];
  67704. mesh?: string;
  67705. meshes?: string[];
  67706. rotation?: number[];
  67707. scale?: number[];
  67708. translation?: number[];
  67709. babylonNode?: Node;
  67710. }
  67711. /** @hidden */
  67712. export interface IGLTFScene extends IGLTFChildRootProperty {
  67713. nodes: string[];
  67714. }
  67715. /** @hidden */
  67716. export interface IGLTFRuntime {
  67717. extensions: {
  67718. [key: string]: any;
  67719. };
  67720. accessors: {
  67721. [key: string]: IGLTFAccessor;
  67722. };
  67723. buffers: {
  67724. [key: string]: IGLTFBuffer;
  67725. };
  67726. bufferViews: {
  67727. [key: string]: IGLTFBufferView;
  67728. };
  67729. meshes: {
  67730. [key: string]: IGLTFMesh;
  67731. };
  67732. lights: {
  67733. [key: string]: IGLTFLight;
  67734. };
  67735. cameras: {
  67736. [key: string]: IGLTFCamera;
  67737. };
  67738. nodes: {
  67739. [key: string]: IGLTFNode;
  67740. };
  67741. images: {
  67742. [key: string]: IGLTFImage;
  67743. };
  67744. textures: {
  67745. [key: string]: IGLTFTexture;
  67746. };
  67747. shaders: {
  67748. [key: string]: IGLTFShader;
  67749. };
  67750. programs: {
  67751. [key: string]: IGLTFProgram;
  67752. };
  67753. samplers: {
  67754. [key: string]: IGLTFSampler;
  67755. };
  67756. techniques: {
  67757. [key: string]: IGLTFTechnique;
  67758. };
  67759. materials: {
  67760. [key: string]: IGLTFMaterial;
  67761. };
  67762. animations: {
  67763. [key: string]: IGLTFAnimation;
  67764. };
  67765. skins: {
  67766. [key: string]: IGLTFSkins;
  67767. };
  67768. currentScene?: Object;
  67769. scenes: {
  67770. [key: string]: IGLTFScene;
  67771. };
  67772. extensionsUsed: string[];
  67773. extensionsRequired?: string[];
  67774. buffersCount: number;
  67775. shaderscount: number;
  67776. scene: Scene;
  67777. rootUrl: string;
  67778. loadedBufferCount: number;
  67779. loadedBufferViews: {
  67780. [name: string]: ArrayBufferView;
  67781. };
  67782. loadedShaderCount: number;
  67783. importOnlyMeshes: boolean;
  67784. importMeshesNames?: string[];
  67785. dummyNodes: Node[];
  67786. }
  67787. /** @hidden */
  67788. export interface INodeToRoot {
  67789. bone: Bone;
  67790. node: IGLTFNode;
  67791. id: string;
  67792. }
  67793. /** @hidden */
  67794. export interface IJointNode {
  67795. node: IGLTFNode;
  67796. id: string;
  67797. }
  67798. }
  67799. declare module BABYLON.GLTF1 {
  67800. /**
  67801. * Utils functions for GLTF
  67802. * @hidden
  67803. */
  67804. export class GLTFUtils {
  67805. /**
  67806. * Sets the given "parameter" matrix
  67807. * @param scene: the Scene object
  67808. * @param source: the source node where to pick the matrix
  67809. * @param parameter: the GLTF technique parameter
  67810. * @param uniformName: the name of the shader's uniform
  67811. * @param shaderMaterial: the shader material
  67812. */
  67813. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67814. /**
  67815. * Sets the given "parameter" matrix
  67816. * @param shaderMaterial: the shader material
  67817. * @param uniform: the name of the shader's uniform
  67818. * @param value: the value of the uniform
  67819. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67820. */
  67821. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67822. /**
  67823. * Returns the wrap mode of the texture
  67824. * @param mode: the mode value
  67825. */
  67826. static GetWrapMode(mode: number): number;
  67827. /**
  67828. * Returns the byte stride giving an accessor
  67829. * @param accessor: the GLTF accessor objet
  67830. */
  67831. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67832. /**
  67833. * Returns the texture filter mode giving a mode value
  67834. * @param mode: the filter mode value
  67835. */
  67836. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67837. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67838. /**
  67839. * Returns a buffer from its accessor
  67840. * @param gltfRuntime: the GLTF runtime
  67841. * @param accessor: the GLTF accessor
  67842. */
  67843. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67844. /**
  67845. * Decodes a buffer view into a string
  67846. * @param view: the buffer view
  67847. */
  67848. static DecodeBufferToText(view: ArrayBufferView): string;
  67849. /**
  67850. * Returns the default material of gltf. Related to
  67851. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67852. * @param scene: the Babylon.js scene
  67853. */
  67854. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67855. private static _DefaultMaterial;
  67856. }
  67857. }
  67858. declare module BABYLON.GLTF1 {
  67859. /**
  67860. * Implementation of the base glTF spec
  67861. * @hidden
  67862. */
  67863. export class GLTFLoaderBase {
  67864. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67865. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67866. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67867. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67868. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67869. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67870. }
  67871. /**
  67872. * glTF V1 Loader
  67873. * @hidden
  67874. */
  67875. export class GLTFLoader implements IGLTFLoader {
  67876. static Extensions: {
  67877. [name: string]: GLTFLoaderExtension;
  67878. };
  67879. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67880. state: Nullable<GLTFLoaderState>;
  67881. dispose(): void;
  67882. private _importMeshAsync;
  67883. /**
  67884. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67885. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67886. * @param scene the scene the meshes should be added to
  67887. * @param data gltf data containing information of the meshes in a loaded file
  67888. * @param rootUrl root url to load from
  67889. * @param onProgress event that fires when loading progress has occured
  67890. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67891. */
  67892. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67893. meshes: AbstractMesh[];
  67894. particleSystems: IParticleSystem[];
  67895. skeletons: Skeleton[];
  67896. animationGroups: AnimationGroup[];
  67897. }>;
  67898. private _loadAsync;
  67899. /**
  67900. * Imports all objects from a loaded gltf file and adds them to the scene
  67901. * @param scene the scene the objects should be added to
  67902. * @param data gltf data containing information of the meshes in a loaded file
  67903. * @param rootUrl root url to load from
  67904. * @param onProgress event that fires when loading progress has occured
  67905. * @returns a promise which completes when objects have been loaded to the scene
  67906. */
  67907. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67908. private _loadShadersAsync;
  67909. private _loadBuffersAsync;
  67910. private _createNodes;
  67911. }
  67912. /** @hidden */
  67913. export abstract class GLTFLoaderExtension {
  67914. private _name;
  67915. constructor(name: string);
  67916. readonly name: string;
  67917. /**
  67918. * Defines an override for loading the runtime
  67919. * Return true to stop further extensions from loading the runtime
  67920. */
  67921. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67922. /**
  67923. * Defines an onverride for creating gltf runtime
  67924. * Return true to stop further extensions from creating the runtime
  67925. */
  67926. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67927. /**
  67928. * Defines an override for loading buffers
  67929. * Return true to stop further extensions from loading this buffer
  67930. */
  67931. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67932. /**
  67933. * Defines an override for loading texture buffers
  67934. * Return true to stop further extensions from loading this texture data
  67935. */
  67936. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67937. /**
  67938. * Defines an override for creating textures
  67939. * Return true to stop further extensions from loading this texture
  67940. */
  67941. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67942. /**
  67943. * Defines an override for loading shader strings
  67944. * Return true to stop further extensions from loading this shader data
  67945. */
  67946. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67947. /**
  67948. * Defines an override for loading materials
  67949. * Return true to stop further extensions from loading this material
  67950. */
  67951. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67952. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67953. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67954. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67955. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67956. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67957. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67958. private static LoadTextureBufferAsync;
  67959. private static CreateTextureAsync;
  67960. private static ApplyExtensions;
  67961. }
  67962. }
  67963. declare module BABYLON.GLTF1 {
  67964. /** @hidden */
  67965. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67966. private _bin;
  67967. constructor();
  67968. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67969. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67970. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67971. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67972. }
  67973. }
  67974. declare module BABYLON.GLTF1 {
  67975. /** @hidden */
  67976. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67977. constructor();
  67978. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67979. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67980. private _loadTexture;
  67981. }
  67982. }
  67983. declare module BABYLON.GLTF2.Loader {
  67984. /**
  67985. * Loader interface with an index field.
  67986. */
  67987. export interface IArrayItem {
  67988. /**
  67989. * The index of this item in the array.
  67990. */
  67991. index: number;
  67992. }
  67993. /**
  67994. * Loader interface with additional members.
  67995. */
  67996. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67997. /** @hidden */
  67998. _data?: Promise<ArrayBufferView>;
  67999. /** @hidden */
  68000. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68001. }
  68002. /**
  68003. * Loader interface with additional members.
  68004. */
  68005. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68006. }
  68007. /** @hidden */
  68008. export interface _IAnimationSamplerData {
  68009. input: Float32Array;
  68010. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68011. output: Float32Array;
  68012. }
  68013. /**
  68014. * Loader interface with additional members.
  68015. */
  68016. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68017. /** @hidden */
  68018. _data?: Promise<_IAnimationSamplerData>;
  68019. }
  68020. /**
  68021. * Loader interface with additional members.
  68022. */
  68023. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68024. channels: IAnimationChannel[];
  68025. samplers: IAnimationSampler[];
  68026. /** @hidden */
  68027. _babylonAnimationGroup?: AnimationGroup;
  68028. }
  68029. /**
  68030. * Loader interface with additional members.
  68031. */
  68032. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68033. /** @hidden */
  68034. _data?: Promise<ArrayBufferView>;
  68035. }
  68036. /**
  68037. * Loader interface with additional members.
  68038. */
  68039. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68040. /** @hidden */
  68041. _data?: Promise<ArrayBufferView>;
  68042. /** @hidden */
  68043. _babylonBuffer?: Promise<Buffer>;
  68044. }
  68045. /**
  68046. * Loader interface with additional members.
  68047. */
  68048. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68049. }
  68050. /**
  68051. * Loader interface with additional members.
  68052. */
  68053. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68054. /** @hidden */
  68055. _data?: Promise<ArrayBufferView>;
  68056. }
  68057. /**
  68058. * Loader interface with additional members.
  68059. */
  68060. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68061. }
  68062. /**
  68063. * Loader interface with additional members.
  68064. */
  68065. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68066. }
  68067. /**
  68068. * Loader interface with additional members.
  68069. */
  68070. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68071. baseColorTexture?: ITextureInfo;
  68072. metallicRoughnessTexture?: ITextureInfo;
  68073. }
  68074. /**
  68075. * Loader interface with additional members.
  68076. */
  68077. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68078. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68079. normalTexture?: IMaterialNormalTextureInfo;
  68080. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68081. emissiveTexture?: ITextureInfo;
  68082. /** @hidden */
  68083. _data?: {
  68084. [babylonDrawMode: number]: {
  68085. babylonMaterial: Material;
  68086. babylonMeshes: AbstractMesh[];
  68087. promise: Promise<void>;
  68088. };
  68089. };
  68090. }
  68091. /**
  68092. * Loader interface with additional members.
  68093. */
  68094. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68095. primitives: IMeshPrimitive[];
  68096. }
  68097. /**
  68098. * Loader interface with additional members.
  68099. */
  68100. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68101. /** @hidden */
  68102. _instanceData?: {
  68103. babylonSourceMesh: Mesh;
  68104. promise: Promise<any>;
  68105. };
  68106. }
  68107. /**
  68108. * Loader interface with additional members.
  68109. */
  68110. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68111. /**
  68112. * The parent glTF node.
  68113. */
  68114. parent?: INode;
  68115. /** @hidden */
  68116. _babylonTransformNode?: TransformNode;
  68117. /** @hidden */
  68118. _primitiveBabylonMeshes?: AbstractMesh[];
  68119. /** @hidden */
  68120. _babylonBones?: Bone[];
  68121. /** @hidden */
  68122. _numMorphTargets?: number;
  68123. }
  68124. /** @hidden */
  68125. export interface _ISamplerData {
  68126. noMipMaps: boolean;
  68127. samplingMode: number;
  68128. wrapU: number;
  68129. wrapV: number;
  68130. }
  68131. /**
  68132. * Loader interface with additional members.
  68133. */
  68134. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68135. /** @hidden */
  68136. _data?: _ISamplerData;
  68137. }
  68138. /**
  68139. * Loader interface with additional members.
  68140. */
  68141. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68142. }
  68143. /**
  68144. * Loader interface with additional members.
  68145. */
  68146. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68147. /** @hidden */
  68148. _data?: {
  68149. babylonSkeleton: Skeleton;
  68150. promise: Promise<void>;
  68151. };
  68152. }
  68153. /**
  68154. * Loader interface with additional members.
  68155. */
  68156. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68157. }
  68158. /**
  68159. * Loader interface with additional members.
  68160. */
  68161. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68162. }
  68163. /**
  68164. * Loader interface with additional members.
  68165. */
  68166. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68167. accessors?: IAccessor[];
  68168. animations?: IAnimation[];
  68169. buffers?: IBuffer[];
  68170. bufferViews?: IBufferView[];
  68171. cameras?: ICamera[];
  68172. images?: IImage[];
  68173. materials?: IMaterial[];
  68174. meshes?: IMesh[];
  68175. nodes?: INode[];
  68176. samplers?: ISampler[];
  68177. scenes?: IScene[];
  68178. skins?: ISkin[];
  68179. textures?: ITexture[];
  68180. }
  68181. }
  68182. declare module BABYLON.GLTF2 {
  68183. /**
  68184. * Interface for a glTF loader extension.
  68185. */
  68186. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68187. /**
  68188. * Called after the loader state changes to LOADING.
  68189. */
  68190. onLoading?(): void;
  68191. /**
  68192. * Called after the loader state changes to READY.
  68193. */
  68194. onReady?(): void;
  68195. /**
  68196. * Define this method to modify the default behavior when loading scenes.
  68197. * @param context The context when loading the asset
  68198. * @param scene The glTF scene property
  68199. * @returns A promise that resolves when the load is complete or null if not handled
  68200. */
  68201. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68202. /**
  68203. * Define this method to modify the default behavior when loading nodes.
  68204. * @param context The context when loading the asset
  68205. * @param node The glTF node property
  68206. * @param assign A function called synchronously after parsing the glTF properties
  68207. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68208. */
  68209. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68210. /**
  68211. * Define this method to modify the default behavior when loading cameras.
  68212. * @param context The context when loading the asset
  68213. * @param camera The glTF camera property
  68214. * @param assign A function called synchronously after parsing the glTF properties
  68215. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68216. */
  68217. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68218. /**
  68219. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68220. * @param context The context when loading the asset
  68221. * @param primitive The glTF mesh primitive property
  68222. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68223. */
  68224. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68225. /**
  68226. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68227. * @param context The context when loading the asset
  68228. * @param name The mesh name when loading the asset
  68229. * @param node The glTF node when loading the asset
  68230. * @param mesh The glTF mesh when loading the asset
  68231. * @param primitive The glTF mesh primitive property
  68232. * @param assign A function called synchronously after parsing the glTF properties
  68233. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68234. */
  68235. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68236. /**
  68237. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68238. * @param context The context when loading the asset
  68239. * @param material The glTF material property
  68240. * @param assign A function called synchronously after parsing the glTF properties
  68241. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68242. */
  68243. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68244. /**
  68245. * Define this method to modify the default behavior when creating materials.
  68246. * @param context The context when loading the asset
  68247. * @param material The glTF material property
  68248. * @param babylonDrawMode The draw mode for the Babylon material
  68249. * @returns The Babylon material or null if not handled
  68250. */
  68251. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68252. /**
  68253. * Define this method to modify the default behavior when loading material properties.
  68254. * @param context The context when loading the asset
  68255. * @param material The glTF material property
  68256. * @param babylonMaterial The Babylon material
  68257. * @returns A promise that resolves when the load is complete or null if not handled
  68258. */
  68259. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68260. /**
  68261. * Define this method to modify the default behavior when loading texture infos.
  68262. * @param context The context when loading the asset
  68263. * @param textureInfo The glTF texture info property
  68264. * @param assign A function called synchronously after parsing the glTF properties
  68265. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68266. */
  68267. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68268. /**
  68269. * Define this method to modify the default behavior when loading animations.
  68270. * @param context The context when loading the asset
  68271. * @param animation The glTF animation property
  68272. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68273. */
  68274. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68275. /**
  68276. * @hidden Define this method to modify the default behavior when loading skins.
  68277. * @param context The context when loading the asset
  68278. * @param node The glTF node property
  68279. * @param skin The glTF skin property
  68280. * @returns A promise that resolves when the load is complete or null if not handled
  68281. */
  68282. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68283. /**
  68284. * @hidden Define this method to modify the default behavior when loading uris.
  68285. * @param context The context when loading the asset
  68286. * @param property The glTF property associated with the uri
  68287. * @param uri The uri to load
  68288. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68289. */
  68290. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68291. }
  68292. }
  68293. declare module BABYLON.GLTF2 {
  68294. /**
  68295. * Helper class for working with arrays when loading the glTF asset
  68296. */
  68297. export class ArrayItem {
  68298. /**
  68299. * Gets an item from the given array.
  68300. * @param context The context when loading the asset
  68301. * @param array The array to get the item from
  68302. * @param index The index to the array
  68303. * @returns The array item
  68304. */
  68305. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68306. /**
  68307. * Assign an `index` field to each item of the given array.
  68308. * @param array The array of items
  68309. */
  68310. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68311. }
  68312. /**
  68313. * The glTF 2.0 loader
  68314. */
  68315. export class GLTFLoader implements IGLTFLoader {
  68316. /** @hidden */
  68317. _completePromises: Promise<any>[];
  68318. private _disposed;
  68319. private _parent;
  68320. private _state;
  68321. private _extensions;
  68322. private _rootUrl;
  68323. private _fileName;
  68324. private _uniqueRootUrl;
  68325. private _gltf;
  68326. private _babylonScene;
  68327. private _rootBabylonMesh;
  68328. private _defaultBabylonMaterialData;
  68329. private _progressCallback?;
  68330. private _requests;
  68331. private static readonly _DefaultSampler;
  68332. private static _ExtensionNames;
  68333. private static _ExtensionFactories;
  68334. /**
  68335. * Registers a loader extension.
  68336. * @param name The name of the loader extension.
  68337. * @param factory The factory function that creates the loader extension.
  68338. */
  68339. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68340. /**
  68341. * Unregisters a loader extension.
  68342. * @param name The name of the loader extenion.
  68343. * @returns A boolean indicating whether the extension has been unregistered
  68344. */
  68345. static UnregisterExtension(name: string): boolean;
  68346. /**
  68347. * Gets the loader state.
  68348. */
  68349. readonly state: Nullable<GLTFLoaderState>;
  68350. /**
  68351. * The glTF object parsed from the JSON.
  68352. */
  68353. readonly gltf: IGLTF;
  68354. /**
  68355. * The Babylon scene when loading the asset.
  68356. */
  68357. readonly babylonScene: Scene;
  68358. /**
  68359. * The root Babylon mesh when loading the asset.
  68360. */
  68361. readonly rootBabylonMesh: Mesh;
  68362. /** @hidden */
  68363. constructor(parent: GLTFFileLoader);
  68364. /** @hidden */
  68365. dispose(): void;
  68366. /** @hidden */
  68367. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68368. meshes: AbstractMesh[];
  68369. particleSystems: IParticleSystem[];
  68370. skeletons: Skeleton[];
  68371. animationGroups: AnimationGroup[];
  68372. }>;
  68373. /** @hidden */
  68374. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68375. private _loadAsync;
  68376. private _loadData;
  68377. private _setupData;
  68378. private _loadExtensions;
  68379. private _checkExtensions;
  68380. private _setState;
  68381. private _createRootNode;
  68382. /**
  68383. * Loads a glTF scene.
  68384. * @param context The context when loading the asset
  68385. * @param scene The glTF scene property
  68386. * @returns A promise that resolves when the load is complete
  68387. */
  68388. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68389. private _forEachPrimitive;
  68390. private _getMeshes;
  68391. private _getSkeletons;
  68392. private _getAnimationGroups;
  68393. private _startAnimations;
  68394. /**
  68395. * Loads a glTF node.
  68396. * @param context The context when loading the asset
  68397. * @param node The glTF node property
  68398. * @param assign A function called synchronously after parsing the glTF properties
  68399. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68400. */
  68401. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68402. private _loadMeshAsync;
  68403. /**
  68404. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68405. * @param context The context when loading the asset
  68406. * @param name The mesh name when loading the asset
  68407. * @param node The glTF node when loading the asset
  68408. * @param mesh The glTF mesh when loading the asset
  68409. * @param primitive The glTF mesh primitive property
  68410. * @param assign A function called synchronously after parsing the glTF properties
  68411. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68412. */
  68413. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68414. private _loadVertexDataAsync;
  68415. private _createMorphTargets;
  68416. private _loadMorphTargetsAsync;
  68417. private _loadMorphTargetVertexDataAsync;
  68418. private static _LoadTransform;
  68419. private _loadSkinAsync;
  68420. private _loadBones;
  68421. private _loadBone;
  68422. private _loadSkinInverseBindMatricesDataAsync;
  68423. private _updateBoneMatrices;
  68424. private _getNodeMatrix;
  68425. /**
  68426. * Loads a glTF camera.
  68427. * @param context The context when loading the asset
  68428. * @param camera The glTF camera property
  68429. * @param assign A function called synchronously after parsing the glTF properties
  68430. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68431. */
  68432. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68433. private _loadAnimationsAsync;
  68434. /**
  68435. * Loads a glTF animation.
  68436. * @param context The context when loading the asset
  68437. * @param animation The glTF animation property
  68438. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68439. */
  68440. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68441. /**
  68442. * @hidden Loads a glTF animation channel.
  68443. * @param context The context when loading the asset
  68444. * @param animationContext The context of the animation when loading the asset
  68445. * @param animation The glTF animation property
  68446. * @param channel The glTF animation channel property
  68447. * @param babylonAnimationGroup The babylon animation group property
  68448. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68449. * @returns A void promise when the channel load is complete
  68450. */
  68451. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68452. private _loadAnimationSamplerAsync;
  68453. private _loadBufferAsync;
  68454. /**
  68455. * Loads a glTF buffer view.
  68456. * @param context The context when loading the asset
  68457. * @param bufferView The glTF buffer view property
  68458. * @returns A promise that resolves with the loaded data when the load is complete
  68459. */
  68460. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68461. private _loadAccessorAsync;
  68462. private _loadFloatAccessorAsync;
  68463. private _loadIndicesAccessorAsync;
  68464. private _loadVertexBufferViewAsync;
  68465. private _loadVertexAccessorAsync;
  68466. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68467. /** @hidden */
  68468. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68469. private _createDefaultMaterial;
  68470. /**
  68471. * Creates a Babylon material from a glTF material.
  68472. * @param context The context when loading the asset
  68473. * @param material The glTF material property
  68474. * @param babylonDrawMode The draw mode for the Babylon material
  68475. * @returns The Babylon material
  68476. */
  68477. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68478. /**
  68479. * Loads properties from a glTF material into a Babylon material.
  68480. * @param context The context when loading the asset
  68481. * @param material The glTF material property
  68482. * @param babylonMaterial The Babylon material
  68483. * @returns A promise that resolves when the load is complete
  68484. */
  68485. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68486. /**
  68487. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68488. * @param context The context when loading the asset
  68489. * @param material The glTF material property
  68490. * @param babylonMaterial The Babylon material
  68491. * @returns A promise that resolves when the load is complete
  68492. */
  68493. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68494. /**
  68495. * Loads the alpha properties from a glTF material into a Babylon material.
  68496. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68497. * @param context The context when loading the asset
  68498. * @param material The glTF material property
  68499. * @param babylonMaterial The Babylon material
  68500. */
  68501. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68502. /**
  68503. * Loads a glTF texture info.
  68504. * @param context The context when loading the asset
  68505. * @param textureInfo The glTF texture info property
  68506. * @param assign A function called synchronously after parsing the glTF properties
  68507. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68508. */
  68509. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68510. private _loadTextureAsync;
  68511. private _loadSampler;
  68512. /**
  68513. * Loads a glTF image.
  68514. * @param context The context when loading the asset
  68515. * @param image The glTF image property
  68516. * @returns A promise that resolves with the loaded data when the load is complete
  68517. */
  68518. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68519. /**
  68520. * Loads a glTF uri.
  68521. * @param context The context when loading the asset
  68522. * @param property The glTF property associated with the uri
  68523. * @param uri The base64 or relative uri
  68524. * @returns A promise that resolves with the loaded data when the load is complete
  68525. */
  68526. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68527. private _onProgress;
  68528. /**
  68529. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68530. * @param babylonObject the Babylon object with metadata
  68531. * @param pointer the JSON pointer
  68532. */
  68533. static AddPointerMetadata(babylonObject: {
  68534. metadata: any;
  68535. }, pointer: string): void;
  68536. private static _GetTextureWrapMode;
  68537. private static _GetTextureSamplingMode;
  68538. private static _GetTypedArrayConstructor;
  68539. private static _GetTypedArray;
  68540. private static _GetNumComponents;
  68541. private static _ValidateUri;
  68542. private static _GetDrawMode;
  68543. private _compileMaterialsAsync;
  68544. private _compileShadowGeneratorsAsync;
  68545. private _forEachExtensions;
  68546. private _applyExtensions;
  68547. private _extensionsOnLoading;
  68548. private _extensionsOnReady;
  68549. private _extensionsLoadSceneAsync;
  68550. private _extensionsLoadNodeAsync;
  68551. private _extensionsLoadCameraAsync;
  68552. private _extensionsLoadVertexDataAsync;
  68553. private _extensionsLoadMeshPrimitiveAsync;
  68554. private _extensionsLoadMaterialAsync;
  68555. private _extensionsCreateMaterial;
  68556. private _extensionsLoadMaterialPropertiesAsync;
  68557. private _extensionsLoadTextureInfoAsync;
  68558. private _extensionsLoadAnimationAsync;
  68559. private _extensionsLoadSkinAsync;
  68560. private _extensionsLoadUriAsync;
  68561. /**
  68562. * Helper method called by a loader extension to load an glTF extension.
  68563. * @param context The context when loading the asset
  68564. * @param property The glTF property to load the extension from
  68565. * @param extensionName The name of the extension to load
  68566. * @param actionAsync The action to run
  68567. * @returns The promise returned by actionAsync or null if the extension does not exist
  68568. */
  68569. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68570. /**
  68571. * Helper method called by a loader extension to load a glTF extra.
  68572. * @param context The context when loading the asset
  68573. * @param property The glTF property to load the extra from
  68574. * @param extensionName The name of the extension to load
  68575. * @param actionAsync The action to run
  68576. * @returns The promise returned by actionAsync or null if the extra does not exist
  68577. */
  68578. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68579. /**
  68580. * Increments the indentation level and logs a message.
  68581. * @param message The message to log
  68582. */
  68583. logOpen(message: string): void;
  68584. /**
  68585. * Decrements the indentation level.
  68586. */
  68587. logClose(): void;
  68588. /**
  68589. * Logs a message
  68590. * @param message The message to log
  68591. */
  68592. log(message: string): void;
  68593. /**
  68594. * Starts a performance counter.
  68595. * @param counterName The name of the performance counter
  68596. */
  68597. startPerformanceCounter(counterName: string): void;
  68598. /**
  68599. * Ends a performance counter.
  68600. * @param counterName The name of the performance counter
  68601. */
  68602. endPerformanceCounter(counterName: string): void;
  68603. }
  68604. }
  68605. declare module BABYLON.GLTF2.Loader.Extensions {
  68606. /**
  68607. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68608. */
  68609. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68610. /** The name of this extension. */
  68611. readonly name: string;
  68612. /** Defines whether this extension is enabled. */
  68613. enabled: boolean;
  68614. private _loader;
  68615. private _lights?;
  68616. /** @hidden */
  68617. constructor(loader: GLTFLoader);
  68618. /** @hidden */
  68619. dispose(): void;
  68620. /** @hidden */
  68621. onLoading(): void;
  68622. /** @hidden */
  68623. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68624. private _loadLightAsync;
  68625. }
  68626. }
  68627. declare module BABYLON.GLTF2.Loader.Extensions {
  68628. /**
  68629. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68630. */
  68631. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68632. /** The name of this extension. */
  68633. readonly name: string;
  68634. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68635. dracoCompression?: DracoCompression;
  68636. /** Defines whether this extension is enabled. */
  68637. enabled: boolean;
  68638. private _loader;
  68639. /** @hidden */
  68640. constructor(loader: GLTFLoader);
  68641. /** @hidden */
  68642. dispose(): void;
  68643. /** @hidden */
  68644. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68645. }
  68646. }
  68647. declare module BABYLON.GLTF2.Loader.Extensions {
  68648. /**
  68649. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68650. */
  68651. export class KHR_lights implements IGLTFLoaderExtension {
  68652. /** The name of this extension. */
  68653. readonly name: string;
  68654. /** Defines whether this extension is enabled. */
  68655. enabled: boolean;
  68656. private _loader;
  68657. private _lights?;
  68658. /** @hidden */
  68659. constructor(loader: GLTFLoader);
  68660. /** @hidden */
  68661. dispose(): void;
  68662. /** @hidden */
  68663. onLoading(): void;
  68664. /** @hidden */
  68665. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68666. }
  68667. }
  68668. declare module BABYLON.GLTF2.Loader.Extensions {
  68669. /**
  68670. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68671. */
  68672. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68673. /** The name of this extension. */
  68674. readonly name: string;
  68675. /** Defines whether this extension is enabled. */
  68676. enabled: boolean;
  68677. private _loader;
  68678. /** @hidden */
  68679. constructor(loader: GLTFLoader);
  68680. /** @hidden */
  68681. dispose(): void;
  68682. /** @hidden */
  68683. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68684. private _loadSpecularGlossinessPropertiesAsync;
  68685. }
  68686. }
  68687. declare module BABYLON.GLTF2.Loader.Extensions {
  68688. /**
  68689. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68690. */
  68691. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68692. /** The name of this extension. */
  68693. readonly name: string;
  68694. /** Defines whether this extension is enabled. */
  68695. enabled: boolean;
  68696. private _loader;
  68697. /** @hidden */
  68698. constructor(loader: GLTFLoader);
  68699. /** @hidden */
  68700. dispose(): void;
  68701. /** @hidden */
  68702. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68703. private _loadUnlitPropertiesAsync;
  68704. }
  68705. }
  68706. declare module BABYLON.GLTF2.Loader.Extensions {
  68707. /**
  68708. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68709. */
  68710. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68711. /** The name of this extension. */
  68712. readonly name: string;
  68713. /** Defines whether this extension is enabled. */
  68714. enabled: boolean;
  68715. private _loader;
  68716. /** @hidden */
  68717. constructor(loader: GLTFLoader);
  68718. /** @hidden */
  68719. dispose(): void;
  68720. /** @hidden */
  68721. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68722. }
  68723. }
  68724. declare module BABYLON.GLTF2.Loader.Extensions {
  68725. /**
  68726. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68727. */
  68728. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68729. /** The name of this extension. */
  68730. readonly name: string;
  68731. /** Defines whether this extension is enabled. */
  68732. enabled: boolean;
  68733. private _loader;
  68734. private _clips;
  68735. private _emitters;
  68736. /** @hidden */
  68737. constructor(loader: GLTFLoader);
  68738. /** @hidden */
  68739. dispose(): void;
  68740. /** @hidden */
  68741. onLoading(): void;
  68742. /** @hidden */
  68743. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68744. /** @hidden */
  68745. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68746. /** @hidden */
  68747. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68748. private _loadClipAsync;
  68749. private _loadEmitterAsync;
  68750. private _getEventAction;
  68751. private _loadAnimationEventAsync;
  68752. }
  68753. }
  68754. declare module BABYLON.GLTF2.Loader.Extensions {
  68755. /**
  68756. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68757. */
  68758. export class MSFT_lod implements IGLTFLoaderExtension {
  68759. /** The name of this extension. */
  68760. readonly name: string;
  68761. /** Defines whether this extension is enabled. */
  68762. enabled: boolean;
  68763. /**
  68764. * Maximum number of LODs to load, starting from the lowest LOD.
  68765. */
  68766. maxLODsToLoad: number;
  68767. /**
  68768. * Observable raised when all node LODs of one level are loaded.
  68769. * The event data is the index of the loaded LOD starting from zero.
  68770. * Dispose the loader to cancel the loading of the next level of LODs.
  68771. */
  68772. onNodeLODsLoadedObservable: Observable<number>;
  68773. /**
  68774. * Observable raised when all material LODs of one level are loaded.
  68775. * The event data is the index of the loaded LOD starting from zero.
  68776. * Dispose the loader to cancel the loading of the next level of LODs.
  68777. */
  68778. onMaterialLODsLoadedObservable: Observable<number>;
  68779. private _loader;
  68780. private _nodeIndexLOD;
  68781. private _nodeSignalLODs;
  68782. private _nodePromiseLODs;
  68783. private _materialIndexLOD;
  68784. private _materialSignalLODs;
  68785. private _materialPromiseLODs;
  68786. /** @hidden */
  68787. constructor(loader: GLTFLoader);
  68788. /** @hidden */
  68789. dispose(): void;
  68790. /** @hidden */
  68791. onReady(): void;
  68792. /** @hidden */
  68793. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68794. /** @hidden */
  68795. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68796. /** @hidden */
  68797. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68798. /**
  68799. * Gets an array of LOD properties from lowest to highest.
  68800. */
  68801. private _getLODs;
  68802. private _disposeUnusedMaterials;
  68803. }
  68804. }
  68805. declare module BABYLON.GLTF2.Loader.Extensions {
  68806. /** @hidden */
  68807. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68808. readonly name: string;
  68809. enabled: boolean;
  68810. private _loader;
  68811. constructor(loader: GLTFLoader);
  68812. dispose(): void;
  68813. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68814. }
  68815. }
  68816. declare module BABYLON.GLTF2.Loader.Extensions {
  68817. /** @hidden */
  68818. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68819. readonly name: string;
  68820. enabled: boolean;
  68821. private _loader;
  68822. constructor(loader: GLTFLoader);
  68823. dispose(): void;
  68824. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68825. }
  68826. }
  68827. declare module BABYLON.GLTF2.Loader.Extensions {
  68828. /**
  68829. * Store glTF extras (if present) in BJS objects' metadata
  68830. */
  68831. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68832. /** The name of this extension. */
  68833. readonly name: string;
  68834. /** Defines whether this extension is enabled. */
  68835. enabled: boolean;
  68836. private _loader;
  68837. private _assignExtras;
  68838. /** @hidden */
  68839. constructor(loader: GLTFLoader);
  68840. /** @hidden */
  68841. dispose(): void;
  68842. /** @hidden */
  68843. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68844. /** @hidden */
  68845. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68846. /** @hidden */
  68847. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68848. }
  68849. }
  68850. declare module BABYLON {
  68851. /**
  68852. * Class reading and parsing the MTL file bundled with the obj file.
  68853. */
  68854. export class MTLFileLoader {
  68855. /**
  68856. * All material loaded from the mtl will be set here
  68857. */
  68858. materials: StandardMaterial[];
  68859. /**
  68860. * This function will read the mtl file and create each material described inside
  68861. * This function could be improve by adding :
  68862. * -some component missing (Ni, Tf...)
  68863. * -including the specific options available
  68864. *
  68865. * @param scene defines the scene the material will be created in
  68866. * @param data defines the mtl data to parse
  68867. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68868. */
  68869. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68870. /**
  68871. * Gets the texture for the material.
  68872. *
  68873. * If the material is imported from input file,
  68874. * We sanitize the url to ensure it takes the textre from aside the material.
  68875. *
  68876. * @param rootUrl The root url to load from
  68877. * @param value The value stored in the mtl
  68878. * @return The Texture
  68879. */
  68880. private static _getTexture;
  68881. }
  68882. /**
  68883. * Options for loading OBJ/MTL files
  68884. */
  68885. type MeshLoadOptions = {
  68886. /**
  68887. * Defines if UVs are optimized by default during load.
  68888. */
  68889. OptimizeWithUV: boolean;
  68890. /**
  68891. * Defines custom scaling of UV coordinates of loaded meshes.
  68892. */
  68893. UVScaling: Vector2;
  68894. /**
  68895. * Invert model on y-axis (does a model scaling inversion)
  68896. */
  68897. InvertY: boolean;
  68898. /**
  68899. * Invert Y-Axis of referenced textures on load
  68900. */
  68901. InvertTextureY: boolean;
  68902. /**
  68903. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68904. */
  68905. ImportVertexColors: boolean;
  68906. /**
  68907. * Compute the normals for the model, even if normals are present in the file.
  68908. */
  68909. ComputeNormals: boolean;
  68910. /**
  68911. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68912. */
  68913. SkipMaterials: boolean;
  68914. /**
  68915. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68916. */
  68917. MaterialLoadingFailsSilently: boolean;
  68918. };
  68919. /**
  68920. * OBJ file type loader.
  68921. * This is a babylon scene loader plugin.
  68922. */
  68923. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68924. /**
  68925. * Defines if UVs are optimized by default during load.
  68926. */
  68927. static OPTIMIZE_WITH_UV: boolean;
  68928. /**
  68929. * Invert model on y-axis (does a model scaling inversion)
  68930. */
  68931. static INVERT_Y: boolean;
  68932. /**
  68933. * Invert Y-Axis of referenced textures on load
  68934. */
  68935. static INVERT_TEXTURE_Y: boolean;
  68936. /**
  68937. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68938. */
  68939. static IMPORT_VERTEX_COLORS: boolean;
  68940. /**
  68941. * Compute the normals for the model, even if normals are present in the file.
  68942. */
  68943. static COMPUTE_NORMALS: boolean;
  68944. /**
  68945. * Defines custom scaling of UV coordinates of loaded meshes.
  68946. */
  68947. static UV_SCALING: Vector2;
  68948. /**
  68949. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68950. */
  68951. static SKIP_MATERIALS: boolean;
  68952. /**
  68953. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68954. *
  68955. * Defaults to true for backwards compatibility.
  68956. */
  68957. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68958. /**
  68959. * Defines the name of the plugin.
  68960. */
  68961. name: string;
  68962. /**
  68963. * Defines the extension the plugin is able to load.
  68964. */
  68965. extensions: string;
  68966. /** @hidden */
  68967. obj: RegExp;
  68968. /** @hidden */
  68969. group: RegExp;
  68970. /** @hidden */
  68971. mtllib: RegExp;
  68972. /** @hidden */
  68973. usemtl: RegExp;
  68974. /** @hidden */
  68975. smooth: RegExp;
  68976. /** @hidden */
  68977. vertexPattern: RegExp;
  68978. /** @hidden */
  68979. normalPattern: RegExp;
  68980. /** @hidden */
  68981. uvPattern: RegExp;
  68982. /** @hidden */
  68983. facePattern1: RegExp;
  68984. /** @hidden */
  68985. facePattern2: RegExp;
  68986. /** @hidden */
  68987. facePattern3: RegExp;
  68988. /** @hidden */
  68989. facePattern4: RegExp;
  68990. /** @hidden */
  68991. facePattern5: RegExp;
  68992. private _meshLoadOptions;
  68993. /**
  68994. * Creates loader for .OBJ files
  68995. *
  68996. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68997. */
  68998. constructor(meshLoadOptions?: MeshLoadOptions);
  68999. private static readonly currentMeshLoadOptions;
  69000. /**
  69001. * Calls synchronously the MTL file attached to this obj.
  69002. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69003. * Without this function materials are not displayed in the first frame (but displayed after).
  69004. * In consequence it is impossible to get material information in your HTML file
  69005. *
  69006. * @param url The URL of the MTL file
  69007. * @param rootUrl
  69008. * @param onSuccess Callback function to be called when the MTL file is loaded
  69009. * @private
  69010. */
  69011. private _loadMTL;
  69012. /**
  69013. * Instantiates a OBJ file loader plugin.
  69014. * @returns the created plugin
  69015. */
  69016. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69017. /**
  69018. * If the data string can be loaded directly.
  69019. *
  69020. * @param data string containing the file data
  69021. * @returns if the data can be loaded directly
  69022. */
  69023. canDirectLoad(data: string): boolean;
  69024. /**
  69025. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69026. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69027. * @param scene the scene the meshes should be added to
  69028. * @param data the OBJ data to load
  69029. * @param rootUrl root url to load from
  69030. * @param onProgress event that fires when loading progress has occured
  69031. * @param fileName Defines the name of the file to load
  69032. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69033. */
  69034. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69035. meshes: AbstractMesh[];
  69036. particleSystems: IParticleSystem[];
  69037. skeletons: Skeleton[];
  69038. animationGroups: AnimationGroup[];
  69039. }>;
  69040. /**
  69041. * Imports all objects from the loaded OBJ data and adds them to the scene
  69042. * @param scene the scene the objects should be added to
  69043. * @param data the OBJ data to load
  69044. * @param rootUrl root url to load from
  69045. * @param onProgress event that fires when loading progress has occured
  69046. * @param fileName Defines the name of the file to load
  69047. * @returns a promise which completes when objects have been loaded to the scene
  69048. */
  69049. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69050. /**
  69051. * Load into an asset container.
  69052. * @param scene The scene to load into
  69053. * @param data The data to import
  69054. * @param rootUrl The root url for scene and resources
  69055. * @param onProgress The callback when the load progresses
  69056. * @param fileName Defines the name of the file to load
  69057. * @returns The loaded asset container
  69058. */
  69059. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69060. /**
  69061. * Read the OBJ file and create an Array of meshes.
  69062. * Each mesh contains all information given by the OBJ and the MTL file.
  69063. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69064. *
  69065. * @param meshesNames
  69066. * @param scene Scene The scene where are displayed the data
  69067. * @param data String The content of the obj file
  69068. * @param rootUrl String The path to the folder
  69069. * @returns Array<AbstractMesh>
  69070. * @private
  69071. */
  69072. private _parseSolid;
  69073. }
  69074. }
  69075. declare module BABYLON {
  69076. /**
  69077. * STL file type loader.
  69078. * This is a babylon scene loader plugin.
  69079. */
  69080. export class STLFileLoader implements ISceneLoaderPlugin {
  69081. /** @hidden */
  69082. solidPattern: RegExp;
  69083. /** @hidden */
  69084. facetsPattern: RegExp;
  69085. /** @hidden */
  69086. normalPattern: RegExp;
  69087. /** @hidden */
  69088. vertexPattern: RegExp;
  69089. /**
  69090. * Defines the name of the plugin.
  69091. */
  69092. name: string;
  69093. /**
  69094. * Defines the extensions the stl loader is able to load.
  69095. * force data to come in as an ArrayBuffer
  69096. * we'll convert to string if it looks like it's an ASCII .stl
  69097. */
  69098. extensions: ISceneLoaderPluginExtensions;
  69099. /**
  69100. * Import meshes into a scene.
  69101. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69102. * @param scene The scene to import into
  69103. * @param data The data to import
  69104. * @param rootUrl The root url for scene and resources
  69105. * @param meshes The meshes array to import into
  69106. * @param particleSystems The particle systems array to import into
  69107. * @param skeletons The skeletons array to import into
  69108. * @param onError The callback when import fails
  69109. * @returns True if successful or false otherwise
  69110. */
  69111. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69112. /**
  69113. * Load into a scene.
  69114. * @param scene The scene to load into
  69115. * @param data The data to import
  69116. * @param rootUrl The root url for scene and resources
  69117. * @param onError The callback when import fails
  69118. * @returns true if successful or false otherwise
  69119. */
  69120. load(scene: Scene, data: any, rootUrl: string): boolean;
  69121. /**
  69122. * Load into an asset container.
  69123. * @param scene The scene to load into
  69124. * @param data The data to import
  69125. * @param rootUrl The root url for scene and resources
  69126. * @param onError The callback when import fails
  69127. * @returns The loaded asset container
  69128. */
  69129. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69130. private _isBinary;
  69131. private _parseBinary;
  69132. private _parseASCII;
  69133. }
  69134. }
  69135. declare module BABYLON {
  69136. /**
  69137. * Class for generating OBJ data from a Babylon scene.
  69138. */
  69139. export class OBJExport {
  69140. /**
  69141. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69142. * @param mesh defines the list of meshes to serialize
  69143. * @param materials defines if materials should be exported
  69144. * @param matlibname defines the name of the associated mtl file
  69145. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69146. * @returns the OBJ content
  69147. */
  69148. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69149. /**
  69150. * Exports the material(s) of a mesh in .MTL file format (text)
  69151. * @param mesh defines the mesh to extract the material from
  69152. * @returns the mtl content
  69153. */
  69154. static MTL(mesh: Mesh): string;
  69155. }
  69156. }
  69157. declare module BABYLON {
  69158. /** @hidden */
  69159. export var __IGLTFExporterExtension: number;
  69160. /**
  69161. * Interface for extending the exporter
  69162. * @hidden
  69163. */
  69164. export interface IGLTFExporterExtension {
  69165. /**
  69166. * The name of this extension
  69167. */
  69168. readonly name: string;
  69169. /**
  69170. * Defines whether this extension is enabled
  69171. */
  69172. enabled: boolean;
  69173. /**
  69174. * Defines whether this extension is required
  69175. */
  69176. required: boolean;
  69177. }
  69178. }
  69179. declare module BABYLON.GLTF2.Exporter {
  69180. /** @hidden */
  69181. export var __IGLTFExporterExtensionV2: number;
  69182. /**
  69183. * Interface for a glTF exporter extension
  69184. * @hidden
  69185. */
  69186. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69187. /**
  69188. * Define this method to modify the default behavior before exporting a texture
  69189. * @param context The context when loading the asset
  69190. * @param babylonTexture The glTF texture info property
  69191. * @param mimeType The mime-type of the generated image
  69192. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69193. */
  69194. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69195. /**
  69196. * Define this method to modify the default behavior when exporting texture info
  69197. * @param context The context when loading the asset
  69198. * @param meshPrimitive glTF mesh primitive
  69199. * @param babylonSubMesh Babylon submesh
  69200. * @param binaryWriter glTF serializer binary writer instance
  69201. * @returns nullable IMeshPrimitive promise
  69202. */
  69203. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69204. /**
  69205. * Define this method to modify the default behavior when exporting a node
  69206. * @param context The context when exporting the node
  69207. * @param node glTF node
  69208. * @param babylonNode BabylonJS node
  69209. * @returns nullable INode promise
  69210. */
  69211. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69212. /**
  69213. * Called after the exporter state changes to EXPORTING
  69214. */
  69215. onExporting?(): void;
  69216. }
  69217. }
  69218. declare module BABYLON.GLTF2.Exporter {
  69219. /**
  69220. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69221. * @hidden
  69222. */
  69223. export class _GLTFMaterialExporter {
  69224. /**
  69225. * Represents the dielectric specular values for R, G and B
  69226. */
  69227. private static readonly _DielectricSpecular;
  69228. /**
  69229. * Allows the maximum specular power to be defined for material calculations
  69230. */
  69231. private static readonly _MaxSpecularPower;
  69232. /**
  69233. * Mapping to store textures
  69234. */
  69235. private _textureMap;
  69236. /**
  69237. * Numeric tolerance value
  69238. */
  69239. private static readonly _Epsilon;
  69240. /**
  69241. * Reference to the glTF Exporter
  69242. */
  69243. private _exporter;
  69244. constructor(exporter: _Exporter);
  69245. /**
  69246. * Specifies if two colors are approximately equal in value
  69247. * @param color1 first color to compare to
  69248. * @param color2 second color to compare to
  69249. * @param epsilon threshold value
  69250. */
  69251. private static FuzzyEquals;
  69252. /**
  69253. * Gets the materials from a Babylon scene and converts them to glTF materials
  69254. * @param scene babylonjs scene
  69255. * @param mimeType texture mime type
  69256. * @param images array of images
  69257. * @param textures array of textures
  69258. * @param materials array of materials
  69259. * @param imageData mapping of texture names to base64 textures
  69260. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69261. */
  69262. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69263. /**
  69264. * Makes a copy of the glTF material without the texture parameters
  69265. * @param originalMaterial original glTF material
  69266. * @returns glTF material without texture parameters
  69267. */
  69268. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69269. /**
  69270. * Specifies if the material has any texture parameters present
  69271. * @param material glTF Material
  69272. * @returns boolean specifying if texture parameters are present
  69273. */
  69274. _hasTexturesPresent(material: IMaterial): boolean;
  69275. /**
  69276. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69277. * @param babylonStandardMaterial
  69278. * @returns glTF Metallic Roughness Material representation
  69279. */
  69280. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69281. /**
  69282. * Computes the metallic factor
  69283. * @param diffuse diffused value
  69284. * @param specular specular value
  69285. * @param oneMinusSpecularStrength one minus the specular strength
  69286. * @returns metallic value
  69287. */
  69288. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69289. /**
  69290. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69291. * @param glTFMaterial glTF material
  69292. * @param babylonMaterial Babylon material
  69293. */
  69294. private static _SetAlphaMode;
  69295. /**
  69296. * Converts a Babylon Standard Material to a glTF Material
  69297. * @param babylonStandardMaterial BJS Standard Material
  69298. * @param mimeType mime type to use for the textures
  69299. * @param images array of glTF image interfaces
  69300. * @param textures array of glTF texture interfaces
  69301. * @param materials array of glTF material interfaces
  69302. * @param imageData map of image file name to data
  69303. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69304. */
  69305. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69306. /**
  69307. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69308. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69309. * @param mimeType mime type to use for the textures
  69310. * @param images array of glTF image interfaces
  69311. * @param textures array of glTF texture interfaces
  69312. * @param materials array of glTF material interfaces
  69313. * @param imageData map of image file name to data
  69314. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69315. */
  69316. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69317. /**
  69318. * Converts an image typed array buffer to a base64 image
  69319. * @param buffer typed array buffer
  69320. * @param width width of the image
  69321. * @param height height of the image
  69322. * @param mimeType mimetype of the image
  69323. * @returns base64 image string
  69324. */
  69325. private _createBase64FromCanvasAsync;
  69326. /**
  69327. * Generates a white texture based on the specified width and height
  69328. * @param width width of the texture in pixels
  69329. * @param height height of the texture in pixels
  69330. * @param scene babylonjs scene
  69331. * @returns white texture
  69332. */
  69333. private _createWhiteTexture;
  69334. /**
  69335. * 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
  69336. * @param texture1 first texture to resize
  69337. * @param texture2 second texture to resize
  69338. * @param scene babylonjs scene
  69339. * @returns resized textures or null
  69340. */
  69341. private _resizeTexturesToSameDimensions;
  69342. /**
  69343. * Converts an array of pixels to a Float32Array
  69344. * Throws an error if the pixel format is not supported
  69345. * @param pixels - array buffer containing pixel values
  69346. * @returns Float32 of pixels
  69347. */
  69348. private _convertPixelArrayToFloat32;
  69349. /**
  69350. * Convert Specular Glossiness Textures to Metallic Roughness
  69351. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69352. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69353. * @param diffuseTexture texture used to store diffuse information
  69354. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69355. * @param factors specular glossiness material factors
  69356. * @param mimeType the mime type to use for the texture
  69357. * @returns pbr metallic roughness interface or null
  69358. */
  69359. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69360. /**
  69361. * Converts specular glossiness material properties to metallic roughness
  69362. * @param specularGlossiness interface with specular glossiness material properties
  69363. * @returns interface with metallic roughness material properties
  69364. */
  69365. private _convertSpecularGlossinessToMetallicRoughness;
  69366. /**
  69367. * Calculates the surface reflectance, independent of lighting conditions
  69368. * @param color Color source to calculate brightness from
  69369. * @returns number representing the perceived brightness, or zero if color is undefined
  69370. */
  69371. private _getPerceivedBrightness;
  69372. /**
  69373. * Returns the maximum color component value
  69374. * @param color
  69375. * @returns maximum color component value, or zero if color is null or undefined
  69376. */
  69377. private _getMaxComponent;
  69378. /**
  69379. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69380. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69381. * @param mimeType mime type to use for the textures
  69382. * @param images array of glTF image interfaces
  69383. * @param textures array of glTF texture interfaces
  69384. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69385. * @param imageData map of image file name to data
  69386. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69387. * @returns glTF PBR Metallic Roughness factors
  69388. */
  69389. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69390. private _getGLTFTextureSampler;
  69391. private _getGLTFTextureWrapMode;
  69392. private _getGLTFTextureWrapModesSampler;
  69393. /**
  69394. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69395. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69396. * @param mimeType mime type to use for the textures
  69397. * @param images array of glTF image interfaces
  69398. * @param textures array of glTF texture interfaces
  69399. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69400. * @param imageData map of image file name to data
  69401. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69402. * @returns glTF PBR Metallic Roughness factors
  69403. */
  69404. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69405. /**
  69406. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69407. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69408. * @param mimeType mime type to use for the textures
  69409. * @param images array of glTF image interfaces
  69410. * @param textures array of glTF texture interfaces
  69411. * @param materials array of glTF material interfaces
  69412. * @param imageData map of image file name to data
  69413. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69414. */
  69415. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69416. private setMetallicRoughnessPbrMaterial;
  69417. private getPixelsFromTexture;
  69418. /**
  69419. * Extracts a texture from a Babylon texture into file data and glTF data
  69420. * @param babylonTexture Babylon texture to extract
  69421. * @param mimeType Mime Type of the babylonTexture
  69422. * @return glTF texture info, or null if the texture format is not supported
  69423. */
  69424. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69425. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69426. /**
  69427. * Builds a texture from base64 string
  69428. * @param base64Texture base64 texture string
  69429. * @param baseTextureName Name to use for the texture
  69430. * @param mimeType image mime type for the texture
  69431. * @param images array of images
  69432. * @param textures array of textures
  69433. * @param imageData map of image data
  69434. * @returns glTF texture info, or null if the texture format is not supported
  69435. */
  69436. private _getTextureInfoFromBase64;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * Class for holding and downloading glTF file data
  69442. */
  69443. export class GLTFData {
  69444. /**
  69445. * Object which contains the file name as the key and its data as the value
  69446. */
  69447. glTFFiles: {
  69448. [fileName: string]: string | Blob;
  69449. };
  69450. /**
  69451. * Initializes the glTF file object
  69452. */
  69453. constructor();
  69454. /**
  69455. * Downloads the glTF data as files based on their names and data
  69456. */
  69457. downloadFiles(): void;
  69458. }
  69459. }
  69460. declare module BABYLON {
  69461. /**
  69462. * Holds a collection of exporter options and parameters
  69463. */
  69464. export interface IExportOptions {
  69465. /**
  69466. * Function which indicates whether a babylon node should be exported or not
  69467. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69468. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69469. */
  69470. shouldExportNode?(node: Node): boolean;
  69471. /**
  69472. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69473. * @param metadata source metadata to read from
  69474. * @returns the data to store to glTF node extras
  69475. */
  69476. metadataSelector?(metadata: any): any;
  69477. /**
  69478. * The sample rate to bake animation curves
  69479. */
  69480. animationSampleRate?: number;
  69481. /**
  69482. * Begin serialization without waiting for the scene to be ready
  69483. */
  69484. exportWithoutWaitingForScene?: boolean;
  69485. }
  69486. /**
  69487. * Class for generating glTF data from a Babylon scene.
  69488. */
  69489. export class GLTF2Export {
  69490. /**
  69491. * Exports the geometry of the scene to .gltf file format asynchronously
  69492. * @param scene Babylon scene with scene hierarchy information
  69493. * @param filePrefix File prefix to use when generating the glTF file
  69494. * @param options Exporter options
  69495. * @returns Returns an object with a .gltf file and associates texture names
  69496. * as keys and their data and paths as values
  69497. */
  69498. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69499. private static _PreExportAsync;
  69500. private static _PostExportAsync;
  69501. /**
  69502. * Exports the geometry of the scene to .glb file format asychronously
  69503. * @param scene Babylon scene with scene hierarchy information
  69504. * @param filePrefix File prefix to use when generating glb file
  69505. * @param options Exporter options
  69506. * @returns Returns an object with a .glb filename as key and data as value
  69507. */
  69508. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69509. }
  69510. }
  69511. declare module BABYLON.GLTF2.Exporter {
  69512. /**
  69513. * @hidden
  69514. */
  69515. export class _GLTFUtilities {
  69516. /**
  69517. * Creates a buffer view based on the supplied arguments
  69518. * @param bufferIndex index value of the specified buffer
  69519. * @param byteOffset byte offset value
  69520. * @param byteLength byte length of the bufferView
  69521. * @param byteStride byte distance between conequential elements
  69522. * @param name name of the buffer view
  69523. * @returns bufferView for glTF
  69524. */
  69525. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69526. /**
  69527. * Creates an accessor based on the supplied arguments
  69528. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69529. * @param name The name of the accessor
  69530. * @param type The type of the accessor
  69531. * @param componentType The datatype of components in the attribute
  69532. * @param count The number of attributes referenced by this accessor
  69533. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69534. * @param min Minimum value of each component in this attribute
  69535. * @param max Maximum value of each component in this attribute
  69536. * @returns accessor for glTF
  69537. */
  69538. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69539. /**
  69540. * Calculates the minimum and maximum values of an array of position floats
  69541. * @param positions Positions array of a mesh
  69542. * @param vertexStart Starting vertex offset to calculate min and max values
  69543. * @param vertexCount Number of vertices to check for min and max values
  69544. * @returns min number array and max number array
  69545. */
  69546. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69547. min: number[];
  69548. max: number[];
  69549. };
  69550. /**
  69551. * Converts a new right-handed Vector3
  69552. * @param vector vector3 array
  69553. * @returns right-handed Vector3
  69554. */
  69555. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69556. /**
  69557. * Converts a Vector3 to right-handed
  69558. * @param vector Vector3 to convert to right-handed
  69559. */
  69560. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69561. /**
  69562. * Converts a three element number array to right-handed
  69563. * @param vector number array to convert to right-handed
  69564. */
  69565. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69566. /**
  69567. * Converts a new right-handed Vector3
  69568. * @param vector vector3 array
  69569. * @returns right-handed Vector3
  69570. */
  69571. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69572. /**
  69573. * Converts a Vector3 to right-handed
  69574. * @param vector Vector3 to convert to right-handed
  69575. */
  69576. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69577. /**
  69578. * Converts a three element number array to right-handed
  69579. * @param vector number array to convert to right-handed
  69580. */
  69581. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69582. /**
  69583. * Converts a Vector4 to right-handed
  69584. * @param vector Vector4 to convert to right-handed
  69585. */
  69586. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69587. /**
  69588. * Converts a Vector4 to right-handed
  69589. * @param vector Vector4 to convert to right-handed
  69590. */
  69591. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69592. /**
  69593. * Converts a Quaternion to right-handed
  69594. * @param quaternion Source quaternion to convert to right-handed
  69595. */
  69596. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69597. /**
  69598. * Converts a Quaternion to right-handed
  69599. * @param quaternion Source quaternion to convert to right-handed
  69600. */
  69601. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69602. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69603. }
  69604. }
  69605. declare module BABYLON.GLTF2.Exporter {
  69606. /**
  69607. * Converts Babylon Scene into glTF 2.0.
  69608. * @hidden
  69609. */
  69610. export class _Exporter {
  69611. /**
  69612. * Stores the glTF to export
  69613. */
  69614. _glTF: IGLTF;
  69615. /**
  69616. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69617. */
  69618. _bufferViews: IBufferView[];
  69619. /**
  69620. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69621. */
  69622. _accessors: IAccessor[];
  69623. /**
  69624. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69625. */
  69626. private _nodes;
  69627. /**
  69628. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69629. */
  69630. private _scenes;
  69631. /**
  69632. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69633. */
  69634. private _meshes;
  69635. /**
  69636. * Stores all the generated material information, which represents the appearance of each primitive
  69637. */
  69638. _materials: IMaterial[];
  69639. _materialMap: {
  69640. [materialID: number]: number;
  69641. };
  69642. /**
  69643. * Stores all the generated texture information, which is referenced by glTF materials
  69644. */
  69645. _textures: ITexture[];
  69646. /**
  69647. * Stores all the generated image information, which is referenced by glTF textures
  69648. */
  69649. _images: IImage[];
  69650. /**
  69651. * Stores all the texture samplers
  69652. */
  69653. _samplers: ISampler[];
  69654. /**
  69655. * Stores all the generated animation samplers, which is referenced by glTF animations
  69656. */
  69657. /**
  69658. * Stores the animations for glTF models
  69659. */
  69660. private _animations;
  69661. /**
  69662. * Stores the total amount of bytes stored in the glTF buffer
  69663. */
  69664. private _totalByteLength;
  69665. /**
  69666. * Stores a reference to the Babylon scene containing the source geometry and material information
  69667. */
  69668. _babylonScene: Scene;
  69669. /**
  69670. * Stores a map of the image data, where the key is the file name and the value
  69671. * is the image data
  69672. */
  69673. _imageData: {
  69674. [fileName: string]: {
  69675. data: Uint8Array;
  69676. mimeType: ImageMimeType;
  69677. };
  69678. };
  69679. /**
  69680. * Stores a map of the unique id of a node to its index in the node array
  69681. */
  69682. private _nodeMap;
  69683. /**
  69684. * Specifies if the Babylon scene should be converted to right-handed on export
  69685. */
  69686. _convertToRightHandedSystem: boolean;
  69687. /**
  69688. * Baked animation sample rate
  69689. */
  69690. private _animationSampleRate;
  69691. private _options;
  69692. private _localEngine;
  69693. _glTFMaterialExporter: _GLTFMaterialExporter;
  69694. private _extensions;
  69695. private static _ExtensionNames;
  69696. private static _ExtensionFactories;
  69697. private _applyExtensions;
  69698. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69699. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69700. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69701. private _forEachExtensions;
  69702. private _extensionsOnExporting;
  69703. /**
  69704. * Load glTF serializer extensions
  69705. */
  69706. private _loadExtensions;
  69707. /**
  69708. * Creates a glTF Exporter instance, which can accept optional exporter options
  69709. * @param babylonScene Babylon scene object
  69710. * @param options Options to modify the behavior of the exporter
  69711. */
  69712. constructor(babylonScene: Scene, options?: IExportOptions);
  69713. /**
  69714. * Registers a glTF exporter extension
  69715. * @param name Name of the extension to export
  69716. * @param factory The factory function that creates the exporter extension
  69717. */
  69718. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69719. /**
  69720. * Un-registers an exporter extension
  69721. * @param name The name fo the exporter extension
  69722. * @returns A boolean indicating whether the extension has been un-registered
  69723. */
  69724. static UnregisterExtension(name: string): boolean;
  69725. /**
  69726. * Lazy load a local engine with premultiplied alpha set to false
  69727. */
  69728. _getLocalEngine(): Engine;
  69729. private reorderIndicesBasedOnPrimitiveMode;
  69730. /**
  69731. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69732. * clock-wise during export to glTF
  69733. * @param submesh BabylonJS submesh
  69734. * @param primitiveMode Primitive mode of the mesh
  69735. * @param sideOrientation the winding order of the submesh
  69736. * @param vertexBufferKind The type of vertex attribute
  69737. * @param meshAttributeArray The vertex attribute data
  69738. * @param byteOffset The offset to the binary data
  69739. * @param binaryWriter The binary data for the glTF file
  69740. */
  69741. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69742. /**
  69743. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69744. * clock-wise during export to glTF
  69745. * @param submesh BabylonJS submesh
  69746. * @param primitiveMode Primitive mode of the mesh
  69747. * @param sideOrientation the winding order of the submesh
  69748. * @param vertexBufferKind The type of vertex attribute
  69749. * @param meshAttributeArray The vertex attribute data
  69750. * @param byteOffset The offset to the binary data
  69751. * @param binaryWriter The binary data for the glTF file
  69752. */
  69753. private reorderTriangleFillMode;
  69754. /**
  69755. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69756. * clock-wise during export to glTF
  69757. * @param submesh BabylonJS submesh
  69758. * @param primitiveMode Primitive mode of the mesh
  69759. * @param sideOrientation the winding order of the submesh
  69760. * @param vertexBufferKind The type of vertex attribute
  69761. * @param meshAttributeArray The vertex attribute data
  69762. * @param byteOffset The offset to the binary data
  69763. * @param binaryWriter The binary data for the glTF file
  69764. */
  69765. private reorderTriangleStripDrawMode;
  69766. /**
  69767. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69768. * clock-wise during export to glTF
  69769. * @param submesh BabylonJS submesh
  69770. * @param primitiveMode Primitive mode of the mesh
  69771. * @param sideOrientation the winding order of the submesh
  69772. * @param vertexBufferKind The type of vertex attribute
  69773. * @param meshAttributeArray The vertex attribute data
  69774. * @param byteOffset The offset to the binary data
  69775. * @param binaryWriter The binary data for the glTF file
  69776. */
  69777. private reorderTriangleFanMode;
  69778. /**
  69779. * Writes the vertex attribute data to binary
  69780. * @param vertices The vertices to write to the binary writer
  69781. * @param byteOffset The offset into the binary writer to overwrite binary data
  69782. * @param vertexAttributeKind The vertex attribute type
  69783. * @param meshAttributeArray The vertex attribute data
  69784. * @param binaryWriter The writer containing the binary data
  69785. */
  69786. private writeVertexAttributeData;
  69787. /**
  69788. * Writes mesh attribute data to a data buffer
  69789. * Returns the bytelength of the data
  69790. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69791. * @param meshAttributeArray Array containing the attribute data
  69792. * @param binaryWriter The buffer to write the binary data to
  69793. * @param indices Used to specify the order of the vertex data
  69794. */
  69795. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69796. /**
  69797. * Generates glTF json data
  69798. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69799. * @param glTFPrefix Text to use when prefixing a glTF file
  69800. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69801. * @returns json data as string
  69802. */
  69803. private generateJSON;
  69804. /**
  69805. * Generates data for .gltf and .bin files based on the glTF prefix string
  69806. * @param glTFPrefix Text to use when prefixing a glTF file
  69807. * @returns GLTFData with glTF file data
  69808. */
  69809. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69810. /**
  69811. * Creates a binary buffer for glTF
  69812. * @returns array buffer for binary data
  69813. */
  69814. private _generateBinaryAsync;
  69815. /**
  69816. * Pads the number to a multiple of 4
  69817. * @param num number to pad
  69818. * @returns padded number
  69819. */
  69820. private _getPadding;
  69821. /**
  69822. * Generates a glb file from the json and binary data
  69823. * Returns an object with the glb file name as the key and data as the value
  69824. * @param glTFPrefix
  69825. * @returns object with glb filename as key and data as value
  69826. */
  69827. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69828. /**
  69829. * Sets the TRS for each node
  69830. * @param node glTF Node for storing the transformation data
  69831. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69832. */
  69833. private setNodeTransformation;
  69834. private getVertexBufferFromMesh;
  69835. /**
  69836. * Creates a bufferview based on the vertices type for the Babylon mesh
  69837. * @param kind Indicates the type of vertices data
  69838. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69839. * @param binaryWriter The buffer to write the bufferview data to
  69840. */
  69841. private createBufferViewKind;
  69842. /**
  69843. * The primitive mode of the Babylon mesh
  69844. * @param babylonMesh The BabylonJS mesh
  69845. */
  69846. private getMeshPrimitiveMode;
  69847. /**
  69848. * Sets the primitive mode of the glTF mesh primitive
  69849. * @param meshPrimitive glTF mesh primitive
  69850. * @param primitiveMode The primitive mode
  69851. */
  69852. private setPrimitiveMode;
  69853. /**
  69854. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69855. * @param meshPrimitive glTF mesh primitive
  69856. * @param attributeKind vertex attribute
  69857. * @returns boolean specifying if uv coordinates are present
  69858. */
  69859. private setAttributeKind;
  69860. /**
  69861. * Sets data for the primitive attributes of each submesh
  69862. * @param mesh glTF Mesh object to store the primitive attribute information
  69863. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69864. * @param binaryWriter Buffer to write the attribute data to
  69865. */
  69866. private setPrimitiveAttributesAsync;
  69867. /**
  69868. * Creates a glTF scene based on the array of meshes
  69869. * Returns the the total byte offset
  69870. * @param babylonScene Babylon scene to get the mesh data from
  69871. * @param binaryWriter Buffer to write binary data to
  69872. */
  69873. private createSceneAsync;
  69874. /**
  69875. * Creates a mapping of Node unique id to node index and handles animations
  69876. * @param babylonScene Babylon Scene
  69877. * @param nodes Babylon transform nodes
  69878. * @param binaryWriter Buffer to write binary data to
  69879. * @returns Node mapping of unique id to index
  69880. */
  69881. private createNodeMapAndAnimationsAsync;
  69882. /**
  69883. * Creates a glTF node from a Babylon mesh
  69884. * @param babylonMesh Source Babylon mesh
  69885. * @param binaryWriter Buffer for storing geometry data
  69886. * @returns glTF node
  69887. */
  69888. private createNodeAsync;
  69889. }
  69890. /**
  69891. * @hidden
  69892. *
  69893. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69894. */
  69895. export class _BinaryWriter {
  69896. /**
  69897. * Array buffer which stores all binary data
  69898. */
  69899. private _arrayBuffer;
  69900. /**
  69901. * View of the array buffer
  69902. */
  69903. private _dataView;
  69904. /**
  69905. * byte offset of data in array buffer
  69906. */
  69907. private _byteOffset;
  69908. /**
  69909. * Initialize binary writer with an initial byte length
  69910. * @param byteLength Initial byte length of the array buffer
  69911. */
  69912. constructor(byteLength: number);
  69913. /**
  69914. * Resize the array buffer to the specified byte length
  69915. * @param byteLength
  69916. */
  69917. private resizeBuffer;
  69918. /**
  69919. * Get an array buffer with the length of the byte offset
  69920. * @returns ArrayBuffer resized to the byte offset
  69921. */
  69922. getArrayBuffer(): ArrayBuffer;
  69923. /**
  69924. * Get the byte offset of the array buffer
  69925. * @returns byte offset
  69926. */
  69927. getByteOffset(): number;
  69928. /**
  69929. * Stores an UInt8 in the array buffer
  69930. * @param entry
  69931. * @param byteOffset If defined, specifies where to set the value as an offset.
  69932. */
  69933. setUInt8(entry: number, byteOffset?: number): void;
  69934. /**
  69935. * Gets an UInt32 in the array buffer
  69936. * @param entry
  69937. * @param byteOffset If defined, specifies where to set the value as an offset.
  69938. */
  69939. getUInt32(byteOffset: number): number;
  69940. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69941. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69942. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69943. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69944. /**
  69945. * Stores a Float32 in the array buffer
  69946. * @param entry
  69947. */
  69948. setFloat32(entry: number, byteOffset?: number): void;
  69949. /**
  69950. * Stores an UInt32 in the array buffer
  69951. * @param entry
  69952. * @param byteOffset If defined, specifies where to set the value as an offset.
  69953. */
  69954. setUInt32(entry: number, byteOffset?: number): void;
  69955. }
  69956. }
  69957. declare module BABYLON.GLTF2.Exporter {
  69958. /**
  69959. * @hidden
  69960. * Interface to store animation data.
  69961. */
  69962. export interface _IAnimationData {
  69963. /**
  69964. * Keyframe data.
  69965. */
  69966. inputs: number[];
  69967. /**
  69968. * Value data.
  69969. */
  69970. outputs: number[][];
  69971. /**
  69972. * Animation interpolation data.
  69973. */
  69974. samplerInterpolation: AnimationSamplerInterpolation;
  69975. /**
  69976. * Minimum keyframe value.
  69977. */
  69978. inputsMin: number;
  69979. /**
  69980. * Maximum keyframe value.
  69981. */
  69982. inputsMax: number;
  69983. }
  69984. /**
  69985. * @hidden
  69986. */
  69987. export interface _IAnimationInfo {
  69988. /**
  69989. * The target channel for the animation
  69990. */
  69991. animationChannelTargetPath: AnimationChannelTargetPath;
  69992. /**
  69993. * The glTF accessor type for the data.
  69994. */
  69995. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69996. /**
  69997. * Specifies if quaternions should be used.
  69998. */
  69999. useQuaternion: boolean;
  70000. }
  70001. /**
  70002. * @hidden
  70003. * Utility class for generating glTF animation data from BabylonJS.
  70004. */
  70005. export class _GLTFAnimation {
  70006. /**
  70007. * @ignore
  70008. *
  70009. * Creates glTF channel animation from BabylonJS animation.
  70010. * @param babylonTransformNode - BabylonJS mesh.
  70011. * @param animation - animation.
  70012. * @param animationChannelTargetPath - The target animation channel.
  70013. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70014. * @param useQuaternion - Specifies if quaternions are used.
  70015. * @returns nullable IAnimationData
  70016. */
  70017. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70018. private static _DeduceAnimationInfo;
  70019. /**
  70020. * @ignore
  70021. * Create node animations from the transform node animations
  70022. * @param babylonNode
  70023. * @param runtimeGLTFAnimation
  70024. * @param idleGLTFAnimations
  70025. * @param nodeMap
  70026. * @param nodes
  70027. * @param binaryWriter
  70028. * @param bufferViews
  70029. * @param accessors
  70030. * @param convertToRightHandedSystem
  70031. */
  70032. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70033. [key: number]: number;
  70034. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70035. /**
  70036. * @ignore
  70037. * Create node animations from the animation groups
  70038. * @param babylonScene
  70039. * @param glTFAnimations
  70040. * @param nodeMap
  70041. * @param nodes
  70042. * @param binaryWriter
  70043. * @param bufferViews
  70044. * @param accessors
  70045. * @param convertToRightHandedSystem
  70046. */
  70047. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70048. [key: number]: number;
  70049. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70050. private static AddAnimation;
  70051. /**
  70052. * Create a baked animation
  70053. * @param babylonTransformNode BabylonJS mesh
  70054. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70055. * @param animationChannelTargetPath animation target channel
  70056. * @param minFrame minimum animation frame
  70057. * @param maxFrame maximum animation frame
  70058. * @param fps frames per second of the animation
  70059. * @param inputs input key frames of the animation
  70060. * @param outputs output key frame data of the animation
  70061. * @param convertToRightHandedSystem converts the values to right-handed
  70062. * @param useQuaternion specifies if quaternions should be used
  70063. */
  70064. private static _CreateBakedAnimation;
  70065. private static _ConvertFactorToVector3OrQuaternion;
  70066. private static _SetInterpolatedValue;
  70067. /**
  70068. * Creates linear animation from the animation key frames
  70069. * @param babylonTransformNode BabylonJS mesh
  70070. * @param animation BabylonJS animation
  70071. * @param animationChannelTargetPath The target animation channel
  70072. * @param frameDelta The difference between the last and first frame of the animation
  70073. * @param inputs Array to store the key frame times
  70074. * @param outputs Array to store the key frame data
  70075. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70076. * @param useQuaternion Specifies if quaternions are used in the animation
  70077. */
  70078. private static _CreateLinearOrStepAnimation;
  70079. /**
  70080. * Creates cubic spline animation from the animation key frames
  70081. * @param babylonTransformNode BabylonJS mesh
  70082. * @param animation BabylonJS animation
  70083. * @param animationChannelTargetPath The target animation channel
  70084. * @param frameDelta The difference between the last and first frame of the animation
  70085. * @param inputs Array to store the key frame times
  70086. * @param outputs Array to store the key frame data
  70087. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70088. * @param useQuaternion Specifies if quaternions are used in the animation
  70089. */
  70090. private static _CreateCubicSplineAnimation;
  70091. private static _GetBasePositionRotationOrScale;
  70092. /**
  70093. * Adds a key frame value
  70094. * @param keyFrame
  70095. * @param animation
  70096. * @param outputs
  70097. * @param animationChannelTargetPath
  70098. * @param basePositionRotationOrScale
  70099. * @param convertToRightHandedSystem
  70100. * @param useQuaternion
  70101. */
  70102. private static _AddKeyframeValue;
  70103. /**
  70104. * Determine the interpolation based on the key frames
  70105. * @param keyFrames
  70106. * @param animationChannelTargetPath
  70107. * @param useQuaternion
  70108. */
  70109. private static _DeduceInterpolation;
  70110. /**
  70111. * Adds an input tangent or output tangent to the output data
  70112. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70113. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70114. * @param outputs The animation data by keyframe
  70115. * @param animationChannelTargetPath The target animation channel
  70116. * @param interpolation The interpolation type
  70117. * @param keyFrame The key frame with the animation data
  70118. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70119. * @param useQuaternion Specifies if quaternions are used
  70120. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70121. */
  70122. private static AddSplineTangent;
  70123. /**
  70124. * Get the minimum and maximum key frames' frame values
  70125. * @param keyFrames animation key frames
  70126. * @returns the minimum and maximum key frame value
  70127. */
  70128. private static calculateMinMaxKeyFrames;
  70129. }
  70130. }
  70131. declare module BABYLON.GLTF2.Exporter {
  70132. /** @hidden */
  70133. export var textureTransformPixelShader: {
  70134. name: string;
  70135. shader: string;
  70136. };
  70137. }
  70138. declare module BABYLON.GLTF2.Exporter.Extensions {
  70139. /**
  70140. * @hidden
  70141. */
  70142. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70143. /** Name of this extension */
  70144. readonly name: string;
  70145. /** Defines whether this extension is enabled */
  70146. enabled: boolean;
  70147. /** Defines whether this extension is required */
  70148. required: boolean;
  70149. /** Reference to the glTF exporter */
  70150. private _exporter;
  70151. constructor(exporter: _Exporter);
  70152. dispose(): void;
  70153. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70154. /**
  70155. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70156. * @param babylonTexture
  70157. * @param offset
  70158. * @param rotation
  70159. * @param scale
  70160. * @param scene
  70161. */
  70162. private _textureTransformTextureAsync;
  70163. }
  70164. }
  70165. declare module BABYLON.GLTF2.Exporter.Extensions {
  70166. /**
  70167. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70168. */
  70169. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70170. /** The name of this extension. */
  70171. readonly name: string;
  70172. /** Defines whether this extension is enabled. */
  70173. enabled: boolean;
  70174. /** Defines whether this extension is required */
  70175. required: boolean;
  70176. /** Reference to the glTF exporter */
  70177. private _exporter;
  70178. private _lights;
  70179. /** @hidden */
  70180. constructor(exporter: _Exporter);
  70181. /** @hidden */
  70182. dispose(): void;
  70183. /** @hidden */
  70184. onExporting(): void;
  70185. /**
  70186. * Define this method to modify the default behavior when exporting a node
  70187. * @param context The context when exporting the node
  70188. * @param node glTF node
  70189. * @param babylonNode BabylonJS node
  70190. * @returns nullable INode promise
  70191. */
  70192. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70193. }
  70194. }
  70195. declare module BABYLON {
  70196. /**
  70197. * Class for generating STL data from a Babylon scene.
  70198. */
  70199. export class STLExport {
  70200. /**
  70201. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70202. * @param meshes list defines the mesh to serialize
  70203. * @param download triggers the automatic download of the file.
  70204. * @param fileName changes the downloads fileName.
  70205. * @param binary changes the STL to a binary type.
  70206. * @param isLittleEndian toggle for binary type exporter.
  70207. * @returns the STL as UTF8 string
  70208. */
  70209. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70210. }
  70211. }
  70212. declare module "babylonjs-gltf2interface" {
  70213. export = BABYLON.GLTF2;
  70214. }
  70215. /**
  70216. * Module for glTF 2.0 Interface
  70217. */
  70218. declare module BABYLON.GLTF2 {
  70219. /**
  70220. * The datatype of the components in the attribute
  70221. */
  70222. const enum AccessorComponentType {
  70223. /**
  70224. * Byte
  70225. */
  70226. BYTE = 5120,
  70227. /**
  70228. * Unsigned Byte
  70229. */
  70230. UNSIGNED_BYTE = 5121,
  70231. /**
  70232. * Short
  70233. */
  70234. SHORT = 5122,
  70235. /**
  70236. * Unsigned Short
  70237. */
  70238. UNSIGNED_SHORT = 5123,
  70239. /**
  70240. * Unsigned Int
  70241. */
  70242. UNSIGNED_INT = 5125,
  70243. /**
  70244. * Float
  70245. */
  70246. FLOAT = 5126,
  70247. }
  70248. /**
  70249. * Specifies if the attirbute is a scalar, vector, or matrix
  70250. */
  70251. const enum AccessorType {
  70252. /**
  70253. * Scalar
  70254. */
  70255. SCALAR = "SCALAR",
  70256. /**
  70257. * Vector2
  70258. */
  70259. VEC2 = "VEC2",
  70260. /**
  70261. * Vector3
  70262. */
  70263. VEC3 = "VEC3",
  70264. /**
  70265. * Vector4
  70266. */
  70267. VEC4 = "VEC4",
  70268. /**
  70269. * Matrix2x2
  70270. */
  70271. MAT2 = "MAT2",
  70272. /**
  70273. * Matrix3x3
  70274. */
  70275. MAT3 = "MAT3",
  70276. /**
  70277. * Matrix4x4
  70278. */
  70279. MAT4 = "MAT4",
  70280. }
  70281. /**
  70282. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70283. */
  70284. const enum AnimationChannelTargetPath {
  70285. /**
  70286. * Translation
  70287. */
  70288. TRANSLATION = "translation",
  70289. /**
  70290. * Rotation
  70291. */
  70292. ROTATION = "rotation",
  70293. /**
  70294. * Scale
  70295. */
  70296. SCALE = "scale",
  70297. /**
  70298. * Weights
  70299. */
  70300. WEIGHTS = "weights",
  70301. }
  70302. /**
  70303. * Interpolation algorithm
  70304. */
  70305. const enum AnimationSamplerInterpolation {
  70306. /**
  70307. * The animated values are linearly interpolated between keyframes
  70308. */
  70309. LINEAR = "LINEAR",
  70310. /**
  70311. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70312. */
  70313. STEP = "STEP",
  70314. /**
  70315. * The animation's interpolation is computed using a cubic spline with specified tangents
  70316. */
  70317. CUBICSPLINE = "CUBICSPLINE",
  70318. }
  70319. /**
  70320. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70321. */
  70322. const enum CameraType {
  70323. /**
  70324. * A perspective camera containing properties to create a perspective projection matrix
  70325. */
  70326. PERSPECTIVE = "perspective",
  70327. /**
  70328. * An orthographic camera containing properties to create an orthographic projection matrix
  70329. */
  70330. ORTHOGRAPHIC = "orthographic",
  70331. }
  70332. /**
  70333. * The mime-type of the image
  70334. */
  70335. const enum ImageMimeType {
  70336. /**
  70337. * JPEG Mime-type
  70338. */
  70339. JPEG = "image/jpeg",
  70340. /**
  70341. * PNG Mime-type
  70342. */
  70343. PNG = "image/png",
  70344. }
  70345. /**
  70346. * The alpha rendering mode of the material
  70347. */
  70348. const enum MaterialAlphaMode {
  70349. /**
  70350. * The alpha value is ignored and the rendered output is fully opaque
  70351. */
  70352. OPAQUE = "OPAQUE",
  70353. /**
  70354. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70355. */
  70356. MASK = "MASK",
  70357. /**
  70358. * 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)
  70359. */
  70360. BLEND = "BLEND",
  70361. }
  70362. /**
  70363. * The type of the primitives to render
  70364. */
  70365. const enum MeshPrimitiveMode {
  70366. /**
  70367. * Points
  70368. */
  70369. POINTS = 0,
  70370. /**
  70371. * Lines
  70372. */
  70373. LINES = 1,
  70374. /**
  70375. * Line Loop
  70376. */
  70377. LINE_LOOP = 2,
  70378. /**
  70379. * Line Strip
  70380. */
  70381. LINE_STRIP = 3,
  70382. /**
  70383. * Triangles
  70384. */
  70385. TRIANGLES = 4,
  70386. /**
  70387. * Triangle Strip
  70388. */
  70389. TRIANGLE_STRIP = 5,
  70390. /**
  70391. * Triangle Fan
  70392. */
  70393. TRIANGLE_FAN = 6,
  70394. }
  70395. /**
  70396. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70397. */
  70398. const enum TextureMagFilter {
  70399. /**
  70400. * Nearest
  70401. */
  70402. NEAREST = 9728,
  70403. /**
  70404. * Linear
  70405. */
  70406. LINEAR = 9729,
  70407. }
  70408. /**
  70409. * Minification filter. All valid values correspond to WebGL enums
  70410. */
  70411. const enum TextureMinFilter {
  70412. /**
  70413. * Nearest
  70414. */
  70415. NEAREST = 9728,
  70416. /**
  70417. * Linear
  70418. */
  70419. LINEAR = 9729,
  70420. /**
  70421. * Nearest Mip-Map Nearest
  70422. */
  70423. NEAREST_MIPMAP_NEAREST = 9984,
  70424. /**
  70425. * Linear Mipmap Nearest
  70426. */
  70427. LINEAR_MIPMAP_NEAREST = 9985,
  70428. /**
  70429. * Nearest Mipmap Linear
  70430. */
  70431. NEAREST_MIPMAP_LINEAR = 9986,
  70432. /**
  70433. * Linear Mipmap Linear
  70434. */
  70435. LINEAR_MIPMAP_LINEAR = 9987,
  70436. }
  70437. /**
  70438. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70439. */
  70440. const enum TextureWrapMode {
  70441. /**
  70442. * Clamp to Edge
  70443. */
  70444. CLAMP_TO_EDGE = 33071,
  70445. /**
  70446. * Mirrored Repeat
  70447. */
  70448. MIRRORED_REPEAT = 33648,
  70449. /**
  70450. * Repeat
  70451. */
  70452. REPEAT = 10497,
  70453. }
  70454. /**
  70455. * glTF Property
  70456. */
  70457. interface IProperty {
  70458. /**
  70459. * Dictionary object with extension-specific objects
  70460. */
  70461. extensions?: {
  70462. [key: string]: any;
  70463. };
  70464. /**
  70465. * Application-Specific data
  70466. */
  70467. extras?: any;
  70468. }
  70469. /**
  70470. * glTF Child of Root Property
  70471. */
  70472. interface IChildRootProperty extends IProperty {
  70473. /**
  70474. * The user-defined name of this object
  70475. */
  70476. name?: string;
  70477. }
  70478. /**
  70479. * Indices of those attributes that deviate from their initialization value
  70480. */
  70481. interface IAccessorSparseIndices extends IProperty {
  70482. /**
  70483. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70484. */
  70485. bufferView: number;
  70486. /**
  70487. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70488. */
  70489. byteOffset?: number;
  70490. /**
  70491. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70492. */
  70493. componentType: AccessorComponentType;
  70494. }
  70495. /**
  70496. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70497. */
  70498. interface IAccessorSparseValues extends IProperty {
  70499. /**
  70500. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70501. */
  70502. bufferView: number;
  70503. /**
  70504. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70505. */
  70506. byteOffset?: number;
  70507. }
  70508. /**
  70509. * Sparse storage of attributes that deviate from their initialization value
  70510. */
  70511. interface IAccessorSparse extends IProperty {
  70512. /**
  70513. * The number of attributes encoded in this sparse accessor
  70514. */
  70515. count: number;
  70516. /**
  70517. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70518. */
  70519. indices: IAccessorSparseIndices;
  70520. /**
  70521. * 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
  70522. */
  70523. values: IAccessorSparseValues;
  70524. }
  70525. /**
  70526. * 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
  70527. */
  70528. interface IAccessor extends IChildRootProperty {
  70529. /**
  70530. * The index of the bufferview
  70531. */
  70532. bufferView?: number;
  70533. /**
  70534. * The offset relative to the start of the bufferView in bytes
  70535. */
  70536. byteOffset?: number;
  70537. /**
  70538. * The datatype of components in the attribute
  70539. */
  70540. componentType: AccessorComponentType;
  70541. /**
  70542. * Specifies whether integer data values should be normalized
  70543. */
  70544. normalized?: boolean;
  70545. /**
  70546. * The number of attributes referenced by this accessor
  70547. */
  70548. count: number;
  70549. /**
  70550. * Specifies if the attribute is a scalar, vector, or matrix
  70551. */
  70552. type: AccessorType;
  70553. /**
  70554. * Maximum value of each component in this attribute
  70555. */
  70556. max?: number[];
  70557. /**
  70558. * Minimum value of each component in this attribute
  70559. */
  70560. min?: number[];
  70561. /**
  70562. * Sparse storage of attributes that deviate from their initialization value
  70563. */
  70564. sparse?: IAccessorSparse;
  70565. }
  70566. /**
  70567. * Targets an animation's sampler at a node's property
  70568. */
  70569. interface IAnimationChannel extends IProperty {
  70570. /**
  70571. * The index of a sampler in this animation used to compute the value for the target
  70572. */
  70573. sampler: number;
  70574. /**
  70575. * The index of the node and TRS property to target
  70576. */
  70577. target: IAnimationChannelTarget;
  70578. }
  70579. /**
  70580. * The index of the node and TRS property that an animation channel targets
  70581. */
  70582. interface IAnimationChannelTarget extends IProperty {
  70583. /**
  70584. * The index of the node to target
  70585. */
  70586. node: number;
  70587. /**
  70588. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70589. */
  70590. path: AnimationChannelTargetPath;
  70591. }
  70592. /**
  70593. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70594. */
  70595. interface IAnimationSampler extends IProperty {
  70596. /**
  70597. * The index of an accessor containing keyframe input values, e.g., time
  70598. */
  70599. input: number;
  70600. /**
  70601. * Interpolation algorithm
  70602. */
  70603. interpolation?: AnimationSamplerInterpolation;
  70604. /**
  70605. * The index of an accessor, containing keyframe output values
  70606. */
  70607. output: number;
  70608. }
  70609. /**
  70610. * A keyframe animation
  70611. */
  70612. interface IAnimation extends IChildRootProperty {
  70613. /**
  70614. * An array of channels, each of which targets an animation's sampler at a node's property
  70615. */
  70616. channels: IAnimationChannel[];
  70617. /**
  70618. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70619. */
  70620. samplers: IAnimationSampler[];
  70621. }
  70622. /**
  70623. * Metadata about the glTF asset
  70624. */
  70625. interface IAsset extends IChildRootProperty {
  70626. /**
  70627. * A copyright message suitable for display to credit the content creator
  70628. */
  70629. copyright?: string;
  70630. /**
  70631. * Tool that generated this glTF model. Useful for debugging
  70632. */
  70633. generator?: string;
  70634. /**
  70635. * The glTF version that this asset targets
  70636. */
  70637. version: string;
  70638. /**
  70639. * The minimum glTF version that this asset targets
  70640. */
  70641. minVersion?: string;
  70642. }
  70643. /**
  70644. * A buffer points to binary geometry, animation, or skins
  70645. */
  70646. interface IBuffer extends IChildRootProperty {
  70647. /**
  70648. * 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
  70649. */
  70650. uri?: string;
  70651. /**
  70652. * The length of the buffer in bytes
  70653. */
  70654. byteLength: number;
  70655. }
  70656. /**
  70657. * A view into a buffer generally representing a subset of the buffer
  70658. */
  70659. interface IBufferView extends IChildRootProperty {
  70660. /**
  70661. * The index of the buffer
  70662. */
  70663. buffer: number;
  70664. /**
  70665. * The offset into the buffer in bytes
  70666. */
  70667. byteOffset?: number;
  70668. /**
  70669. * The lenth of the bufferView in bytes
  70670. */
  70671. byteLength: number;
  70672. /**
  70673. * The stride, in bytes
  70674. */
  70675. byteStride?: number;
  70676. }
  70677. /**
  70678. * An orthographic camera containing properties to create an orthographic projection matrix
  70679. */
  70680. interface ICameraOrthographic extends IProperty {
  70681. /**
  70682. * The floating-point horizontal magnification of the view. Must not be zero
  70683. */
  70684. xmag: number;
  70685. /**
  70686. * The floating-point vertical magnification of the view. Must not be zero
  70687. */
  70688. ymag: number;
  70689. /**
  70690. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70691. */
  70692. zfar: number;
  70693. /**
  70694. * The floating-point distance to the near clipping plane
  70695. */
  70696. znear: number;
  70697. }
  70698. /**
  70699. * A perspective camera containing properties to create a perspective projection matrix
  70700. */
  70701. interface ICameraPerspective extends IProperty {
  70702. /**
  70703. * The floating-point aspect ratio of the field of view
  70704. */
  70705. aspectRatio?: number;
  70706. /**
  70707. * The floating-point vertical field of view in radians
  70708. */
  70709. yfov: number;
  70710. /**
  70711. * The floating-point distance to the far clipping plane
  70712. */
  70713. zfar?: number;
  70714. /**
  70715. * The floating-point distance to the near clipping plane
  70716. */
  70717. znear: number;
  70718. }
  70719. /**
  70720. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70721. */
  70722. interface ICamera extends IChildRootProperty {
  70723. /**
  70724. * An orthographic camera containing properties to create an orthographic projection matrix
  70725. */
  70726. orthographic?: ICameraOrthographic;
  70727. /**
  70728. * A perspective camera containing properties to create a perspective projection matrix
  70729. */
  70730. perspective?: ICameraPerspective;
  70731. /**
  70732. * Specifies if the camera uses a perspective or orthographic projection
  70733. */
  70734. type: CameraType;
  70735. }
  70736. /**
  70737. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70738. */
  70739. interface IImage extends IChildRootProperty {
  70740. /**
  70741. * 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
  70742. */
  70743. uri?: string;
  70744. /**
  70745. * The image's MIME type
  70746. */
  70747. mimeType?: ImageMimeType;
  70748. /**
  70749. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70750. */
  70751. bufferView?: number;
  70752. }
  70753. /**
  70754. * Material Normal Texture Info
  70755. */
  70756. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70757. /**
  70758. * The scalar multiplier applied to each normal vector of the normal texture
  70759. */
  70760. scale?: number;
  70761. }
  70762. /**
  70763. * Material Occlusion Texture Info
  70764. */
  70765. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70766. /**
  70767. * A scalar multiplier controlling the amount of occlusion applied
  70768. */
  70769. strength?: number;
  70770. }
  70771. /**
  70772. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70773. */
  70774. interface IMaterialPbrMetallicRoughness {
  70775. /**
  70776. * The material's base color factor
  70777. */
  70778. baseColorFactor?: number[];
  70779. /**
  70780. * The base color texture
  70781. */
  70782. baseColorTexture?: ITextureInfo;
  70783. /**
  70784. * The metalness of the material
  70785. */
  70786. metallicFactor?: number;
  70787. /**
  70788. * The roughness of the material
  70789. */
  70790. roughnessFactor?: number;
  70791. /**
  70792. * The metallic-roughness texture
  70793. */
  70794. metallicRoughnessTexture?: ITextureInfo;
  70795. }
  70796. /**
  70797. * The material appearance of a primitive
  70798. */
  70799. interface IMaterial extends IChildRootProperty {
  70800. /**
  70801. * 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
  70802. */
  70803. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70804. /**
  70805. * The normal map texture
  70806. */
  70807. normalTexture?: IMaterialNormalTextureInfo;
  70808. /**
  70809. * The occlusion map texture
  70810. */
  70811. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70812. /**
  70813. * The emissive map texture
  70814. */
  70815. emissiveTexture?: ITextureInfo;
  70816. /**
  70817. * 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
  70818. */
  70819. emissiveFactor?: number[];
  70820. /**
  70821. * The alpha rendering mode of the material
  70822. */
  70823. alphaMode?: MaterialAlphaMode;
  70824. /**
  70825. * The alpha cutoff value of the material
  70826. */
  70827. alphaCutoff?: number;
  70828. /**
  70829. * Specifies whether the material is double sided
  70830. */
  70831. doubleSided?: boolean;
  70832. }
  70833. /**
  70834. * Geometry to be rendered with the given material
  70835. */
  70836. interface IMeshPrimitive extends IProperty {
  70837. /**
  70838. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70839. */
  70840. attributes: {
  70841. [name: string]: number;
  70842. };
  70843. /**
  70844. * The index of the accessor that contains the indices
  70845. */
  70846. indices?: number;
  70847. /**
  70848. * The index of the material to apply to this primitive when rendering
  70849. */
  70850. material?: number;
  70851. /**
  70852. * The type of primitives to render. All valid values correspond to WebGL enums
  70853. */
  70854. mode?: MeshPrimitiveMode;
  70855. /**
  70856. * 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
  70857. */
  70858. targets?: {
  70859. [name: string]: number;
  70860. }[];
  70861. }
  70862. /**
  70863. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70864. */
  70865. interface IMesh extends IChildRootProperty {
  70866. /**
  70867. * An array of primitives, each defining geometry to be rendered with a material
  70868. */
  70869. primitives: IMeshPrimitive[];
  70870. /**
  70871. * Array of weights to be applied to the Morph Targets
  70872. */
  70873. weights?: number[];
  70874. }
  70875. /**
  70876. * A node in the node hierarchy
  70877. */
  70878. interface INode extends IChildRootProperty {
  70879. /**
  70880. * The index of the camera referenced by this node
  70881. */
  70882. camera?: number;
  70883. /**
  70884. * The indices of this node's children
  70885. */
  70886. children?: number[];
  70887. /**
  70888. * The index of the skin referenced by this node
  70889. */
  70890. skin?: number;
  70891. /**
  70892. * A floating-point 4x4 transformation matrix stored in column-major order
  70893. */
  70894. matrix?: number[];
  70895. /**
  70896. * The index of the mesh in this node
  70897. */
  70898. mesh?: number;
  70899. /**
  70900. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70901. */
  70902. rotation?: number[];
  70903. /**
  70904. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70905. */
  70906. scale?: number[];
  70907. /**
  70908. * The node's translation along the x, y, and z axes
  70909. */
  70910. translation?: number[];
  70911. /**
  70912. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70913. */
  70914. weights?: number[];
  70915. }
  70916. /**
  70917. * Texture sampler properties for filtering and wrapping modes
  70918. */
  70919. interface ISampler extends IChildRootProperty {
  70920. /**
  70921. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70922. */
  70923. magFilter?: TextureMagFilter;
  70924. /**
  70925. * Minification filter. All valid values correspond to WebGL enums
  70926. */
  70927. minFilter?: TextureMinFilter;
  70928. /**
  70929. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70930. */
  70931. wrapS?: TextureWrapMode;
  70932. /**
  70933. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70934. */
  70935. wrapT?: TextureWrapMode;
  70936. }
  70937. /**
  70938. * The root nodes of a scene
  70939. */
  70940. interface IScene extends IChildRootProperty {
  70941. /**
  70942. * The indices of each root node
  70943. */
  70944. nodes: number[];
  70945. }
  70946. /**
  70947. * Joints and matrices defining a skin
  70948. */
  70949. interface ISkin extends IChildRootProperty {
  70950. /**
  70951. * 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
  70952. */
  70953. inverseBindMatrices?: number;
  70954. /**
  70955. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70956. */
  70957. skeleton?: number;
  70958. /**
  70959. * 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)
  70960. */
  70961. joints: number[];
  70962. }
  70963. /**
  70964. * A texture and its sampler
  70965. */
  70966. interface ITexture extends IChildRootProperty {
  70967. /**
  70968. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70969. */
  70970. sampler?: number;
  70971. /**
  70972. * The index of the image used by this texture
  70973. */
  70974. source: number;
  70975. }
  70976. /**
  70977. * Reference to a texture
  70978. */
  70979. interface ITextureInfo extends IProperty {
  70980. /**
  70981. * The index of the texture
  70982. */
  70983. index: number;
  70984. /**
  70985. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70986. */
  70987. texCoord?: number;
  70988. }
  70989. /**
  70990. * The root object for a glTF asset
  70991. */
  70992. interface IGLTF extends IProperty {
  70993. /**
  70994. * An array of accessors. An accessor is a typed view into a bufferView
  70995. */
  70996. accessors?: IAccessor[];
  70997. /**
  70998. * An array of keyframe animations
  70999. */
  71000. animations?: IAnimation[];
  71001. /**
  71002. * Metadata about the glTF asset
  71003. */
  71004. asset: IAsset;
  71005. /**
  71006. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71007. */
  71008. buffers?: IBuffer[];
  71009. /**
  71010. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71011. */
  71012. bufferViews?: IBufferView[];
  71013. /**
  71014. * An array of cameras
  71015. */
  71016. cameras?: ICamera[];
  71017. /**
  71018. * Names of glTF extensions used somewhere in this asset
  71019. */
  71020. extensionsUsed?: string[];
  71021. /**
  71022. * Names of glTF extensions required to properly load this asset
  71023. */
  71024. extensionsRequired?: string[];
  71025. /**
  71026. * An array of images. An image defines data used to create a texture
  71027. */
  71028. images?: IImage[];
  71029. /**
  71030. * An array of materials. A material defines the appearance of a primitive
  71031. */
  71032. materials?: IMaterial[];
  71033. /**
  71034. * An array of meshes. A mesh is a set of primitives to be rendered
  71035. */
  71036. meshes?: IMesh[];
  71037. /**
  71038. * An array of nodes
  71039. */
  71040. nodes?: INode[];
  71041. /**
  71042. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71043. */
  71044. samplers?: ISampler[];
  71045. /**
  71046. * The index of the default scene
  71047. */
  71048. scene?: number;
  71049. /**
  71050. * An array of scenes
  71051. */
  71052. scenes?: IScene[];
  71053. /**
  71054. * An array of skins. A skin is defined by joints and matrices
  71055. */
  71056. skins?: ISkin[];
  71057. /**
  71058. * An array of textures
  71059. */
  71060. textures?: ITexture[];
  71061. }
  71062. /**
  71063. * The glTF validation results
  71064. * @ignore
  71065. */
  71066. interface IGLTFValidationResults {
  71067. info: {
  71068. generator: string;
  71069. hasAnimations: boolean;
  71070. hasDefaultScene: boolean;
  71071. hasMaterials: boolean;
  71072. hasMorphTargets: boolean;
  71073. hasSkins: boolean;
  71074. hasTextures: boolean;
  71075. maxAttributesUsed: number;
  71076. primitivesCount: number
  71077. };
  71078. issues: {
  71079. messages: Array<string>;
  71080. numErrors: number;
  71081. numHints: number;
  71082. numInfos: number;
  71083. numWarnings: number;
  71084. truncated: boolean
  71085. };
  71086. mimeType: string;
  71087. uri: string;
  71088. validatedAt: string;
  71089. validatorVersion: string;
  71090. }
  71091. /**
  71092. * The glTF validation options
  71093. */
  71094. interface IGLTFValidationOptions {
  71095. /** Uri to use */
  71096. uri?: string;
  71097. /** Function used to load external resources */
  71098. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71099. /** Boolean indicating that we need to validate accessor data */
  71100. validateAccessorData?: boolean;
  71101. /** max number of issues allowed */
  71102. maxIssues?: number;
  71103. /** Ignored issues */
  71104. ignoredIssues?: Array<string>;
  71105. /** Value to override severy settings */
  71106. severityOverrides?: Object;
  71107. }
  71108. /**
  71109. * The glTF validator object
  71110. * @ignore
  71111. */
  71112. interface IGLTFValidator {
  71113. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71114. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71115. }
  71116. }
  71117. declare module BABYLON {
  71118. /** @hidden */
  71119. export var cellPixelShader: {
  71120. name: string;
  71121. shader: string;
  71122. };
  71123. }
  71124. declare module BABYLON {
  71125. /** @hidden */
  71126. export var cellVertexShader: {
  71127. name: string;
  71128. shader: string;
  71129. };
  71130. }
  71131. declare module BABYLON {
  71132. export class CellMaterial extends BABYLON.PushMaterial {
  71133. private _diffuseTexture;
  71134. diffuseTexture: BABYLON.BaseTexture;
  71135. diffuseColor: BABYLON.Color3;
  71136. _computeHighLevel: boolean;
  71137. computeHighLevel: boolean;
  71138. private _disableLighting;
  71139. disableLighting: boolean;
  71140. private _maxSimultaneousLights;
  71141. maxSimultaneousLights: number;
  71142. private _renderId;
  71143. constructor(name: string, scene: BABYLON.Scene);
  71144. needAlphaBlending(): boolean;
  71145. needAlphaTesting(): boolean;
  71146. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71147. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71148. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71149. getAnimatables(): BABYLON.IAnimatable[];
  71150. getActiveTextures(): BABYLON.BaseTexture[];
  71151. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71152. dispose(forceDisposeEffect?: boolean): void;
  71153. getClassName(): string;
  71154. clone(name: string): CellMaterial;
  71155. serialize(): any;
  71156. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71157. }
  71158. }
  71159. declare module BABYLON {
  71160. export class CustomShaderStructure {
  71161. FragmentStore: string;
  71162. VertexStore: string;
  71163. constructor();
  71164. }
  71165. export class ShaderSpecialParts {
  71166. constructor();
  71167. Fragment_Begin: string;
  71168. Fragment_Definitions: string;
  71169. Fragment_MainBegin: string;
  71170. Fragment_Custom_Diffuse: string;
  71171. Fragment_Before_Lights: string;
  71172. Fragment_Before_Fog: string;
  71173. Fragment_Custom_Alpha: string;
  71174. Fragment_Before_FragColor: string;
  71175. Vertex_Begin: string;
  71176. Vertex_Definitions: string;
  71177. Vertex_MainBegin: string;
  71178. Vertex_Before_PositionUpdated: string;
  71179. Vertex_Before_NormalUpdated: string;
  71180. Vertex_MainEnd: string;
  71181. }
  71182. export class CustomMaterial extends BABYLON.StandardMaterial {
  71183. static ShaderIndexer: number;
  71184. CustomParts: ShaderSpecialParts;
  71185. _isCreatedShader: boolean;
  71186. _createdShaderName: string;
  71187. _customUniform: string[];
  71188. _newUniforms: string[];
  71189. _newUniformInstances: any[];
  71190. _newSamplerInstances: BABYLON.Texture[];
  71191. FragmentShader: string;
  71192. VertexShader: string;
  71193. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71194. ReviewUniform(name: string, arr: string[]): string[];
  71195. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71196. constructor(name: string, scene: BABYLON.Scene);
  71197. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71198. Fragment_Begin(shaderPart: string): CustomMaterial;
  71199. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71200. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71201. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71202. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71203. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71204. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71205. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71206. Vertex_Begin(shaderPart: string): CustomMaterial;
  71207. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71208. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71209. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71210. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71211. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71212. }
  71213. }
  71214. declare module BABYLON {
  71215. export class ShaderAlebdoParts {
  71216. constructor();
  71217. Fragment_Begin: string;
  71218. Fragment_Definitions: string;
  71219. Fragment_MainBegin: string;
  71220. Fragment_Custom_Albedo: string;
  71221. Fragment_Before_Lights: string;
  71222. Fragment_Custom_MetallicRoughness: string;
  71223. Fragment_Custom_MicroSurface: string;
  71224. Fragment_Before_Fog: string;
  71225. Fragment_Custom_Alpha: string;
  71226. Fragment_Before_FragColor: string;
  71227. Vertex_Begin: string;
  71228. Vertex_Definitions: string;
  71229. Vertex_MainBegin: string;
  71230. Vertex_Before_PositionUpdated: string;
  71231. Vertex_Before_NormalUpdated: string;
  71232. Vertex_MainEnd: string;
  71233. }
  71234. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71235. static ShaderIndexer: number;
  71236. CustomParts: ShaderAlebdoParts;
  71237. _isCreatedShader: boolean;
  71238. _createdShaderName: string;
  71239. _customUniform: string[];
  71240. _newUniforms: string[];
  71241. _newUniformInstances: any[];
  71242. _newSamplerInstances: BABYLON.Texture[];
  71243. FragmentShader: string;
  71244. VertexShader: string;
  71245. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71246. ReviewUniform(name: string, arr: string[]): string[];
  71247. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71248. constructor(name: string, scene: BABYLON.Scene);
  71249. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71250. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71251. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71252. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71253. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71254. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71255. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71256. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71257. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71258. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71259. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71260. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71261. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71262. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71263. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71264. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71265. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71266. }
  71267. }
  71268. declare module BABYLON {
  71269. /** @hidden */
  71270. export var firePixelShader: {
  71271. name: string;
  71272. shader: string;
  71273. };
  71274. }
  71275. declare module BABYLON {
  71276. /** @hidden */
  71277. export var fireVertexShader: {
  71278. name: string;
  71279. shader: string;
  71280. };
  71281. }
  71282. declare module BABYLON {
  71283. export class FireMaterial extends BABYLON.PushMaterial {
  71284. private _diffuseTexture;
  71285. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71286. private _distortionTexture;
  71287. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71288. private _opacityTexture;
  71289. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71290. diffuseColor: BABYLON.Color3;
  71291. speed: number;
  71292. private _scaledDiffuse;
  71293. private _renderId;
  71294. private _lastTime;
  71295. constructor(name: string, scene: BABYLON.Scene);
  71296. needAlphaBlending(): boolean;
  71297. needAlphaTesting(): boolean;
  71298. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71299. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71300. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71301. getAnimatables(): BABYLON.IAnimatable[];
  71302. getActiveTextures(): BABYLON.BaseTexture[];
  71303. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71304. getClassName(): string;
  71305. dispose(forceDisposeEffect?: boolean): void;
  71306. clone(name: string): FireMaterial;
  71307. serialize(): any;
  71308. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71309. }
  71310. }
  71311. declare module BABYLON {
  71312. /** @hidden */
  71313. export var furPixelShader: {
  71314. name: string;
  71315. shader: string;
  71316. };
  71317. }
  71318. declare module BABYLON {
  71319. /** @hidden */
  71320. export var furVertexShader: {
  71321. name: string;
  71322. shader: string;
  71323. };
  71324. }
  71325. declare module BABYLON {
  71326. export class FurMaterial extends BABYLON.PushMaterial {
  71327. private _diffuseTexture;
  71328. diffuseTexture: BABYLON.BaseTexture;
  71329. private _heightTexture;
  71330. heightTexture: BABYLON.BaseTexture;
  71331. diffuseColor: BABYLON.Color3;
  71332. furLength: number;
  71333. furAngle: number;
  71334. furColor: BABYLON.Color3;
  71335. furOffset: number;
  71336. furSpacing: number;
  71337. furGravity: BABYLON.Vector3;
  71338. furSpeed: number;
  71339. furDensity: number;
  71340. furOcclusion: number;
  71341. furTexture: BABYLON.DynamicTexture;
  71342. private _disableLighting;
  71343. disableLighting: boolean;
  71344. private _maxSimultaneousLights;
  71345. maxSimultaneousLights: number;
  71346. highLevelFur: boolean;
  71347. _meshes: BABYLON.AbstractMesh[];
  71348. private _renderId;
  71349. private _furTime;
  71350. constructor(name: string, scene: BABYLON.Scene);
  71351. furTime: number;
  71352. needAlphaBlending(): boolean;
  71353. needAlphaTesting(): boolean;
  71354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71355. updateFur(): void;
  71356. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71357. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71358. getAnimatables(): BABYLON.IAnimatable[];
  71359. getActiveTextures(): BABYLON.BaseTexture[];
  71360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71361. dispose(forceDisposeEffect?: boolean): void;
  71362. clone(name: string): FurMaterial;
  71363. serialize(): any;
  71364. getClassName(): string;
  71365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71366. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71367. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71368. }
  71369. }
  71370. declare module BABYLON {
  71371. /** @hidden */
  71372. export var gradientPixelShader: {
  71373. name: string;
  71374. shader: string;
  71375. };
  71376. }
  71377. declare module BABYLON {
  71378. /** @hidden */
  71379. export var gradientVertexShader: {
  71380. name: string;
  71381. shader: string;
  71382. };
  71383. }
  71384. declare module BABYLON {
  71385. export class GradientMaterial extends BABYLON.PushMaterial {
  71386. private _maxSimultaneousLights;
  71387. maxSimultaneousLights: number;
  71388. topColor: BABYLON.Color3;
  71389. topColorAlpha: number;
  71390. bottomColor: BABYLON.Color3;
  71391. bottomColorAlpha: number;
  71392. offset: number;
  71393. scale: number;
  71394. smoothness: number;
  71395. private _disableLighting;
  71396. disableLighting: boolean;
  71397. private _renderId;
  71398. constructor(name: string, scene: BABYLON.Scene);
  71399. needAlphaBlending(): boolean;
  71400. needAlphaTesting(): boolean;
  71401. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71402. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71403. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71404. getAnimatables(): BABYLON.IAnimatable[];
  71405. dispose(forceDisposeEffect?: boolean): void;
  71406. clone(name: string): GradientMaterial;
  71407. serialize(): any;
  71408. getClassName(): string;
  71409. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71410. }
  71411. }
  71412. declare module BABYLON {
  71413. /** @hidden */
  71414. export var gridPixelShader: {
  71415. name: string;
  71416. shader: string;
  71417. };
  71418. }
  71419. declare module BABYLON {
  71420. /** @hidden */
  71421. export var gridVertexShader: {
  71422. name: string;
  71423. shader: string;
  71424. };
  71425. }
  71426. declare module BABYLON {
  71427. /**
  71428. * The grid materials allows you to wrap any shape with a grid.
  71429. * Colors are customizable.
  71430. */
  71431. export class GridMaterial extends BABYLON.PushMaterial {
  71432. /**
  71433. * Main color of the grid (e.g. between lines)
  71434. */
  71435. mainColor: BABYLON.Color3;
  71436. /**
  71437. * Color of the grid lines.
  71438. */
  71439. lineColor: BABYLON.Color3;
  71440. /**
  71441. * The scale of the grid compared to unit.
  71442. */
  71443. gridRatio: number;
  71444. /**
  71445. * Allows setting an offset for the grid lines.
  71446. */
  71447. gridOffset: BABYLON.Vector3;
  71448. /**
  71449. * The frequency of thicker lines.
  71450. */
  71451. majorUnitFrequency: number;
  71452. /**
  71453. * The visibility of minor units in the grid.
  71454. */
  71455. minorUnitVisibility: number;
  71456. /**
  71457. * The grid opacity outside of the lines.
  71458. */
  71459. opacity: number;
  71460. /**
  71461. * Determine RBG output is premultiplied by alpha value.
  71462. */
  71463. preMultiplyAlpha: boolean;
  71464. private _opacityTexture;
  71465. opacityTexture: BABYLON.BaseTexture;
  71466. private _gridControl;
  71467. private _renderId;
  71468. /**
  71469. * constructor
  71470. * @param name The name given to the material in order to identify it afterwards.
  71471. * @param scene The scene the material is used in.
  71472. */
  71473. constructor(name: string, scene: BABYLON.Scene);
  71474. /**
  71475. * Returns wehter or not the grid requires alpha blending.
  71476. */
  71477. needAlphaBlending(): boolean;
  71478. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71479. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71480. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71481. /**
  71482. * Dispose the material and its associated resources.
  71483. * @param forceDisposeEffect will also dispose the used effect when true
  71484. */
  71485. dispose(forceDisposeEffect?: boolean): void;
  71486. clone(name: string): GridMaterial;
  71487. serialize(): any;
  71488. getClassName(): string;
  71489. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71490. }
  71491. }
  71492. declare module BABYLON {
  71493. /** @hidden */
  71494. export var lavaPixelShader: {
  71495. name: string;
  71496. shader: string;
  71497. };
  71498. }
  71499. declare module BABYLON {
  71500. /** @hidden */
  71501. export var lavaVertexShader: {
  71502. name: string;
  71503. shader: string;
  71504. };
  71505. }
  71506. declare module BABYLON {
  71507. export class LavaMaterial extends BABYLON.PushMaterial {
  71508. private _diffuseTexture;
  71509. diffuseTexture: BABYLON.BaseTexture;
  71510. noiseTexture: BABYLON.BaseTexture;
  71511. fogColor: BABYLON.Color3;
  71512. speed: number;
  71513. movingSpeed: number;
  71514. lowFrequencySpeed: number;
  71515. fogDensity: number;
  71516. private _lastTime;
  71517. diffuseColor: BABYLON.Color3;
  71518. private _disableLighting;
  71519. disableLighting: boolean;
  71520. private _unlit;
  71521. unlit: boolean;
  71522. private _maxSimultaneousLights;
  71523. maxSimultaneousLights: number;
  71524. private _scaledDiffuse;
  71525. private _renderId;
  71526. constructor(name: string, scene: BABYLON.Scene);
  71527. needAlphaBlending(): boolean;
  71528. needAlphaTesting(): boolean;
  71529. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71530. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71531. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71532. getAnimatables(): BABYLON.IAnimatable[];
  71533. getActiveTextures(): BABYLON.BaseTexture[];
  71534. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71535. dispose(forceDisposeEffect?: boolean): void;
  71536. clone(name: string): LavaMaterial;
  71537. serialize(): any;
  71538. getClassName(): string;
  71539. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71540. }
  71541. }
  71542. declare module BABYLON {
  71543. /** @hidden */
  71544. export var mixPixelShader: {
  71545. name: string;
  71546. shader: string;
  71547. };
  71548. }
  71549. declare module BABYLON {
  71550. /** @hidden */
  71551. export var mixVertexShader: {
  71552. name: string;
  71553. shader: string;
  71554. };
  71555. }
  71556. declare module BABYLON {
  71557. export class MixMaterial extends BABYLON.PushMaterial {
  71558. /**
  71559. * Mix textures
  71560. */
  71561. private _mixTexture1;
  71562. mixTexture1: BABYLON.BaseTexture;
  71563. private _mixTexture2;
  71564. mixTexture2: BABYLON.BaseTexture;
  71565. /**
  71566. * Diffuse textures
  71567. */
  71568. private _diffuseTexture1;
  71569. diffuseTexture1: BABYLON.Texture;
  71570. private _diffuseTexture2;
  71571. diffuseTexture2: BABYLON.Texture;
  71572. private _diffuseTexture3;
  71573. diffuseTexture3: BABYLON.Texture;
  71574. private _diffuseTexture4;
  71575. diffuseTexture4: BABYLON.Texture;
  71576. private _diffuseTexture5;
  71577. diffuseTexture5: BABYLON.Texture;
  71578. private _diffuseTexture6;
  71579. diffuseTexture6: BABYLON.Texture;
  71580. private _diffuseTexture7;
  71581. diffuseTexture7: BABYLON.Texture;
  71582. private _diffuseTexture8;
  71583. diffuseTexture8: BABYLON.Texture;
  71584. /**
  71585. * Uniforms
  71586. */
  71587. diffuseColor: BABYLON.Color3;
  71588. specularColor: BABYLON.Color3;
  71589. specularPower: number;
  71590. private _disableLighting;
  71591. disableLighting: boolean;
  71592. private _maxSimultaneousLights;
  71593. maxSimultaneousLights: number;
  71594. private _renderId;
  71595. constructor(name: string, scene: BABYLON.Scene);
  71596. needAlphaBlending(): boolean;
  71597. needAlphaTesting(): boolean;
  71598. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71599. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71600. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71601. getAnimatables(): BABYLON.IAnimatable[];
  71602. getActiveTextures(): BABYLON.BaseTexture[];
  71603. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71604. dispose(forceDisposeEffect?: boolean): void;
  71605. clone(name: string): MixMaterial;
  71606. serialize(): any;
  71607. getClassName(): string;
  71608. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71609. }
  71610. }
  71611. declare module BABYLON {
  71612. /** @hidden */
  71613. export var normalPixelShader: {
  71614. name: string;
  71615. shader: string;
  71616. };
  71617. }
  71618. declare module BABYLON {
  71619. /** @hidden */
  71620. export var normalVertexShader: {
  71621. name: string;
  71622. shader: string;
  71623. };
  71624. }
  71625. declare module BABYLON {
  71626. export class NormalMaterial extends BABYLON.PushMaterial {
  71627. private _diffuseTexture;
  71628. diffuseTexture: BABYLON.BaseTexture;
  71629. diffuseColor: BABYLON.Color3;
  71630. private _disableLighting;
  71631. disableLighting: boolean;
  71632. private _maxSimultaneousLights;
  71633. maxSimultaneousLights: number;
  71634. private _renderId;
  71635. constructor(name: string, scene: BABYLON.Scene);
  71636. needAlphaBlending(): boolean;
  71637. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71638. needAlphaTesting(): boolean;
  71639. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71640. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71641. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71642. getAnimatables(): BABYLON.IAnimatable[];
  71643. getActiveTextures(): BABYLON.BaseTexture[];
  71644. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71645. dispose(forceDisposeEffect?: boolean): void;
  71646. clone(name: string): NormalMaterial;
  71647. serialize(): any;
  71648. getClassName(): string;
  71649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var shadowOnlyPixelShader: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. /** @hidden */
  71661. export var shadowOnlyVertexShader: {
  71662. name: string;
  71663. shader: string;
  71664. };
  71665. }
  71666. declare module BABYLON {
  71667. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71668. private _renderId;
  71669. private _activeLight;
  71670. constructor(name: string, scene: BABYLON.Scene);
  71671. shadowColor: BABYLON.Color3;
  71672. needAlphaBlending(): boolean;
  71673. needAlphaTesting(): boolean;
  71674. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71675. activeLight: BABYLON.IShadowLight;
  71676. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71677. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71678. clone(name: string): ShadowOnlyMaterial;
  71679. serialize(): any;
  71680. getClassName(): string;
  71681. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71682. }
  71683. }
  71684. declare module BABYLON {
  71685. /** @hidden */
  71686. export var simplePixelShader: {
  71687. name: string;
  71688. shader: string;
  71689. };
  71690. }
  71691. declare module BABYLON {
  71692. /** @hidden */
  71693. export var simpleVertexShader: {
  71694. name: string;
  71695. shader: string;
  71696. };
  71697. }
  71698. declare module BABYLON {
  71699. export class SimpleMaterial extends BABYLON.PushMaterial {
  71700. private _diffuseTexture;
  71701. diffuseTexture: BABYLON.BaseTexture;
  71702. diffuseColor: BABYLON.Color3;
  71703. private _disableLighting;
  71704. disableLighting: boolean;
  71705. private _maxSimultaneousLights;
  71706. maxSimultaneousLights: number;
  71707. private _renderId;
  71708. constructor(name: string, scene: BABYLON.Scene);
  71709. needAlphaBlending(): boolean;
  71710. needAlphaTesting(): boolean;
  71711. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71712. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71713. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71714. getAnimatables(): BABYLON.IAnimatable[];
  71715. getActiveTextures(): BABYLON.BaseTexture[];
  71716. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71717. dispose(forceDisposeEffect?: boolean): void;
  71718. clone(name: string): SimpleMaterial;
  71719. serialize(): any;
  71720. getClassName(): string;
  71721. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71722. }
  71723. }
  71724. declare module BABYLON {
  71725. /** @hidden */
  71726. export var skyPixelShader: {
  71727. name: string;
  71728. shader: string;
  71729. };
  71730. }
  71731. declare module BABYLON {
  71732. /** @hidden */
  71733. export var skyVertexShader: {
  71734. name: string;
  71735. shader: string;
  71736. };
  71737. }
  71738. declare module BABYLON {
  71739. /**
  71740. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71741. * @see https://doc.babylonjs.com/extensions/sky
  71742. */
  71743. export class SkyMaterial extends BABYLON.PushMaterial {
  71744. /**
  71745. * Defines the overall luminance of sky in interval ]0, 1[.
  71746. */
  71747. luminance: number;
  71748. /**
  71749. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71750. */
  71751. turbidity: number;
  71752. /**
  71753. * Defines the sky appearance (light intensity).
  71754. */
  71755. rayleigh: number;
  71756. /**
  71757. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71758. */
  71759. mieCoefficient: number;
  71760. /**
  71761. * Defines the amount of haze particles following the Mie scattering theory.
  71762. */
  71763. mieDirectionalG: number;
  71764. /**
  71765. * Defines the distance of the sun according to the active scene camera.
  71766. */
  71767. distance: number;
  71768. /**
  71769. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71770. * "inclined".
  71771. */
  71772. inclination: number;
  71773. /**
  71774. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71775. * an object direction and a reference direction.
  71776. */
  71777. azimuth: number;
  71778. /**
  71779. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71780. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71781. */
  71782. sunPosition: BABYLON.Vector3;
  71783. /**
  71784. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71785. * .sunPosition property.
  71786. */
  71787. useSunPosition: boolean;
  71788. /**
  71789. * Defines an offset vector used to get a horizon offset.
  71790. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71791. */
  71792. cameraOffset: BABYLON.Vector3;
  71793. private _cameraPosition;
  71794. private _renderId;
  71795. /**
  71796. * Instantiates a new sky material.
  71797. * This material allows to create dynamic and texture free
  71798. * effects for skyboxes by taking care of the atmosphere state.
  71799. * @see https://doc.babylonjs.com/extensions/sky
  71800. * @param name Define the name of the material in the scene
  71801. * @param scene Define the scene the material belong to
  71802. */
  71803. constructor(name: string, scene: BABYLON.Scene);
  71804. /**
  71805. * Specifies if the material will require alpha blending
  71806. * @returns a boolean specifying if alpha blending is needed
  71807. */
  71808. needAlphaBlending(): boolean;
  71809. /**
  71810. * Specifies if this material should be rendered in alpha test mode
  71811. * @returns false as the sky material doesn't need alpha testing.
  71812. */
  71813. needAlphaTesting(): boolean;
  71814. /**
  71815. * Get the texture used for alpha test purpose.
  71816. * @returns null as the sky material has no texture.
  71817. */
  71818. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71819. /**
  71820. * Get if the submesh is ready to be used and all its information available.
  71821. * Child classes can use it to update shaders
  71822. * @param mesh defines the mesh to check
  71823. * @param subMesh defines which submesh to check
  71824. * @param useInstances specifies that instances should be used
  71825. * @returns a boolean indicating that the submesh is ready or not
  71826. */
  71827. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71828. /**
  71829. * Binds the submesh to this material by preparing the effect and shader to draw
  71830. * @param world defines the world transformation matrix
  71831. * @param mesh defines the mesh containing the submesh
  71832. * @param subMesh defines the submesh to bind the material to
  71833. */
  71834. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71835. /**
  71836. * Get the list of animatables in the material.
  71837. * @returns the list of animatables object used in the material
  71838. */
  71839. getAnimatables(): BABYLON.IAnimatable[];
  71840. /**
  71841. * Disposes the material
  71842. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71843. */
  71844. dispose(forceDisposeEffect?: boolean): void;
  71845. /**
  71846. * Makes a duplicate of the material, and gives it a new name
  71847. * @param name defines the new name for the duplicated material
  71848. * @returns the cloned material
  71849. */
  71850. clone(name: string): SkyMaterial;
  71851. /**
  71852. * Serializes this material in a JSON representation
  71853. * @returns the serialized material object
  71854. */
  71855. serialize(): any;
  71856. /**
  71857. * Gets the current class name of the material e.g. "SkyMaterial"
  71858. * Mainly use in serialization.
  71859. * @returns the class name
  71860. */
  71861. getClassName(): string;
  71862. /**
  71863. * Creates a sky material from parsed material data
  71864. * @param source defines the JSON representation of the material
  71865. * @param scene defines the hosting scene
  71866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71867. * @returns a new sky material
  71868. */
  71869. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71870. }
  71871. }
  71872. declare module BABYLON {
  71873. /** @hidden */
  71874. export var terrainPixelShader: {
  71875. name: string;
  71876. shader: string;
  71877. };
  71878. }
  71879. declare module BABYLON {
  71880. /** @hidden */
  71881. export var terrainVertexShader: {
  71882. name: string;
  71883. shader: string;
  71884. };
  71885. }
  71886. declare module BABYLON {
  71887. export class TerrainMaterial extends BABYLON.PushMaterial {
  71888. private _mixTexture;
  71889. mixTexture: BABYLON.BaseTexture;
  71890. private _diffuseTexture1;
  71891. diffuseTexture1: BABYLON.Texture;
  71892. private _diffuseTexture2;
  71893. diffuseTexture2: BABYLON.Texture;
  71894. private _diffuseTexture3;
  71895. diffuseTexture3: BABYLON.Texture;
  71896. private _bumpTexture1;
  71897. bumpTexture1: BABYLON.Texture;
  71898. private _bumpTexture2;
  71899. bumpTexture2: BABYLON.Texture;
  71900. private _bumpTexture3;
  71901. bumpTexture3: BABYLON.Texture;
  71902. diffuseColor: BABYLON.Color3;
  71903. specularColor: BABYLON.Color3;
  71904. specularPower: number;
  71905. private _disableLighting;
  71906. disableLighting: boolean;
  71907. private _maxSimultaneousLights;
  71908. maxSimultaneousLights: number;
  71909. private _renderId;
  71910. constructor(name: string, scene: BABYLON.Scene);
  71911. needAlphaBlending(): boolean;
  71912. needAlphaTesting(): boolean;
  71913. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71914. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71915. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71916. getAnimatables(): BABYLON.IAnimatable[];
  71917. getActiveTextures(): BABYLON.BaseTexture[];
  71918. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71919. dispose(forceDisposeEffect?: boolean): void;
  71920. clone(name: string): TerrainMaterial;
  71921. serialize(): any;
  71922. getClassName(): string;
  71923. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71924. }
  71925. }
  71926. declare module BABYLON {
  71927. /** @hidden */
  71928. export var triplanarPixelShader: {
  71929. name: string;
  71930. shader: string;
  71931. };
  71932. }
  71933. declare module BABYLON {
  71934. /** @hidden */
  71935. export var triplanarVertexShader: {
  71936. name: string;
  71937. shader: string;
  71938. };
  71939. }
  71940. declare module BABYLON {
  71941. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71942. mixTexture: BABYLON.BaseTexture;
  71943. private _diffuseTextureX;
  71944. diffuseTextureX: BABYLON.BaseTexture;
  71945. private _diffuseTextureY;
  71946. diffuseTextureY: BABYLON.BaseTexture;
  71947. private _diffuseTextureZ;
  71948. diffuseTextureZ: BABYLON.BaseTexture;
  71949. private _normalTextureX;
  71950. normalTextureX: BABYLON.BaseTexture;
  71951. private _normalTextureY;
  71952. normalTextureY: BABYLON.BaseTexture;
  71953. private _normalTextureZ;
  71954. normalTextureZ: BABYLON.BaseTexture;
  71955. tileSize: number;
  71956. diffuseColor: BABYLON.Color3;
  71957. specularColor: BABYLON.Color3;
  71958. specularPower: number;
  71959. private _disableLighting;
  71960. disableLighting: boolean;
  71961. private _maxSimultaneousLights;
  71962. maxSimultaneousLights: number;
  71963. private _renderId;
  71964. constructor(name: string, scene: BABYLON.Scene);
  71965. needAlphaBlending(): boolean;
  71966. needAlphaTesting(): boolean;
  71967. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71968. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71969. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71970. getAnimatables(): BABYLON.IAnimatable[];
  71971. getActiveTextures(): BABYLON.BaseTexture[];
  71972. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71973. dispose(forceDisposeEffect?: boolean): void;
  71974. clone(name: string): TriPlanarMaterial;
  71975. serialize(): any;
  71976. getClassName(): string;
  71977. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71978. }
  71979. }
  71980. declare module BABYLON {
  71981. /** @hidden */
  71982. export var waterPixelShader: {
  71983. name: string;
  71984. shader: string;
  71985. };
  71986. }
  71987. declare module BABYLON {
  71988. /** @hidden */
  71989. export var waterVertexShader: {
  71990. name: string;
  71991. shader: string;
  71992. };
  71993. }
  71994. declare module BABYLON {
  71995. export class WaterMaterial extends BABYLON.PushMaterial {
  71996. renderTargetSize: BABYLON.Vector2;
  71997. private _bumpTexture;
  71998. bumpTexture: BABYLON.BaseTexture;
  71999. diffuseColor: BABYLON.Color3;
  72000. specularColor: BABYLON.Color3;
  72001. specularPower: number;
  72002. private _disableLighting;
  72003. disableLighting: boolean;
  72004. private _maxSimultaneousLights;
  72005. maxSimultaneousLights: number;
  72006. /**
  72007. * @param {number}: Represents the wind force
  72008. */
  72009. windForce: number;
  72010. /**
  72011. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72012. */
  72013. windDirection: BABYLON.Vector2;
  72014. /**
  72015. * @param {number}: Wave height, represents the height of the waves
  72016. */
  72017. waveHeight: number;
  72018. /**
  72019. * @param {number}: Bump height, represents the bump height related to the bump map
  72020. */
  72021. bumpHeight: number;
  72022. /**
  72023. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72024. */
  72025. private _bumpSuperimpose;
  72026. bumpSuperimpose: boolean;
  72027. /**
  72028. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72029. */
  72030. private _fresnelSeparate;
  72031. fresnelSeparate: boolean;
  72032. /**
  72033. * @param {boolean}: bump Waves modify the reflection.
  72034. */
  72035. private _bumpAffectsReflection;
  72036. bumpAffectsReflection: boolean;
  72037. /**
  72038. * @param {number}: The water color blended with the refraction (near)
  72039. */
  72040. waterColor: BABYLON.Color3;
  72041. /**
  72042. * @param {number}: The blend factor related to the water color
  72043. */
  72044. colorBlendFactor: number;
  72045. /**
  72046. * @param {number}: The water color blended with the reflection (far)
  72047. */
  72048. waterColor2: BABYLON.Color3;
  72049. /**
  72050. * @param {number}: The blend factor related to the water color (reflection, far)
  72051. */
  72052. colorBlendFactor2: number;
  72053. /**
  72054. * @param {number}: Represents the maximum length of a wave
  72055. */
  72056. waveLength: number;
  72057. /**
  72058. * @param {number}: Defines the waves speed
  72059. */
  72060. waveSpeed: number;
  72061. /**
  72062. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72063. * will avoid calculating useless pixels in the pixel shader of the water material.
  72064. */
  72065. disableClipPlane: boolean;
  72066. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72067. private _mesh;
  72068. private _refractionRTT;
  72069. private _reflectionRTT;
  72070. private _reflectionTransform;
  72071. private _lastTime;
  72072. private _lastDeltaTime;
  72073. private _renderId;
  72074. private _useLogarithmicDepth;
  72075. private _waitingRenderList;
  72076. private _imageProcessingConfiguration;
  72077. private _imageProcessingObserver;
  72078. /**
  72079. * Gets a boolean indicating that current material needs to register RTT
  72080. */
  72081. readonly hasRenderTargetTextures: boolean;
  72082. /**
  72083. * Constructor
  72084. */
  72085. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72086. useLogarithmicDepth: boolean;
  72087. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72088. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72089. addToRenderList(node: any): void;
  72090. enableRenderTargets(enable: boolean): void;
  72091. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72092. readonly renderTargetsEnabled: boolean;
  72093. needAlphaBlending(): boolean;
  72094. needAlphaTesting(): boolean;
  72095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72096. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72097. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72098. private _createRenderTargets;
  72099. getAnimatables(): BABYLON.IAnimatable[];
  72100. getActiveTextures(): BABYLON.BaseTexture[];
  72101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72102. dispose(forceDisposeEffect?: boolean): void;
  72103. clone(name: string): WaterMaterial;
  72104. serialize(): any;
  72105. getClassName(): string;
  72106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72107. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72108. }
  72109. }
  72110. declare module BABYLON {
  72111. /** @hidden */
  72112. export var asciiartPixelShader: {
  72113. name: string;
  72114. shader: string;
  72115. };
  72116. }
  72117. declare module BABYLON {
  72118. /**
  72119. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72120. *
  72121. * It basically takes care rendering the font front the given font size to a texture.
  72122. * This is used later on in the postprocess.
  72123. */
  72124. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72125. private _font;
  72126. private _text;
  72127. private _charSize;
  72128. /**
  72129. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72130. */
  72131. readonly charSize: number;
  72132. /**
  72133. * Create a new instance of the Ascii Art FontTexture class
  72134. * @param name the name of the texture
  72135. * @param font the font to use, use the W3C CSS notation
  72136. * @param text the caracter set to use in the rendering.
  72137. * @param scene the scene that owns the texture
  72138. */
  72139. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72140. /**
  72141. * Gets the max char width of a font.
  72142. * @param font the font to use, use the W3C CSS notation
  72143. * @return the max char width
  72144. */
  72145. private getFontWidth;
  72146. /**
  72147. * Gets the max char height of a font.
  72148. * @param font the font to use, use the W3C CSS notation
  72149. * @return the max char height
  72150. */
  72151. private getFontHeight;
  72152. /**
  72153. * Clones the current AsciiArtTexture.
  72154. * @return the clone of the texture.
  72155. */
  72156. clone(): AsciiArtFontTexture;
  72157. /**
  72158. * Parses a json object representing the texture and returns an instance of it.
  72159. * @param source the source JSON representation
  72160. * @param scene the scene to create the texture for
  72161. * @return the parsed texture
  72162. */
  72163. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72164. }
  72165. /**
  72166. * Option available in the Ascii Art Post Process.
  72167. */
  72168. export interface IAsciiArtPostProcessOptions {
  72169. /**
  72170. * The font to use following the w3c font definition.
  72171. */
  72172. font?: string;
  72173. /**
  72174. * The character set to use in the postprocess.
  72175. */
  72176. characterSet?: string;
  72177. /**
  72178. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72179. * This number is defined between 0 and 1;
  72180. */
  72181. mixToTile?: number;
  72182. /**
  72183. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72184. * This number is defined between 0 and 1;
  72185. */
  72186. mixToNormal?: number;
  72187. }
  72188. /**
  72189. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72190. *
  72191. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72192. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72193. */
  72194. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72195. /**
  72196. * The font texture used to render the char in the post process.
  72197. */
  72198. private _asciiArtFontTexture;
  72199. /**
  72200. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72201. * This number is defined between 0 and 1;
  72202. */
  72203. mixToTile: number;
  72204. /**
  72205. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72206. * This number is defined between 0 and 1;
  72207. */
  72208. mixToNormal: number;
  72209. /**
  72210. * Instantiates a new Ascii Art Post Process.
  72211. * @param name the name to give to the postprocess
  72212. * @camera the camera to apply the post process to.
  72213. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72214. */
  72215. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /** @hidden */
  72220. export var digitalrainPixelShader: {
  72221. name: string;
  72222. shader: string;
  72223. };
  72224. }
  72225. declare module BABYLON {
  72226. /**
  72227. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72228. *
  72229. * It basically takes care rendering the font front the given font size to a texture.
  72230. * This is used later on in the postprocess.
  72231. */
  72232. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72233. private _font;
  72234. private _text;
  72235. private _charSize;
  72236. /**
  72237. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72238. */
  72239. readonly charSize: number;
  72240. /**
  72241. * Create a new instance of the Digital Rain FontTexture class
  72242. * @param name the name of the texture
  72243. * @param font the font to use, use the W3C CSS notation
  72244. * @param text the caracter set to use in the rendering.
  72245. * @param scene the scene that owns the texture
  72246. */
  72247. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72248. /**
  72249. * Gets the max char width of a font.
  72250. * @param font the font to use, use the W3C CSS notation
  72251. * @return the max char width
  72252. */
  72253. private getFontWidth;
  72254. /**
  72255. * Gets the max char height of a font.
  72256. * @param font the font to use, use the W3C CSS notation
  72257. * @return the max char height
  72258. */
  72259. private getFontHeight;
  72260. /**
  72261. * Clones the current DigitalRainFontTexture.
  72262. * @return the clone of the texture.
  72263. */
  72264. clone(): DigitalRainFontTexture;
  72265. /**
  72266. * Parses a json object representing the texture and returns an instance of it.
  72267. * @param source the source JSON representation
  72268. * @param scene the scene to create the texture for
  72269. * @return the parsed texture
  72270. */
  72271. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72272. }
  72273. /**
  72274. * Option available in the Digital Rain Post Process.
  72275. */
  72276. export interface IDigitalRainPostProcessOptions {
  72277. /**
  72278. * The font to use following the w3c font definition.
  72279. */
  72280. font?: string;
  72281. /**
  72282. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72283. * This number is defined between 0 and 1;
  72284. */
  72285. mixToTile?: number;
  72286. /**
  72287. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72288. * This number is defined between 0 and 1;
  72289. */
  72290. mixToNormal?: number;
  72291. }
  72292. /**
  72293. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72294. *
  72295. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72296. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72297. */
  72298. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72299. /**
  72300. * The font texture used to render the char in the post process.
  72301. */
  72302. private _digitalRainFontTexture;
  72303. /**
  72304. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72305. * This number is defined between 0 and 1;
  72306. */
  72307. mixToTile: number;
  72308. /**
  72309. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72310. * This number is defined between 0 and 1;
  72311. */
  72312. mixToNormal: number;
  72313. /**
  72314. * Instantiates a new Digital Rain Post Process.
  72315. * @param name the name to give to the postprocess
  72316. * @camera the camera to apply the post process to.
  72317. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72318. */
  72319. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72320. }
  72321. }
  72322. declare module BABYLON {
  72323. /** @hidden */
  72324. export var oceanPostProcessPixelShader: {
  72325. name: string;
  72326. shader: string;
  72327. };
  72328. }
  72329. declare module BABYLON {
  72330. /**
  72331. * Option available in the Ocean Post Process.
  72332. */
  72333. export interface IOceanPostProcessOptions {
  72334. /**
  72335. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72336. */
  72337. reflectionSize?: number | {
  72338. width: number;
  72339. height: number;
  72340. } | {
  72341. ratio: number;
  72342. };
  72343. /**
  72344. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72345. */
  72346. refractionSize?: number | {
  72347. width: number;
  72348. height: number;
  72349. } | {
  72350. ratio: number;
  72351. };
  72352. }
  72353. /**
  72354. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72355. *
  72356. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72357. * Example usage:
  72358. * var pp = new OceanPostProcess("myOcean", camera);
  72359. * pp.reflectionEnabled = true;
  72360. * pp.refractionEnabled = true;
  72361. */
  72362. export class OceanPostProcess extends BABYLON.PostProcess {
  72363. /**
  72364. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72365. */
  72366. /**
  72367. * Sets weither or not the real-time reflection is enabled on the ocean.
  72368. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72369. */
  72370. reflectionEnabled: boolean;
  72371. /**
  72372. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72373. */
  72374. /**
  72375. * Sets weither or not the real-time refraction is enabled on the ocean.
  72376. * Is set to true, the refraction render target texture will be used as refraction texture.
  72377. */
  72378. refractionEnabled: boolean;
  72379. /**
  72380. * Gets wether or not the post-processes is supported by the running hardware.
  72381. * This requires draw buffer supports.
  72382. */
  72383. readonly isSupported: boolean;
  72384. /**
  72385. * This is the reflection mirror texture used to display reflections on the ocean.
  72386. * By default, render list is empty.
  72387. */
  72388. reflectionTexture: BABYLON.MirrorTexture;
  72389. /**
  72390. * This is the refraction render target texture used to display refraction on the ocean.
  72391. * By default, render list is empty.
  72392. */
  72393. refractionTexture: BABYLON.RenderTargetTexture;
  72394. private _time;
  72395. private _cameraRotation;
  72396. private _cameraViewMatrix;
  72397. private _reflectionEnabled;
  72398. private _refractionEnabled;
  72399. private _geometryRenderer;
  72400. /**
  72401. * Instantiates a new Ocean Post Process.
  72402. * @param name the name to give to the postprocess.
  72403. * @camera the camera to apply the post process to.
  72404. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72405. */
  72406. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72407. /**
  72408. * Returns the appropriate defines according to the current configuration.
  72409. */
  72410. private _getDefines;
  72411. /**
  72412. * Computes the current camera rotation as the shader requires a camera rotation.
  72413. */
  72414. private _computeCameraRotation;
  72415. }
  72416. }
  72417. declare module BABYLON {
  72418. /** @hidden */
  72419. export var brickProceduralTexturePixelShader: {
  72420. name: string;
  72421. shader: string;
  72422. };
  72423. }
  72424. declare module BABYLON {
  72425. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72426. private _numberOfBricksHeight;
  72427. private _numberOfBricksWidth;
  72428. private _jointColor;
  72429. private _brickColor;
  72430. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72431. updateShaderUniforms(): void;
  72432. numberOfBricksHeight: number;
  72433. numberOfBricksWidth: number;
  72434. jointColor: BABYLON.Color3;
  72435. brickColor: BABYLON.Color3;
  72436. /**
  72437. * Serializes this brick procedural texture
  72438. * @returns a serialized brick procedural texture object
  72439. */
  72440. serialize(): any;
  72441. /**
  72442. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72443. * @param parsedTexture defines parsed texture data
  72444. * @param scene defines the current scene
  72445. * @param rootUrl defines the root URL containing brick procedural texture information
  72446. * @returns a parsed Brick Procedural BABYLON.Texture
  72447. */
  72448. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72449. }
  72450. }
  72451. declare module BABYLON {
  72452. /** @hidden */
  72453. export var cloudProceduralTexturePixelShader: {
  72454. name: string;
  72455. shader: string;
  72456. };
  72457. }
  72458. declare module BABYLON {
  72459. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72460. private _skyColor;
  72461. private _cloudColor;
  72462. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72463. updateShaderUniforms(): void;
  72464. skyColor: BABYLON.Color4;
  72465. cloudColor: BABYLON.Color4;
  72466. /**
  72467. * Serializes this cloud procedural texture
  72468. * @returns a serialized cloud procedural texture object
  72469. */
  72470. serialize(): any;
  72471. /**
  72472. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72473. * @param parsedTexture defines parsed texture data
  72474. * @param scene defines the current scene
  72475. * @param rootUrl defines the root URL containing cloud procedural texture information
  72476. * @returns a parsed Cloud Procedural BABYLON.Texture
  72477. */
  72478. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72479. }
  72480. }
  72481. declare module BABYLON {
  72482. /** @hidden */
  72483. export var fireProceduralTexturePixelShader: {
  72484. name: string;
  72485. shader: string;
  72486. };
  72487. }
  72488. declare module BABYLON {
  72489. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72490. private _time;
  72491. private _speed;
  72492. private _autoGenerateTime;
  72493. private _fireColors;
  72494. private _alphaThreshold;
  72495. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72496. updateShaderUniforms(): void;
  72497. render(useCameraPostProcess?: boolean): void;
  72498. static readonly PurpleFireColors: BABYLON.Color3[];
  72499. static readonly GreenFireColors: BABYLON.Color3[];
  72500. static readonly RedFireColors: BABYLON.Color3[];
  72501. static readonly BlueFireColors: BABYLON.Color3[];
  72502. autoGenerateTime: boolean;
  72503. fireColors: BABYLON.Color3[];
  72504. time: number;
  72505. speed: BABYLON.Vector2;
  72506. alphaThreshold: number;
  72507. /**
  72508. * Serializes this fire procedural texture
  72509. * @returns a serialized fire procedural texture object
  72510. */
  72511. serialize(): any;
  72512. /**
  72513. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72514. * @param parsedTexture defines parsed texture data
  72515. * @param scene defines the current scene
  72516. * @param rootUrl defines the root URL containing fire procedural texture information
  72517. * @returns a parsed Fire Procedural BABYLON.Texture
  72518. */
  72519. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72520. }
  72521. }
  72522. declare module BABYLON {
  72523. /** @hidden */
  72524. export var grassProceduralTexturePixelShader: {
  72525. name: string;
  72526. shader: string;
  72527. };
  72528. }
  72529. declare module BABYLON {
  72530. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72531. private _grassColors;
  72532. private _groundColor;
  72533. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72534. updateShaderUniforms(): void;
  72535. grassColors: BABYLON.Color3[];
  72536. groundColor: BABYLON.Color3;
  72537. /**
  72538. * Serializes this grass procedural texture
  72539. * @returns a serialized grass procedural texture object
  72540. */
  72541. serialize(): any;
  72542. /**
  72543. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72544. * @param parsedTexture defines parsed texture data
  72545. * @param scene defines the current scene
  72546. * @param rootUrl defines the root URL containing grass procedural texture information
  72547. * @returns a parsed Grass Procedural BABYLON.Texture
  72548. */
  72549. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72550. }
  72551. }
  72552. declare module BABYLON {
  72553. /** @hidden */
  72554. export var marbleProceduralTexturePixelShader: {
  72555. name: string;
  72556. shader: string;
  72557. };
  72558. }
  72559. declare module BABYLON {
  72560. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72561. private _numberOfTilesHeight;
  72562. private _numberOfTilesWidth;
  72563. private _amplitude;
  72564. private _jointColor;
  72565. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72566. updateShaderUniforms(): void;
  72567. numberOfTilesHeight: number;
  72568. amplitude: number;
  72569. numberOfTilesWidth: number;
  72570. jointColor: BABYLON.Color3;
  72571. /**
  72572. * Serializes this marble procedural texture
  72573. * @returns a serialized marble procedural texture object
  72574. */
  72575. serialize(): any;
  72576. /**
  72577. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72578. * @param parsedTexture defines parsed texture data
  72579. * @param scene defines the current scene
  72580. * @param rootUrl defines the root URL containing marble procedural texture information
  72581. * @returns a parsed Marble Procedural BABYLON.Texture
  72582. */
  72583. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72584. }
  72585. }
  72586. declare module BABYLON {
  72587. /** @hidden */
  72588. export var normalMapProceduralTexturePixelShader: {
  72589. name: string;
  72590. shader: string;
  72591. };
  72592. }
  72593. declare module BABYLON {
  72594. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72595. private _baseTexture;
  72596. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72597. updateShaderUniforms(): void;
  72598. render(useCameraPostProcess?: boolean): void;
  72599. resize(size: any, generateMipMaps: any): void;
  72600. baseTexture: BABYLON.Texture;
  72601. /**
  72602. * Serializes this normal map procedural texture
  72603. * @returns a serialized normal map procedural texture object
  72604. */
  72605. serialize(): any;
  72606. /**
  72607. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72608. * @param parsedTexture defines parsed texture data
  72609. * @param scene defines the current scene
  72610. * @param rootUrl defines the root URL containing normal map procedural texture information
  72611. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72612. */
  72613. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72614. }
  72615. }
  72616. declare module BABYLON {
  72617. /** @hidden */
  72618. export var perlinNoiseProceduralTexturePixelShader: {
  72619. name: string;
  72620. shader: string;
  72621. };
  72622. }
  72623. declare module BABYLON {
  72624. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72625. time: number;
  72626. timeScale: number;
  72627. translationSpeed: number;
  72628. private _currentTranslation;
  72629. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72630. updateShaderUniforms(): void;
  72631. render(useCameraPostProcess?: boolean): void;
  72632. resize(size: any, generateMipMaps: any): void;
  72633. /**
  72634. * Serializes this perlin noise procedural texture
  72635. * @returns a serialized perlin noise procedural texture object
  72636. */
  72637. serialize(): any;
  72638. /**
  72639. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72640. * @param parsedTexture defines parsed texture data
  72641. * @param scene defines the current scene
  72642. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72643. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72644. */
  72645. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /** @hidden */
  72650. export var roadProceduralTexturePixelShader: {
  72651. name: string;
  72652. shader: string;
  72653. };
  72654. }
  72655. declare module BABYLON {
  72656. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72657. private _roadColor;
  72658. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72659. updateShaderUniforms(): void;
  72660. roadColor: BABYLON.Color3;
  72661. /**
  72662. * Serializes this road procedural texture
  72663. * @returns a serialized road procedural texture object
  72664. */
  72665. serialize(): any;
  72666. /**
  72667. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72668. * @param parsedTexture defines parsed texture data
  72669. * @param scene defines the current scene
  72670. * @param rootUrl defines the root URL containing road procedural texture information
  72671. * @returns a parsed Road Procedural BABYLON.Texture
  72672. */
  72673. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72674. }
  72675. }
  72676. declare module BABYLON {
  72677. /** @hidden */
  72678. export var starfieldProceduralTexturePixelShader: {
  72679. name: string;
  72680. shader: string;
  72681. };
  72682. }
  72683. declare module BABYLON {
  72684. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72685. private _time;
  72686. private _alpha;
  72687. private _beta;
  72688. private _zoom;
  72689. private _formuparam;
  72690. private _stepsize;
  72691. private _tile;
  72692. private _brightness;
  72693. private _darkmatter;
  72694. private _distfading;
  72695. private _saturation;
  72696. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72697. updateShaderUniforms(): void;
  72698. time: number;
  72699. alpha: number;
  72700. beta: number;
  72701. formuparam: number;
  72702. stepsize: number;
  72703. zoom: number;
  72704. tile: number;
  72705. brightness: number;
  72706. darkmatter: number;
  72707. distfading: number;
  72708. saturation: number;
  72709. /**
  72710. * Serializes this starfield procedural texture
  72711. * @returns a serialized starfield procedural texture object
  72712. */
  72713. serialize(): any;
  72714. /**
  72715. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72716. * @param parsedTexture defines parsed texture data
  72717. * @param scene defines the current scene
  72718. * @param rootUrl defines the root URL containing startfield procedural texture information
  72719. * @returns a parsed Starfield Procedural BABYLON.Texture
  72720. */
  72721. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72722. }
  72723. }
  72724. declare module BABYLON {
  72725. /** @hidden */
  72726. export var woodProceduralTexturePixelShader: {
  72727. name: string;
  72728. shader: string;
  72729. };
  72730. }
  72731. declare module BABYLON {
  72732. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72733. private _ampScale;
  72734. private _woodColor;
  72735. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72736. updateShaderUniforms(): void;
  72737. ampScale: number;
  72738. woodColor: BABYLON.Color3;
  72739. /**
  72740. * Serializes this wood procedural texture
  72741. * @returns a serialized wood procedural texture object
  72742. */
  72743. serialize(): any;
  72744. /**
  72745. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72746. * @param parsedTexture defines parsed texture data
  72747. * @param scene defines the current scene
  72748. * @param rootUrl defines the root URL containing wood procedural texture information
  72749. * @returns a parsed Wood Procedural BABYLON.Texture
  72750. */
  72751. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72752. }
  72753. }