documentation.d.ts 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. 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);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * 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)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * 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
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * 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"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * 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".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * 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"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * 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".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** 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 */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** 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 */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** 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 */
  4090. static readonly GEQUAL: number;
  4091. /** 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 */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * 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.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. 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;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** 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 */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows 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. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows 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. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows 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. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * 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)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /**
  11217. * Force the sprite under the pointer
  11218. * @param sprite defines the sprite to use
  11219. */
  11220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11221. /**
  11222. * Gets the sprite under the pointer
  11223. * @returns a Sprite or null if no sprite is under the pointer
  11224. */
  11225. getPointerOverSprite(): Nullable<Sprite>;
  11226. }
  11227. /**
  11228. * Defines the sprite scene component responsible to manage sprites
  11229. * in a given scene.
  11230. */
  11231. export class SpriteSceneComponent implements ISceneComponent {
  11232. /**
  11233. * The component name helpfull to identify the component in the list of scene components.
  11234. */
  11235. readonly name: string;
  11236. /**
  11237. * The scene the component belongs to.
  11238. */
  11239. scene: Scene;
  11240. /** @hidden */
  11241. private _spritePredicate;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Disposes the component and the associated ressources.
  11258. */
  11259. dispose(): void;
  11260. private _pickSpriteButKeepRay;
  11261. private _pointerMove;
  11262. private _pointerDown;
  11263. private _pointerUp;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogFragmentDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var fogFragment: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /** @hidden */
  11282. export var spritesPixelShader: {
  11283. name: string;
  11284. shader: string;
  11285. };
  11286. }
  11287. declare module BABYLON {
  11288. /** @hidden */
  11289. export var fogVertexDeclaration: {
  11290. name: string;
  11291. shader: string;
  11292. };
  11293. }
  11294. declare module BABYLON {
  11295. /** @hidden */
  11296. export var spritesVertexShader: {
  11297. name: string;
  11298. shader: string;
  11299. };
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11304. */
  11305. export interface ISpriteManager extends IDisposable {
  11306. /**
  11307. * Restricts the camera to viewing objects with the same layerMask.
  11308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11309. */
  11310. layerMask: number;
  11311. /**
  11312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11313. */
  11314. isPickable: boolean;
  11315. /**
  11316. * Specifies the rendering group id for this mesh (0 by default)
  11317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11318. */
  11319. renderingGroupId: number;
  11320. /**
  11321. * Defines the list of sprites managed by the manager.
  11322. */
  11323. sprites: Array<Sprite>;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Renders the list of sprites on screen.
  11335. */
  11336. render(): void;
  11337. }
  11338. /**
  11339. * Class used to manage multiple sprites on the same spritesheet
  11340. * @see http://doc.babylonjs.com/babylon101/sprites
  11341. */
  11342. export class SpriteManager implements ISpriteManager {
  11343. /** defines the manager's name */
  11344. name: string;
  11345. /** Gets the list of sprites */
  11346. sprites: Sprite[];
  11347. /** Gets or sets the rendering group id (0 by default) */
  11348. renderingGroupId: number;
  11349. /** Gets or sets camera layer mask */
  11350. layerMask: number;
  11351. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11352. fogEnabled: boolean;
  11353. /** Gets or sets a boolean indicating if the sprites are pickable */
  11354. isPickable: boolean;
  11355. /** Defines the default width of a cell in the spritesheet */
  11356. cellWidth: number;
  11357. /** Defines the default height of a cell in the spritesheet */
  11358. cellHeight: number;
  11359. /**
  11360. * An event triggered when the manager is disposed.
  11361. */
  11362. onDisposeObservable: Observable<SpriteManager>;
  11363. private _onDisposeObserver;
  11364. /**
  11365. * Callback called when the manager is disposed
  11366. */
  11367. onDispose: () => void;
  11368. private _capacity;
  11369. private _spriteTexture;
  11370. private _epsilon;
  11371. private _scene;
  11372. private _vertexData;
  11373. private _buffer;
  11374. private _vertexBuffers;
  11375. private _indexBuffer;
  11376. private _effectBase;
  11377. private _effectFog;
  11378. /**
  11379. * Gets or sets the spritesheet texture
  11380. */
  11381. texture: Texture;
  11382. /**
  11383. * Creates a new sprite manager
  11384. * @param name defines the manager's name
  11385. * @param imgUrl defines the sprite sheet url
  11386. * @param capacity defines the maximum allowed number of sprites
  11387. * @param cellSize defines the size of a sprite cell
  11388. * @param scene defines the hosting scene
  11389. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11390. * @param samplingMode defines the smapling mode to use with spritesheet
  11391. */
  11392. constructor(
  11393. /** defines the manager's name */
  11394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11395. private _appendSpriteVertex;
  11396. /**
  11397. * Intersects the sprites with a ray
  11398. * @param ray defines the ray to intersect with
  11399. * @param camera defines the current active camera
  11400. * @param predicate defines a predicate used to select candidate sprites
  11401. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11402. * @returns null if no hit or a PickingInfo
  11403. */
  11404. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11405. /**
  11406. * Render all child sprites
  11407. */
  11408. render(): void;
  11409. /**
  11410. * Release associated resources
  11411. */
  11412. dispose(): void;
  11413. }
  11414. }
  11415. declare module BABYLON {
  11416. /**
  11417. * Class used to represent a sprite
  11418. * @see http://doc.babylonjs.com/babylon101/sprites
  11419. */
  11420. export class Sprite {
  11421. /** defines the name */
  11422. name: string;
  11423. /** Gets or sets the current world position */
  11424. position: Vector3;
  11425. /** Gets or sets the main color */
  11426. color: Color4;
  11427. /** Gets or sets the width */
  11428. width: number;
  11429. /** Gets or sets the height */
  11430. height: number;
  11431. /** Gets or sets rotation angle */
  11432. angle: number;
  11433. /** Gets or sets the cell index in the sprite sheet */
  11434. cellIndex: number;
  11435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11436. invertU: number;
  11437. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11438. invertV: number;
  11439. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11440. disposeWhenFinishedAnimating: boolean;
  11441. /** Gets the list of attached animations */
  11442. animations: Animation[];
  11443. /** Gets or sets a boolean indicating if the sprite can be picked */
  11444. isPickable: boolean;
  11445. /**
  11446. * Gets or sets the associated action manager
  11447. */
  11448. actionManager: Nullable<ActionManager>;
  11449. private _animationStarted;
  11450. private _loopAnimation;
  11451. private _fromIndex;
  11452. private _toIndex;
  11453. private _delay;
  11454. private _direction;
  11455. private _manager;
  11456. private _time;
  11457. private _onAnimationEnd;
  11458. /**
  11459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11460. */
  11461. isVisible: boolean;
  11462. /**
  11463. * Gets or sets the sprite size
  11464. */
  11465. size: number;
  11466. /**
  11467. * Creates a new Sprite
  11468. * @param name defines the name
  11469. * @param manager defines the manager
  11470. */
  11471. constructor(
  11472. /** defines the name */
  11473. name: string, manager: ISpriteManager);
  11474. /**
  11475. * Starts an animation
  11476. * @param from defines the initial key
  11477. * @param to defines the end key
  11478. * @param loop defines if the animation must loop
  11479. * @param delay defines the start delay (in ms)
  11480. * @param onAnimationEnd defines a callback to call when animation ends
  11481. */
  11482. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11483. /** Stops current animation (if any) */
  11484. stopAnimation(): void;
  11485. /** @hidden */
  11486. _animate(deltaTime: number): void;
  11487. /** Release associated resources */
  11488. dispose(): void;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /**
  11493. * Information about the result of picking within a scene
  11494. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11495. */
  11496. export class PickingInfo {
  11497. /** @hidden */
  11498. _pickingUnavailable: boolean;
  11499. /**
  11500. * If the pick collided with an object
  11501. */
  11502. hit: boolean;
  11503. /**
  11504. * Distance away where the pick collided
  11505. */
  11506. distance: number;
  11507. /**
  11508. * The location of pick collision
  11509. */
  11510. pickedPoint: Nullable<Vector3>;
  11511. /**
  11512. * The mesh corresponding the the pick collision
  11513. */
  11514. pickedMesh: Nullable<AbstractMesh>;
  11515. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11516. bu: number;
  11517. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11518. bv: number;
  11519. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11520. faceId: number;
  11521. /** Id of the the submesh that was picked */
  11522. subMeshId: number;
  11523. /** If a sprite was picked, this will be the sprite the pick collided with */
  11524. pickedSprite: Nullable<Sprite>;
  11525. /**
  11526. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11527. */
  11528. originMesh: Nullable<AbstractMesh>;
  11529. /**
  11530. * The ray that was used to perform the picking.
  11531. */
  11532. ray: Nullable<Ray>;
  11533. /**
  11534. * Gets the normal correspodning to the face the pick collided with
  11535. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11536. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11537. * @returns The normal correspodning to the face the pick collided with
  11538. */
  11539. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11540. /**
  11541. * Gets the texture coordinates of where the pick occured
  11542. * @returns the vector containing the coordnates of the texture
  11543. */
  11544. getTextureCoordinates(): Nullable<Vector2>;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Gather the list of pointer event types as constants.
  11550. */
  11551. export class PointerEventTypes {
  11552. /**
  11553. * 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.
  11554. */
  11555. static readonly POINTERDOWN: number;
  11556. /**
  11557. * The pointerup event is fired when a pointer is no longer active.
  11558. */
  11559. static readonly POINTERUP: number;
  11560. /**
  11561. * The pointermove event is fired when a pointer changes coordinates.
  11562. */
  11563. static readonly POINTERMOVE: number;
  11564. /**
  11565. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11566. */
  11567. static readonly POINTERWHEEL: number;
  11568. /**
  11569. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11570. */
  11571. static readonly POINTERPICK: number;
  11572. /**
  11573. * The pointertap event is fired when a the object has been touched and released without drag.
  11574. */
  11575. static readonly POINTERTAP: number;
  11576. /**
  11577. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11578. */
  11579. static readonly POINTERDOUBLETAP: number;
  11580. }
  11581. /**
  11582. * Base class of pointer info types.
  11583. */
  11584. export class PointerInfoBase {
  11585. /**
  11586. * Defines the type of event (PointerEventTypes)
  11587. */
  11588. type: number;
  11589. /**
  11590. * Defines the related dom event
  11591. */
  11592. event: PointerEvent | MouseWheelEvent;
  11593. /**
  11594. * Instantiates the base class of pointers info.
  11595. * @param type Defines the type of event (PointerEventTypes)
  11596. * @param event Defines the related dom event
  11597. */
  11598. constructor(
  11599. /**
  11600. * Defines the type of event (PointerEventTypes)
  11601. */
  11602. type: number,
  11603. /**
  11604. * Defines the related dom event
  11605. */
  11606. event: PointerEvent | MouseWheelEvent);
  11607. }
  11608. /**
  11609. * This class is used to store pointer related info for the onPrePointerObservable event.
  11610. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11611. */
  11612. export class PointerInfoPre extends PointerInfoBase {
  11613. /**
  11614. * Ray from a pointer if availible (eg. 6dof controller)
  11615. */
  11616. ray: Nullable<Ray>;
  11617. /**
  11618. * Defines the local position of the pointer on the canvas.
  11619. */
  11620. localPosition: Vector2;
  11621. /**
  11622. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11623. */
  11624. skipOnPointerObservable: boolean;
  11625. /**
  11626. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11627. * @param type Defines the type of event (PointerEventTypes)
  11628. * @param event Defines the related dom event
  11629. * @param localX Defines the local x coordinates of the pointer when the event occured
  11630. * @param localY Defines the local y coordinates of the pointer when the event occured
  11631. */
  11632. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11633. }
  11634. /**
  11635. * This type contains all the data related to a pointer event in Babylon.js.
  11636. * 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.
  11637. */
  11638. export class PointerInfo extends PointerInfoBase {
  11639. /**
  11640. * Defines the picking info associated to the info (if any)\
  11641. */
  11642. pickInfo: Nullable<PickingInfo>;
  11643. /**
  11644. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. * @param pickInfo Defines the picking info associated to the info (if any)\
  11648. */
  11649. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11650. /**
  11651. * Defines the picking info associated to the info (if any)\
  11652. */
  11653. pickInfo: Nullable<PickingInfo>);
  11654. }
  11655. /**
  11656. * Data relating to a touch event on the screen.
  11657. */
  11658. export interface PointerTouch {
  11659. /**
  11660. * X coordinate of touch.
  11661. */
  11662. x: number;
  11663. /**
  11664. * Y coordinate of touch.
  11665. */
  11666. y: number;
  11667. /**
  11668. * Id of touch. Unique for each finger.
  11669. */
  11670. pointerId: number;
  11671. /**
  11672. * Event type passed from DOM.
  11673. */
  11674. type: any;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Manage the mouse inputs to control the movement of a free camera.
  11680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11681. */
  11682. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11683. /**
  11684. * Define if touch is enabled in the mouse input
  11685. */
  11686. touchEnabled: boolean;
  11687. /**
  11688. * Defines the camera the input is attached to.
  11689. */
  11690. camera: FreeCamera;
  11691. /**
  11692. * Defines the buttons associated with the input to handle camera move.
  11693. */
  11694. buttons: number[];
  11695. /**
  11696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11697. */
  11698. angularSensibility: number;
  11699. private _pointerInput;
  11700. private _onMouseMove;
  11701. private _observer;
  11702. private previousPosition;
  11703. /**
  11704. * Observable for when a pointer move event occurs containing the move offset
  11705. */
  11706. onPointerMovedObservable: Observable<{
  11707. offsetX: number;
  11708. offsetY: number;
  11709. }>;
  11710. /**
  11711. * @hidden
  11712. * If the camera should be rotated automatically based on pointer movement
  11713. */
  11714. _allowCameraRotation: boolean;
  11715. /**
  11716. * Manage the mouse inputs to control the movement of a free camera.
  11717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11718. * @param touchEnabled Defines if touch is enabled or not
  11719. */
  11720. constructor(
  11721. /**
  11722. * Define if touch is enabled in the mouse input
  11723. */
  11724. touchEnabled?: boolean);
  11725. /**
  11726. * Attach the input controls to a specific dom element to get the input from.
  11727. * @param element Defines the element the controls should be listened from
  11728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11729. */
  11730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11731. /**
  11732. * Called on JS contextmenu event.
  11733. * Override this method to provide functionality.
  11734. */
  11735. protected onContextMenu(evt: PointerEvent): void;
  11736. /**
  11737. * Detach the current controls from the specified dom element.
  11738. * @param element Defines the element to stop listening the inputs from
  11739. */
  11740. detachControl(element: Nullable<HTMLElement>): void;
  11741. /**
  11742. * Gets the class name of the current intput.
  11743. * @returns the class name
  11744. */
  11745. getClassName(): string;
  11746. /**
  11747. * Get the friendly name associated with the input class.
  11748. * @returns the input friendly name
  11749. */
  11750. getSimpleName(): string;
  11751. }
  11752. }
  11753. declare module BABYLON {
  11754. /**
  11755. * Manage the touch inputs to control the movement of a free camera.
  11756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11757. */
  11758. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11759. /**
  11760. * Defines the camera the input is attached to.
  11761. */
  11762. camera: FreeCamera;
  11763. /**
  11764. * Defines the touch sensibility for rotation.
  11765. * The higher the faster.
  11766. */
  11767. touchAngularSensibility: number;
  11768. /**
  11769. * Defines the touch sensibility for move.
  11770. * The higher the faster.
  11771. */
  11772. touchMoveSensibility: number;
  11773. private _offsetX;
  11774. private _offsetY;
  11775. private _pointerPressed;
  11776. private _pointerInput;
  11777. private _observer;
  11778. private _onLostFocus;
  11779. /**
  11780. * Attach the input controls to a specific dom element to get the input from.
  11781. * @param element Defines the element the controls should be listened from
  11782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11783. */
  11784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11785. /**
  11786. * Detach the current controls from the specified dom element.
  11787. * @param element Defines the element to stop listening the inputs from
  11788. */
  11789. detachControl(element: Nullable<HTMLElement>): void;
  11790. /**
  11791. * Update the current camera state depending on the inputs that have been used this frame.
  11792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11793. */
  11794. checkInputs(): void;
  11795. /**
  11796. * Gets the class name of the current intput.
  11797. * @returns the class name
  11798. */
  11799. getClassName(): string;
  11800. /**
  11801. * Get the friendly name associated with the input class.
  11802. * @returns the input friendly name
  11803. */
  11804. getSimpleName(): string;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Default Inputs manager for the FreeCamera.
  11810. * It groups all the default supported inputs for ease of use.
  11811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11812. */
  11813. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11814. /**
  11815. * @hidden
  11816. */
  11817. _mouseInput: Nullable<FreeCameraMouseInput>;
  11818. /**
  11819. * Instantiates a new FreeCameraInputsManager.
  11820. * @param camera Defines the camera the inputs belong to
  11821. */
  11822. constructor(camera: FreeCamera);
  11823. /**
  11824. * Add keyboard input support to the input manager.
  11825. * @returns the current input manager
  11826. */
  11827. addKeyboard(): FreeCameraInputsManager;
  11828. /**
  11829. * Add mouse input support to the input manager.
  11830. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11831. * @returns the current input manager
  11832. */
  11833. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11834. /**
  11835. * Removes the mouse input support from the manager
  11836. * @returns the current input manager
  11837. */
  11838. removeMouse(): FreeCameraInputsManager;
  11839. /**
  11840. * Add touch input support to the input manager.
  11841. * @returns the current input manager
  11842. */
  11843. addTouch(): FreeCameraInputsManager;
  11844. /**
  11845. * Remove all attached input methods from a camera
  11846. */
  11847. clear(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11853. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11855. */
  11856. export class FreeCamera extends TargetCamera {
  11857. /**
  11858. * Define the collision ellipsoid of the camera.
  11859. * This is helpful to simulate a camera body like the player body around the camera
  11860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11861. */
  11862. ellipsoid: Vector3;
  11863. /**
  11864. * Define an offset for the position of the ellipsoid around the camera.
  11865. * This can be helpful to determine the center of the body near the gravity center of the body
  11866. * instead of its head.
  11867. */
  11868. ellipsoidOffset: Vector3;
  11869. /**
  11870. * Enable or disable collisions of the camera with the rest of the scene objects.
  11871. */
  11872. checkCollisions: boolean;
  11873. /**
  11874. * Enable or disable gravity on the camera.
  11875. */
  11876. applyGravity: boolean;
  11877. /**
  11878. * Define the input manager associated to the camera.
  11879. */
  11880. inputs: FreeCameraInputsManager;
  11881. /**
  11882. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11883. * Higher values reduce sensitivity.
  11884. */
  11885. /**
  11886. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11887. * Higher values reduce sensitivity.
  11888. */
  11889. angularSensibility: number;
  11890. /**
  11891. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11892. */
  11893. keysUp: number[];
  11894. /**
  11895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11896. */
  11897. keysDown: number[];
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11900. */
  11901. keysLeft: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11904. */
  11905. keysRight: number[];
  11906. /**
  11907. * Event raised when the camera collide with a mesh in the scene.
  11908. */
  11909. onCollide: (collidedMesh: AbstractMesh) => void;
  11910. private _collider;
  11911. private _needMoveForGravity;
  11912. private _oldPosition;
  11913. private _diffPosition;
  11914. private _newPosition;
  11915. /** @hidden */
  11916. _localDirection: Vector3;
  11917. /** @hidden */
  11918. _transformedDirection: Vector3;
  11919. /**
  11920. * Instantiates a Free Camera.
  11921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11922. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. * @param name Define the name of the camera in the scene
  11925. * @param position Define the start position of the camera in the scene
  11926. * @param scene Define the scene the camera belongs to
  11927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11930. /**
  11931. * Attached controls to the current camera.
  11932. * @param element Defines the element the controls should be listened from
  11933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11934. */
  11935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11936. /**
  11937. * Detach the current controls from the camera.
  11938. * The camera will stop reacting to inputs.
  11939. * @param element Defines the element to stop listening the inputs from
  11940. */
  11941. detachControl(element: HTMLElement): void;
  11942. private _collisionMask;
  11943. /**
  11944. * Define a collision mask to limit the list of object the camera can collide with
  11945. */
  11946. collisionMask: number;
  11947. /** @hidden */
  11948. _collideWithWorld(displacement: Vector3): void;
  11949. private _onCollisionPositionChange;
  11950. /** @hidden */
  11951. _checkInputs(): void;
  11952. /** @hidden */
  11953. _decideIfNeedsToMove(): boolean;
  11954. /** @hidden */
  11955. _updatePosition(): void;
  11956. /**
  11957. * Destroy the camera and release the current resources hold by it.
  11958. */
  11959. dispose(): void;
  11960. /**
  11961. * Gets the current object class name.
  11962. * @return the class name
  11963. */
  11964. getClassName(): string;
  11965. }
  11966. }
  11967. declare module BABYLON {
  11968. /**
  11969. * Represents a gamepad control stick position
  11970. */
  11971. export class StickValues {
  11972. /**
  11973. * The x component of the control stick
  11974. */
  11975. x: number;
  11976. /**
  11977. * The y component of the control stick
  11978. */
  11979. y: number;
  11980. /**
  11981. * Initializes the gamepad x and y control stick values
  11982. * @param x The x component of the gamepad control stick value
  11983. * @param y The y component of the gamepad control stick value
  11984. */
  11985. constructor(
  11986. /**
  11987. * The x component of the control stick
  11988. */
  11989. x: number,
  11990. /**
  11991. * The y component of the control stick
  11992. */
  11993. y: number);
  11994. }
  11995. /**
  11996. * An interface which manages callbacks for gamepad button changes
  11997. */
  11998. export interface GamepadButtonChanges {
  11999. /**
  12000. * Called when a gamepad has been changed
  12001. */
  12002. changed: boolean;
  12003. /**
  12004. * Called when a gamepad press event has been triggered
  12005. */
  12006. pressChanged: boolean;
  12007. /**
  12008. * Called when a touch event has been triggered
  12009. */
  12010. touchChanged: boolean;
  12011. /**
  12012. * Called when a value has changed
  12013. */
  12014. valueChanged: boolean;
  12015. }
  12016. /**
  12017. * Represents a gamepad
  12018. */
  12019. export class Gamepad {
  12020. /**
  12021. * The id of the gamepad
  12022. */
  12023. id: string;
  12024. /**
  12025. * The index of the gamepad
  12026. */
  12027. index: number;
  12028. /**
  12029. * The browser gamepad
  12030. */
  12031. browserGamepad: any;
  12032. /**
  12033. * Specifies what type of gamepad this represents
  12034. */
  12035. type: number;
  12036. private _leftStick;
  12037. private _rightStick;
  12038. /** @hidden */
  12039. _isConnected: boolean;
  12040. private _leftStickAxisX;
  12041. private _leftStickAxisY;
  12042. private _rightStickAxisX;
  12043. private _rightStickAxisY;
  12044. /**
  12045. * Triggered when the left control stick has been changed
  12046. */
  12047. private _onleftstickchanged;
  12048. /**
  12049. * Triggered when the right control stick has been changed
  12050. */
  12051. private _onrightstickchanged;
  12052. /**
  12053. * Represents a gamepad controller
  12054. */
  12055. static GAMEPAD: number;
  12056. /**
  12057. * Represents a generic controller
  12058. */
  12059. static GENERIC: number;
  12060. /**
  12061. * Represents an XBox controller
  12062. */
  12063. static XBOX: number;
  12064. /**
  12065. * Represents a pose-enabled controller
  12066. */
  12067. static POSE_ENABLED: number;
  12068. /**
  12069. * Specifies whether the left control stick should be Y-inverted
  12070. */
  12071. protected _invertLeftStickY: boolean;
  12072. /**
  12073. * Specifies if the gamepad has been connected
  12074. */
  12075. readonly isConnected: boolean;
  12076. /**
  12077. * Initializes the gamepad
  12078. * @param id The id of the gamepad
  12079. * @param index The index of the gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. * @param leftStickX The x component of the left joystick
  12082. * @param leftStickY The y component of the left joystick
  12083. * @param rightStickX The x component of the right joystick
  12084. * @param rightStickY The y component of the right joystick
  12085. */
  12086. constructor(
  12087. /**
  12088. * The id of the gamepad
  12089. */
  12090. id: string,
  12091. /**
  12092. * The index of the gamepad
  12093. */
  12094. index: number,
  12095. /**
  12096. * The browser gamepad
  12097. */
  12098. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12099. /**
  12100. * Callback triggered when the left joystick has changed
  12101. * @param callback
  12102. */
  12103. onleftstickchanged(callback: (values: StickValues) => void): void;
  12104. /**
  12105. * Callback triggered when the right joystick has changed
  12106. * @param callback
  12107. */
  12108. onrightstickchanged(callback: (values: StickValues) => void): void;
  12109. /**
  12110. * Gets the left joystick
  12111. */
  12112. /**
  12113. * Sets the left joystick values
  12114. */
  12115. leftStick: StickValues;
  12116. /**
  12117. * Gets the right joystick
  12118. */
  12119. /**
  12120. * Sets the right joystick value
  12121. */
  12122. rightStick: StickValues;
  12123. /**
  12124. * Updates the gamepad joystick positions
  12125. */
  12126. update(): void;
  12127. /**
  12128. * Disposes the gamepad
  12129. */
  12130. dispose(): void;
  12131. }
  12132. /**
  12133. * Represents a generic gamepad
  12134. */
  12135. export class GenericPad extends Gamepad {
  12136. private _buttons;
  12137. private _onbuttondown;
  12138. private _onbuttonup;
  12139. /**
  12140. * Observable triggered when a button has been pressed
  12141. */
  12142. onButtonDownObservable: Observable<number>;
  12143. /**
  12144. * Observable triggered when a button has been released
  12145. */
  12146. onButtonUpObservable: Observable<number>;
  12147. /**
  12148. * Callback triggered when a button has been pressed
  12149. * @param callback Called when a button has been pressed
  12150. */
  12151. onbuttondown(callback: (buttonPressed: number) => void): void;
  12152. /**
  12153. * Callback triggered when a button has been released
  12154. * @param callback Called when a button has been released
  12155. */
  12156. onbuttonup(callback: (buttonReleased: number) => void): void;
  12157. /**
  12158. * Initializes the generic gamepad
  12159. * @param id The id of the generic gamepad
  12160. * @param index The index of the generic gamepad
  12161. * @param browserGamepad The browser gamepad
  12162. */
  12163. constructor(id: string, index: number, browserGamepad: any);
  12164. private _setButtonValue;
  12165. /**
  12166. * Updates the generic gamepad
  12167. */
  12168. update(): void;
  12169. /**
  12170. * Disposes the generic gamepad
  12171. */
  12172. dispose(): void;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. interface Engine {
  12177. /**
  12178. * Creates a raw texture
  12179. * @param data defines the data to store in the texture
  12180. * @param width defines the width of the texture
  12181. * @param height defines the height of the texture
  12182. * @param format defines the format of the data
  12183. * @param generateMipMaps defines if the engine should generate the mip levels
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12186. * @param compression defines the compression used (null by default)
  12187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12188. * @returns the raw texture inside an InternalTexture
  12189. */
  12190. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12191. /**
  12192. * Update a raw texture
  12193. * @param texture defines the texture to update
  12194. * @param data defines the data to store in the texture
  12195. * @param format defines the format of the data
  12196. * @param invertY defines if data must be stored with Y axis inverted
  12197. */
  12198. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12199. /**
  12200. * Update a raw texture
  12201. * @param texture defines the texture to update
  12202. * @param data defines the data to store in the texture
  12203. * @param format defines the format of the data
  12204. * @param invertY defines if data must be stored with Y axis inverted
  12205. * @param compression defines the compression used (null by default)
  12206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12207. */
  12208. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12209. /**
  12210. * Creates a new raw cube texture
  12211. * @param data defines the array of data to use to create each face
  12212. * @param size defines the size of the textures
  12213. * @param format defines the format of the data
  12214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12215. * @param generateMipMaps defines if the engine should generate the mip levels
  12216. * @param invertY defines if data must be stored with Y axis inverted
  12217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12218. * @param compression defines the compression used (null by default)
  12219. * @returns the cube texture as an InternalTexture
  12220. */
  12221. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12222. /**
  12223. * Update a raw cube texture
  12224. * @param texture defines the texture to udpdate
  12225. * @param data defines the data to store
  12226. * @param format defines the data format
  12227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12228. * @param invertY defines if data must be stored with Y axis inverted
  12229. */
  12230. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12231. /**
  12232. * Update a raw cube texture
  12233. * @param texture defines the texture to udpdate
  12234. * @param data defines the data to store
  12235. * @param format defines the data format
  12236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12237. * @param invertY defines if data must be stored with Y axis inverted
  12238. * @param compression defines the compression used (null by default)
  12239. */
  12240. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12241. /**
  12242. * Update a raw cube texture
  12243. * @param texture defines the texture to udpdate
  12244. * @param data defines the data to store
  12245. * @param format defines the data format
  12246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12247. * @param invertY defines if data must be stored with Y axis inverted
  12248. * @param compression defines the compression used (null by default)
  12249. * @param level defines which level of the texture to update
  12250. */
  12251. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12252. /**
  12253. * Creates a new raw cube texture from a specified url
  12254. * @param url defines the url where the data is located
  12255. * @param scene defines the current scene
  12256. * @param size defines the size of the textures
  12257. * @param format defines the format of the data
  12258. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12259. * @param noMipmap defines if the engine should avoid generating the mip levels
  12260. * @param callback defines a callback used to extract texture data from loaded data
  12261. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12262. * @param onLoad defines a callback called when texture is loaded
  12263. * @param onError defines a callback called if there is an error
  12264. * @returns the cube texture as an InternalTexture
  12265. */
  12266. 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;
  12267. /**
  12268. * Creates a new raw cube texture from a specified url
  12269. * @param url defines the url where the data is located
  12270. * @param scene defines the current scene
  12271. * @param size defines the size of the textures
  12272. * @param format defines the format of the data
  12273. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12274. * @param noMipmap defines if the engine should avoid generating the mip levels
  12275. * @param callback defines a callback used to extract texture data from loaded data
  12276. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12277. * @param onLoad defines a callback called when texture is loaded
  12278. * @param onError defines a callback called if there is an error
  12279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12280. * @param invertY defines if data must be stored with Y axis inverted
  12281. * @returns the cube texture as an InternalTexture
  12282. */
  12283. 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;
  12284. /**
  12285. * Creates a new raw 3D texture
  12286. * @param data defines the data used to create the texture
  12287. * @param width defines the width of the texture
  12288. * @param height defines the height of the texture
  12289. * @param depth defines the depth of the texture
  12290. * @param format defines the format of the texture
  12291. * @param generateMipMaps defines if the engine must generate mip levels
  12292. * @param invertY defines if data must be stored with Y axis inverted
  12293. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12294. * @param compression defines the compressed used (can be null)
  12295. * @param textureType defines the compressed used (can be null)
  12296. * @returns a new raw 3D texture (stored in an InternalTexture)
  12297. */
  12298. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12299. /**
  12300. * Update a raw 3D texture
  12301. * @param texture defines the texture to update
  12302. * @param data defines the data to store
  12303. * @param format defines the data format
  12304. * @param invertY defines if data must be stored with Y axis inverted
  12305. */
  12306. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12307. /**
  12308. * Update a raw 3D texture
  12309. * @param texture defines the texture to update
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param invertY defines if data must be stored with Y axis inverted
  12313. * @param compression defines the used compression (can be null)
  12314. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12315. */
  12316. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Raw texture can help creating a texture directly from an array of data.
  12322. * This can be super useful if you either get the data from an uncompressed source or
  12323. * if you wish to create your texture pixel by pixel.
  12324. */
  12325. export class RawTexture extends Texture {
  12326. /**
  12327. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12328. */
  12329. format: number;
  12330. private _engine;
  12331. /**
  12332. * Instantiates a new RawTexture.
  12333. * Raw texture can help creating a texture directly from an array of data.
  12334. * This can be super useful if you either get the data from an uncompressed source or
  12335. * if you wish to create your texture pixel by pixel.
  12336. * @param data define the array of data to use to create the texture
  12337. * @param width define the width of the texture
  12338. * @param height define the height of the texture
  12339. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12340. * @param scene define the scene the texture belongs to
  12341. * @param generateMipMaps define whether mip maps should be generated or not
  12342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12345. */
  12346. constructor(data: ArrayBufferView, width: number, height: number,
  12347. /**
  12348. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12349. */
  12350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12351. /**
  12352. * Updates the texture underlying data.
  12353. * @param data Define the new data of the texture
  12354. */
  12355. update(data: ArrayBufferView): void;
  12356. /**
  12357. * Creates a luminance texture from some data.
  12358. * @param data Define the texture data
  12359. * @param width Define the width of the texture
  12360. * @param height Define the height of the texture
  12361. * @param scene Define the scene the texture belongs to
  12362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12365. * @returns the luminance texture
  12366. */
  12367. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12368. /**
  12369. * Creates a luminance alpha texture from some data.
  12370. * @param data Define the texture data
  12371. * @param width Define the width of the texture
  12372. * @param height Define the height of the texture
  12373. * @param scene Define the scene the texture belongs to
  12374. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12375. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12376. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12377. * @returns the luminance alpha texture
  12378. */
  12379. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12380. /**
  12381. * Creates an alpha texture from some data.
  12382. * @param data Define the texture data
  12383. * @param width Define the width of the texture
  12384. * @param height Define the height of the texture
  12385. * @param scene Define the scene the texture belongs to
  12386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12389. * @returns the alpha texture
  12390. */
  12391. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12392. /**
  12393. * Creates a RGB texture from some data.
  12394. * @param data Define the texture data
  12395. * @param width Define the width of the texture
  12396. * @param height Define the height of the texture
  12397. * @param scene Define the scene the texture belongs to
  12398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12402. * @returns the RGB alpha texture
  12403. */
  12404. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12405. /**
  12406. * Creates a RGBA texture from some data.
  12407. * @param data Define the texture data
  12408. * @param width Define the width of the texture
  12409. * @param height Define the height of the texture
  12410. * @param scene Define the scene the texture belongs to
  12411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12415. * @returns the RGBA texture
  12416. */
  12417. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12418. /**
  12419. * Creates a R texture from some data.
  12420. * @param data Define the texture data
  12421. * @param width Define the width of the texture
  12422. * @param height Define the height of the texture
  12423. * @param scene Define the scene the texture belongs to
  12424. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12427. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12428. * @returns the R texture
  12429. */
  12430. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12431. }
  12432. }
  12433. declare module BABYLON {
  12434. /**
  12435. * Interface for the size containing width and height
  12436. */
  12437. export interface ISize {
  12438. /**
  12439. * Width
  12440. */
  12441. width: number;
  12442. /**
  12443. * Heighht
  12444. */
  12445. height: number;
  12446. }
  12447. /**
  12448. * Size containing widht and height
  12449. */
  12450. export class Size implements ISize {
  12451. /**
  12452. * Width
  12453. */
  12454. width: number;
  12455. /**
  12456. * Height
  12457. */
  12458. height: number;
  12459. /**
  12460. * Creates a Size object from the given width and height (floats).
  12461. * @param width width of the new size
  12462. * @param height height of the new size
  12463. */
  12464. constructor(width: number, height: number);
  12465. /**
  12466. * Returns a string with the Size width and height
  12467. * @returns a string with the Size width and height
  12468. */
  12469. toString(): string;
  12470. /**
  12471. * "Size"
  12472. * @returns the string "Size"
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Returns the Size hash code.
  12477. * @returns a hash code for a unique width and height
  12478. */
  12479. getHashCode(): number;
  12480. /**
  12481. * Updates the current size from the given one.
  12482. * @param src the given size
  12483. */
  12484. copyFrom(src: Size): void;
  12485. /**
  12486. * Updates in place the current Size from the given floats.
  12487. * @param width width of the new size
  12488. * @param height height of the new size
  12489. * @returns the updated Size.
  12490. */
  12491. copyFromFloats(width: number, height: number): Size;
  12492. /**
  12493. * Updates in place the current Size from the given floats.
  12494. * @param width width to set
  12495. * @param height height to set
  12496. * @returns the updated Size.
  12497. */
  12498. set(width: number, height: number): Size;
  12499. /**
  12500. * Multiplies the width and height by numbers
  12501. * @param w factor to multiple the width by
  12502. * @param h factor to multiple the height by
  12503. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12504. */
  12505. multiplyByFloats(w: number, h: number): Size;
  12506. /**
  12507. * Clones the size
  12508. * @returns a new Size copied from the given one.
  12509. */
  12510. clone(): Size;
  12511. /**
  12512. * True if the current Size and the given one width and height are strictly equal.
  12513. * @param other the other size to compare against
  12514. * @returns True if the current Size and the given one width and height are strictly equal.
  12515. */
  12516. equals(other: Size): boolean;
  12517. /**
  12518. * The surface of the Size : width * height (float).
  12519. */
  12520. readonly surface: number;
  12521. /**
  12522. * Create a new size of zero
  12523. * @returns a new Size set to (0.0, 0.0)
  12524. */
  12525. static Zero(): Size;
  12526. /**
  12527. * Sums the width and height of two sizes
  12528. * @param otherSize size to add to this size
  12529. * @returns a new Size set as the addition result of the current Size and the given one.
  12530. */
  12531. add(otherSize: Size): Size;
  12532. /**
  12533. * Subtracts the width and height of two
  12534. * @param otherSize size to subtract to this size
  12535. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12536. */
  12537. subtract(otherSize: Size): Size;
  12538. /**
  12539. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12540. * @param start starting size to lerp between
  12541. * @param end end size to lerp between
  12542. * @param amount amount to lerp between the start and end values
  12543. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12544. */
  12545. static Lerp(start: Size, end: Size, amount: number): Size;
  12546. }
  12547. }
  12548. declare module BABYLON {
  12549. /**
  12550. * Defines a runtime animation
  12551. */
  12552. export class RuntimeAnimation {
  12553. private _events;
  12554. /**
  12555. * The current frame of the runtime animation
  12556. */
  12557. private _currentFrame;
  12558. /**
  12559. * The animation used by the runtime animation
  12560. */
  12561. private _animation;
  12562. /**
  12563. * The target of the runtime animation
  12564. */
  12565. private _target;
  12566. /**
  12567. * The initiating animatable
  12568. */
  12569. private _host;
  12570. /**
  12571. * The original value of the runtime animation
  12572. */
  12573. private _originalValue;
  12574. /**
  12575. * The original blend value of the runtime animation
  12576. */
  12577. private _originalBlendValue;
  12578. /**
  12579. * The offsets cache of the runtime animation
  12580. */
  12581. private _offsetsCache;
  12582. /**
  12583. * The high limits cache of the runtime animation
  12584. */
  12585. private _highLimitsCache;
  12586. /**
  12587. * Specifies if the runtime animation has been stopped
  12588. */
  12589. private _stopped;
  12590. /**
  12591. * The blending factor of the runtime animation
  12592. */
  12593. private _blendingFactor;
  12594. /**
  12595. * The BabylonJS scene
  12596. */
  12597. private _scene;
  12598. /**
  12599. * The current value of the runtime animation
  12600. */
  12601. private _currentValue;
  12602. /** @hidden */
  12603. _animationState: _IAnimationState;
  12604. /**
  12605. * The active target of the runtime animation
  12606. */
  12607. private _activeTargets;
  12608. private _currentActiveTarget;
  12609. private _directTarget;
  12610. /**
  12611. * The target path of the runtime animation
  12612. */
  12613. private _targetPath;
  12614. /**
  12615. * The weight of the runtime animation
  12616. */
  12617. private _weight;
  12618. /**
  12619. * The ratio offset of the runtime animation
  12620. */
  12621. private _ratioOffset;
  12622. /**
  12623. * The previous delay of the runtime animation
  12624. */
  12625. private _previousDelay;
  12626. /**
  12627. * The previous ratio of the runtime animation
  12628. */
  12629. private _previousRatio;
  12630. private _enableBlending;
  12631. private _keys;
  12632. private _minFrame;
  12633. private _maxFrame;
  12634. private _minValue;
  12635. private _maxValue;
  12636. private _targetIsArray;
  12637. /**
  12638. * Gets the current frame of the runtime animation
  12639. */
  12640. readonly currentFrame: number;
  12641. /**
  12642. * Gets the weight of the runtime animation
  12643. */
  12644. readonly weight: number;
  12645. /**
  12646. * Gets the current value of the runtime animation
  12647. */
  12648. readonly currentValue: any;
  12649. /**
  12650. * Gets the target path of the runtime animation
  12651. */
  12652. readonly targetPath: string;
  12653. /**
  12654. * Gets the actual target of the runtime animation
  12655. */
  12656. readonly target: any;
  12657. /** @hidden */
  12658. _onLoop: () => void;
  12659. /**
  12660. * Create a new RuntimeAnimation object
  12661. * @param target defines the target of the animation
  12662. * @param animation defines the source animation object
  12663. * @param scene defines the hosting scene
  12664. * @param host defines the initiating Animatable
  12665. */
  12666. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12667. private _preparePath;
  12668. /**
  12669. * Gets the animation from the runtime animation
  12670. */
  12671. readonly animation: Animation;
  12672. /**
  12673. * Resets the runtime animation to the beginning
  12674. * @param restoreOriginal defines whether to restore the target property to the original value
  12675. */
  12676. reset(restoreOriginal?: boolean): void;
  12677. /**
  12678. * Specifies if the runtime animation is stopped
  12679. * @returns Boolean specifying if the runtime animation is stopped
  12680. */
  12681. isStopped(): boolean;
  12682. /**
  12683. * Disposes of the runtime animation
  12684. */
  12685. dispose(): void;
  12686. /**
  12687. * Apply the interpolated value to the target
  12688. * @param currentValue defines the value computed by the animation
  12689. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12690. */
  12691. setValue(currentValue: any, weight: number): void;
  12692. private _getOriginalValues;
  12693. private _setValue;
  12694. /**
  12695. * Gets the loop pmode of the runtime animation
  12696. * @returns Loop Mode
  12697. */
  12698. private _getCorrectLoopMode;
  12699. /**
  12700. * Move the current animation to a given frame
  12701. * @param frame defines the frame to move to
  12702. */
  12703. goToFrame(frame: number): void;
  12704. /**
  12705. * @hidden Internal use only
  12706. */
  12707. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12708. /**
  12709. * Execute the current animation
  12710. * @param delay defines the delay to add to the current frame
  12711. * @param from defines the lower bound of the animation range
  12712. * @param to defines the upper bound of the animation range
  12713. * @param loop defines if the current animation must loop
  12714. * @param speedRatio defines the current speed ratio
  12715. * @param weight defines the weight of the animation (default is -1 so no weight)
  12716. * @param onLoop optional callback called when animation loops
  12717. * @returns a boolean indicating if the animation is running
  12718. */
  12719. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12720. }
  12721. }
  12722. declare module BABYLON {
  12723. /**
  12724. * Class used to store an actual running animation
  12725. */
  12726. export class Animatable {
  12727. /** defines the target object */
  12728. target: any;
  12729. /** defines the starting frame number (default is 0) */
  12730. fromFrame: number;
  12731. /** defines the ending frame number (default is 100) */
  12732. toFrame: number;
  12733. /** defines if the animation must loop (default is false) */
  12734. loopAnimation: boolean;
  12735. /** defines a callback to call when animation ends if it is not looping */
  12736. onAnimationEnd?: (() => void) | null | undefined;
  12737. /** defines a callback to call when animation loops */
  12738. onAnimationLoop?: (() => void) | null | undefined;
  12739. private _localDelayOffset;
  12740. private _pausedDelay;
  12741. private _runtimeAnimations;
  12742. private _paused;
  12743. private _scene;
  12744. private _speedRatio;
  12745. private _weight;
  12746. private _syncRoot;
  12747. /**
  12748. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12749. * This will only apply for non looping animation (default is true)
  12750. */
  12751. disposeOnEnd: boolean;
  12752. /**
  12753. * Gets a boolean indicating if the animation has started
  12754. */
  12755. animationStarted: boolean;
  12756. /**
  12757. * Observer raised when the animation ends
  12758. */
  12759. onAnimationEndObservable: Observable<Animatable>;
  12760. /**
  12761. * Observer raised when the animation loops
  12762. */
  12763. onAnimationLoopObservable: Observable<Animatable>;
  12764. /**
  12765. * Gets the root Animatable used to synchronize and normalize animations
  12766. */
  12767. readonly syncRoot: Nullable<Animatable>;
  12768. /**
  12769. * Gets the current frame of the first RuntimeAnimation
  12770. * Used to synchronize Animatables
  12771. */
  12772. readonly masterFrame: number;
  12773. /**
  12774. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12775. */
  12776. weight: number;
  12777. /**
  12778. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12779. */
  12780. speedRatio: number;
  12781. /**
  12782. * Creates a new Animatable
  12783. * @param scene defines the hosting scene
  12784. * @param target defines the target object
  12785. * @param fromFrame defines the starting frame number (default is 0)
  12786. * @param toFrame defines the ending frame number (default is 100)
  12787. * @param loopAnimation defines if the animation must loop (default is false)
  12788. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12789. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12790. * @param animations defines a group of animation to add to the new Animatable
  12791. * @param onAnimationLoop defines a callback to call when animation loops
  12792. */
  12793. constructor(scene: Scene,
  12794. /** defines the target object */
  12795. target: any,
  12796. /** defines the starting frame number (default is 0) */
  12797. fromFrame?: number,
  12798. /** defines the ending frame number (default is 100) */
  12799. toFrame?: number,
  12800. /** defines if the animation must loop (default is false) */
  12801. loopAnimation?: boolean, speedRatio?: number,
  12802. /** defines a callback to call when animation ends if it is not looping */
  12803. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12804. /** defines a callback to call when animation loops */
  12805. onAnimationLoop?: (() => void) | null | undefined);
  12806. /**
  12807. * Synchronize and normalize current Animatable with a source Animatable
  12808. * This is useful when using animation weights and when animations are not of the same length
  12809. * @param root defines the root Animatable to synchronize with
  12810. * @returns the current Animatable
  12811. */
  12812. syncWith(root: Animatable): Animatable;
  12813. /**
  12814. * Gets the list of runtime animations
  12815. * @returns an array of RuntimeAnimation
  12816. */
  12817. getAnimations(): RuntimeAnimation[];
  12818. /**
  12819. * Adds more animations to the current animatable
  12820. * @param target defines the target of the animations
  12821. * @param animations defines the new animations to add
  12822. */
  12823. appendAnimations(target: any, animations: Animation[]): void;
  12824. /**
  12825. * Gets the source animation for a specific property
  12826. * @param property defines the propertyu to look for
  12827. * @returns null or the source animation for the given property
  12828. */
  12829. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12830. /**
  12831. * Gets the runtime animation for a specific property
  12832. * @param property defines the propertyu to look for
  12833. * @returns null or the runtime animation for the given property
  12834. */
  12835. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12836. /**
  12837. * Resets the animatable to its original state
  12838. */
  12839. reset(): void;
  12840. /**
  12841. * Allows the animatable to blend with current running animations
  12842. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12843. * @param blendingSpeed defines the blending speed to use
  12844. */
  12845. enableBlending(blendingSpeed: number): void;
  12846. /**
  12847. * Disable animation blending
  12848. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12849. */
  12850. disableBlending(): void;
  12851. /**
  12852. * Jump directly to a given frame
  12853. * @param frame defines the frame to jump to
  12854. */
  12855. goToFrame(frame: number): void;
  12856. /**
  12857. * Pause the animation
  12858. */
  12859. pause(): void;
  12860. /**
  12861. * Restart the animation
  12862. */
  12863. restart(): void;
  12864. private _raiseOnAnimationEnd;
  12865. /**
  12866. * Stop and delete the current animation
  12867. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12868. * @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)
  12869. */
  12870. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12871. /**
  12872. * Wait asynchronously for the animation to end
  12873. * @returns a promise which will be fullfilled when the animation ends
  12874. */
  12875. waitAsync(): Promise<Animatable>;
  12876. /** @hidden */
  12877. _animate(delay: number): boolean;
  12878. }
  12879. interface Scene {
  12880. /** @hidden */
  12881. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12882. /** @hidden */
  12883. _processLateAnimationBindingsForMatrices(holder: {
  12884. totalWeight: number;
  12885. animations: RuntimeAnimation[];
  12886. originalValue: Matrix;
  12887. }): any;
  12888. /** @hidden */
  12889. _processLateAnimationBindingsForQuaternions(holder: {
  12890. totalWeight: number;
  12891. animations: RuntimeAnimation[];
  12892. originalValue: Quaternion;
  12893. }, refQuaternion: Quaternion): Quaternion;
  12894. /** @hidden */
  12895. _processLateAnimationBindings(): void;
  12896. /**
  12897. * Will start the animation sequence of a given target
  12898. * @param target defines the target
  12899. * @param from defines from which frame should animation start
  12900. * @param to defines until which frame should animation run.
  12901. * @param weight defines the weight to apply to the animation (1.0 by default)
  12902. * @param loop defines if the animation loops
  12903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12904. * @param onAnimationEnd defines the function to be executed when the animation ends
  12905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12906. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12907. * @param onAnimationLoop defines the callback to call when an animation loops
  12908. * @returns the animatable object created for this animation
  12909. */
  12910. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12911. /**
  12912. * Will start the animation sequence of a given target
  12913. * @param target defines the target
  12914. * @param from defines from which frame should animation start
  12915. * @param to defines until which frame should animation run.
  12916. * @param loop defines if the animation loops
  12917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12918. * @param onAnimationEnd defines the function to be executed when the animation ends
  12919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12920. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12921. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12922. * @param onAnimationLoop defines the callback to call when an animation loops
  12923. * @returns the animatable object created for this animation
  12924. */
  12925. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12926. /**
  12927. * Will start the animation sequence of a given target and its hierarchy
  12928. * @param target defines the target
  12929. * @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.
  12930. * @param from defines from which frame should animation start
  12931. * @param to defines until which frame should animation run.
  12932. * @param loop defines if the animation loops
  12933. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12934. * @param onAnimationEnd defines the function to be executed when the animation ends
  12935. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12936. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12938. * @param onAnimationLoop defines the callback to call when an animation loops
  12939. * @returns the list of created animatables
  12940. */
  12941. 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[];
  12942. /**
  12943. * Begin a new animation on a given node
  12944. * @param target defines the target where the animation will take place
  12945. * @param animations defines the list of animations to start
  12946. * @param from defines the initial value
  12947. * @param to defines the final value
  12948. * @param loop defines if you want animation to loop (off by default)
  12949. * @param speedRatio defines the speed ratio to apply to all animations
  12950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12951. * @param onAnimationLoop defines the callback to call when an animation loops
  12952. * @returns the list of created animatables
  12953. */
  12954. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12955. /**
  12956. * Begin a new animation on a given node and its hierarchy
  12957. * @param target defines the root node where the animation will take place
  12958. * @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.
  12959. * @param animations defines the list of animations to start
  12960. * @param from defines the initial value
  12961. * @param to defines the final value
  12962. * @param loop defines if you want animation to loop (off by default)
  12963. * @param speedRatio defines the speed ratio to apply to all animations
  12964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12965. * @param onAnimationLoop defines the callback to call when an animation loops
  12966. * @returns the list of animatables created for all nodes
  12967. */
  12968. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12969. /**
  12970. * Gets the animatable associated with a specific target
  12971. * @param target defines the target of the animatable
  12972. * @returns the required animatable if found
  12973. */
  12974. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12975. /**
  12976. * Gets all animatables associated with a given target
  12977. * @param target defines the target to look animatables for
  12978. * @returns an array of Animatables
  12979. */
  12980. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12981. /**
  12982. * Stops and removes all animations that have been applied to the scene
  12983. */
  12984. stopAllAnimations(): void;
  12985. }
  12986. interface Bone {
  12987. /**
  12988. * Copy an animation range from another bone
  12989. * @param source defines the source bone
  12990. * @param rangeName defines the range name to copy
  12991. * @param frameOffset defines the frame offset
  12992. * @param rescaleAsRequired defines if rescaling must be applied if required
  12993. * @param skelDimensionsRatio defines the scaling ratio
  12994. * @returns true if operation was successful
  12995. */
  12996. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * Class used to override all child animations of a given target
  13002. */
  13003. export class AnimationPropertiesOverride {
  13004. /**
  13005. * Gets or sets a value indicating if animation blending must be used
  13006. */
  13007. enableBlending: boolean;
  13008. /**
  13009. * Gets or sets the blending speed to use when enableBlending is true
  13010. */
  13011. blendingSpeed: number;
  13012. /**
  13013. * Gets or sets the default loop mode to use
  13014. */
  13015. loopMode: number;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Class used to handle skinning animations
  13021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13022. */
  13023. export class Skeleton implements IAnimatable {
  13024. /** defines the skeleton name */
  13025. name: string;
  13026. /** defines the skeleton Id */
  13027. id: string;
  13028. /**
  13029. * Defines the list of child bones
  13030. */
  13031. bones: Bone[];
  13032. /**
  13033. * Defines an estimate of the dimension of the skeleton at rest
  13034. */
  13035. dimensionsAtRest: Vector3;
  13036. /**
  13037. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13038. */
  13039. needInitialSkinMatrix: boolean;
  13040. /**
  13041. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13042. */
  13043. overrideMesh: Nullable<AbstractMesh>;
  13044. /**
  13045. * Gets the list of animations attached to this skeleton
  13046. */
  13047. animations: Array<Animation>;
  13048. private _scene;
  13049. private _isDirty;
  13050. private _transformMatrices;
  13051. private _transformMatrixTexture;
  13052. private _meshesWithPoseMatrix;
  13053. private _animatables;
  13054. private _identity;
  13055. private _synchronizedWithMesh;
  13056. private _ranges;
  13057. private _lastAbsoluteTransformsUpdateId;
  13058. private _canUseTextureForBones;
  13059. private _uniqueId;
  13060. /** @hidden */
  13061. _numBonesWithLinkedTransformNode: number;
  13062. /** @hidden */
  13063. _hasWaitingData: Nullable<boolean>;
  13064. /**
  13065. * Specifies if the skeleton should be serialized
  13066. */
  13067. doNotSerialize: boolean;
  13068. private _useTextureToStoreBoneMatrices;
  13069. /**
  13070. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13071. * Please note that this option is not available if the hardware does not support it
  13072. */
  13073. useTextureToStoreBoneMatrices: boolean;
  13074. private _animationPropertiesOverride;
  13075. /**
  13076. * Gets or sets the animation properties override
  13077. */
  13078. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13079. /**
  13080. * List of inspectable custom properties (used by the Inspector)
  13081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13082. */
  13083. inspectableCustomProperties: IInspectable[];
  13084. /**
  13085. * An observable triggered before computing the skeleton's matrices
  13086. */
  13087. onBeforeComputeObservable: Observable<Skeleton>;
  13088. /**
  13089. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13090. */
  13091. readonly isUsingTextureForMatrices: boolean;
  13092. /**
  13093. * Gets the unique ID of this skeleton
  13094. */
  13095. readonly uniqueId: number;
  13096. /**
  13097. * Creates a new skeleton
  13098. * @param name defines the skeleton name
  13099. * @param id defines the skeleton Id
  13100. * @param scene defines the hosting scene
  13101. */
  13102. constructor(
  13103. /** defines the skeleton name */
  13104. name: string,
  13105. /** defines the skeleton Id */
  13106. id: string, scene: Scene);
  13107. /**
  13108. * Gets the current object class name.
  13109. * @return the class name
  13110. */
  13111. getClassName(): string;
  13112. /**
  13113. * Returns an array containing the root bones
  13114. * @returns an array containing the root bones
  13115. */
  13116. getChildren(): Array<Bone>;
  13117. /**
  13118. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13120. * @returns a Float32Array containing matrices data
  13121. */
  13122. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13123. /**
  13124. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13125. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13126. * @returns a raw texture containing the data
  13127. */
  13128. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13129. /**
  13130. * Gets the current hosting scene
  13131. * @returns a scene object
  13132. */
  13133. getScene(): Scene;
  13134. /**
  13135. * Gets a string representing the current skeleton data
  13136. * @param fullDetails defines a boolean indicating if we want a verbose version
  13137. * @returns a string representing the current skeleton data
  13138. */
  13139. toString(fullDetails?: boolean): string;
  13140. /**
  13141. * Get bone's index searching by name
  13142. * @param name defines bone's name to search for
  13143. * @return the indice of the bone. Returns -1 if not found
  13144. */
  13145. getBoneIndexByName(name: string): number;
  13146. /**
  13147. * Creater a new animation range
  13148. * @param name defines the name of the range
  13149. * @param from defines the start key
  13150. * @param to defines the end key
  13151. */
  13152. createAnimationRange(name: string, from: number, to: number): void;
  13153. /**
  13154. * Delete a specific animation range
  13155. * @param name defines the name of the range
  13156. * @param deleteFrames defines if frames must be removed as well
  13157. */
  13158. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13159. /**
  13160. * Gets a specific animation range
  13161. * @param name defines the name of the range to look for
  13162. * @returns the requested animation range or null if not found
  13163. */
  13164. getAnimationRange(name: string): Nullable<AnimationRange>;
  13165. /**
  13166. * Gets the list of all animation ranges defined on this skeleton
  13167. * @returns an array
  13168. */
  13169. getAnimationRanges(): Nullable<AnimationRange>[];
  13170. /**
  13171. * Copy animation range from a source skeleton.
  13172. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13173. * @param source defines the source skeleton
  13174. * @param name defines the name of the range to copy
  13175. * @param rescaleAsRequired defines if rescaling must be applied if required
  13176. * @returns true if operation was successful
  13177. */
  13178. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13179. /**
  13180. * Forces the skeleton to go to rest pose
  13181. */
  13182. returnToRest(): void;
  13183. private _getHighestAnimationFrame;
  13184. /**
  13185. * Begin a specific animation range
  13186. * @param name defines the name of the range to start
  13187. * @param loop defines if looping must be turned on (false by default)
  13188. * @param speedRatio defines the speed ratio to apply (1 by default)
  13189. * @param onAnimationEnd defines a callback which will be called when animation will end
  13190. * @returns a new animatable
  13191. */
  13192. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13193. /** @hidden */
  13194. _markAsDirty(): void;
  13195. /** @hidden */
  13196. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13197. /** @hidden */
  13198. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13199. private _computeTransformMatrices;
  13200. /**
  13201. * Build all resources required to render a skeleton
  13202. */
  13203. prepare(): void;
  13204. /**
  13205. * Gets the list of animatables currently running for this skeleton
  13206. * @returns an array of animatables
  13207. */
  13208. getAnimatables(): IAnimatable[];
  13209. /**
  13210. * Clone the current skeleton
  13211. * @param name defines the name of the new skeleton
  13212. * @param id defines the id of the new skeleton
  13213. * @returns the new skeleton
  13214. */
  13215. clone(name: string, id: string): Skeleton;
  13216. /**
  13217. * Enable animation blending for this skeleton
  13218. * @param blendingSpeed defines the blending speed to apply
  13219. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13220. */
  13221. enableBlending(blendingSpeed?: number): void;
  13222. /**
  13223. * Releases all resources associated with the current skeleton
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Serialize the skeleton in a JSON object
  13228. * @returns a JSON object
  13229. */
  13230. serialize(): any;
  13231. /**
  13232. * Creates a new skeleton from serialized data
  13233. * @param parsedSkeleton defines the serialized data
  13234. * @param scene defines the hosting scene
  13235. * @returns a new skeleton
  13236. */
  13237. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13238. /**
  13239. * Compute all node absolute transforms
  13240. * @param forceUpdate defines if computation must be done even if cache is up to date
  13241. */
  13242. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13243. /**
  13244. * Gets the root pose matrix
  13245. * @returns a matrix
  13246. */
  13247. getPoseMatrix(): Nullable<Matrix>;
  13248. /**
  13249. * Sorts bones per internal index
  13250. */
  13251. sortBones(): void;
  13252. private _sortBones;
  13253. }
  13254. }
  13255. declare module BABYLON {
  13256. /**
  13257. * Class used to store bone information
  13258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13259. */
  13260. export class Bone extends Node {
  13261. /**
  13262. * defines the bone name
  13263. */
  13264. name: string;
  13265. private static _tmpVecs;
  13266. private static _tmpQuat;
  13267. private static _tmpMats;
  13268. /**
  13269. * Gets the list of child bones
  13270. */
  13271. children: Bone[];
  13272. /** Gets the animations associated with this bone */
  13273. animations: Animation[];
  13274. /**
  13275. * Gets or sets bone length
  13276. */
  13277. length: number;
  13278. /**
  13279. * @hidden Internal only
  13280. * Set this value to map this bone to a different index in the transform matrices
  13281. * Set this value to -1 to exclude the bone from the transform matrices
  13282. */
  13283. _index: Nullable<number>;
  13284. private _skeleton;
  13285. private _localMatrix;
  13286. private _restPose;
  13287. private _baseMatrix;
  13288. private _absoluteTransform;
  13289. private _invertedAbsoluteTransform;
  13290. private _parent;
  13291. private _scalingDeterminant;
  13292. private _worldTransform;
  13293. private _localScaling;
  13294. private _localRotation;
  13295. private _localPosition;
  13296. private _needToDecompose;
  13297. private _needToCompose;
  13298. /** @hidden */
  13299. _linkedTransformNode: Nullable<TransformNode>;
  13300. /** @hidden */
  13301. _waitingTransformNodeId: Nullable<string>;
  13302. /** @hidden */
  13303. /** @hidden */
  13304. _matrix: Matrix;
  13305. /**
  13306. * Create a new bone
  13307. * @param name defines the bone name
  13308. * @param skeleton defines the parent skeleton
  13309. * @param parentBone defines the parent (can be null if the bone is the root)
  13310. * @param localMatrix defines the local matrix
  13311. * @param restPose defines the rest pose matrix
  13312. * @param baseMatrix defines the base matrix
  13313. * @param index defines index of the bone in the hiearchy
  13314. */
  13315. constructor(
  13316. /**
  13317. * defines the bone name
  13318. */
  13319. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13320. /**
  13321. * Gets the current object class name.
  13322. * @return the class name
  13323. */
  13324. getClassName(): string;
  13325. /**
  13326. * Gets the parent skeleton
  13327. * @returns a skeleton
  13328. */
  13329. getSkeleton(): Skeleton;
  13330. /**
  13331. * Gets parent bone
  13332. * @returns a bone or null if the bone is the root of the bone hierarchy
  13333. */
  13334. getParent(): Nullable<Bone>;
  13335. /**
  13336. * Returns an array containing the root bones
  13337. * @returns an array containing the root bones
  13338. */
  13339. getChildren(): Array<Bone>;
  13340. /**
  13341. * Sets the parent bone
  13342. * @param parent defines the parent (can be null if the bone is the root)
  13343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13344. */
  13345. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13346. /**
  13347. * Gets the local matrix
  13348. * @returns a matrix
  13349. */
  13350. getLocalMatrix(): Matrix;
  13351. /**
  13352. * Gets the base matrix (initial matrix which remains unchanged)
  13353. * @returns a matrix
  13354. */
  13355. getBaseMatrix(): Matrix;
  13356. /**
  13357. * Gets the rest pose matrix
  13358. * @returns a matrix
  13359. */
  13360. getRestPose(): Matrix;
  13361. /**
  13362. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13363. */
  13364. getWorldMatrix(): Matrix;
  13365. /**
  13366. * Sets the local matrix to rest pose matrix
  13367. */
  13368. returnToRest(): void;
  13369. /**
  13370. * Gets the inverse of the absolute transform matrix.
  13371. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13372. * @returns a matrix
  13373. */
  13374. getInvertedAbsoluteTransform(): Matrix;
  13375. /**
  13376. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13377. * @returns a matrix
  13378. */
  13379. getAbsoluteTransform(): Matrix;
  13380. /**
  13381. * Links with the given transform node.
  13382. * The local matrix of this bone is copied from the transform node every frame.
  13383. * @param transformNode defines the transform node to link to
  13384. */
  13385. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13386. /** Gets or sets current position (in local space) */
  13387. position: Vector3;
  13388. /** Gets or sets current rotation (in local space) */
  13389. rotation: Vector3;
  13390. /** Gets or sets current rotation quaternion (in local space) */
  13391. rotationQuaternion: Quaternion;
  13392. /** Gets or sets current scaling (in local space) */
  13393. scaling: Vector3;
  13394. /**
  13395. * Gets the animation properties override
  13396. */
  13397. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13398. private _decompose;
  13399. private _compose;
  13400. /**
  13401. * Update the base and local matrices
  13402. * @param matrix defines the new base or local matrix
  13403. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13404. * @param updateLocalMatrix defines if the local matrix should be updated
  13405. */
  13406. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13407. /** @hidden */
  13408. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13409. /**
  13410. * Flag the bone as dirty (Forcing it to update everything)
  13411. */
  13412. markAsDirty(): void;
  13413. /** @hidden */
  13414. _markAsDirtyAndCompose(): void;
  13415. private _markAsDirtyAndDecompose;
  13416. /**
  13417. * Translate the bone in local or world space
  13418. * @param vec The amount to translate the bone
  13419. * @param space The space that the translation is in
  13420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13421. */
  13422. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13423. /**
  13424. * Set the postion of the bone in local or world space
  13425. * @param position The position to set the bone
  13426. * @param space The space that the position is in
  13427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13428. */
  13429. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13430. /**
  13431. * Set the absolute position of the bone (world space)
  13432. * @param position The position to set the bone
  13433. * @param mesh The mesh that this bone is attached to
  13434. */
  13435. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13436. /**
  13437. * Scale the bone on the x, y and z axes (in local space)
  13438. * @param x The amount to scale the bone on the x axis
  13439. * @param y The amount to scale the bone on the y axis
  13440. * @param z The amount to scale the bone on the z axis
  13441. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13442. */
  13443. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13444. /**
  13445. * Set the bone scaling in local space
  13446. * @param scale defines the scaling vector
  13447. */
  13448. setScale(scale: Vector3): void;
  13449. /**
  13450. * Gets the current scaling in local space
  13451. * @returns the current scaling vector
  13452. */
  13453. getScale(): Vector3;
  13454. /**
  13455. * Gets the current scaling in local space and stores it in a target vector
  13456. * @param result defines the target vector
  13457. */
  13458. getScaleToRef(result: Vector3): void;
  13459. /**
  13460. * Set the yaw, pitch, and roll of the bone in local or world space
  13461. * @param yaw The rotation of the bone on the y axis
  13462. * @param pitch The rotation of the bone on the x axis
  13463. * @param roll The rotation of the bone on the z axis
  13464. * @param space The space that the axes of rotation are in
  13465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13466. */
  13467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13468. /**
  13469. * Add a rotation to the bone on an axis in local or world space
  13470. * @param axis The axis to rotate the bone on
  13471. * @param amount The amount to rotate the bone
  13472. * @param space The space that the axis is in
  13473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13474. */
  13475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13476. /**
  13477. * Set the rotation of the bone to a particular axis angle in local or world space
  13478. * @param axis The axis to rotate the bone on
  13479. * @param angle The angle that the bone should be rotated to
  13480. * @param space The space that the axis is in
  13481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13482. */
  13483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13484. /**
  13485. * Set the euler rotation of the bone in local of world space
  13486. * @param rotation The euler rotation that the bone should be set to
  13487. * @param space The space that the rotation is in
  13488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13489. */
  13490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13491. /**
  13492. * Set the quaternion rotation of the bone in local of world space
  13493. * @param quat The quaternion rotation that the bone should be set to
  13494. * @param space The space that the rotation is in
  13495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13496. */
  13497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13498. /**
  13499. * Set the rotation matrix of the bone in local of world space
  13500. * @param rotMat The rotation matrix that the bone should be set to
  13501. * @param space The space that the rotation is in
  13502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13503. */
  13504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13505. private _rotateWithMatrix;
  13506. private _getNegativeRotationToRef;
  13507. /**
  13508. * Get the position of the bone in local or world space
  13509. * @param space The space that the returned position is in
  13510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13511. * @returns The position of the bone
  13512. */
  13513. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13514. /**
  13515. * Copy the position of the bone to a vector3 in local or world space
  13516. * @param space The space that the returned position is in
  13517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13518. * @param result The vector3 to copy the position to
  13519. */
  13520. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13521. /**
  13522. * Get the absolute position of the bone (world space)
  13523. * @param mesh The mesh that this bone is attached to
  13524. * @returns The absolute position of the bone
  13525. */
  13526. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13527. /**
  13528. * Copy the absolute position of the bone (world space) to the result param
  13529. * @param mesh The mesh that this bone is attached to
  13530. * @param result The vector3 to copy the absolute position to
  13531. */
  13532. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13533. /**
  13534. * Compute the absolute transforms of this bone and its children
  13535. */
  13536. computeAbsoluteTransforms(): void;
  13537. /**
  13538. * Get the world direction from an axis that is in the local space of the bone
  13539. * @param localAxis The local direction that is used to compute the world direction
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @returns The world direction
  13542. */
  13543. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13544. /**
  13545. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13546. * @param localAxis The local direction that is used to compute the world direction
  13547. * @param mesh The mesh that this bone is attached to
  13548. * @param result The vector3 that the world direction will be copied to
  13549. */
  13550. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13551. /**
  13552. * Get the euler rotation of the bone in local or world space
  13553. * @param space The space that the rotation should be in
  13554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13555. * @returns The euler rotation
  13556. */
  13557. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13558. /**
  13559. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13560. * @param space The space that the rotation should be in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. * @param result The vector3 that the rotation should be copied to
  13563. */
  13564. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13565. /**
  13566. * Get the quaternion rotation of the bone in either local or world space
  13567. * @param space The space that the rotation should be in
  13568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13569. * @returns The quaternion rotation
  13570. */
  13571. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13572. /**
  13573. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13574. * @param space The space that the rotation should be in
  13575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13576. * @param result The quaternion that the rotation should be copied to
  13577. */
  13578. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13579. /**
  13580. * Get the rotation matrix of the bone in local or world space
  13581. * @param space The space that the rotation should be in
  13582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13583. * @returns The rotation matrix
  13584. */
  13585. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13586. /**
  13587. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13588. * @param space The space that the rotation should be in
  13589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13590. * @param result The quaternion that the rotation should be copied to
  13591. */
  13592. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13593. /**
  13594. * Get the world position of a point that is in the local space of the bone
  13595. * @param position The local position
  13596. * @param mesh The mesh that this bone is attached to
  13597. * @returns The world position
  13598. */
  13599. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13600. /**
  13601. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13602. * @param position The local position
  13603. * @param mesh The mesh that this bone is attached to
  13604. * @param result The vector3 that the world position should be copied to
  13605. */
  13606. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13607. /**
  13608. * Get the local position of a point that is in world space
  13609. * @param position The world position
  13610. * @param mesh The mesh that this bone is attached to
  13611. * @returns The local position
  13612. */
  13613. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13614. /**
  13615. * Get the local position of a point that is in world space and copy it to the result param
  13616. * @param position The world position
  13617. * @param mesh The mesh that this bone is attached to
  13618. * @param result The vector3 that the local position should be copied to
  13619. */
  13620. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13621. }
  13622. }
  13623. declare module BABYLON {
  13624. /**
  13625. * 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.
  13626. * @see https://doc.babylonjs.com/how_to/transformnode
  13627. */
  13628. export class TransformNode extends Node {
  13629. /**
  13630. * Object will not rotate to face the camera
  13631. */
  13632. static BILLBOARDMODE_NONE: number;
  13633. /**
  13634. * Object will rotate to face the camera but only on the x axis
  13635. */
  13636. static BILLBOARDMODE_X: number;
  13637. /**
  13638. * Object will rotate to face the camera but only on the y axis
  13639. */
  13640. static BILLBOARDMODE_Y: number;
  13641. /**
  13642. * Object will rotate to face the camera but only on the z axis
  13643. */
  13644. static BILLBOARDMODE_Z: number;
  13645. /**
  13646. * Object will rotate to face the camera
  13647. */
  13648. static BILLBOARDMODE_ALL: number;
  13649. private _forward;
  13650. private _forwardInverted;
  13651. private _up;
  13652. private _right;
  13653. private _rightInverted;
  13654. private _position;
  13655. private _rotation;
  13656. private _rotationQuaternion;
  13657. protected _scaling: Vector3;
  13658. protected _isDirty: boolean;
  13659. private _transformToBoneReferal;
  13660. private _billboardMode;
  13661. /**
  13662. * Gets or sets the billboard mode. Default is 0.
  13663. *
  13664. * | Value | Type | Description |
  13665. * | --- | --- | --- |
  13666. * | 0 | BILLBOARDMODE_NONE | |
  13667. * | 1 | BILLBOARDMODE_X | |
  13668. * | 2 | BILLBOARDMODE_Y | |
  13669. * | 4 | BILLBOARDMODE_Z | |
  13670. * | 7 | BILLBOARDMODE_ALL | |
  13671. *
  13672. */
  13673. billboardMode: number;
  13674. private _preserveParentRotationForBillboard;
  13675. /**
  13676. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13677. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13678. */
  13679. preserveParentRotationForBillboard: boolean;
  13680. /**
  13681. * 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
  13682. */
  13683. scalingDeterminant: number;
  13684. private _infiniteDistance;
  13685. /**
  13686. * Gets or sets the distance of the object to max, often used by skybox
  13687. */
  13688. infiniteDistance: boolean;
  13689. /**
  13690. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13691. * By default the system will update normals to compensate
  13692. */
  13693. ignoreNonUniformScaling: boolean;
  13694. /**
  13695. * 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
  13696. */
  13697. reIntegrateRotationIntoRotationQuaternion: boolean;
  13698. /** @hidden */
  13699. _poseMatrix: Nullable<Matrix>;
  13700. /** @hidden */
  13701. _localMatrix: Matrix;
  13702. private _usePivotMatrix;
  13703. private _absolutePosition;
  13704. private _pivotMatrix;
  13705. private _pivotMatrixInverse;
  13706. protected _postMultiplyPivotMatrix: boolean;
  13707. protected _isWorldMatrixFrozen: boolean;
  13708. /** @hidden */
  13709. _indexInSceneTransformNodesArray: number;
  13710. /**
  13711. * An event triggered after the world matrix is updated
  13712. */
  13713. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13714. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13715. /**
  13716. * Gets a string identifying the name of the class
  13717. * @returns "TransformNode" string
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13722. */
  13723. position: Vector3;
  13724. /**
  13725. * 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)).
  13726. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13727. */
  13728. rotation: Vector3;
  13729. /**
  13730. * 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)).
  13731. */
  13732. scaling: Vector3;
  13733. /**
  13734. * 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).
  13735. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13736. */
  13737. rotationQuaternion: Nullable<Quaternion>;
  13738. /**
  13739. * The forward direction of that transform in world space.
  13740. */
  13741. readonly forward: Vector3;
  13742. /**
  13743. * The up direction of that transform in world space.
  13744. */
  13745. readonly up: Vector3;
  13746. /**
  13747. * The right direction of that transform in world space.
  13748. */
  13749. readonly right: Vector3;
  13750. /**
  13751. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13752. * @param matrix the matrix to copy the pose from
  13753. * @returns this TransformNode.
  13754. */
  13755. updatePoseMatrix(matrix: Matrix): TransformNode;
  13756. /**
  13757. * Returns the mesh Pose matrix.
  13758. * @returns the pose matrix
  13759. */
  13760. getPoseMatrix(): Matrix;
  13761. /** @hidden */
  13762. _isSynchronized(): boolean;
  13763. /** @hidden */
  13764. _initCache(): void;
  13765. /**
  13766. * Flag the transform node as dirty (Forcing it to update everything)
  13767. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13768. * @returns this transform node
  13769. */
  13770. markAsDirty(property: string): TransformNode;
  13771. /**
  13772. * Returns the current mesh absolute position.
  13773. * Returns a Vector3.
  13774. */
  13775. readonly absolutePosition: Vector3;
  13776. /**
  13777. * Sets a new matrix to apply before all other transformation
  13778. * @param matrix defines the transform matrix
  13779. * @returns the current TransformNode
  13780. */
  13781. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13782. /**
  13783. * Sets a new pivot matrix to the current node
  13784. * @param matrix defines the new pivot matrix to use
  13785. * @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
  13786. * @returns the current TransformNode
  13787. */
  13788. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13789. /**
  13790. * Returns the mesh pivot matrix.
  13791. * Default : Identity.
  13792. * @returns the matrix
  13793. */
  13794. getPivotMatrix(): Matrix;
  13795. /**
  13796. * Prevents the World matrix to be computed any longer.
  13797. * @returns the TransformNode.
  13798. */
  13799. freezeWorldMatrix(): TransformNode;
  13800. /**
  13801. * Allows back the World matrix computation.
  13802. * @returns the TransformNode.
  13803. */
  13804. unfreezeWorldMatrix(): this;
  13805. /**
  13806. * True if the World matrix has been frozen.
  13807. */
  13808. readonly isWorldMatrixFrozen: boolean;
  13809. /**
  13810. * Retuns the mesh absolute position in the World.
  13811. * @returns a Vector3.
  13812. */
  13813. getAbsolutePosition(): Vector3;
  13814. /**
  13815. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13816. * @param absolutePosition the absolute position to set
  13817. * @returns the TransformNode.
  13818. */
  13819. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13820. /**
  13821. * Sets the mesh position in its local space.
  13822. * @param vector3 the position to set in localspace
  13823. * @returns the TransformNode.
  13824. */
  13825. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13826. /**
  13827. * Returns the mesh position in the local space from the current World matrix values.
  13828. * @returns a new Vector3.
  13829. */
  13830. getPositionExpressedInLocalSpace(): Vector3;
  13831. /**
  13832. * Translates the mesh along the passed Vector3 in its local space.
  13833. * @param vector3 the distance to translate in localspace
  13834. * @returns the TransformNode.
  13835. */
  13836. locallyTranslate(vector3: Vector3): TransformNode;
  13837. private static _lookAtVectorCache;
  13838. /**
  13839. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13840. * @param targetPoint the position (must be in same space as current mesh) to look at
  13841. * @param yawCor optional yaw (y-axis) correction in radians
  13842. * @param pitchCor optional pitch (x-axis) correction in radians
  13843. * @param rollCor optional roll (z-axis) correction in radians
  13844. * @param space the choosen space of the target
  13845. * @returns the TransformNode.
  13846. */
  13847. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13848. /**
  13849. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13850. * This Vector3 is expressed in the World space.
  13851. * @param localAxis axis to rotate
  13852. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13853. */
  13854. getDirection(localAxis: Vector3): Vector3;
  13855. /**
  13856. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13857. * localAxis is expressed in the mesh local space.
  13858. * result is computed in the Wordl space from the mesh World matrix.
  13859. * @param localAxis axis to rotate
  13860. * @param result the resulting transformnode
  13861. * @returns this TransformNode.
  13862. */
  13863. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13864. /**
  13865. * Sets this transform node rotation to the given local axis.
  13866. * @param localAxis the axis in local space
  13867. * @param yawCor optional yaw (y-axis) correction in radians
  13868. * @param pitchCor optional pitch (x-axis) correction in radians
  13869. * @param rollCor optional roll (z-axis) correction in radians
  13870. * @returns this TransformNode
  13871. */
  13872. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13873. /**
  13874. * Sets a new pivot point to the current node
  13875. * @param point defines the new pivot point to use
  13876. * @param space defines if the point is in world or local space (local by default)
  13877. * @returns the current TransformNode
  13878. */
  13879. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13880. /**
  13881. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13882. * @returns the pivot point
  13883. */
  13884. getPivotPoint(): Vector3;
  13885. /**
  13886. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13887. * @param result the vector3 to store the result
  13888. * @returns this TransformNode.
  13889. */
  13890. getPivotPointToRef(result: Vector3): TransformNode;
  13891. /**
  13892. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13893. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13894. */
  13895. getAbsolutePivotPoint(): Vector3;
  13896. /**
  13897. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13898. * @param result vector3 to store the result
  13899. * @returns this TransformNode.
  13900. */
  13901. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13902. /**
  13903. * Defines the passed node as the parent of the current node.
  13904. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13905. * @see https://doc.babylonjs.com/how_to/parenting
  13906. * @param node the node ot set as the parent
  13907. * @returns this TransformNode.
  13908. */
  13909. setParent(node: Nullable<Node>): TransformNode;
  13910. private _nonUniformScaling;
  13911. /**
  13912. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13913. */
  13914. readonly nonUniformScaling: boolean;
  13915. /** @hidden */
  13916. _updateNonUniformScalingState(value: boolean): boolean;
  13917. /**
  13918. * Attach the current TransformNode to another TransformNode associated with a bone
  13919. * @param bone Bone affecting the TransformNode
  13920. * @param affectedTransformNode TransformNode associated with the bone
  13921. * @returns this object
  13922. */
  13923. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13924. /**
  13925. * Detach the transform node if its associated with a bone
  13926. * @returns this object
  13927. */
  13928. detachFromBone(): TransformNode;
  13929. private static _rotationAxisCache;
  13930. /**
  13931. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13932. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13933. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13934. * The passed axis is also normalized.
  13935. * @param axis the axis to rotate around
  13936. * @param amount the amount to rotate in radians
  13937. * @param space Space to rotate in (Default: local)
  13938. * @returns the TransformNode.
  13939. */
  13940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13941. /**
  13942. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13943. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13944. * The passed axis is also normalized. .
  13945. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13946. * @param point the point to rotate around
  13947. * @param axis the axis to rotate around
  13948. * @param amount the amount to rotate in radians
  13949. * @returns the TransformNode
  13950. */
  13951. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13952. /**
  13953. * Translates the mesh along the axis vector for the passed distance in the given space.
  13954. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13955. * @param axis the axis to translate in
  13956. * @param distance the distance to translate
  13957. * @param space Space to rotate in (Default: local)
  13958. * @returns the TransformNode.
  13959. */
  13960. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13961. /**
  13962. * Adds a rotation step to the mesh current rotation.
  13963. * x, y, z are Euler angles expressed in radians.
  13964. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13965. * This means this rotation is made in the mesh local space only.
  13966. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13967. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13968. * ```javascript
  13969. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13970. * ```
  13971. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13972. * 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.
  13973. * @param x Rotation to add
  13974. * @param y Rotation to add
  13975. * @param z Rotation to add
  13976. * @returns the TransformNode.
  13977. */
  13978. addRotation(x: number, y: number, z: number): TransformNode;
  13979. /**
  13980. * @hidden
  13981. */
  13982. protected _getEffectiveParent(): Nullable<Node>;
  13983. /**
  13984. * Computes the world matrix of the node
  13985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13986. * @returns the world matrix
  13987. */
  13988. computeWorldMatrix(force?: boolean): Matrix;
  13989. protected _afterComputeWorldMatrix(): void;
  13990. /**
  13991. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13992. * @param func callback function to add
  13993. *
  13994. * @returns the TransformNode.
  13995. */
  13996. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13997. /**
  13998. * Removes a registered callback function.
  13999. * @param func callback function to remove
  14000. * @returns the TransformNode.
  14001. */
  14002. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14003. /**
  14004. * Gets the position of the current mesh in camera space
  14005. * @param camera defines the camera to use
  14006. * @returns a position
  14007. */
  14008. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14009. /**
  14010. * Returns the distance from the mesh to the active camera
  14011. * @param camera defines the camera to use
  14012. * @returns the distance
  14013. */
  14014. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14015. /**
  14016. * Clone the current transform node
  14017. * @param name Name of the new clone
  14018. * @param newParent New parent for the clone
  14019. * @param doNotCloneChildren Do not clone children hierarchy
  14020. * @returns the new transform node
  14021. */
  14022. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14023. /**
  14024. * Serializes the objects information.
  14025. * @param currentSerializationObject defines the object to serialize in
  14026. * @returns the serialized object
  14027. */
  14028. serialize(currentSerializationObject?: any): any;
  14029. /**
  14030. * Returns a new TransformNode object parsed from the source provided.
  14031. * @param parsedTransformNode is the source.
  14032. * @param scene the scne the object belongs to
  14033. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14034. * @returns a new TransformNode object parsed from the source provided.
  14035. */
  14036. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14037. /**
  14038. * Get all child-transformNodes of this node
  14039. * @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
  14040. * @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
  14041. * @returns an array of TransformNode
  14042. */
  14043. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14044. /**
  14045. * Releases resources associated with this transform node.
  14046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14048. */
  14049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14050. /**
  14051. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14052. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14053. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14054. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14055. * @returns the current mesh
  14056. */
  14057. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14058. }
  14059. }
  14060. declare module BABYLON {
  14061. /**
  14062. * Defines the types of pose enabled controllers that are supported
  14063. */
  14064. export enum PoseEnabledControllerType {
  14065. /**
  14066. * HTC Vive
  14067. */
  14068. VIVE = 0,
  14069. /**
  14070. * Oculus Rift
  14071. */
  14072. OCULUS = 1,
  14073. /**
  14074. * Windows mixed reality
  14075. */
  14076. WINDOWS = 2,
  14077. /**
  14078. * Samsung gear VR
  14079. */
  14080. GEAR_VR = 3,
  14081. /**
  14082. * Google Daydream
  14083. */
  14084. DAYDREAM = 4,
  14085. /**
  14086. * Generic
  14087. */
  14088. GENERIC = 5
  14089. }
  14090. /**
  14091. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14092. */
  14093. export interface MutableGamepadButton {
  14094. /**
  14095. * Value of the button/trigger
  14096. */
  14097. value: number;
  14098. /**
  14099. * If the button/trigger is currently touched
  14100. */
  14101. touched: boolean;
  14102. /**
  14103. * If the button/trigger is currently pressed
  14104. */
  14105. pressed: boolean;
  14106. }
  14107. /**
  14108. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14109. * @hidden
  14110. */
  14111. export interface ExtendedGamepadButton extends GamepadButton {
  14112. /**
  14113. * If the button/trigger is currently pressed
  14114. */
  14115. readonly pressed: boolean;
  14116. /**
  14117. * If the button/trigger is currently touched
  14118. */
  14119. readonly touched: boolean;
  14120. /**
  14121. * Value of the button/trigger
  14122. */
  14123. readonly value: number;
  14124. }
  14125. /** @hidden */
  14126. export interface _GamePadFactory {
  14127. /**
  14128. * Returns wether or not the current gamepad can be created for this type of controller.
  14129. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14130. * @returns true if it can be created, otherwise false
  14131. */
  14132. canCreate(gamepadInfo: any): boolean;
  14133. /**
  14134. * Creates a new instance of the Gamepad.
  14135. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14136. * @returns the new gamepad instance
  14137. */
  14138. create(gamepadInfo: any): Gamepad;
  14139. }
  14140. /**
  14141. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14142. */
  14143. export class PoseEnabledControllerHelper {
  14144. /** @hidden */
  14145. static _ControllerFactories: _GamePadFactory[];
  14146. /** @hidden */
  14147. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14148. /**
  14149. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14150. * @param vrGamepad the gamepad to initialized
  14151. * @returns a vr controller of the type the gamepad identified as
  14152. */
  14153. static InitiateController(vrGamepad: any): Gamepad;
  14154. }
  14155. /**
  14156. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14157. */
  14158. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14159. /**
  14160. * If the controller is used in a webXR session
  14161. */
  14162. isXR: boolean;
  14163. private _deviceRoomPosition;
  14164. private _deviceRoomRotationQuaternion;
  14165. /**
  14166. * The device position in babylon space
  14167. */
  14168. devicePosition: Vector3;
  14169. /**
  14170. * The device rotation in babylon space
  14171. */
  14172. deviceRotationQuaternion: Quaternion;
  14173. /**
  14174. * The scale factor of the device in babylon space
  14175. */
  14176. deviceScaleFactor: number;
  14177. /**
  14178. * (Likely devicePosition should be used instead) The device position in its room space
  14179. */
  14180. position: Vector3;
  14181. /**
  14182. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14183. */
  14184. rotationQuaternion: Quaternion;
  14185. /**
  14186. * The type of controller (Eg. Windows mixed reality)
  14187. */
  14188. controllerType: PoseEnabledControllerType;
  14189. protected _calculatedPosition: Vector3;
  14190. private _calculatedRotation;
  14191. /**
  14192. * The raw pose from the device
  14193. */
  14194. rawPose: DevicePose;
  14195. private _trackPosition;
  14196. private _maxRotationDistFromHeadset;
  14197. private _draggedRoomRotation;
  14198. /**
  14199. * @hidden
  14200. */
  14201. _disableTrackPosition(fixedPosition: Vector3): void;
  14202. /**
  14203. * Internal, the mesh attached to the controller
  14204. * @hidden
  14205. */
  14206. _mesh: Nullable<AbstractMesh>;
  14207. private _poseControlledCamera;
  14208. private _leftHandSystemQuaternion;
  14209. /**
  14210. * Internal, matrix used to convert room space to babylon space
  14211. * @hidden
  14212. */
  14213. _deviceToWorld: Matrix;
  14214. /**
  14215. * Node to be used when casting a ray from the controller
  14216. * @hidden
  14217. */
  14218. _pointingPoseNode: Nullable<TransformNode>;
  14219. /**
  14220. * Name of the child mesh that can be used to cast a ray from the controller
  14221. */
  14222. static readonly POINTING_POSE: string;
  14223. /**
  14224. * Creates a new PoseEnabledController from a gamepad
  14225. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14226. */
  14227. constructor(browserGamepad: any);
  14228. private _workingMatrix;
  14229. /**
  14230. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14231. */
  14232. update(): void;
  14233. /**
  14234. * Updates only the pose device and mesh without doing any button event checking
  14235. */
  14236. protected _updatePoseAndMesh(): void;
  14237. /**
  14238. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14239. * @param poseData raw pose fromthe device
  14240. */
  14241. updateFromDevice(poseData: DevicePose): void;
  14242. /**
  14243. * @hidden
  14244. */
  14245. _meshAttachedObservable: Observable<AbstractMesh>;
  14246. /**
  14247. * Attaches a mesh to the controller
  14248. * @param mesh the mesh to be attached
  14249. */
  14250. attachToMesh(mesh: AbstractMesh): void;
  14251. /**
  14252. * Attaches the controllers mesh to a camera
  14253. * @param camera the camera the mesh should be attached to
  14254. */
  14255. attachToPoseControlledCamera(camera: TargetCamera): void;
  14256. /**
  14257. * Disposes of the controller
  14258. */
  14259. dispose(): void;
  14260. /**
  14261. * The mesh that is attached to the controller
  14262. */
  14263. readonly mesh: Nullable<AbstractMesh>;
  14264. /**
  14265. * Gets the ray of the controller in the direction the controller is pointing
  14266. * @param length the length the resulting ray should be
  14267. * @returns a ray in the direction the controller is pointing
  14268. */
  14269. getForwardRay(length?: number): Ray;
  14270. }
  14271. }
  14272. declare module BABYLON {
  14273. /**
  14274. * Defines the WebVRController object that represents controllers tracked in 3D space
  14275. */
  14276. export abstract class WebVRController extends PoseEnabledController {
  14277. /**
  14278. * Internal, the default controller model for the controller
  14279. */
  14280. protected _defaultModel: AbstractMesh;
  14281. /**
  14282. * Fired when the trigger state has changed
  14283. */
  14284. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14285. /**
  14286. * Fired when the main button state has changed
  14287. */
  14288. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14289. /**
  14290. * Fired when the secondary button state has changed
  14291. */
  14292. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14293. /**
  14294. * Fired when the pad state has changed
  14295. */
  14296. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14297. /**
  14298. * Fired when controllers stick values have changed
  14299. */
  14300. onPadValuesChangedObservable: Observable<StickValues>;
  14301. /**
  14302. * Array of button availible on the controller
  14303. */
  14304. protected _buttons: Array<MutableGamepadButton>;
  14305. private _onButtonStateChange;
  14306. /**
  14307. * Fired when a controller button's state has changed
  14308. * @param callback the callback containing the button that was modified
  14309. */
  14310. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14311. /**
  14312. * X and Y axis corresponding to the controllers joystick
  14313. */
  14314. pad: StickValues;
  14315. /**
  14316. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14317. */
  14318. hand: string;
  14319. /**
  14320. * The default controller model for the controller
  14321. */
  14322. readonly defaultModel: AbstractMesh;
  14323. /**
  14324. * Creates a new WebVRController from a gamepad
  14325. * @param vrGamepad the gamepad that the WebVRController should be created from
  14326. */
  14327. constructor(vrGamepad: any);
  14328. /**
  14329. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14330. */
  14331. update(): void;
  14332. /**
  14333. * Function to be called when a button is modified
  14334. */
  14335. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14336. /**
  14337. * Loads a mesh and attaches it to the controller
  14338. * @param scene the scene the mesh should be added to
  14339. * @param meshLoaded callback for when the mesh has been loaded
  14340. */
  14341. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14342. private _setButtonValue;
  14343. private _changes;
  14344. private _checkChanges;
  14345. /**
  14346. * Disposes of th webVRCOntroller
  14347. */
  14348. dispose(): void;
  14349. }
  14350. }
  14351. declare module BABYLON {
  14352. /**
  14353. * The HemisphericLight simulates the ambient environment light,
  14354. * so the passed direction is the light reflection direction, not the incoming direction.
  14355. */
  14356. export class HemisphericLight extends Light {
  14357. /**
  14358. * The groundColor is the light in the opposite direction to the one specified during creation.
  14359. * 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.
  14360. */
  14361. groundColor: Color3;
  14362. /**
  14363. * The light reflection direction, not the incoming direction.
  14364. */
  14365. direction: Vector3;
  14366. /**
  14367. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14368. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14369. * The HemisphericLight can't cast shadows.
  14370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14371. * @param name The friendly name of the light
  14372. * @param direction The direction of the light reflection
  14373. * @param scene The scene the light belongs to
  14374. */
  14375. constructor(name: string, direction: Vector3, scene: Scene);
  14376. protected _buildUniformLayout(): void;
  14377. /**
  14378. * Returns the string "HemisphericLight".
  14379. * @return The class name
  14380. */
  14381. getClassName(): string;
  14382. /**
  14383. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14384. * Returns the updated direction.
  14385. * @param target The target the direction should point to
  14386. * @return The computed direction
  14387. */
  14388. setDirectionToTarget(target: Vector3): Vector3;
  14389. /**
  14390. * Returns the shadow generator associated to the light.
  14391. * @returns Always null for hemispheric lights because it does not support shadows.
  14392. */
  14393. getShadowGenerator(): Nullable<IShadowGenerator>;
  14394. /**
  14395. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14396. * @param effect The effect to update
  14397. * @param lightIndex The index of the light in the effect to update
  14398. * @returns The hemispheric light
  14399. */
  14400. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14401. /**
  14402. * Computes the world matrix of the node
  14403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14404. * @param useWasUpdatedFlag defines a reserved property
  14405. * @returns the world matrix
  14406. */
  14407. computeWorldMatrix(): Matrix;
  14408. /**
  14409. * Returns the integer 3.
  14410. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14411. */
  14412. getTypeID(): number;
  14413. /**
  14414. * Prepares the list of defines specific to the light type.
  14415. * @param defines the list of defines
  14416. * @param lightIndex defines the index of the light for the effect
  14417. */
  14418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14419. }
  14420. }
  14421. declare module BABYLON {
  14422. /** @hidden */
  14423. export var vrMultiviewToSingleviewPixelShader: {
  14424. name: string;
  14425. shader: string;
  14426. };
  14427. }
  14428. declare module BABYLON {
  14429. /**
  14430. * Renders to multiple views with a single draw call
  14431. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14432. */
  14433. export class MultiviewRenderTarget extends RenderTargetTexture {
  14434. /**
  14435. * Creates a multiview render target
  14436. * @param scene scene used with the render target
  14437. * @param size the size of the render target (used for each view)
  14438. */
  14439. constructor(scene: Scene, size?: number | {
  14440. width: number;
  14441. height: number;
  14442. } | {
  14443. ratio: number;
  14444. });
  14445. /**
  14446. * @hidden
  14447. * @param faceIndex the face index, if its a cube texture
  14448. */
  14449. _bindFrameBuffer(faceIndex?: number): void;
  14450. /**
  14451. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14452. * @returns the view count
  14453. */
  14454. getViewCount(): number;
  14455. }
  14456. }
  14457. declare module BABYLON {
  14458. /**
  14459. * Reprasents a camera frustum
  14460. */
  14461. export class Frustum {
  14462. /**
  14463. * Gets the planes representing the frustum
  14464. * @param transform matrix to be applied to the returned planes
  14465. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14466. */
  14467. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14468. /**
  14469. * Gets the near frustum plane transformed by the transform matrix
  14470. * @param transform transformation matrix to be applied to the resulting frustum plane
  14471. * @param frustumPlane the resuling frustum plane
  14472. */
  14473. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14474. /**
  14475. * Gets the far frustum plane transformed by the transform matrix
  14476. * @param transform transformation matrix to be applied to the resulting frustum plane
  14477. * @param frustumPlane the resuling frustum plane
  14478. */
  14479. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14480. /**
  14481. * Gets the left frustum plane transformed by the transform matrix
  14482. * @param transform transformation matrix to be applied to the resulting frustum plane
  14483. * @param frustumPlane the resuling frustum plane
  14484. */
  14485. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14486. /**
  14487. * Gets the right frustum plane transformed by the transform matrix
  14488. * @param transform transformation matrix to be applied to the resulting frustum plane
  14489. * @param frustumPlane the resuling frustum plane
  14490. */
  14491. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14492. /**
  14493. * Gets the top frustum plane transformed by the transform matrix
  14494. * @param transform transformation matrix to be applied to the resulting frustum plane
  14495. * @param frustumPlane the resuling frustum plane
  14496. */
  14497. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14498. /**
  14499. * Gets the bottom frustum plane transformed by the transform matrix
  14500. * @param transform transformation matrix to be applied to the resulting frustum plane
  14501. * @param frustumPlane the resuling frustum plane
  14502. */
  14503. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14504. /**
  14505. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14506. * @param transform transformation matrix to be applied to the resulting frustum planes
  14507. * @param frustumPlanes the resuling frustum planes
  14508. */
  14509. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. interface Engine {
  14514. /**
  14515. * Creates a new multiview render target
  14516. * @param width defines the width of the texture
  14517. * @param height defines the height of the texture
  14518. * @returns the created multiview texture
  14519. */
  14520. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14521. /**
  14522. * Binds a multiview framebuffer to be drawn to
  14523. * @param multiviewTexture texture to bind
  14524. */
  14525. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14526. }
  14527. interface Camera {
  14528. /**
  14529. * @hidden
  14530. * 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)
  14531. */
  14532. _useMultiviewToSingleView: boolean;
  14533. /**
  14534. * @hidden
  14535. * 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)
  14536. */
  14537. _multiviewTexture: Nullable<RenderTargetTexture>;
  14538. /**
  14539. * @hidden
  14540. * ensures the multiview texture of the camera exists and has the specified width/height
  14541. * @param width height to set on the multiview texture
  14542. * @param height width to set on the multiview texture
  14543. */
  14544. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14545. }
  14546. interface Scene {
  14547. /** @hidden */
  14548. _transformMatrixR: Matrix;
  14549. /** @hidden */
  14550. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14551. /** @hidden */
  14552. _createMultiviewUbo(): void;
  14553. /** @hidden */
  14554. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14555. /** @hidden */
  14556. _renderMultiviewToSingleView(camera: Camera): void;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. /**
  14561. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14562. * This will not be used for webXR as it supports displaying texture arrays directly
  14563. */
  14564. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14565. /**
  14566. * Initializes a VRMultiviewToSingleview
  14567. * @param name name of the post process
  14568. * @param camera camera to be applied to
  14569. * @param scaleFactor scaling factor to the size of the output texture
  14570. */
  14571. constructor(name: string, camera: Camera, scaleFactor: number);
  14572. }
  14573. }
  14574. declare module BABYLON {
  14575. interface Engine {
  14576. /** @hidden */
  14577. _vrDisplay: any;
  14578. /** @hidden */
  14579. _vrSupported: boolean;
  14580. /** @hidden */
  14581. _oldSize: Size;
  14582. /** @hidden */
  14583. _oldHardwareScaleFactor: number;
  14584. /** @hidden */
  14585. _vrExclusivePointerMode: boolean;
  14586. /** @hidden */
  14587. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14588. /** @hidden */
  14589. _onVRDisplayPointerRestricted: () => void;
  14590. /** @hidden */
  14591. _onVRDisplayPointerUnrestricted: () => void;
  14592. /** @hidden */
  14593. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14594. /** @hidden */
  14595. _onVrDisplayDisconnect: Nullable<() => void>;
  14596. /** @hidden */
  14597. _onVrDisplayPresentChange: Nullable<() => void>;
  14598. /**
  14599. * Observable signaled when VR display mode changes
  14600. */
  14601. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14602. /**
  14603. * Observable signaled when VR request present is complete
  14604. */
  14605. onVRRequestPresentComplete: Observable<boolean>;
  14606. /**
  14607. * Observable signaled when VR request present starts
  14608. */
  14609. onVRRequestPresentStart: Observable<Engine>;
  14610. /**
  14611. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14612. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14613. */
  14614. isInVRExclusivePointerMode: boolean;
  14615. /**
  14616. * Gets a boolean indicating if a webVR device was detected
  14617. * @returns true if a webVR device was detected
  14618. */
  14619. isVRDevicePresent(): boolean;
  14620. /**
  14621. * Gets the current webVR device
  14622. * @returns the current webVR device (or null)
  14623. */
  14624. getVRDevice(): any;
  14625. /**
  14626. * Initializes a webVR display and starts listening to display change events
  14627. * The onVRDisplayChangedObservable will be notified upon these changes
  14628. * @returns A promise containing a VRDisplay and if vr is supported
  14629. */
  14630. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14631. /** @hidden */
  14632. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14633. /**
  14634. * Call this function to switch to webVR mode
  14635. * Will do nothing if webVR is not supported or if there is no webVR device
  14636. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14637. */
  14638. enableVR(): void;
  14639. /** @hidden */
  14640. _onVRFullScreenTriggered(): void;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. /**
  14645. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14646. * IMPORTANT!! The data is right-hand data.
  14647. * @export
  14648. * @interface DevicePose
  14649. */
  14650. export interface DevicePose {
  14651. /**
  14652. * The position of the device, values in array are [x,y,z].
  14653. */
  14654. readonly position: Nullable<Float32Array>;
  14655. /**
  14656. * The linearVelocity of the device, values in array are [x,y,z].
  14657. */
  14658. readonly linearVelocity: Nullable<Float32Array>;
  14659. /**
  14660. * The linearAcceleration of the device, values in array are [x,y,z].
  14661. */
  14662. readonly linearAcceleration: Nullable<Float32Array>;
  14663. /**
  14664. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14665. */
  14666. readonly orientation: Nullable<Float32Array>;
  14667. /**
  14668. * The angularVelocity of the device, values in array are [x,y,z].
  14669. */
  14670. readonly angularVelocity: Nullable<Float32Array>;
  14671. /**
  14672. * The angularAcceleration of the device, values in array are [x,y,z].
  14673. */
  14674. readonly angularAcceleration: Nullable<Float32Array>;
  14675. }
  14676. /**
  14677. * Interface representing a pose controlled object in Babylon.
  14678. * A pose controlled object has both regular pose values as well as pose values
  14679. * from an external device such as a VR head mounted display
  14680. */
  14681. export interface PoseControlled {
  14682. /**
  14683. * The position of the object in babylon space.
  14684. */
  14685. position: Vector3;
  14686. /**
  14687. * The rotation quaternion of the object in babylon space.
  14688. */
  14689. rotationQuaternion: Quaternion;
  14690. /**
  14691. * The position of the device in babylon space.
  14692. */
  14693. devicePosition?: Vector3;
  14694. /**
  14695. * The rotation quaternion of the device in babylon space.
  14696. */
  14697. deviceRotationQuaternion: Quaternion;
  14698. /**
  14699. * The raw pose coming from the device.
  14700. */
  14701. rawPose: Nullable<DevicePose>;
  14702. /**
  14703. * The scale of the device to be used when translating from device space to babylon space.
  14704. */
  14705. deviceScaleFactor: number;
  14706. /**
  14707. * Updates the poseControlled values based on the input device pose.
  14708. * @param poseData the pose data to update the object with
  14709. */
  14710. updateFromDevice(poseData: DevicePose): void;
  14711. }
  14712. /**
  14713. * Set of options to customize the webVRCamera
  14714. */
  14715. export interface WebVROptions {
  14716. /**
  14717. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14718. */
  14719. trackPosition?: boolean;
  14720. /**
  14721. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14722. */
  14723. positionScale?: number;
  14724. /**
  14725. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14726. */
  14727. displayName?: string;
  14728. /**
  14729. * Should the native controller meshes be initialized. (default: true)
  14730. */
  14731. controllerMeshes?: boolean;
  14732. /**
  14733. * Creating a default HemiLight only on controllers. (default: true)
  14734. */
  14735. defaultLightingOnControllers?: boolean;
  14736. /**
  14737. * If you don't want to use the default VR button of the helper. (default: false)
  14738. */
  14739. useCustomVRButton?: boolean;
  14740. /**
  14741. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14742. */
  14743. customVRButton?: HTMLButtonElement;
  14744. /**
  14745. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14746. */
  14747. rayLength?: number;
  14748. /**
  14749. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14750. */
  14751. defaultHeight?: number;
  14752. /**
  14753. * If multiview should be used if availible (default: false)
  14754. */
  14755. useMultiview?: boolean;
  14756. }
  14757. /**
  14758. * This represents a WebVR camera.
  14759. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14760. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14761. */
  14762. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14763. private webVROptions;
  14764. /**
  14765. * @hidden
  14766. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14767. */
  14768. _vrDevice: any;
  14769. /**
  14770. * The rawPose of the vrDevice.
  14771. */
  14772. rawPose: Nullable<DevicePose>;
  14773. private _onVREnabled;
  14774. private _specsVersion;
  14775. private _attached;
  14776. private _frameData;
  14777. protected _descendants: Array<Node>;
  14778. private _deviceRoomPosition;
  14779. /** @hidden */
  14780. _deviceRoomRotationQuaternion: Quaternion;
  14781. private _standingMatrix;
  14782. /**
  14783. * Represents device position in babylon space.
  14784. */
  14785. devicePosition: Vector3;
  14786. /**
  14787. * Represents device rotation in babylon space.
  14788. */
  14789. deviceRotationQuaternion: Quaternion;
  14790. /**
  14791. * The scale of the device to be used when translating from device space to babylon space.
  14792. */
  14793. deviceScaleFactor: number;
  14794. private _deviceToWorld;
  14795. private _worldToDevice;
  14796. /**
  14797. * References to the webVR controllers for the vrDevice.
  14798. */
  14799. controllers: Array<WebVRController>;
  14800. /**
  14801. * Emits an event when a controller is attached.
  14802. */
  14803. onControllersAttachedObservable: Observable<WebVRController[]>;
  14804. /**
  14805. * Emits an event when a controller's mesh has been loaded;
  14806. */
  14807. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14808. /**
  14809. * Emits an event when the HMD's pose has been updated.
  14810. */
  14811. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14812. private _poseSet;
  14813. /**
  14814. * If the rig cameras be used as parent instead of this camera.
  14815. */
  14816. rigParenting: boolean;
  14817. private _lightOnControllers;
  14818. private _defaultHeight?;
  14819. /**
  14820. * Instantiates a WebVRFreeCamera.
  14821. * @param name The name of the WebVRFreeCamera
  14822. * @param position The starting anchor position for the camera
  14823. * @param scene The scene the camera belongs to
  14824. * @param webVROptions a set of customizable options for the webVRCamera
  14825. */
  14826. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14827. /**
  14828. * Gets the device distance from the ground in meters.
  14829. * @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.
  14830. */
  14831. deviceDistanceToRoomGround(): number;
  14832. /**
  14833. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14834. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14835. */
  14836. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14837. /**
  14838. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14839. * @returns A promise with a boolean set to if the standing matrix is supported.
  14840. */
  14841. useStandingMatrixAsync(): Promise<boolean>;
  14842. /**
  14843. * Disposes the camera
  14844. */
  14845. dispose(): void;
  14846. /**
  14847. * Gets a vrController by name.
  14848. * @param name The name of the controller to retreive
  14849. * @returns the controller matching the name specified or null if not found
  14850. */
  14851. getControllerByName(name: string): Nullable<WebVRController>;
  14852. private _leftController;
  14853. /**
  14854. * The controller corresponding to the users left hand.
  14855. */
  14856. readonly leftController: Nullable<WebVRController>;
  14857. private _rightController;
  14858. /**
  14859. * The controller corresponding to the users right hand.
  14860. */
  14861. readonly rightController: Nullable<WebVRController>;
  14862. /**
  14863. * Casts a ray forward from the vrCamera's gaze.
  14864. * @param length Length of the ray (default: 100)
  14865. * @returns the ray corresponding to the gaze
  14866. */
  14867. getForwardRay(length?: number): Ray;
  14868. /**
  14869. * @hidden
  14870. * Updates the camera based on device's frame data
  14871. */
  14872. _checkInputs(): void;
  14873. /**
  14874. * Updates the poseControlled values based on the input device pose.
  14875. * @param poseData Pose coming from the device
  14876. */
  14877. updateFromDevice(poseData: DevicePose): void;
  14878. private _htmlElementAttached;
  14879. private _detachIfAttached;
  14880. /**
  14881. * WebVR's attach control will start broadcasting frames to the device.
  14882. * Note that in certain browsers (chrome for example) this function must be called
  14883. * within a user-interaction callback. Example:
  14884. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14885. *
  14886. * @param element html element to attach the vrDevice to
  14887. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14888. */
  14889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14890. /**
  14891. * Detaches the camera from the html element and disables VR
  14892. *
  14893. * @param element html element to detach from
  14894. */
  14895. detachControl(element: HTMLElement): void;
  14896. /**
  14897. * @returns the name of this class
  14898. */
  14899. getClassName(): string;
  14900. /**
  14901. * Calls resetPose on the vrDisplay
  14902. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14903. */
  14904. resetToCurrentRotation(): void;
  14905. /**
  14906. * @hidden
  14907. * Updates the rig cameras (left and right eye)
  14908. */
  14909. _updateRigCameras(): void;
  14910. private _workingVector;
  14911. private _oneVector;
  14912. private _workingMatrix;
  14913. private updateCacheCalled;
  14914. private _correctPositionIfNotTrackPosition;
  14915. /**
  14916. * @hidden
  14917. * Updates the cached values of the camera
  14918. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14919. */
  14920. _updateCache(ignoreParentClass?: boolean): void;
  14921. /**
  14922. * @hidden
  14923. * Get current device position in babylon world
  14924. */
  14925. _computeDevicePosition(): void;
  14926. /**
  14927. * Updates the current device position and rotation in the babylon world
  14928. */
  14929. update(): void;
  14930. /**
  14931. * @hidden
  14932. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14933. * @returns an identity matrix
  14934. */
  14935. _getViewMatrix(): Matrix;
  14936. private _tmpMatrix;
  14937. /**
  14938. * This function is called by the two RIG cameras.
  14939. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14940. * @hidden
  14941. */
  14942. _getWebVRViewMatrix(): Matrix;
  14943. /** @hidden */
  14944. _getWebVRProjectionMatrix(): Matrix;
  14945. private _onGamepadConnectedObserver;
  14946. private _onGamepadDisconnectedObserver;
  14947. private _updateCacheWhenTrackingDisabledObserver;
  14948. /**
  14949. * Initializes the controllers and their meshes
  14950. */
  14951. initControllers(): void;
  14952. }
  14953. }
  14954. declare module BABYLON {
  14955. /**
  14956. * Size options for a post process
  14957. */
  14958. export type PostProcessOptions = {
  14959. width: number;
  14960. height: number;
  14961. };
  14962. /**
  14963. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14964. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14965. */
  14966. export class PostProcess {
  14967. /** Name of the PostProcess. */
  14968. name: string;
  14969. /**
  14970. * Gets or sets the unique id of the post process
  14971. */
  14972. uniqueId: number;
  14973. /**
  14974. * Width of the texture to apply the post process on
  14975. */
  14976. width: number;
  14977. /**
  14978. * Height of the texture to apply the post process on
  14979. */
  14980. height: number;
  14981. /**
  14982. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14983. * @hidden
  14984. */
  14985. _outputTexture: Nullable<InternalTexture>;
  14986. /**
  14987. * Sampling mode used by the shader
  14988. * See https://doc.babylonjs.com/classes/3.1/texture
  14989. */
  14990. renderTargetSamplingMode: number;
  14991. /**
  14992. * Clear color to use when screen clearing
  14993. */
  14994. clearColor: Color4;
  14995. /**
  14996. * If the buffer needs to be cleared before applying the post process. (default: true)
  14997. * Should be set to false if shader will overwrite all previous pixels.
  14998. */
  14999. autoClear: boolean;
  15000. /**
  15001. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15002. */
  15003. alphaMode: number;
  15004. /**
  15005. * Sets the setAlphaBlendConstants of the babylon engine
  15006. */
  15007. alphaConstants: Color4;
  15008. /**
  15009. * Animations to be used for the post processing
  15010. */
  15011. animations: Animation[];
  15012. /**
  15013. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15014. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15015. */
  15016. enablePixelPerfectMode: boolean;
  15017. /**
  15018. * Force the postprocess to be applied without taking in account viewport
  15019. */
  15020. forceFullscreenViewport: boolean;
  15021. /**
  15022. * List of inspectable custom properties (used by the Inspector)
  15023. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15024. */
  15025. inspectableCustomProperties: IInspectable[];
  15026. /**
  15027. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15028. *
  15029. * | Value | Type | Description |
  15030. * | ----- | ----------------------------------- | ----------- |
  15031. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15032. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15033. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15034. *
  15035. */
  15036. scaleMode: number;
  15037. /**
  15038. * Force textures to be a power of two (default: false)
  15039. */
  15040. alwaysForcePOT: boolean;
  15041. private _samples;
  15042. /**
  15043. * Number of sample textures (default: 1)
  15044. */
  15045. samples: number;
  15046. /**
  15047. * Modify the scale of the post process to be the same as the viewport (default: false)
  15048. */
  15049. adaptScaleToCurrentViewport: boolean;
  15050. private _camera;
  15051. private _scene;
  15052. private _engine;
  15053. private _options;
  15054. private _reusable;
  15055. private _textureType;
  15056. /**
  15057. * Smart array of input and output textures for the post process.
  15058. * @hidden
  15059. */
  15060. _textures: SmartArray<InternalTexture>;
  15061. /**
  15062. * The index in _textures that corresponds to the output texture.
  15063. * @hidden
  15064. */
  15065. _currentRenderTextureInd: number;
  15066. private _effect;
  15067. private _samplers;
  15068. private _fragmentUrl;
  15069. private _vertexUrl;
  15070. private _parameters;
  15071. private _scaleRatio;
  15072. protected _indexParameters: any;
  15073. private _shareOutputWithPostProcess;
  15074. private _texelSize;
  15075. private _forcedOutputTexture;
  15076. /**
  15077. * Returns the fragment url or shader name used in the post process.
  15078. * @returns the fragment url or name in the shader store.
  15079. */
  15080. getEffectName(): string;
  15081. /**
  15082. * An event triggered when the postprocess is activated.
  15083. */
  15084. onActivateObservable: Observable<Camera>;
  15085. private _onActivateObserver;
  15086. /**
  15087. * A function that is added to the onActivateObservable
  15088. */
  15089. onActivate: Nullable<(camera: Camera) => void>;
  15090. /**
  15091. * An event triggered when the postprocess changes its size.
  15092. */
  15093. onSizeChangedObservable: Observable<PostProcess>;
  15094. private _onSizeChangedObserver;
  15095. /**
  15096. * A function that is added to the onSizeChangedObservable
  15097. */
  15098. onSizeChanged: (postProcess: PostProcess) => void;
  15099. /**
  15100. * An event triggered when the postprocess applies its effect.
  15101. */
  15102. onApplyObservable: Observable<Effect>;
  15103. private _onApplyObserver;
  15104. /**
  15105. * A function that is added to the onApplyObservable
  15106. */
  15107. onApply: (effect: Effect) => void;
  15108. /**
  15109. * An event triggered before rendering the postprocess
  15110. */
  15111. onBeforeRenderObservable: Observable<Effect>;
  15112. private _onBeforeRenderObserver;
  15113. /**
  15114. * A function that is added to the onBeforeRenderObservable
  15115. */
  15116. onBeforeRender: (effect: Effect) => void;
  15117. /**
  15118. * An event triggered after rendering the postprocess
  15119. */
  15120. onAfterRenderObservable: Observable<Effect>;
  15121. private _onAfterRenderObserver;
  15122. /**
  15123. * A function that is added to the onAfterRenderObservable
  15124. */
  15125. onAfterRender: (efect: Effect) => void;
  15126. /**
  15127. * 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
  15128. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15129. */
  15130. inputTexture: InternalTexture;
  15131. /**
  15132. * Gets the camera which post process is applied to.
  15133. * @returns The camera the post process is applied to.
  15134. */
  15135. getCamera(): Camera;
  15136. /**
  15137. * Gets the texel size of the postprocess.
  15138. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15139. */
  15140. readonly texelSize: Vector2;
  15141. /**
  15142. * Creates a new instance PostProcess
  15143. * @param name The name of the PostProcess.
  15144. * @param fragmentUrl The url of the fragment shader to be used.
  15145. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15146. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15147. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15148. * @param camera The camera to apply the render pass to.
  15149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15150. * @param engine The engine which the post process will be applied. (default: current engine)
  15151. * @param reusable If the post process can be reused on the same frame. (default: false)
  15152. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15153. * @param textureType Type of textures used when performing the post process. (default: 0)
  15154. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15155. * @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
  15156. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15157. */
  15158. constructor(
  15159. /** Name of the PostProcess. */
  15160. 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);
  15161. /**
  15162. * Gets a string idenfifying the name of the class
  15163. * @returns "PostProcess" string
  15164. */
  15165. getClassName(): string;
  15166. /**
  15167. * Gets the engine which this post process belongs to.
  15168. * @returns The engine the post process was enabled with.
  15169. */
  15170. getEngine(): Engine;
  15171. /**
  15172. * The effect that is created when initializing the post process.
  15173. * @returns The created effect corresponding the the postprocess.
  15174. */
  15175. getEffect(): Effect;
  15176. /**
  15177. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15178. * @param postProcess The post process to share the output with.
  15179. * @returns This post process.
  15180. */
  15181. shareOutputWith(postProcess: PostProcess): PostProcess;
  15182. /**
  15183. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15184. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15185. */
  15186. useOwnOutput(): void;
  15187. /**
  15188. * Updates the effect with the current post process compile time values and recompiles the shader.
  15189. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15190. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15191. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15192. * @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
  15193. * @param onCompiled Called when the shader has been compiled.
  15194. * @param onError Called if there is an error when compiling a shader.
  15195. */
  15196. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15197. /**
  15198. * The post process is reusable if it can be used multiple times within one frame.
  15199. * @returns If the post process is reusable
  15200. */
  15201. isReusable(): boolean;
  15202. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15203. markTextureDirty(): void;
  15204. /**
  15205. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15206. * 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.
  15207. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15208. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15209. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15210. * @returns The target texture that was bound to be written to.
  15211. */
  15212. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15213. /**
  15214. * If the post process is supported.
  15215. */
  15216. readonly isSupported: boolean;
  15217. /**
  15218. * The aspect ratio of the output texture.
  15219. */
  15220. readonly aspectRatio: number;
  15221. /**
  15222. * Get a value indicating if the post-process is ready to be used
  15223. * @returns true if the post-process is ready (shader is compiled)
  15224. */
  15225. isReady(): boolean;
  15226. /**
  15227. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15228. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15229. */
  15230. apply(): Nullable<Effect>;
  15231. private _disposeTextures;
  15232. /**
  15233. * Disposes the post process.
  15234. * @param camera The camera to dispose the post process on.
  15235. */
  15236. dispose(camera?: Camera): void;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /** @hidden */
  15241. export var kernelBlurVaryingDeclaration: {
  15242. name: string;
  15243. shader: string;
  15244. };
  15245. }
  15246. declare module BABYLON {
  15247. /** @hidden */
  15248. export var kernelBlurFragment: {
  15249. name: string;
  15250. shader: string;
  15251. };
  15252. }
  15253. declare module BABYLON {
  15254. /** @hidden */
  15255. export var kernelBlurFragment2: {
  15256. name: string;
  15257. shader: string;
  15258. };
  15259. }
  15260. declare module BABYLON {
  15261. /** @hidden */
  15262. export var kernelBlurPixelShader: {
  15263. name: string;
  15264. shader: string;
  15265. };
  15266. }
  15267. declare module BABYLON {
  15268. /** @hidden */
  15269. export var kernelBlurVertex: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module BABYLON {
  15275. /** @hidden */
  15276. export var kernelBlurVertexShader: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module BABYLON {
  15282. /**
  15283. * The Blur Post Process which blurs an image based on a kernel and direction.
  15284. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15285. */
  15286. export class BlurPostProcess extends PostProcess {
  15287. /** The direction in which to blur the image. */
  15288. direction: Vector2;
  15289. private blockCompilation;
  15290. protected _kernel: number;
  15291. protected _idealKernel: number;
  15292. protected _packedFloat: boolean;
  15293. private _staticDefines;
  15294. /**
  15295. * Sets the length in pixels of the blur sample region
  15296. */
  15297. /**
  15298. * Gets the length in pixels of the blur sample region
  15299. */
  15300. kernel: number;
  15301. /**
  15302. * Sets wether or not the blur needs to unpack/repack floats
  15303. */
  15304. /**
  15305. * Gets wether or not the blur is unpacking/repacking floats
  15306. */
  15307. packedFloat: boolean;
  15308. /**
  15309. * Creates a new instance BlurPostProcess
  15310. * @param name The name of the effect.
  15311. * @param direction The direction in which to blur the image.
  15312. * @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.
  15313. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15314. * @param camera The camera to apply the render pass to.
  15315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15316. * @param engine The engine which the post process will be applied. (default: current engine)
  15317. * @param reusable If the post process can be reused on the same frame. (default: false)
  15318. * @param textureType Type of textures used when performing the post process. (default: 0)
  15319. * @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)
  15320. */
  15321. constructor(name: string,
  15322. /** The direction in which to blur the image. */
  15323. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15324. /**
  15325. * Updates the effect with the current post process compile time values and recompiles the shader.
  15326. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15327. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15328. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15329. * @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
  15330. * @param onCompiled Called when the shader has been compiled.
  15331. * @param onError Called if there is an error when compiling a shader.
  15332. */
  15333. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15334. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15335. /**
  15336. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15337. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15338. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15339. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15340. * The gaps between physical kernels are compensated for in the weighting of the samples
  15341. * @param idealKernel Ideal blur kernel.
  15342. * @return Nearest best kernel.
  15343. */
  15344. protected _nearestBestKernel(idealKernel: number): number;
  15345. /**
  15346. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15347. * @param x The point on the Gaussian distribution to sample.
  15348. * @return the value of the Gaussian function at x.
  15349. */
  15350. protected _gaussianWeight(x: number): number;
  15351. /**
  15352. * Generates a string that can be used as a floating point number in GLSL.
  15353. * @param x Value to print.
  15354. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15355. * @return GLSL float string.
  15356. */
  15357. protected _glslFloat(x: number, decimalFigures?: number): string;
  15358. }
  15359. }
  15360. declare module BABYLON {
  15361. /**
  15362. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15363. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15364. * You can then easily use it as a reflectionTexture on a flat surface.
  15365. * In case the surface is not a plane, please consider relying on reflection probes.
  15366. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15367. */
  15368. export class MirrorTexture extends RenderTargetTexture {
  15369. private scene;
  15370. /**
  15371. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15372. * 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.
  15373. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15374. */
  15375. mirrorPlane: Plane;
  15376. /**
  15377. * Define the blur ratio used to blur the reflection if needed.
  15378. */
  15379. blurRatio: number;
  15380. /**
  15381. * Define the adaptive blur kernel used to blur the reflection if needed.
  15382. * This will autocompute the closest best match for the `blurKernel`
  15383. */
  15384. adaptiveBlurKernel: number;
  15385. /**
  15386. * Define the blur kernel used to blur the reflection if needed.
  15387. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15388. */
  15389. blurKernel: number;
  15390. /**
  15391. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15392. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15393. */
  15394. blurKernelX: number;
  15395. /**
  15396. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15397. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15398. */
  15399. blurKernelY: number;
  15400. private _autoComputeBlurKernel;
  15401. protected _onRatioRescale(): void;
  15402. private _updateGammaSpace;
  15403. private _imageProcessingConfigChangeObserver;
  15404. private _transformMatrix;
  15405. private _mirrorMatrix;
  15406. private _savedViewMatrix;
  15407. private _blurX;
  15408. private _blurY;
  15409. private _adaptiveBlurKernel;
  15410. private _blurKernelX;
  15411. private _blurKernelY;
  15412. private _blurRatio;
  15413. /**
  15414. * Instantiates a Mirror Texture.
  15415. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15416. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15417. * You can then easily use it as a reflectionTexture on a flat surface.
  15418. * In case the surface is not a plane, please consider relying on reflection probes.
  15419. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15420. * @param name
  15421. * @param size
  15422. * @param scene
  15423. * @param generateMipMaps
  15424. * @param type
  15425. * @param samplingMode
  15426. * @param generateDepthBuffer
  15427. */
  15428. constructor(name: string, size: number | {
  15429. width: number;
  15430. height: number;
  15431. } | {
  15432. ratio: number;
  15433. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15434. private _preparePostProcesses;
  15435. /**
  15436. * Clone the mirror texture.
  15437. * @returns the cloned texture
  15438. */
  15439. clone(): MirrorTexture;
  15440. /**
  15441. * Serialize the texture to a JSON representation you could use in Parse later on
  15442. * @returns the serialized JSON representation
  15443. */
  15444. serialize(): any;
  15445. /**
  15446. * Dispose the texture and release its associated resources.
  15447. */
  15448. dispose(): void;
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15454. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15455. */
  15456. export class Texture extends BaseTexture {
  15457. /** @hidden */
  15458. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15459. /** @hidden */
  15460. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15461. /** @hidden */
  15462. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15463. /** nearest is mag = nearest and min = nearest and mip = linear */
  15464. static readonly NEAREST_SAMPLINGMODE: number;
  15465. /** nearest is mag = nearest and min = nearest and mip = linear */
  15466. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15468. static readonly BILINEAR_SAMPLINGMODE: number;
  15469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15470. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15471. /** Trilinear is mag = linear and min = linear and mip = linear */
  15472. static readonly TRILINEAR_SAMPLINGMODE: number;
  15473. /** Trilinear is mag = linear and min = linear and mip = linear */
  15474. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15475. /** mag = nearest and min = nearest and mip = nearest */
  15476. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15477. /** mag = nearest and min = linear and mip = nearest */
  15478. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15479. /** mag = nearest and min = linear and mip = linear */
  15480. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15481. /** mag = nearest and min = linear and mip = none */
  15482. static readonly NEAREST_LINEAR: number;
  15483. /** mag = nearest and min = nearest and mip = none */
  15484. static readonly NEAREST_NEAREST: number;
  15485. /** mag = linear and min = nearest and mip = nearest */
  15486. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15487. /** mag = linear and min = nearest and mip = linear */
  15488. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15489. /** mag = linear and min = linear and mip = none */
  15490. static readonly LINEAR_LINEAR: number;
  15491. /** mag = linear and min = nearest and mip = none */
  15492. static readonly LINEAR_NEAREST: number;
  15493. /** Explicit coordinates mode */
  15494. static readonly EXPLICIT_MODE: number;
  15495. /** Spherical coordinates mode */
  15496. static readonly SPHERICAL_MODE: number;
  15497. /** Planar coordinates mode */
  15498. static readonly PLANAR_MODE: number;
  15499. /** Cubic coordinates mode */
  15500. static readonly CUBIC_MODE: number;
  15501. /** Projection coordinates mode */
  15502. static readonly PROJECTION_MODE: number;
  15503. /** Inverse Cubic coordinates mode */
  15504. static readonly SKYBOX_MODE: number;
  15505. /** Inverse Cubic coordinates mode */
  15506. static readonly INVCUBIC_MODE: number;
  15507. /** Equirectangular coordinates mode */
  15508. static readonly EQUIRECTANGULAR_MODE: number;
  15509. /** Equirectangular Fixed coordinates mode */
  15510. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15511. /** Equirectangular Fixed Mirrored coordinates mode */
  15512. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15513. /** Texture is not repeating outside of 0..1 UVs */
  15514. static readonly CLAMP_ADDRESSMODE: number;
  15515. /** Texture is repeating outside of 0..1 UVs */
  15516. static readonly WRAP_ADDRESSMODE: number;
  15517. /** Texture is repeating and mirrored */
  15518. static readonly MIRROR_ADDRESSMODE: number;
  15519. /**
  15520. * 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
  15521. */
  15522. static UseSerializedUrlIfAny: boolean;
  15523. /**
  15524. * Define the url of the texture.
  15525. */
  15526. url: Nullable<string>;
  15527. /**
  15528. * Define an offset on the texture to offset the u coordinates of the UVs
  15529. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15530. */
  15531. uOffset: number;
  15532. /**
  15533. * Define an offset on the texture to offset the v coordinates of the UVs
  15534. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15535. */
  15536. vOffset: number;
  15537. /**
  15538. * Define an offset on the texture to scale the u coordinates of the UVs
  15539. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15540. */
  15541. uScale: number;
  15542. /**
  15543. * Define an offset on the texture to scale the v coordinates of the UVs
  15544. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15545. */
  15546. vScale: number;
  15547. /**
  15548. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15549. * @see http://doc.babylonjs.com/how_to/more_materials
  15550. */
  15551. uAng: number;
  15552. /**
  15553. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15554. * @see http://doc.babylonjs.com/how_to/more_materials
  15555. */
  15556. vAng: number;
  15557. /**
  15558. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15559. * @see http://doc.babylonjs.com/how_to/more_materials
  15560. */
  15561. wAng: number;
  15562. /**
  15563. * Defines the center of rotation (U)
  15564. */
  15565. uRotationCenter: number;
  15566. /**
  15567. * Defines the center of rotation (V)
  15568. */
  15569. vRotationCenter: number;
  15570. /**
  15571. * Defines the center of rotation (W)
  15572. */
  15573. wRotationCenter: number;
  15574. /**
  15575. * Are mip maps generated for this texture or not.
  15576. */
  15577. readonly noMipmap: boolean;
  15578. /**
  15579. * List of inspectable custom properties (used by the Inspector)
  15580. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15581. */
  15582. inspectableCustomProperties: Nullable<IInspectable[]>;
  15583. private _noMipmap;
  15584. /** @hidden */
  15585. _invertY: boolean;
  15586. private _rowGenerationMatrix;
  15587. private _cachedTextureMatrix;
  15588. private _projectionModeMatrix;
  15589. private _t0;
  15590. private _t1;
  15591. private _t2;
  15592. private _cachedUOffset;
  15593. private _cachedVOffset;
  15594. private _cachedUScale;
  15595. private _cachedVScale;
  15596. private _cachedUAng;
  15597. private _cachedVAng;
  15598. private _cachedWAng;
  15599. private _cachedProjectionMatrixId;
  15600. private _cachedCoordinatesMode;
  15601. /** @hidden */
  15602. protected _initialSamplingMode: number;
  15603. /** @hidden */
  15604. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15605. private _deleteBuffer;
  15606. protected _format: Nullable<number>;
  15607. private _delayedOnLoad;
  15608. private _delayedOnError;
  15609. /**
  15610. * Observable triggered once the texture has been loaded.
  15611. */
  15612. onLoadObservable: Observable<Texture>;
  15613. protected _isBlocking: boolean;
  15614. /**
  15615. * Is the texture preventing material to render while loading.
  15616. * If false, a default texture will be used instead of the loading one during the preparation step.
  15617. */
  15618. isBlocking: boolean;
  15619. /**
  15620. * Get the current sampling mode associated with the texture.
  15621. */
  15622. readonly samplingMode: number;
  15623. /**
  15624. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15625. */
  15626. readonly invertY: boolean;
  15627. /**
  15628. * Instantiates a new texture.
  15629. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15630. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15631. * @param url define the url of the picture to load as a texture
  15632. * @param scene define the scene or engine the texture will belong to
  15633. * @param noMipmap define if the texture will require mip maps or not
  15634. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15635. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15636. * @param onLoad define a callback triggered when the texture has been loaded
  15637. * @param onError define a callback triggered when an error occurred during the loading session
  15638. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15639. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15640. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15641. */
  15642. 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 | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15643. /**
  15644. * Update the url (and optional buffer) of this texture if url was null during construction.
  15645. * @param url the url of the texture
  15646. * @param buffer the buffer of the texture (defaults to null)
  15647. * @param onLoad callback called when the texture is loaded (defaults to null)
  15648. */
  15649. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15650. /**
  15651. * Finish the loading sequence of a texture flagged as delayed load.
  15652. * @hidden
  15653. */
  15654. delayLoad(): void;
  15655. private _prepareRowForTextureGeneration;
  15656. /**
  15657. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15658. * @returns the transform matrix of the texture.
  15659. */
  15660. getTextureMatrix(): Matrix;
  15661. /**
  15662. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15663. * @returns The reflection texture transform
  15664. */
  15665. getReflectionTextureMatrix(): Matrix;
  15666. /**
  15667. * Clones the texture.
  15668. * @returns the cloned texture
  15669. */
  15670. clone(): Texture;
  15671. /**
  15672. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15673. * @returns The JSON representation of the texture
  15674. */
  15675. serialize(): any;
  15676. /**
  15677. * Get the current class name of the texture useful for serialization or dynamic coding.
  15678. * @returns "Texture"
  15679. */
  15680. getClassName(): string;
  15681. /**
  15682. * Dispose the texture and release its associated resources.
  15683. */
  15684. dispose(): void;
  15685. /**
  15686. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15687. * @param parsedTexture Define the JSON representation of the texture
  15688. * @param scene Define the scene the parsed texture should be instantiated in
  15689. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15690. * @returns The parsed texture if successful
  15691. */
  15692. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15693. /**
  15694. * Creates a texture from its base 64 representation.
  15695. * @param data Define the base64 payload without the data: prefix
  15696. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15697. * @param scene Define the scene the texture should belong to
  15698. * @param noMipmap Forces the texture to not create mip map information if true
  15699. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15700. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15701. * @param onLoad define a callback triggered when the texture has been loaded
  15702. * @param onError define a callback triggered when an error occurred during the loading session
  15703. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15704. * @returns the created texture
  15705. */
  15706. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15707. /**
  15708. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15709. * @param data Define the base64 payload without the data: prefix
  15710. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15711. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15712. * @param scene Define the scene the texture should belong to
  15713. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15714. * @param noMipmap Forces the texture to not create mip map information if true
  15715. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15716. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15717. * @param onLoad define a callback triggered when the texture has been loaded
  15718. * @param onError define a callback triggered when an error occurred during the loading session
  15719. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15720. * @returns the created texture
  15721. */
  15722. 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;
  15723. }
  15724. }
  15725. declare module BABYLON {
  15726. /**
  15727. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15728. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15729. */
  15730. export class PostProcessManager {
  15731. private _scene;
  15732. private _indexBuffer;
  15733. private _vertexBuffers;
  15734. /**
  15735. * Creates a new instance PostProcess
  15736. * @param scene The scene that the post process is associated with.
  15737. */
  15738. constructor(scene: Scene);
  15739. private _prepareBuffers;
  15740. private _buildIndexBuffer;
  15741. /**
  15742. * Rebuilds the vertex buffers of the manager.
  15743. * @hidden
  15744. */
  15745. _rebuild(): void;
  15746. /**
  15747. * Prepares a frame to be run through a post process.
  15748. * @param sourceTexture The input texture to the post procesess. (default: null)
  15749. * @param postProcesses An array of post processes to be run. (default: null)
  15750. * @returns True if the post processes were able to be run.
  15751. * @hidden
  15752. */
  15753. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15754. /**
  15755. * Manually render a set of post processes to a texture.
  15756. * @param postProcesses An array of post processes to be run.
  15757. * @param targetTexture The target texture to render to.
  15758. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15759. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15760. * @param lodLevel defines which lod of the texture to render to
  15761. */
  15762. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15763. /**
  15764. * Finalize the result of the output of the postprocesses.
  15765. * @param doNotPresent If true the result will not be displayed to the screen.
  15766. * @param targetTexture The target texture to render to.
  15767. * @param faceIndex The index of the face to bind the target texture to.
  15768. * @param postProcesses The array of post processes to render.
  15769. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15770. * @hidden
  15771. */
  15772. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15773. /**
  15774. * Disposes of the post process manager.
  15775. */
  15776. dispose(): void;
  15777. }
  15778. }
  15779. declare module BABYLON {
  15780. /** Interface used by value gradients (color, factor, ...) */
  15781. export interface IValueGradient {
  15782. /**
  15783. * Gets or sets the gradient value (between 0 and 1)
  15784. */
  15785. gradient: number;
  15786. }
  15787. /** Class used to store color4 gradient */
  15788. export class ColorGradient implements IValueGradient {
  15789. /**
  15790. * Gets or sets the gradient value (between 0 and 1)
  15791. */
  15792. gradient: number;
  15793. /**
  15794. * Gets or sets first associated color
  15795. */
  15796. color1: Color4;
  15797. /**
  15798. * Gets or sets second associated color
  15799. */
  15800. color2?: Color4;
  15801. /**
  15802. * Will get a color picked randomly between color1 and color2.
  15803. * If color2 is undefined then color1 will be used
  15804. * @param result defines the target Color4 to store the result in
  15805. */
  15806. getColorToRef(result: Color4): void;
  15807. }
  15808. /** Class used to store color 3 gradient */
  15809. export class Color3Gradient implements IValueGradient {
  15810. /**
  15811. * Gets or sets the gradient value (between 0 and 1)
  15812. */
  15813. gradient: number;
  15814. /**
  15815. * Gets or sets the associated color
  15816. */
  15817. color: Color3;
  15818. }
  15819. /** Class used to store factor gradient */
  15820. export class FactorGradient implements IValueGradient {
  15821. /**
  15822. * Gets or sets the gradient value (between 0 and 1)
  15823. */
  15824. gradient: number;
  15825. /**
  15826. * Gets or sets first associated factor
  15827. */
  15828. factor1: number;
  15829. /**
  15830. * Gets or sets second associated factor
  15831. */
  15832. factor2?: number;
  15833. /**
  15834. * Will get a number picked randomly between factor1 and factor2.
  15835. * If factor2 is undefined then factor1 will be used
  15836. * @returns the picked number
  15837. */
  15838. getFactor(): number;
  15839. }
  15840. /**
  15841. * Helper used to simplify some generic gradient tasks
  15842. */
  15843. export class GradientHelper {
  15844. /**
  15845. * Gets the current gradient from an array of IValueGradient
  15846. * @param ratio defines the current ratio to get
  15847. * @param gradients defines the array of IValueGradient
  15848. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15849. */
  15850. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15851. }
  15852. }
  15853. declare module BABYLON {
  15854. interface AbstractScene {
  15855. /**
  15856. * The list of procedural textures added to the scene
  15857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15858. */
  15859. proceduralTextures: Array<ProceduralTexture>;
  15860. }
  15861. /**
  15862. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15863. * in a given scene.
  15864. */
  15865. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15866. /**
  15867. * The component name helpfull to identify the component in the list of scene components.
  15868. */
  15869. readonly name: string;
  15870. /**
  15871. * The scene the component belongs to.
  15872. */
  15873. scene: Scene;
  15874. /**
  15875. * Creates a new instance of the component for the given scene
  15876. * @param scene Defines the scene to register the component in
  15877. */
  15878. constructor(scene: Scene);
  15879. /**
  15880. * Registers the component in a given scene
  15881. */
  15882. register(): void;
  15883. /**
  15884. * Rebuilds the elements related to this component in case of
  15885. * context lost for instance.
  15886. */
  15887. rebuild(): void;
  15888. /**
  15889. * Disposes the component and the associated ressources.
  15890. */
  15891. dispose(): void;
  15892. private _beforeClear;
  15893. }
  15894. }
  15895. declare module BABYLON {
  15896. interface Engine {
  15897. /**
  15898. * Creates a new render target cube texture
  15899. * @param size defines the size of the texture
  15900. * @param options defines the options used to create the texture
  15901. * @returns a new render target cube texture stored in an InternalTexture
  15902. */
  15903. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15904. }
  15905. }
  15906. declare module BABYLON {
  15907. /** @hidden */
  15908. export var proceduralVertexShader: {
  15909. name: string;
  15910. shader: string;
  15911. };
  15912. }
  15913. declare module BABYLON {
  15914. /**
  15915. * 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.
  15916. * This is the base class of any Procedural texture and contains most of the shareable code.
  15917. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15918. */
  15919. export class ProceduralTexture extends Texture {
  15920. isCube: boolean;
  15921. /**
  15922. * Define if the texture is enabled or not (disabled texture will not render)
  15923. */
  15924. isEnabled: boolean;
  15925. /**
  15926. * Define if the texture must be cleared before rendering (default is true)
  15927. */
  15928. autoClear: boolean;
  15929. /**
  15930. * Callback called when the texture is generated
  15931. */
  15932. onGenerated: () => void;
  15933. /**
  15934. * Event raised when the texture is generated
  15935. */
  15936. onGeneratedObservable: Observable<ProceduralTexture>;
  15937. /** @hidden */
  15938. _generateMipMaps: boolean;
  15939. /** @hidden **/
  15940. _effect: Effect;
  15941. /** @hidden */
  15942. _textures: {
  15943. [key: string]: Texture;
  15944. };
  15945. private _size;
  15946. private _currentRefreshId;
  15947. private _refreshRate;
  15948. private _vertexBuffers;
  15949. private _indexBuffer;
  15950. private _uniforms;
  15951. private _samplers;
  15952. private _fragment;
  15953. private _floats;
  15954. private _ints;
  15955. private _floatsArrays;
  15956. private _colors3;
  15957. private _colors4;
  15958. private _vectors2;
  15959. private _vectors3;
  15960. private _matrices;
  15961. private _fallbackTexture;
  15962. private _fallbackTextureUsed;
  15963. private _engine;
  15964. private _cachedDefines;
  15965. private _contentUpdateId;
  15966. private _contentData;
  15967. /**
  15968. * Instantiates a new procedural texture.
  15969. * 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.
  15970. * This is the base class of any Procedural texture and contains most of the shareable code.
  15971. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15972. * @param name Define the name of the texture
  15973. * @param size Define the size of the texture to create
  15974. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15975. * @param scene Define the scene the texture belongs to
  15976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15977. * @param generateMipMaps Define if the texture should creates mip maps or not
  15978. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15979. */
  15980. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15981. /**
  15982. * The effect that is created when initializing the post process.
  15983. * @returns The created effect corresponding the the postprocess.
  15984. */
  15985. getEffect(): Effect;
  15986. /**
  15987. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15988. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15989. */
  15990. getContent(): Nullable<ArrayBufferView>;
  15991. private _createIndexBuffer;
  15992. /** @hidden */
  15993. _rebuild(): void;
  15994. /**
  15995. * Resets the texture in order to recreate its associated resources.
  15996. * This can be called in case of context loss
  15997. */
  15998. reset(): void;
  15999. protected _getDefines(): string;
  16000. /**
  16001. * Is the texture ready to be used ? (rendered at least once)
  16002. * @returns true if ready, otherwise, false.
  16003. */
  16004. isReady(): boolean;
  16005. /**
  16006. * Resets the refresh counter of the texture and start bak from scratch.
  16007. * Could be useful to regenerate the texture if it is setup to render only once.
  16008. */
  16009. resetRefreshCounter(): void;
  16010. /**
  16011. * Set the fragment shader to use in order to render the texture.
  16012. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16013. */
  16014. setFragment(fragment: any): void;
  16015. /**
  16016. * Define the refresh rate of the texture or the rendering frequency.
  16017. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16018. */
  16019. refreshRate: number;
  16020. /** @hidden */
  16021. _shouldRender(): boolean;
  16022. /**
  16023. * Get the size the texture is rendering at.
  16024. * @returns the size (texture is always squared)
  16025. */
  16026. getRenderSize(): number;
  16027. /**
  16028. * Resize the texture to new value.
  16029. * @param size Define the new size the texture should have
  16030. * @param generateMipMaps Define whether the new texture should create mip maps
  16031. */
  16032. resize(size: number, generateMipMaps: boolean): void;
  16033. private _checkUniform;
  16034. /**
  16035. * Set a texture in the shader program used to render.
  16036. * @param name Define the name of the uniform samplers as defined in the shader
  16037. * @param texture Define the texture to bind to this sampler
  16038. * @return the texture itself allowing "fluent" like uniform updates
  16039. */
  16040. setTexture(name: string, texture: Texture): ProceduralTexture;
  16041. /**
  16042. * Set a float in the shader.
  16043. * @param name Define the name of the uniform as defined in the shader
  16044. * @param value Define the value to give to the uniform
  16045. * @return the texture itself allowing "fluent" like uniform updates
  16046. */
  16047. setFloat(name: string, value: number): ProceduralTexture;
  16048. /**
  16049. * Set a int in the shader.
  16050. * @param name Define the name of the uniform as defined in the shader
  16051. * @param value Define the value to give to the uniform
  16052. * @return the texture itself allowing "fluent" like uniform updates
  16053. */
  16054. setInt(name: string, value: number): ProceduralTexture;
  16055. /**
  16056. * Set an array of floats in the shader.
  16057. * @param name Define the name of the uniform as defined in the shader
  16058. * @param value Define the value to give to the uniform
  16059. * @return the texture itself allowing "fluent" like uniform updates
  16060. */
  16061. setFloats(name: string, value: number[]): ProceduralTexture;
  16062. /**
  16063. * Set a vec3 in the shader from a Color3.
  16064. * @param name Define the name of the uniform as defined in the shader
  16065. * @param value Define the value to give to the uniform
  16066. * @return the texture itself allowing "fluent" like uniform updates
  16067. */
  16068. setColor3(name: string, value: Color3): ProceduralTexture;
  16069. /**
  16070. * Set a vec4 in the shader from a Color4.
  16071. * @param name Define the name of the uniform as defined in the shader
  16072. * @param value Define the value to give to the uniform
  16073. * @return the texture itself allowing "fluent" like uniform updates
  16074. */
  16075. setColor4(name: string, value: Color4): ProceduralTexture;
  16076. /**
  16077. * Set a vec2 in the shader from a Vector2.
  16078. * @param name Define the name of the uniform as defined in the shader
  16079. * @param value Define the value to give to the uniform
  16080. * @return the texture itself allowing "fluent" like uniform updates
  16081. */
  16082. setVector2(name: string, value: Vector2): ProceduralTexture;
  16083. /**
  16084. * Set a vec3 in the shader from a Vector3.
  16085. * @param name Define the name of the uniform as defined in the shader
  16086. * @param value Define the value to give to the uniform
  16087. * @return the texture itself allowing "fluent" like uniform updates
  16088. */
  16089. setVector3(name: string, value: Vector3): ProceduralTexture;
  16090. /**
  16091. * Set a mat4 in the shader from a MAtrix.
  16092. * @param name Define the name of the uniform as defined in the shader
  16093. * @param value Define the value to give to the uniform
  16094. * @return the texture itself allowing "fluent" like uniform updates
  16095. */
  16096. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16097. /**
  16098. * Render the texture to its associated render target.
  16099. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16100. */
  16101. render(useCameraPostProcess?: boolean): void;
  16102. /**
  16103. * Clone the texture.
  16104. * @returns the cloned texture
  16105. */
  16106. clone(): ProceduralTexture;
  16107. /**
  16108. * Dispose the texture and release its asoociated resources.
  16109. */
  16110. dispose(): void;
  16111. }
  16112. }
  16113. declare module BABYLON {
  16114. /**
  16115. * This represents the base class for particle system in Babylon.
  16116. * 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.
  16117. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16118. * @example https://doc.babylonjs.com/babylon101/particles
  16119. */
  16120. export class BaseParticleSystem {
  16121. /**
  16122. * Source color is added to the destination color without alpha affecting the result
  16123. */
  16124. static BLENDMODE_ONEONE: number;
  16125. /**
  16126. * Blend current color and particle color using particle’s alpha
  16127. */
  16128. static BLENDMODE_STANDARD: number;
  16129. /**
  16130. * Add current color and particle color multiplied by particle’s alpha
  16131. */
  16132. static BLENDMODE_ADD: number;
  16133. /**
  16134. * Multiply current color with particle color
  16135. */
  16136. static BLENDMODE_MULTIPLY: number;
  16137. /**
  16138. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16139. */
  16140. static BLENDMODE_MULTIPLYADD: number;
  16141. /**
  16142. * List of animations used by the particle system.
  16143. */
  16144. animations: Animation[];
  16145. /**
  16146. * The id of the Particle system.
  16147. */
  16148. id: string;
  16149. /**
  16150. * The friendly name of the Particle system.
  16151. */
  16152. name: string;
  16153. /**
  16154. * The rendering group used by the Particle system to chose when to render.
  16155. */
  16156. renderingGroupId: number;
  16157. /**
  16158. * The emitter represents the Mesh or position we are attaching the particle system to.
  16159. */
  16160. emitter: Nullable<AbstractMesh | Vector3>;
  16161. /**
  16162. * The maximum number of particles to emit per frame
  16163. */
  16164. emitRate: number;
  16165. /**
  16166. * If you want to launch only a few particles at once, that can be done, as well.
  16167. */
  16168. manualEmitCount: number;
  16169. /**
  16170. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16171. */
  16172. updateSpeed: number;
  16173. /**
  16174. * The amount of time the particle system is running (depends of the overall update speed).
  16175. */
  16176. targetStopDuration: number;
  16177. /**
  16178. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16179. */
  16180. disposeOnStop: boolean;
  16181. /**
  16182. * Minimum power of emitting particles.
  16183. */
  16184. minEmitPower: number;
  16185. /**
  16186. * Maximum power of emitting particles.
  16187. */
  16188. maxEmitPower: number;
  16189. /**
  16190. * Minimum life time of emitting particles.
  16191. */
  16192. minLifeTime: number;
  16193. /**
  16194. * Maximum life time of emitting particles.
  16195. */
  16196. maxLifeTime: number;
  16197. /**
  16198. * Minimum Size of emitting particles.
  16199. */
  16200. minSize: number;
  16201. /**
  16202. * Maximum Size of emitting particles.
  16203. */
  16204. maxSize: number;
  16205. /**
  16206. * Minimum scale of emitting particles on X axis.
  16207. */
  16208. minScaleX: number;
  16209. /**
  16210. * Maximum scale of emitting particles on X axis.
  16211. */
  16212. maxScaleX: number;
  16213. /**
  16214. * Minimum scale of emitting particles on Y axis.
  16215. */
  16216. minScaleY: number;
  16217. /**
  16218. * Maximum scale of emitting particles on Y axis.
  16219. */
  16220. maxScaleY: number;
  16221. /**
  16222. * Gets or sets the minimal initial rotation in radians.
  16223. */
  16224. minInitialRotation: number;
  16225. /**
  16226. * Gets or sets the maximal initial rotation in radians.
  16227. */
  16228. maxInitialRotation: number;
  16229. /**
  16230. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16231. */
  16232. minAngularSpeed: number;
  16233. /**
  16234. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16235. */
  16236. maxAngularSpeed: number;
  16237. /**
  16238. * The texture used to render each particle. (this can be a spritesheet)
  16239. */
  16240. particleTexture: Nullable<Texture>;
  16241. /**
  16242. * The layer mask we are rendering the particles through.
  16243. */
  16244. layerMask: number;
  16245. /**
  16246. * This can help using your own shader to render the particle system.
  16247. * The according effect will be created
  16248. */
  16249. customShader: any;
  16250. /**
  16251. * By default particle system starts as soon as they are created. This prevents the
  16252. * automatic start to happen and let you decide when to start emitting particles.
  16253. */
  16254. preventAutoStart: boolean;
  16255. private _noiseTexture;
  16256. /**
  16257. * Gets or sets a texture used to add random noise to particle positions
  16258. */
  16259. noiseTexture: Nullable<ProceduralTexture>;
  16260. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16261. noiseStrength: Vector3;
  16262. /**
  16263. * Callback triggered when the particle animation is ending.
  16264. */
  16265. onAnimationEnd: Nullable<() => void>;
  16266. /**
  16267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16268. */
  16269. blendMode: number;
  16270. /**
  16271. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16272. * to override the particles.
  16273. */
  16274. forceDepthWrite: boolean;
  16275. /** 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 */
  16276. preWarmCycles: number;
  16277. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16278. preWarmStepOffset: number;
  16279. /**
  16280. * 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)
  16281. */
  16282. spriteCellChangeSpeed: number;
  16283. /**
  16284. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16285. */
  16286. startSpriteCellID: number;
  16287. /**
  16288. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16289. */
  16290. endSpriteCellID: number;
  16291. /**
  16292. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16293. */
  16294. spriteCellWidth: number;
  16295. /**
  16296. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16297. */
  16298. spriteCellHeight: number;
  16299. /**
  16300. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16301. */
  16302. spriteRandomStartCell: boolean;
  16303. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16304. translationPivot: Vector2;
  16305. /** @hidden */
  16306. protected _isAnimationSheetEnabled: boolean;
  16307. /**
  16308. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16309. */
  16310. beginAnimationOnStart: boolean;
  16311. /**
  16312. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16313. */
  16314. beginAnimationFrom: number;
  16315. /**
  16316. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16317. */
  16318. beginAnimationTo: number;
  16319. /**
  16320. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16321. */
  16322. beginAnimationLoop: boolean;
  16323. /**
  16324. * Gets or sets a world offset applied to all particles
  16325. */
  16326. worldOffset: Vector3;
  16327. /**
  16328. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16329. */
  16330. isAnimationSheetEnabled: boolean;
  16331. /**
  16332. * Get hosting scene
  16333. * @returns the scene
  16334. */
  16335. getScene(): Scene;
  16336. /**
  16337. * You can use gravity if you want to give an orientation to your particles.
  16338. */
  16339. gravity: Vector3;
  16340. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16341. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16342. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16343. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16344. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16345. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16346. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16347. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16348. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16349. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16350. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16351. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16352. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16353. /**
  16354. * Defines the delay in milliseconds before starting the system (0 by default)
  16355. */
  16356. startDelay: number;
  16357. /**
  16358. * Gets the current list of drag gradients.
  16359. * You must use addDragGradient and removeDragGradient to udpate this list
  16360. * @returns the list of drag gradients
  16361. */
  16362. getDragGradients(): Nullable<Array<FactorGradient>>;
  16363. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16364. limitVelocityDamping: number;
  16365. /**
  16366. * Gets the current list of limit velocity gradients.
  16367. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16368. * @returns the list of limit velocity gradients
  16369. */
  16370. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16371. /**
  16372. * Gets the current list of color gradients.
  16373. * You must use addColorGradient and removeColorGradient to udpate this list
  16374. * @returns the list of color gradients
  16375. */
  16376. getColorGradients(): Nullable<Array<ColorGradient>>;
  16377. /**
  16378. * Gets the current list of size gradients.
  16379. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16380. * @returns the list of size gradients
  16381. */
  16382. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16383. /**
  16384. * Gets the current list of color remap gradients.
  16385. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16386. * @returns the list of color remap gradients
  16387. */
  16388. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16389. /**
  16390. * Gets the current list of alpha remap gradients.
  16391. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16392. * @returns the list of alpha remap gradients
  16393. */
  16394. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16395. /**
  16396. * Gets the current list of life time gradients.
  16397. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16398. * @returns the list of life time gradients
  16399. */
  16400. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Gets the current list of angular speed gradients.
  16403. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16404. * @returns the list of angular speed gradients
  16405. */
  16406. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16407. /**
  16408. * Gets the current list of velocity gradients.
  16409. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16410. * @returns the list of velocity gradients
  16411. */
  16412. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Gets the current list of start size gradients.
  16415. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16416. * @returns the list of start size gradients
  16417. */
  16418. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16419. /**
  16420. * Gets the current list of emit rate gradients.
  16421. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16422. * @returns the list of emit rate gradients
  16423. */
  16424. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16425. /**
  16426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16428. */
  16429. direction1: Vector3;
  16430. /**
  16431. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16433. */
  16434. direction2: Vector3;
  16435. /**
  16436. * 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.
  16437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16438. */
  16439. minEmitBox: Vector3;
  16440. /**
  16441. * 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.
  16442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16443. */
  16444. maxEmitBox: Vector3;
  16445. /**
  16446. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16447. */
  16448. color1: Color4;
  16449. /**
  16450. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16451. */
  16452. color2: Color4;
  16453. /**
  16454. * Color the particle will have at the end of its lifetime
  16455. */
  16456. colorDead: Color4;
  16457. /**
  16458. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16459. */
  16460. textureMask: Color4;
  16461. /**
  16462. * The particle emitter type defines the emitter used by the particle system.
  16463. * It can be for example box, sphere, or cone...
  16464. */
  16465. particleEmitterType: IParticleEmitterType;
  16466. /** @hidden */
  16467. _isSubEmitter: boolean;
  16468. /**
  16469. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16470. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16471. */
  16472. billboardMode: number;
  16473. protected _isBillboardBased: boolean;
  16474. /**
  16475. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16476. */
  16477. isBillboardBased: boolean;
  16478. /**
  16479. * The scene the particle system belongs to.
  16480. */
  16481. protected _scene: Scene;
  16482. /**
  16483. * Local cache of defines for image processing.
  16484. */
  16485. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16486. /**
  16487. * Default configuration related to image processing available in the standard Material.
  16488. */
  16489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16490. /**
  16491. * Gets the image processing configuration used either in this material.
  16492. */
  16493. /**
  16494. * Sets the Default image processing configuration used either in the this material.
  16495. *
  16496. * If sets to null, the scene one is in use.
  16497. */
  16498. imageProcessingConfiguration: ImageProcessingConfiguration;
  16499. /**
  16500. * Attaches a new image processing configuration to the Standard Material.
  16501. * @param configuration
  16502. */
  16503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16504. /** @hidden */
  16505. protected _reset(): void;
  16506. /** @hidden */
  16507. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16508. /**
  16509. * Instantiates a particle system.
  16510. * 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.
  16511. * @param name The name of the particle system
  16512. */
  16513. constructor(name: string);
  16514. /**
  16515. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16518. * @returns the emitter
  16519. */
  16520. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16521. /**
  16522. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16523. * @param radius The radius of the hemisphere to emit from
  16524. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16525. * @returns the emitter
  16526. */
  16527. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16528. /**
  16529. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16530. * @param radius The radius of the sphere to emit from
  16531. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16532. * @returns the emitter
  16533. */
  16534. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16535. /**
  16536. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16537. * @param radius The radius of the sphere to emit from
  16538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16540. * @returns the emitter
  16541. */
  16542. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16543. /**
  16544. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16545. * @param radius The radius of the emission cylinder
  16546. * @param height The height of the emission cylinder
  16547. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16548. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16549. * @returns the emitter
  16550. */
  16551. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16552. /**
  16553. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16554. * @param radius The radius of the cylinder to emit from
  16555. * @param height The height of the emission cylinder
  16556. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16559. * @returns the emitter
  16560. */
  16561. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16562. /**
  16563. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16564. * @param radius The radius of the cone to emit from
  16565. * @param angle The base angle of the cone
  16566. * @returns the emitter
  16567. */
  16568. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16569. /**
  16570. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16573. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16574. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16575. * @returns the emitter
  16576. */
  16577. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16578. }
  16579. }
  16580. declare module BABYLON {
  16581. /**
  16582. * Type of sub emitter
  16583. */
  16584. export enum SubEmitterType {
  16585. /**
  16586. * Attached to the particle over it's lifetime
  16587. */
  16588. ATTACHED = 0,
  16589. /**
  16590. * Created when the particle dies
  16591. */
  16592. END = 1
  16593. }
  16594. /**
  16595. * Sub emitter class used to emit particles from an existing particle
  16596. */
  16597. export class SubEmitter {
  16598. /**
  16599. * the particle system to be used by the sub emitter
  16600. */
  16601. particleSystem: ParticleSystem;
  16602. /**
  16603. * Type of the submitter (Default: END)
  16604. */
  16605. type: SubEmitterType;
  16606. /**
  16607. * 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)
  16608. * Note: This only is supported when using an emitter of type Mesh
  16609. */
  16610. inheritDirection: boolean;
  16611. /**
  16612. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16613. */
  16614. inheritedVelocityAmount: number;
  16615. /**
  16616. * Creates a sub emitter
  16617. * @param particleSystem the particle system to be used by the sub emitter
  16618. */
  16619. constructor(
  16620. /**
  16621. * the particle system to be used by the sub emitter
  16622. */
  16623. particleSystem: ParticleSystem);
  16624. /**
  16625. * Clones the sub emitter
  16626. * @returns the cloned sub emitter
  16627. */
  16628. clone(): SubEmitter;
  16629. /**
  16630. * Serialize current object to a JSON object
  16631. * @returns the serialized object
  16632. */
  16633. serialize(): any;
  16634. /** @hidden */
  16635. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16636. /**
  16637. * Creates a new SubEmitter from a serialized JSON version
  16638. * @param serializationObject defines the JSON object to read from
  16639. * @param scene defines the hosting scene
  16640. * @param rootUrl defines the rootUrl for data loading
  16641. * @returns a new SubEmitter
  16642. */
  16643. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16644. /** Release associated resources */
  16645. dispose(): void;
  16646. }
  16647. }
  16648. declare module BABYLON {
  16649. /** @hidden */
  16650. export var clipPlaneFragmentDeclaration: {
  16651. name: string;
  16652. shader: string;
  16653. };
  16654. }
  16655. declare module BABYLON {
  16656. /** @hidden */
  16657. export var imageProcessingDeclaration: {
  16658. name: string;
  16659. shader: string;
  16660. };
  16661. }
  16662. declare module BABYLON {
  16663. /** @hidden */
  16664. export var imageProcessingFunctions: {
  16665. name: string;
  16666. shader: string;
  16667. };
  16668. }
  16669. declare module BABYLON {
  16670. /** @hidden */
  16671. export var clipPlaneFragment: {
  16672. name: string;
  16673. shader: string;
  16674. };
  16675. }
  16676. declare module BABYLON {
  16677. /** @hidden */
  16678. export var particlesPixelShader: {
  16679. name: string;
  16680. shader: string;
  16681. };
  16682. }
  16683. declare module BABYLON {
  16684. /** @hidden */
  16685. export var clipPlaneVertexDeclaration: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module BABYLON {
  16691. /** @hidden */
  16692. export var clipPlaneVertex: {
  16693. name: string;
  16694. shader: string;
  16695. };
  16696. }
  16697. declare module BABYLON {
  16698. /** @hidden */
  16699. export var particlesVertexShader: {
  16700. name: string;
  16701. shader: string;
  16702. };
  16703. }
  16704. declare module BABYLON {
  16705. /**
  16706. * This represents a particle system in Babylon.
  16707. * 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.
  16708. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16709. * @example https://doc.babylonjs.com/babylon101/particles
  16710. */
  16711. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16712. /**
  16713. * Billboard mode will only apply to Y axis
  16714. */
  16715. static readonly BILLBOARDMODE_Y: number;
  16716. /**
  16717. * Billboard mode will apply to all axes
  16718. */
  16719. static readonly BILLBOARDMODE_ALL: number;
  16720. /**
  16721. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16722. */
  16723. static readonly BILLBOARDMODE_STRETCHED: number;
  16724. /**
  16725. * This function can be defined to provide custom update for active particles.
  16726. * This function will be called instead of regular update (age, position, color, etc.).
  16727. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16728. */
  16729. updateFunction: (particles: Particle[]) => void;
  16730. private _emitterWorldMatrix;
  16731. /**
  16732. * This function can be defined to specify initial direction for every new particle.
  16733. * It by default use the emitterType defined function
  16734. */
  16735. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16736. /**
  16737. * This function can be defined to specify initial position for every new particle.
  16738. * It by default use the emitterType defined function
  16739. */
  16740. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16741. /**
  16742. * @hidden
  16743. */
  16744. _inheritedVelocityOffset: Vector3;
  16745. /**
  16746. * An event triggered when the system is disposed
  16747. */
  16748. onDisposeObservable: Observable<ParticleSystem>;
  16749. private _onDisposeObserver;
  16750. /**
  16751. * Sets a callback that will be triggered when the system is disposed
  16752. */
  16753. onDispose: () => void;
  16754. private _particles;
  16755. private _epsilon;
  16756. private _capacity;
  16757. private _stockParticles;
  16758. private _newPartsExcess;
  16759. private _vertexData;
  16760. private _vertexBuffer;
  16761. private _vertexBuffers;
  16762. private _spriteBuffer;
  16763. private _indexBuffer;
  16764. private _effect;
  16765. private _customEffect;
  16766. private _cachedDefines;
  16767. private _scaledColorStep;
  16768. private _colorDiff;
  16769. private _scaledDirection;
  16770. private _scaledGravity;
  16771. private _currentRenderId;
  16772. private _alive;
  16773. private _useInstancing;
  16774. private _started;
  16775. private _stopped;
  16776. private _actualFrame;
  16777. private _scaledUpdateSpeed;
  16778. private _vertexBufferSize;
  16779. /** @hidden */
  16780. _currentEmitRateGradient: Nullable<FactorGradient>;
  16781. /** @hidden */
  16782. _currentEmitRate1: number;
  16783. /** @hidden */
  16784. _currentEmitRate2: number;
  16785. /** @hidden */
  16786. _currentStartSizeGradient: Nullable<FactorGradient>;
  16787. /** @hidden */
  16788. _currentStartSize1: number;
  16789. /** @hidden */
  16790. _currentStartSize2: number;
  16791. private readonly _rawTextureWidth;
  16792. private _rampGradientsTexture;
  16793. private _useRampGradients;
  16794. /** Gets or sets a boolean indicating that ramp gradients must be used
  16795. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16796. */
  16797. useRampGradients: boolean;
  16798. /**
  16799. * 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.
  16800. * 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: [])
  16801. */
  16802. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16803. private _subEmitters;
  16804. /**
  16805. * @hidden
  16806. * If the particle systems emitter should be disposed when the particle system is disposed
  16807. */
  16808. _disposeEmitterOnDispose: boolean;
  16809. /**
  16810. * The current active Sub-systems, this property is used by the root particle system only.
  16811. */
  16812. activeSubSystems: Array<ParticleSystem>;
  16813. private _rootParticleSystem;
  16814. /**
  16815. * Gets the current list of active particles
  16816. */
  16817. readonly particles: Particle[];
  16818. /**
  16819. * Returns the string "ParticleSystem"
  16820. * @returns a string containing the class name
  16821. */
  16822. getClassName(): string;
  16823. /**
  16824. * Instantiates a particle system.
  16825. * 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.
  16826. * @param name The name of the particle system
  16827. * @param capacity The max number of particles alive at the same time
  16828. * @param scene The scene the particle system belongs to
  16829. * @param customEffect a custom effect used to change the way particles are rendered by default
  16830. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16831. * @param epsilon Offset used to render the particles
  16832. */
  16833. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16834. private _addFactorGradient;
  16835. private _removeFactorGradient;
  16836. /**
  16837. * Adds a new life time gradient
  16838. * @param gradient defines the gradient to use (between 0 and 1)
  16839. * @param factor defines the life time factor to affect to the specified gradient
  16840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16841. * @returns the current particle system
  16842. */
  16843. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16844. /**
  16845. * Remove a specific life time gradient
  16846. * @param gradient defines the gradient to remove
  16847. * @returns the current particle system
  16848. */
  16849. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16850. /**
  16851. * Adds a new size gradient
  16852. * @param gradient defines the gradient to use (between 0 and 1)
  16853. * @param factor defines the size factor to affect to the specified gradient
  16854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16855. * @returns the current particle system
  16856. */
  16857. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16858. /**
  16859. * Remove a specific size gradient
  16860. * @param gradient defines the gradient to remove
  16861. * @returns the current particle system
  16862. */
  16863. removeSizeGradient(gradient: number): IParticleSystem;
  16864. /**
  16865. * Adds a new color remap gradient
  16866. * @param gradient defines the gradient to use (between 0 and 1)
  16867. * @param min defines the color remap minimal range
  16868. * @param max defines the color remap maximal range
  16869. * @returns the current particle system
  16870. */
  16871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16872. /**
  16873. * Remove a specific color remap gradient
  16874. * @param gradient defines the gradient to remove
  16875. * @returns the current particle system
  16876. */
  16877. removeColorRemapGradient(gradient: number): IParticleSystem;
  16878. /**
  16879. * Adds a new alpha remap gradient
  16880. * @param gradient defines the gradient to use (between 0 and 1)
  16881. * @param min defines the alpha remap minimal range
  16882. * @param max defines the alpha remap maximal range
  16883. * @returns the current particle system
  16884. */
  16885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16886. /**
  16887. * Remove a specific alpha remap gradient
  16888. * @param gradient defines the gradient to remove
  16889. * @returns the current particle system
  16890. */
  16891. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Adds a new velocity gradient
  16908. * @param gradient defines the gradient to use (between 0 and 1)
  16909. * @param factor defines the velocity to affect to the specified gradient
  16910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16911. * @returns the current particle system
  16912. */
  16913. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16914. /**
  16915. * Remove a specific velocity gradient
  16916. * @param gradient defines the gradient to remove
  16917. * @returns the current particle system
  16918. */
  16919. removeVelocityGradient(gradient: number): IParticleSystem;
  16920. /**
  16921. * Adds a new limit velocity gradient
  16922. * @param gradient defines the gradient to use (between 0 and 1)
  16923. * @param factor defines the limit velocity value to affect to the specified gradient
  16924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16925. * @returns the current particle system
  16926. */
  16927. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16928. /**
  16929. * Remove a specific limit velocity gradient
  16930. * @param gradient defines the gradient to remove
  16931. * @returns the current particle system
  16932. */
  16933. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16934. /**
  16935. * Adds a new drag gradient
  16936. * @param gradient defines the gradient to use (between 0 and 1)
  16937. * @param factor defines the drag value to affect to the specified gradient
  16938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16939. * @returns the current particle system
  16940. */
  16941. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16942. /**
  16943. * Remove a specific drag gradient
  16944. * @param gradient defines the gradient to remove
  16945. * @returns the current particle system
  16946. */
  16947. removeDragGradient(gradient: number): IParticleSystem;
  16948. /**
  16949. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param factor defines the emit rate value to affect to the specified gradient
  16952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16953. * @returns the current particle system
  16954. */
  16955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16956. /**
  16957. * Remove a specific emit rate gradient
  16958. * @param gradient defines the gradient to remove
  16959. * @returns the current particle system
  16960. */
  16961. removeEmitRateGradient(gradient: number): IParticleSystem;
  16962. /**
  16963. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16964. * @param gradient defines the gradient to use (between 0 and 1)
  16965. * @param factor defines the start size value to affect to the specified gradient
  16966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16967. * @returns the current particle system
  16968. */
  16969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16970. /**
  16971. * Remove a specific start size gradient
  16972. * @param gradient defines the gradient to remove
  16973. * @returns the current particle system
  16974. */
  16975. removeStartSizeGradient(gradient: number): IParticleSystem;
  16976. private _createRampGradientTexture;
  16977. /**
  16978. * Gets the current list of ramp gradients.
  16979. * You must use addRampGradient and removeRampGradient to udpate this list
  16980. * @returns the list of ramp gradients
  16981. */
  16982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16983. /**
  16984. * Adds a new ramp gradient used to remap particle colors
  16985. * @param gradient defines the gradient to use (between 0 and 1)
  16986. * @param color defines the color to affect to the specified gradient
  16987. * @returns the current particle system
  16988. */
  16989. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16990. /**
  16991. * Remove a specific ramp gradient
  16992. * @param gradient defines the gradient to remove
  16993. * @returns the current particle system
  16994. */
  16995. removeRampGradient(gradient: number): ParticleSystem;
  16996. /**
  16997. * Adds a new color gradient
  16998. * @param gradient defines the gradient to use (between 0 and 1)
  16999. * @param color1 defines the color to affect to the specified gradient
  17000. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17001. * @returns this particle system
  17002. */
  17003. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17004. /**
  17005. * Remove a specific color gradient
  17006. * @param gradient defines the gradient to remove
  17007. * @returns this particle system
  17008. */
  17009. removeColorGradient(gradient: number): IParticleSystem;
  17010. private _fetchR;
  17011. protected _reset(): void;
  17012. private _resetEffect;
  17013. private _createVertexBuffers;
  17014. private _createIndexBuffer;
  17015. /**
  17016. * Gets the maximum number of particles active at the same time.
  17017. * @returns The max number of active particles.
  17018. */
  17019. getCapacity(): number;
  17020. /**
  17021. * Gets whether there are still active particles in the system.
  17022. * @returns True if it is alive, otherwise false.
  17023. */
  17024. isAlive(): boolean;
  17025. /**
  17026. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17027. * @returns True if it has been started, otherwise false.
  17028. */
  17029. isStarted(): boolean;
  17030. private _prepareSubEmitterInternalArray;
  17031. /**
  17032. * Starts the particle system and begins to emit
  17033. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17034. */
  17035. start(delay?: number): void;
  17036. /**
  17037. * Stops the particle system.
  17038. * @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.
  17039. */
  17040. stop(stopSubEmitters?: boolean): void;
  17041. /**
  17042. * Remove all active particles
  17043. */
  17044. reset(): void;
  17045. /**
  17046. * @hidden (for internal use only)
  17047. */
  17048. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17049. /**
  17050. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17051. * Its lifetime will start back at 0.
  17052. */
  17053. recycleParticle: (particle: Particle) => void;
  17054. private _stopSubEmitters;
  17055. private _createParticle;
  17056. private _removeFromRoot;
  17057. private _emitFromParticle;
  17058. private _update;
  17059. /** @hidden */
  17060. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17061. /** @hidden */
  17062. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17063. /** @hidden */
  17064. private _getEffect;
  17065. /**
  17066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17067. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17068. */
  17069. animate(preWarmOnly?: boolean): void;
  17070. private _appendParticleVertices;
  17071. /**
  17072. * Rebuilds the particle system.
  17073. */
  17074. rebuild(): void;
  17075. /**
  17076. * Is this system ready to be used/rendered
  17077. * @return true if the system is ready
  17078. */
  17079. isReady(): boolean;
  17080. private _render;
  17081. /**
  17082. * Renders the particle system in its current state.
  17083. * @returns the current number of particles
  17084. */
  17085. render(): number;
  17086. /**
  17087. * Disposes the particle system and free the associated resources
  17088. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17089. */
  17090. dispose(disposeTexture?: boolean): void;
  17091. /**
  17092. * Clones the particle system.
  17093. * @param name The name of the cloned object
  17094. * @param newEmitter The new emitter to use
  17095. * @returns the cloned particle system
  17096. */
  17097. clone(name: string, newEmitter: any): ParticleSystem;
  17098. /**
  17099. * Serializes the particle system to a JSON object.
  17100. * @returns the JSON object
  17101. */
  17102. serialize(): any;
  17103. /** @hidden */
  17104. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17105. /** @hidden */
  17106. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17107. /**
  17108. * Parses a JSON object to create a particle system.
  17109. * @param parsedParticleSystem The JSON object to parse
  17110. * @param scene The scene to create the particle system in
  17111. * @param rootUrl The root url to use to load external dependencies like texture
  17112. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17113. * @returns the Parsed particle system
  17114. */
  17115. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17116. }
  17117. }
  17118. declare module BABYLON {
  17119. /**
  17120. * A particle represents one of the element emitted by a particle system.
  17121. * This is mainly define by its coordinates, direction, velocity and age.
  17122. */
  17123. export class Particle {
  17124. /**
  17125. * The particle system the particle belongs to.
  17126. */
  17127. particleSystem: ParticleSystem;
  17128. private static _Count;
  17129. /**
  17130. * Unique ID of the particle
  17131. */
  17132. id: number;
  17133. /**
  17134. * The world position of the particle in the scene.
  17135. */
  17136. position: Vector3;
  17137. /**
  17138. * The world direction of the particle in the scene.
  17139. */
  17140. direction: Vector3;
  17141. /**
  17142. * The color of the particle.
  17143. */
  17144. color: Color4;
  17145. /**
  17146. * The color change of the particle per step.
  17147. */
  17148. colorStep: Color4;
  17149. /**
  17150. * Defines how long will the life of the particle be.
  17151. */
  17152. lifeTime: number;
  17153. /**
  17154. * The current age of the particle.
  17155. */
  17156. age: number;
  17157. /**
  17158. * The current size of the particle.
  17159. */
  17160. size: number;
  17161. /**
  17162. * The current scale of the particle.
  17163. */
  17164. scale: Vector2;
  17165. /**
  17166. * The current angle of the particle.
  17167. */
  17168. angle: number;
  17169. /**
  17170. * Defines how fast is the angle changing.
  17171. */
  17172. angularSpeed: number;
  17173. /**
  17174. * Defines the cell index used by the particle to be rendered from a sprite.
  17175. */
  17176. cellIndex: number;
  17177. /**
  17178. * The information required to support color remapping
  17179. */
  17180. remapData: Vector4;
  17181. /** @hidden */
  17182. _randomCellOffset?: number;
  17183. /** @hidden */
  17184. _initialDirection: Nullable<Vector3>;
  17185. /** @hidden */
  17186. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17187. /** @hidden */
  17188. _initialStartSpriteCellID: number;
  17189. /** @hidden */
  17190. _initialEndSpriteCellID: number;
  17191. /** @hidden */
  17192. _currentColorGradient: Nullable<ColorGradient>;
  17193. /** @hidden */
  17194. _currentColor1: Color4;
  17195. /** @hidden */
  17196. _currentColor2: Color4;
  17197. /** @hidden */
  17198. _currentSizeGradient: Nullable<FactorGradient>;
  17199. /** @hidden */
  17200. _currentSize1: number;
  17201. /** @hidden */
  17202. _currentSize2: number;
  17203. /** @hidden */
  17204. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17205. /** @hidden */
  17206. _currentAngularSpeed1: number;
  17207. /** @hidden */
  17208. _currentAngularSpeed2: number;
  17209. /** @hidden */
  17210. _currentVelocityGradient: Nullable<FactorGradient>;
  17211. /** @hidden */
  17212. _currentVelocity1: number;
  17213. /** @hidden */
  17214. _currentVelocity2: number;
  17215. /** @hidden */
  17216. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17217. /** @hidden */
  17218. _currentLimitVelocity1: number;
  17219. /** @hidden */
  17220. _currentLimitVelocity2: number;
  17221. /** @hidden */
  17222. _currentDragGradient: Nullable<FactorGradient>;
  17223. /** @hidden */
  17224. _currentDrag1: number;
  17225. /** @hidden */
  17226. _currentDrag2: number;
  17227. /** @hidden */
  17228. _randomNoiseCoordinates1: Vector3;
  17229. /** @hidden */
  17230. _randomNoiseCoordinates2: Vector3;
  17231. /**
  17232. * Creates a new instance Particle
  17233. * @param particleSystem the particle system the particle belongs to
  17234. */
  17235. constructor(
  17236. /**
  17237. * The particle system the particle belongs to.
  17238. */
  17239. particleSystem: ParticleSystem);
  17240. private updateCellInfoFromSystem;
  17241. /**
  17242. * Defines how the sprite cell index is updated for the particle
  17243. */
  17244. updateCellIndex(): void;
  17245. /** @hidden */
  17246. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17247. /** @hidden */
  17248. _inheritParticleInfoToSubEmitters(): void;
  17249. /** @hidden */
  17250. _reset(): void;
  17251. /**
  17252. * Copy the properties of particle to another one.
  17253. * @param other the particle to copy the information to.
  17254. */
  17255. copyTo(other: Particle): void;
  17256. }
  17257. }
  17258. declare module BABYLON {
  17259. /**
  17260. * Particle emitter represents a volume emitting particles.
  17261. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17262. */
  17263. export interface IParticleEmitterType {
  17264. /**
  17265. * Called by the particle System when the direction is computed for the created particle.
  17266. * @param worldMatrix is the world matrix of the particle system
  17267. * @param directionToUpdate is the direction vector to update with the result
  17268. * @param particle is the particle we are computed the direction for
  17269. */
  17270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17271. /**
  17272. * Called by the particle System when the position is computed for the created particle.
  17273. * @param worldMatrix is the world matrix of the particle system
  17274. * @param positionToUpdate is the position vector to update with the result
  17275. * @param particle is the particle we are computed the position for
  17276. */
  17277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17278. /**
  17279. * Clones the current emitter and returns a copy of it
  17280. * @returns the new emitter
  17281. */
  17282. clone(): IParticleEmitterType;
  17283. /**
  17284. * Called by the GPUParticleSystem to setup the update shader
  17285. * @param effect defines the update shader
  17286. */
  17287. applyToShader(effect: Effect): void;
  17288. /**
  17289. * Returns a string to use to update the GPU particles update shader
  17290. * @returns the effect defines string
  17291. */
  17292. getEffectDefines(): string;
  17293. /**
  17294. * Returns a string representing the class name
  17295. * @returns a string containing the class name
  17296. */
  17297. getClassName(): string;
  17298. /**
  17299. * Serializes the particle system to a JSON object.
  17300. * @returns the JSON object
  17301. */
  17302. serialize(): any;
  17303. /**
  17304. * Parse properties from a JSON object
  17305. * @param serializationObject defines the JSON object
  17306. */
  17307. parse(serializationObject: any): void;
  17308. }
  17309. }
  17310. declare module BABYLON {
  17311. /**
  17312. * Particle emitter emitting particles from the inside of a box.
  17313. * It emits the particles randomly between 2 given directions.
  17314. */
  17315. export class BoxParticleEmitter implements IParticleEmitterType {
  17316. /**
  17317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17318. */
  17319. direction1: Vector3;
  17320. /**
  17321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17322. */
  17323. direction2: Vector3;
  17324. /**
  17325. * 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.
  17326. */
  17327. minEmitBox: Vector3;
  17328. /**
  17329. * 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.
  17330. */
  17331. maxEmitBox: Vector3;
  17332. /**
  17333. * Creates a new instance BoxParticleEmitter
  17334. */
  17335. constructor();
  17336. /**
  17337. * Called by the particle System when the direction is computed for the created particle.
  17338. * @param worldMatrix is the world matrix of the particle system
  17339. * @param directionToUpdate is the direction vector to update with the result
  17340. * @param particle is the particle we are computed the direction for
  17341. */
  17342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17343. /**
  17344. * Called by the particle System when the position is computed for the created particle.
  17345. * @param worldMatrix is the world matrix of the particle system
  17346. * @param positionToUpdate is the position vector to update with the result
  17347. * @param particle is the particle we are computed the position for
  17348. */
  17349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17350. /**
  17351. * Clones the current emitter and returns a copy of it
  17352. * @returns the new emitter
  17353. */
  17354. clone(): BoxParticleEmitter;
  17355. /**
  17356. * Called by the GPUParticleSystem to setup the update shader
  17357. * @param effect defines the update shader
  17358. */
  17359. applyToShader(effect: Effect): void;
  17360. /**
  17361. * Returns a string to use to update the GPU particles update shader
  17362. * @returns a string containng the defines string
  17363. */
  17364. getEffectDefines(): string;
  17365. /**
  17366. * Returns the string "BoxParticleEmitter"
  17367. * @returns a string containing the class name
  17368. */
  17369. getClassName(): string;
  17370. /**
  17371. * Serializes the particle system to a JSON object.
  17372. * @returns the JSON object
  17373. */
  17374. serialize(): any;
  17375. /**
  17376. * Parse properties from a JSON object
  17377. * @param serializationObject defines the JSON object
  17378. */
  17379. parse(serializationObject: any): void;
  17380. }
  17381. }
  17382. declare module BABYLON {
  17383. /**
  17384. * Particle emitter emitting particles from the inside of a cone.
  17385. * It emits the particles alongside the cone volume from the base to the particle.
  17386. * The emission direction might be randomized.
  17387. */
  17388. export class ConeParticleEmitter implements IParticleEmitterType {
  17389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17390. directionRandomizer: number;
  17391. private _radius;
  17392. private _angle;
  17393. private _height;
  17394. /**
  17395. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17396. */
  17397. radiusRange: number;
  17398. /**
  17399. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17400. */
  17401. heightRange: number;
  17402. /**
  17403. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17404. */
  17405. emitFromSpawnPointOnly: boolean;
  17406. /**
  17407. * Gets or sets the radius of the emission cone
  17408. */
  17409. radius: number;
  17410. /**
  17411. * Gets or sets the angle of the emission cone
  17412. */
  17413. angle: number;
  17414. private _buildHeight;
  17415. /**
  17416. * Creates a new instance ConeParticleEmitter
  17417. * @param radius the radius of the emission cone (1 by default)
  17418. * @param angle the cone base angle (PI by default)
  17419. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17420. */
  17421. constructor(radius?: number, angle?: number,
  17422. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17423. directionRandomizer?: number);
  17424. /**
  17425. * Called by the particle System when the direction is computed for the created particle.
  17426. * @param worldMatrix is the world matrix of the particle system
  17427. * @param directionToUpdate is the direction vector to update with the result
  17428. * @param particle is the particle we are computed the direction for
  17429. */
  17430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17431. /**
  17432. * Called by the particle System when the position is computed for the created particle.
  17433. * @param worldMatrix is the world matrix of the particle system
  17434. * @param positionToUpdate is the position vector to update with the result
  17435. * @param particle is the particle we are computed the position for
  17436. */
  17437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17438. /**
  17439. * Clones the current emitter and returns a copy of it
  17440. * @returns the new emitter
  17441. */
  17442. clone(): ConeParticleEmitter;
  17443. /**
  17444. * Called by the GPUParticleSystem to setup the update shader
  17445. * @param effect defines the update shader
  17446. */
  17447. applyToShader(effect: Effect): void;
  17448. /**
  17449. * Returns a string to use to update the GPU particles update shader
  17450. * @returns a string containng the defines string
  17451. */
  17452. getEffectDefines(): string;
  17453. /**
  17454. * Returns the string "ConeParticleEmitter"
  17455. * @returns a string containing the class name
  17456. */
  17457. getClassName(): string;
  17458. /**
  17459. * Serializes the particle system to a JSON object.
  17460. * @returns the JSON object
  17461. */
  17462. serialize(): any;
  17463. /**
  17464. * Parse properties from a JSON object
  17465. * @param serializationObject defines the JSON object
  17466. */
  17467. parse(serializationObject: any): void;
  17468. }
  17469. }
  17470. declare module BABYLON {
  17471. /**
  17472. * Particle emitter emitting particles from the inside of a cylinder.
  17473. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17474. */
  17475. export class CylinderParticleEmitter implements IParticleEmitterType {
  17476. /**
  17477. * The radius of the emission cylinder.
  17478. */
  17479. radius: number;
  17480. /**
  17481. * The height of the emission cylinder.
  17482. */
  17483. height: number;
  17484. /**
  17485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17486. */
  17487. radiusRange: number;
  17488. /**
  17489. * How much to randomize the particle direction [0-1].
  17490. */
  17491. directionRandomizer: number;
  17492. /**
  17493. * Creates a new instance CylinderParticleEmitter
  17494. * @param radius the radius of the emission cylinder (1 by default)
  17495. * @param height the height of the emission cylinder (1 by default)
  17496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17498. */
  17499. constructor(
  17500. /**
  17501. * The radius of the emission cylinder.
  17502. */
  17503. radius?: number,
  17504. /**
  17505. * The height of the emission cylinder.
  17506. */
  17507. height?: number,
  17508. /**
  17509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17510. */
  17511. radiusRange?: number,
  17512. /**
  17513. * How much to randomize the particle direction [0-1].
  17514. */
  17515. directionRandomizer?: number);
  17516. /**
  17517. * Called by the particle System when the direction is computed for the created particle.
  17518. * @param worldMatrix is the world matrix of the particle system
  17519. * @param directionToUpdate is the direction vector to update with the result
  17520. * @param particle is the particle we are computed the direction for
  17521. */
  17522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17523. /**
  17524. * Called by the particle System when the position is computed for the created particle.
  17525. * @param worldMatrix is the world matrix of the particle system
  17526. * @param positionToUpdate is the position vector to update with the result
  17527. * @param particle is the particle we are computed the position for
  17528. */
  17529. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17530. /**
  17531. * Clones the current emitter and returns a copy of it
  17532. * @returns the new emitter
  17533. */
  17534. clone(): CylinderParticleEmitter;
  17535. /**
  17536. * Called by the GPUParticleSystem to setup the update shader
  17537. * @param effect defines the update shader
  17538. */
  17539. applyToShader(effect: Effect): void;
  17540. /**
  17541. * Returns a string to use to update the GPU particles update shader
  17542. * @returns a string containng the defines string
  17543. */
  17544. getEffectDefines(): string;
  17545. /**
  17546. * Returns the string "CylinderParticleEmitter"
  17547. * @returns a string containing the class name
  17548. */
  17549. getClassName(): string;
  17550. /**
  17551. * Serializes the particle system to a JSON object.
  17552. * @returns the JSON object
  17553. */
  17554. serialize(): any;
  17555. /**
  17556. * Parse properties from a JSON object
  17557. * @param serializationObject defines the JSON object
  17558. */
  17559. parse(serializationObject: any): void;
  17560. }
  17561. /**
  17562. * Particle emitter emitting particles from the inside of a cylinder.
  17563. * It emits the particles randomly between two vectors.
  17564. */
  17565. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17566. /**
  17567. * The min limit of the emission direction.
  17568. */
  17569. direction1: Vector3;
  17570. /**
  17571. * The max limit of the emission direction.
  17572. */
  17573. direction2: Vector3;
  17574. /**
  17575. * Creates a new instance CylinderDirectedParticleEmitter
  17576. * @param radius the radius of the emission cylinder (1 by default)
  17577. * @param height the height of the emission cylinder (1 by default)
  17578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17579. * @param direction1 the min limit of the emission direction (up vector by default)
  17580. * @param direction2 the max limit of the emission direction (up vector by default)
  17581. */
  17582. constructor(radius?: number, height?: number, radiusRange?: number,
  17583. /**
  17584. * The min limit of the emission direction.
  17585. */
  17586. direction1?: Vector3,
  17587. /**
  17588. * The max limit of the emission direction.
  17589. */
  17590. direction2?: Vector3);
  17591. /**
  17592. * Called by the particle System when the direction is computed for the created particle.
  17593. * @param worldMatrix is the world matrix of the particle system
  17594. * @param directionToUpdate is the direction vector to update with the result
  17595. * @param particle is the particle we are computed the direction for
  17596. */
  17597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17598. /**
  17599. * Clones the current emitter and returns a copy of it
  17600. * @returns the new emitter
  17601. */
  17602. clone(): CylinderDirectedParticleEmitter;
  17603. /**
  17604. * Called by the GPUParticleSystem to setup the update shader
  17605. * @param effect defines the update shader
  17606. */
  17607. applyToShader(effect: Effect): void;
  17608. /**
  17609. * Returns a string to use to update the GPU particles update shader
  17610. * @returns a string containng the defines string
  17611. */
  17612. getEffectDefines(): string;
  17613. /**
  17614. * Returns the string "CylinderDirectedParticleEmitter"
  17615. * @returns a string containing the class name
  17616. */
  17617. getClassName(): string;
  17618. /**
  17619. * Serializes the particle system to a JSON object.
  17620. * @returns the JSON object
  17621. */
  17622. serialize(): any;
  17623. /**
  17624. * Parse properties from a JSON object
  17625. * @param serializationObject defines the JSON object
  17626. */
  17627. parse(serializationObject: any): void;
  17628. }
  17629. }
  17630. declare module BABYLON {
  17631. /**
  17632. * Particle emitter emitting particles from the inside of a hemisphere.
  17633. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17634. */
  17635. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17636. /**
  17637. * The radius of the emission hemisphere.
  17638. */
  17639. radius: number;
  17640. /**
  17641. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17642. */
  17643. radiusRange: number;
  17644. /**
  17645. * How much to randomize the particle direction [0-1].
  17646. */
  17647. directionRandomizer: number;
  17648. /**
  17649. * Creates a new instance HemisphericParticleEmitter
  17650. * @param radius the radius of the emission hemisphere (1 by default)
  17651. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17652. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17653. */
  17654. constructor(
  17655. /**
  17656. * The radius of the emission hemisphere.
  17657. */
  17658. radius?: number,
  17659. /**
  17660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17661. */
  17662. radiusRange?: number,
  17663. /**
  17664. * How much to randomize the particle direction [0-1].
  17665. */
  17666. directionRandomizer?: number);
  17667. /**
  17668. * Called by the particle System when the direction is computed for the created particle.
  17669. * @param worldMatrix is the world matrix of the particle system
  17670. * @param directionToUpdate is the direction vector to update with the result
  17671. * @param particle is the particle we are computed the direction for
  17672. */
  17673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17674. /**
  17675. * Called by the particle System when the position is computed for the created particle.
  17676. * @param worldMatrix is the world matrix of the particle system
  17677. * @param positionToUpdate is the position vector to update with the result
  17678. * @param particle is the particle we are computed the position for
  17679. */
  17680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17681. /**
  17682. * Clones the current emitter and returns a copy of it
  17683. * @returns the new emitter
  17684. */
  17685. clone(): HemisphericParticleEmitter;
  17686. /**
  17687. * Called by the GPUParticleSystem to setup the update shader
  17688. * @param effect defines the update shader
  17689. */
  17690. applyToShader(effect: Effect): void;
  17691. /**
  17692. * Returns a string to use to update the GPU particles update shader
  17693. * @returns a string containng the defines string
  17694. */
  17695. getEffectDefines(): string;
  17696. /**
  17697. * Returns the string "HemisphericParticleEmitter"
  17698. * @returns a string containing the class name
  17699. */
  17700. getClassName(): string;
  17701. /**
  17702. * Serializes the particle system to a JSON object.
  17703. * @returns the JSON object
  17704. */
  17705. serialize(): any;
  17706. /**
  17707. * Parse properties from a JSON object
  17708. * @param serializationObject defines the JSON object
  17709. */
  17710. parse(serializationObject: any): void;
  17711. }
  17712. }
  17713. declare module BABYLON {
  17714. /**
  17715. * Particle emitter emitting particles from a point.
  17716. * It emits the particles randomly between 2 given directions.
  17717. */
  17718. export class PointParticleEmitter implements IParticleEmitterType {
  17719. /**
  17720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17721. */
  17722. direction1: Vector3;
  17723. /**
  17724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17725. */
  17726. direction2: Vector3;
  17727. /**
  17728. * Creates a new instance PointParticleEmitter
  17729. */
  17730. constructor();
  17731. /**
  17732. * Called by the particle System when the direction is computed for the created particle.
  17733. * @param worldMatrix is the world matrix of the particle system
  17734. * @param directionToUpdate is the direction vector to update with the result
  17735. * @param particle is the particle we are computed the direction for
  17736. */
  17737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17738. /**
  17739. * Called by the particle System when the position is computed for the created particle.
  17740. * @param worldMatrix is the world matrix of the particle system
  17741. * @param positionToUpdate is the position vector to update with the result
  17742. * @param particle is the particle we are computed the position for
  17743. */
  17744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17745. /**
  17746. * Clones the current emitter and returns a copy of it
  17747. * @returns the new emitter
  17748. */
  17749. clone(): PointParticleEmitter;
  17750. /**
  17751. * Called by the GPUParticleSystem to setup the update shader
  17752. * @param effect defines the update shader
  17753. */
  17754. applyToShader(effect: Effect): void;
  17755. /**
  17756. * Returns a string to use to update the GPU particles update shader
  17757. * @returns a string containng the defines string
  17758. */
  17759. getEffectDefines(): string;
  17760. /**
  17761. * Returns the string "PointParticleEmitter"
  17762. * @returns a string containing the class name
  17763. */
  17764. getClassName(): string;
  17765. /**
  17766. * Serializes the particle system to a JSON object.
  17767. * @returns the JSON object
  17768. */
  17769. serialize(): any;
  17770. /**
  17771. * Parse properties from a JSON object
  17772. * @param serializationObject defines the JSON object
  17773. */
  17774. parse(serializationObject: any): void;
  17775. }
  17776. }
  17777. declare module BABYLON {
  17778. /**
  17779. * Particle emitter emitting particles from the inside of a sphere.
  17780. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17781. */
  17782. export class SphereParticleEmitter implements IParticleEmitterType {
  17783. /**
  17784. * The radius of the emission sphere.
  17785. */
  17786. radius: number;
  17787. /**
  17788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17789. */
  17790. radiusRange: number;
  17791. /**
  17792. * How much to randomize the particle direction [0-1].
  17793. */
  17794. directionRandomizer: number;
  17795. /**
  17796. * Creates a new instance SphereParticleEmitter
  17797. * @param radius the radius of the emission sphere (1 by default)
  17798. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17800. */
  17801. constructor(
  17802. /**
  17803. * The radius of the emission sphere.
  17804. */
  17805. radius?: number,
  17806. /**
  17807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17808. */
  17809. radiusRange?: number,
  17810. /**
  17811. * How much to randomize the particle direction [0-1].
  17812. */
  17813. directionRandomizer?: number);
  17814. /**
  17815. * Called by the particle System when the direction is computed for the created particle.
  17816. * @param worldMatrix is the world matrix of the particle system
  17817. * @param directionToUpdate is the direction vector to update with the result
  17818. * @param particle is the particle we are computed the direction for
  17819. */
  17820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17821. /**
  17822. * Called by the particle System when the position is computed for the created particle.
  17823. * @param worldMatrix is the world matrix of the particle system
  17824. * @param positionToUpdate is the position vector to update with the result
  17825. * @param particle is the particle we are computed the position for
  17826. */
  17827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17828. /**
  17829. * Clones the current emitter and returns a copy of it
  17830. * @returns the new emitter
  17831. */
  17832. clone(): SphereParticleEmitter;
  17833. /**
  17834. * Called by the GPUParticleSystem to setup the update shader
  17835. * @param effect defines the update shader
  17836. */
  17837. applyToShader(effect: Effect): void;
  17838. /**
  17839. * Returns a string to use to update the GPU particles update shader
  17840. * @returns a string containng the defines string
  17841. */
  17842. getEffectDefines(): string;
  17843. /**
  17844. * Returns the string "SphereParticleEmitter"
  17845. * @returns a string containing the class name
  17846. */
  17847. getClassName(): string;
  17848. /**
  17849. * Serializes the particle system to a JSON object.
  17850. * @returns the JSON object
  17851. */
  17852. serialize(): any;
  17853. /**
  17854. * Parse properties from a JSON object
  17855. * @param serializationObject defines the JSON object
  17856. */
  17857. parse(serializationObject: any): void;
  17858. }
  17859. /**
  17860. * Particle emitter emitting particles from the inside of a sphere.
  17861. * It emits the particles randomly between two vectors.
  17862. */
  17863. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17864. /**
  17865. * The min limit of the emission direction.
  17866. */
  17867. direction1: Vector3;
  17868. /**
  17869. * The max limit of the emission direction.
  17870. */
  17871. direction2: Vector3;
  17872. /**
  17873. * Creates a new instance SphereDirectedParticleEmitter
  17874. * @param radius the radius of the emission sphere (1 by default)
  17875. * @param direction1 the min limit of the emission direction (up vector by default)
  17876. * @param direction2 the max limit of the emission direction (up vector by default)
  17877. */
  17878. constructor(radius?: number,
  17879. /**
  17880. * The min limit of the emission direction.
  17881. */
  17882. direction1?: Vector3,
  17883. /**
  17884. * The max limit of the emission direction.
  17885. */
  17886. direction2?: Vector3);
  17887. /**
  17888. * Called by the particle System when the direction is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param directionToUpdate is the direction vector to update with the result
  17891. * @param particle is the particle we are computed the direction for
  17892. */
  17893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): SphereDirectedParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "SphereDirectedParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module BABYLON {
  17927. /**
  17928. * Interface representing a particle system in Babylon.js.
  17929. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17930. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17931. */
  17932. export interface IParticleSystem {
  17933. /**
  17934. * List of animations used by the particle system.
  17935. */
  17936. animations: Animation[];
  17937. /**
  17938. * The id of the Particle system.
  17939. */
  17940. id: string;
  17941. /**
  17942. * The name of the Particle system.
  17943. */
  17944. name: string;
  17945. /**
  17946. * The emitter represents the Mesh or position we are attaching the particle system to.
  17947. */
  17948. emitter: Nullable<AbstractMesh | Vector3>;
  17949. /**
  17950. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17951. */
  17952. isBillboardBased: boolean;
  17953. /**
  17954. * The rendering group used by the Particle system to chose when to render.
  17955. */
  17956. renderingGroupId: number;
  17957. /**
  17958. * The layer mask we are rendering the particles through.
  17959. */
  17960. layerMask: number;
  17961. /**
  17962. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17963. */
  17964. updateSpeed: number;
  17965. /**
  17966. * The amount of time the particle system is running (depends of the overall update speed).
  17967. */
  17968. targetStopDuration: number;
  17969. /**
  17970. * The texture used to render each particle. (this can be a spritesheet)
  17971. */
  17972. particleTexture: Nullable<Texture>;
  17973. /**
  17974. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17975. */
  17976. blendMode: number;
  17977. /**
  17978. * Minimum life time of emitting particles.
  17979. */
  17980. minLifeTime: number;
  17981. /**
  17982. * Maximum life time of emitting particles.
  17983. */
  17984. maxLifeTime: number;
  17985. /**
  17986. * Minimum Size of emitting particles.
  17987. */
  17988. minSize: number;
  17989. /**
  17990. * Maximum Size of emitting particles.
  17991. */
  17992. maxSize: number;
  17993. /**
  17994. * Minimum scale of emitting particles on X axis.
  17995. */
  17996. minScaleX: number;
  17997. /**
  17998. * Maximum scale of emitting particles on X axis.
  17999. */
  18000. maxScaleX: number;
  18001. /**
  18002. * Minimum scale of emitting particles on Y axis.
  18003. */
  18004. minScaleY: number;
  18005. /**
  18006. * Maximum scale of emitting particles on Y axis.
  18007. */
  18008. maxScaleY: number;
  18009. /**
  18010. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18011. */
  18012. color1: Color4;
  18013. /**
  18014. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18015. */
  18016. color2: Color4;
  18017. /**
  18018. * Color the particle will have at the end of its lifetime.
  18019. */
  18020. colorDead: Color4;
  18021. /**
  18022. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18023. */
  18024. emitRate: number;
  18025. /**
  18026. * You can use gravity if you want to give an orientation to your particles.
  18027. */
  18028. gravity: Vector3;
  18029. /**
  18030. * Minimum power of emitting particles.
  18031. */
  18032. minEmitPower: number;
  18033. /**
  18034. * Maximum power of emitting particles.
  18035. */
  18036. maxEmitPower: number;
  18037. /**
  18038. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18039. */
  18040. minAngularSpeed: number;
  18041. /**
  18042. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18043. */
  18044. maxAngularSpeed: number;
  18045. /**
  18046. * Gets or sets the minimal initial rotation in radians.
  18047. */
  18048. minInitialRotation: number;
  18049. /**
  18050. * Gets or sets the maximal initial rotation in radians.
  18051. */
  18052. maxInitialRotation: number;
  18053. /**
  18054. * The particle emitter type defines the emitter used by the particle system.
  18055. * It can be for example box, sphere, or cone...
  18056. */
  18057. particleEmitterType: Nullable<IParticleEmitterType>;
  18058. /**
  18059. * Defines the delay in milliseconds before starting the system (0 by default)
  18060. */
  18061. startDelay: number;
  18062. /**
  18063. * 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
  18064. */
  18065. preWarmCycles: number;
  18066. /**
  18067. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18068. */
  18069. preWarmStepOffset: number;
  18070. /**
  18071. * 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)
  18072. */
  18073. spriteCellChangeSpeed: number;
  18074. /**
  18075. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18076. */
  18077. startSpriteCellID: number;
  18078. /**
  18079. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18080. */
  18081. endSpriteCellID: number;
  18082. /**
  18083. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18084. */
  18085. spriteCellWidth: number;
  18086. /**
  18087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18088. */
  18089. spriteCellHeight: number;
  18090. /**
  18091. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18092. */
  18093. spriteRandomStartCell: boolean;
  18094. /**
  18095. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18096. */
  18097. isAnimationSheetEnabled: boolean;
  18098. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18099. translationPivot: Vector2;
  18100. /**
  18101. * Gets or sets a texture used to add random noise to particle positions
  18102. */
  18103. noiseTexture: Nullable<BaseTexture>;
  18104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18105. noiseStrength: Vector3;
  18106. /**
  18107. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18108. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18109. */
  18110. billboardMode: number;
  18111. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18112. limitVelocityDamping: number;
  18113. /**
  18114. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18115. */
  18116. beginAnimationOnStart: boolean;
  18117. /**
  18118. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18119. */
  18120. beginAnimationFrom: number;
  18121. /**
  18122. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18123. */
  18124. beginAnimationTo: number;
  18125. /**
  18126. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18127. */
  18128. beginAnimationLoop: boolean;
  18129. /**
  18130. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18131. */
  18132. disposeOnStop: boolean;
  18133. /**
  18134. * Gets the maximum number of particles active at the same time.
  18135. * @returns The max number of active particles.
  18136. */
  18137. getCapacity(): number;
  18138. /**
  18139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18140. * @returns True if it has been started, otherwise false.
  18141. */
  18142. isStarted(): boolean;
  18143. /**
  18144. * Animates the particle system for this frame.
  18145. */
  18146. animate(): void;
  18147. /**
  18148. * Renders the particle system in its current state.
  18149. * @returns the current number of particles
  18150. */
  18151. render(): number;
  18152. /**
  18153. * Dispose the particle system and frees its associated resources.
  18154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18155. */
  18156. dispose(disposeTexture?: boolean): void;
  18157. /**
  18158. * Clones the particle system.
  18159. * @param name The name of the cloned object
  18160. * @param newEmitter The new emitter to use
  18161. * @returns the cloned particle system
  18162. */
  18163. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18164. /**
  18165. * Serializes the particle system to a JSON object.
  18166. * @returns the JSON object
  18167. */
  18168. serialize(): any;
  18169. /**
  18170. * Rebuild the particle system
  18171. */
  18172. rebuild(): void;
  18173. /**
  18174. * Starts the particle system and begins to emit
  18175. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18176. */
  18177. start(delay?: number): void;
  18178. /**
  18179. * Stops the particle system.
  18180. */
  18181. stop(): void;
  18182. /**
  18183. * Remove all active particles
  18184. */
  18185. reset(): void;
  18186. /**
  18187. * Is this system ready to be used/rendered
  18188. * @return true if the system is ready
  18189. */
  18190. isReady(): boolean;
  18191. /**
  18192. * Adds a new color gradient
  18193. * @param gradient defines the gradient to use (between 0 and 1)
  18194. * @param color1 defines the color to affect to the specified gradient
  18195. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18196. * @returns the current particle system
  18197. */
  18198. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18199. /**
  18200. * Remove a specific color gradient
  18201. * @param gradient defines the gradient to remove
  18202. * @returns the current particle system
  18203. */
  18204. removeColorGradient(gradient: number): IParticleSystem;
  18205. /**
  18206. * Adds a new size gradient
  18207. * @param gradient defines the gradient to use (between 0 and 1)
  18208. * @param factor defines the size factor to affect to the specified gradient
  18209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18210. * @returns the current particle system
  18211. */
  18212. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18213. /**
  18214. * Remove a specific size gradient
  18215. * @param gradient defines the gradient to remove
  18216. * @returns the current particle system
  18217. */
  18218. removeSizeGradient(gradient: number): IParticleSystem;
  18219. /**
  18220. * Gets the current list of color gradients.
  18221. * You must use addColorGradient and removeColorGradient to udpate this list
  18222. * @returns the list of color gradients
  18223. */
  18224. getColorGradients(): Nullable<Array<ColorGradient>>;
  18225. /**
  18226. * Gets the current list of size gradients.
  18227. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18228. * @returns the list of size gradients
  18229. */
  18230. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18231. /**
  18232. * Gets the current list of angular speed gradients.
  18233. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18234. * @returns the list of angular speed gradients
  18235. */
  18236. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18237. /**
  18238. * Adds a new angular speed gradient
  18239. * @param gradient defines the gradient to use (between 0 and 1)
  18240. * @param factor defines the angular speed to affect to the specified gradient
  18241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18242. * @returns the current particle system
  18243. */
  18244. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18245. /**
  18246. * Remove a specific angular speed gradient
  18247. * @param gradient defines the gradient to remove
  18248. * @returns the current particle system
  18249. */
  18250. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18251. /**
  18252. * Gets the current list of velocity gradients.
  18253. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18254. * @returns the list of velocity gradients
  18255. */
  18256. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18257. /**
  18258. * Adds a new velocity gradient
  18259. * @param gradient defines the gradient to use (between 0 and 1)
  18260. * @param factor defines the velocity to affect to the specified gradient
  18261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18262. * @returns the current particle system
  18263. */
  18264. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18265. /**
  18266. * Remove a specific velocity gradient
  18267. * @param gradient defines the gradient to remove
  18268. * @returns the current particle system
  18269. */
  18270. removeVelocityGradient(gradient: number): IParticleSystem;
  18271. /**
  18272. * Gets the current list of limit velocity gradients.
  18273. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18274. * @returns the list of limit velocity gradients
  18275. */
  18276. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18277. /**
  18278. * Adds a new limit velocity gradient
  18279. * @param gradient defines the gradient to use (between 0 and 1)
  18280. * @param factor defines the limit velocity to affect to the specified gradient
  18281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18282. * @returns the current particle system
  18283. */
  18284. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18285. /**
  18286. * Remove a specific limit velocity gradient
  18287. * @param gradient defines the gradient to remove
  18288. * @returns the current particle system
  18289. */
  18290. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18291. /**
  18292. * Adds a new drag gradient
  18293. * @param gradient defines the gradient to use (between 0 and 1)
  18294. * @param factor defines the drag to affect to the specified gradient
  18295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18296. * @returns the current particle system
  18297. */
  18298. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18299. /**
  18300. * Remove a specific drag gradient
  18301. * @param gradient defines the gradient to remove
  18302. * @returns the current particle system
  18303. */
  18304. removeDragGradient(gradient: number): IParticleSystem;
  18305. /**
  18306. * Gets the current list of drag gradients.
  18307. * You must use addDragGradient and removeDragGradient to udpate this list
  18308. * @returns the list of drag gradients
  18309. */
  18310. getDragGradients(): Nullable<Array<FactorGradient>>;
  18311. /**
  18312. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18313. * @param gradient defines the gradient to use (between 0 and 1)
  18314. * @param factor defines the emit rate to affect to the specified gradient
  18315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18316. * @returns the current particle system
  18317. */
  18318. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18319. /**
  18320. * Remove a specific emit rate gradient
  18321. * @param gradient defines the gradient to remove
  18322. * @returns the current particle system
  18323. */
  18324. removeEmitRateGradient(gradient: number): IParticleSystem;
  18325. /**
  18326. * Gets the current list of emit rate gradients.
  18327. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18328. * @returns the list of emit rate gradients
  18329. */
  18330. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18331. /**
  18332. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18333. * @param gradient defines the gradient to use (between 0 and 1)
  18334. * @param factor defines the start size to affect to the specified gradient
  18335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18336. * @returns the current particle system
  18337. */
  18338. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18339. /**
  18340. * Remove a specific start size gradient
  18341. * @param gradient defines the gradient to remove
  18342. * @returns the current particle system
  18343. */
  18344. removeStartSizeGradient(gradient: number): IParticleSystem;
  18345. /**
  18346. * Gets the current list of start size gradients.
  18347. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18348. * @returns the list of start size gradients
  18349. */
  18350. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18351. /**
  18352. * Adds a new life time gradient
  18353. * @param gradient defines the gradient to use (between 0 and 1)
  18354. * @param factor defines the life time factor to affect to the specified gradient
  18355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18356. * @returns the current particle system
  18357. */
  18358. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18359. /**
  18360. * Remove a specific life time gradient
  18361. * @param gradient defines the gradient to remove
  18362. * @returns the current particle system
  18363. */
  18364. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18365. /**
  18366. * Gets the current list of life time gradients.
  18367. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18368. * @returns the list of life time gradients
  18369. */
  18370. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18371. /**
  18372. * Gets the current list of color gradients.
  18373. * You must use addColorGradient and removeColorGradient to udpate this list
  18374. * @returns the list of color gradients
  18375. */
  18376. getColorGradients(): Nullable<Array<ColorGradient>>;
  18377. /**
  18378. * Adds a new ramp gradient used to remap particle colors
  18379. * @param gradient defines the gradient to use (between 0 and 1)
  18380. * @param color defines the color to affect to the specified gradient
  18381. * @returns the current particle system
  18382. */
  18383. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18384. /**
  18385. * Gets the current list of ramp gradients.
  18386. * You must use addRampGradient and removeRampGradient to udpate this list
  18387. * @returns the list of ramp gradients
  18388. */
  18389. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18390. /** Gets or sets a boolean indicating that ramp gradients must be used
  18391. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18392. */
  18393. useRampGradients: boolean;
  18394. /**
  18395. * Adds a new color remap gradient
  18396. * @param gradient defines the gradient to use (between 0 and 1)
  18397. * @param min defines the color remap minimal range
  18398. * @param max defines the color remap maximal range
  18399. * @returns the current particle system
  18400. */
  18401. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18402. /**
  18403. * Gets the current list of color remap gradients.
  18404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18405. * @returns the list of color remap gradients
  18406. */
  18407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18408. /**
  18409. * Adds a new alpha remap gradient
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param min defines the alpha remap minimal range
  18412. * @param max defines the alpha remap maximal range
  18413. * @returns the current particle system
  18414. */
  18415. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18416. /**
  18417. * Gets the current list of alpha remap gradients.
  18418. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18419. * @returns the list of alpha remap gradients
  18420. */
  18421. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18422. /**
  18423. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18426. * @returns the emitter
  18427. */
  18428. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18429. /**
  18430. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18431. * @param radius The radius of the hemisphere to emit from
  18432. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18433. * @returns the emitter
  18434. */
  18435. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18436. /**
  18437. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18438. * @param radius The radius of the sphere to emit from
  18439. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18440. * @returns the emitter
  18441. */
  18442. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18443. /**
  18444. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18445. * @param radius The radius of the sphere to emit from
  18446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18448. * @returns the emitter
  18449. */
  18450. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18451. /**
  18452. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18453. * @param radius The radius of the emission cylinder
  18454. * @param height The height of the emission cylinder
  18455. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18456. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18457. * @returns the emitter
  18458. */
  18459. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18460. /**
  18461. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18462. * @param radius The radius of the cylinder to emit from
  18463. * @param height The height of the emission cylinder
  18464. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18467. * @returns the emitter
  18468. */
  18469. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18470. /**
  18471. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18472. * @param radius The radius of the cone to emit from
  18473. * @param angle The base angle of the cone
  18474. * @returns the emitter
  18475. */
  18476. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18477. /**
  18478. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18481. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18482. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18483. * @returns the emitter
  18484. */
  18485. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18486. /**
  18487. * Get hosting scene
  18488. * @returns the scene
  18489. */
  18490. getScene(): Scene;
  18491. }
  18492. }
  18493. declare module BABYLON {
  18494. /**
  18495. * Creates an instance based on a source mesh.
  18496. */
  18497. export class InstancedMesh extends AbstractMesh {
  18498. private _sourceMesh;
  18499. private _currentLOD;
  18500. /** @hidden */
  18501. _indexInSourceMeshInstanceArray: number;
  18502. constructor(name: string, source: Mesh);
  18503. /**
  18504. * Returns the string "InstancedMesh".
  18505. */
  18506. getClassName(): string;
  18507. /** Gets the list of lights affecting that mesh */
  18508. readonly lightSources: Light[];
  18509. _resyncLightSources(): void;
  18510. _resyncLighSource(light: Light): void;
  18511. _removeLightSource(light: Light): void;
  18512. /**
  18513. * If the source mesh receives shadows
  18514. */
  18515. readonly receiveShadows: boolean;
  18516. /**
  18517. * The material of the source mesh
  18518. */
  18519. readonly material: Nullable<Material>;
  18520. /**
  18521. * Visibility of the source mesh
  18522. */
  18523. readonly visibility: number;
  18524. /**
  18525. * Skeleton of the source mesh
  18526. */
  18527. readonly skeleton: Nullable<Skeleton>;
  18528. /**
  18529. * Rendering ground id of the source mesh
  18530. */
  18531. renderingGroupId: number;
  18532. /**
  18533. * Returns the total number of vertices (integer).
  18534. */
  18535. getTotalVertices(): number;
  18536. /**
  18537. * Returns a positive integer : the total number of indices in this mesh geometry.
  18538. * @returns the numner of indices or zero if the mesh has no geometry.
  18539. */
  18540. getTotalIndices(): number;
  18541. /**
  18542. * The source mesh of the instance
  18543. */
  18544. readonly sourceMesh: Mesh;
  18545. /**
  18546. * Is this node ready to be used/rendered
  18547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18548. * @return {boolean} is it ready
  18549. */
  18550. isReady(completeCheck?: boolean): boolean;
  18551. /**
  18552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18553. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18554. * @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.
  18555. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18556. */
  18557. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18558. /**
  18559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18561. * The `data` are either a numeric array either a Float32Array.
  18562. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18563. * 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).
  18564. * Note that a new underlying VertexBuffer object is created each call.
  18565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18566. *
  18567. * Possible `kind` values :
  18568. * - VertexBuffer.PositionKind
  18569. * - VertexBuffer.UVKind
  18570. * - VertexBuffer.UV2Kind
  18571. * - VertexBuffer.UV3Kind
  18572. * - VertexBuffer.UV4Kind
  18573. * - VertexBuffer.UV5Kind
  18574. * - VertexBuffer.UV6Kind
  18575. * - VertexBuffer.ColorKind
  18576. * - VertexBuffer.MatricesIndicesKind
  18577. * - VertexBuffer.MatricesIndicesExtraKind
  18578. * - VertexBuffer.MatricesWeightsKind
  18579. * - VertexBuffer.MatricesWeightsExtraKind
  18580. *
  18581. * Returns the Mesh.
  18582. */
  18583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18584. /**
  18585. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18586. * If the mesh has no geometry, it is simply returned as it is.
  18587. * The `data` are either a numeric array either a Float32Array.
  18588. * No new underlying VertexBuffer object is created.
  18589. * 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.
  18590. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18591. *
  18592. * Possible `kind` values :
  18593. * - VertexBuffer.PositionKind
  18594. * - VertexBuffer.UVKind
  18595. * - VertexBuffer.UV2Kind
  18596. * - VertexBuffer.UV3Kind
  18597. * - VertexBuffer.UV4Kind
  18598. * - VertexBuffer.UV5Kind
  18599. * - VertexBuffer.UV6Kind
  18600. * - VertexBuffer.ColorKind
  18601. * - VertexBuffer.MatricesIndicesKind
  18602. * - VertexBuffer.MatricesIndicesExtraKind
  18603. * - VertexBuffer.MatricesWeightsKind
  18604. * - VertexBuffer.MatricesWeightsExtraKind
  18605. *
  18606. * Returns the Mesh.
  18607. */
  18608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18609. /**
  18610. * Sets the mesh indices.
  18611. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18612. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18613. * This method creates a new index buffer each call.
  18614. * Returns the Mesh.
  18615. */
  18616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18617. /**
  18618. * Boolean : True if the mesh owns the requested kind of data.
  18619. */
  18620. isVerticesDataPresent(kind: string): boolean;
  18621. /**
  18622. * Returns an array of indices (IndicesArray).
  18623. */
  18624. getIndices(): Nullable<IndicesArray>;
  18625. readonly _positions: Nullable<Vector3[]>;
  18626. /**
  18627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18628. * This means the mesh underlying bounding box and sphere are recomputed.
  18629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18630. * @returns the current mesh
  18631. */
  18632. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18633. /** @hidden */
  18634. _preActivate(): InstancedMesh;
  18635. /** @hidden */
  18636. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18637. /** @hidden */
  18638. _postActivate(): void;
  18639. getWorldMatrix(): Matrix;
  18640. readonly isAnInstance: boolean;
  18641. /**
  18642. * Returns the current associated LOD AbstractMesh.
  18643. */
  18644. getLOD(camera: Camera): AbstractMesh;
  18645. /** @hidden */
  18646. _syncSubMeshes(): InstancedMesh;
  18647. /** @hidden */
  18648. _generatePointsArray(): boolean;
  18649. /**
  18650. * Creates a new InstancedMesh from the current mesh.
  18651. * - name (string) : the cloned mesh name
  18652. * - newParent (optional Node) : the optional Node to parent the clone to.
  18653. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18654. *
  18655. * Returns the clone.
  18656. */
  18657. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18658. /**
  18659. * Disposes the InstancedMesh.
  18660. * Returns nothing.
  18661. */
  18662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18663. }
  18664. }
  18665. declare module BABYLON {
  18666. /**
  18667. * Defines the options associated with the creation of a shader material.
  18668. */
  18669. export interface IShaderMaterialOptions {
  18670. /**
  18671. * Does the material work in alpha blend mode
  18672. */
  18673. needAlphaBlending: boolean;
  18674. /**
  18675. * Does the material work in alpha test mode
  18676. */
  18677. needAlphaTesting: boolean;
  18678. /**
  18679. * The list of attribute names used in the shader
  18680. */
  18681. attributes: string[];
  18682. /**
  18683. * The list of unifrom names used in the shader
  18684. */
  18685. uniforms: string[];
  18686. /**
  18687. * The list of UBO names used in the shader
  18688. */
  18689. uniformBuffers: string[];
  18690. /**
  18691. * The list of sampler names used in the shader
  18692. */
  18693. samplers: string[];
  18694. /**
  18695. * The list of defines used in the shader
  18696. */
  18697. defines: string[];
  18698. }
  18699. /**
  18700. * 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.
  18701. *
  18702. * This returned material effects how the mesh will look based on the code in the shaders.
  18703. *
  18704. * @see http://doc.babylonjs.com/how_to/shader_material
  18705. */
  18706. export class ShaderMaterial extends Material {
  18707. private _shaderPath;
  18708. private _options;
  18709. private _textures;
  18710. private _textureArrays;
  18711. private _floats;
  18712. private _ints;
  18713. private _floatsArrays;
  18714. private _colors3;
  18715. private _colors3Arrays;
  18716. private _colors4;
  18717. private _colors4Arrays;
  18718. private _vectors2;
  18719. private _vectors3;
  18720. private _vectors4;
  18721. private _matrices;
  18722. private _matrices3x3;
  18723. private _matrices2x2;
  18724. private _vectors2Arrays;
  18725. private _vectors3Arrays;
  18726. private _vectors4Arrays;
  18727. private _cachedWorldViewMatrix;
  18728. private _cachedWorldViewProjectionMatrix;
  18729. private _renderId;
  18730. /**
  18731. * Instantiate a new shader material.
  18732. * 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.
  18733. * This returned material effects how the mesh will look based on the code in the shaders.
  18734. * @see http://doc.babylonjs.com/how_to/shader_material
  18735. * @param name Define the name of the material in the scene
  18736. * @param scene Define the scene the material belongs to
  18737. * @param shaderPath Defines the route to the shader code in one of three ways:
  18738. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18739. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18740. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18741. * @param options Define the options used to create the shader
  18742. */
  18743. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18744. /**
  18745. * Gets the options used to compile the shader.
  18746. * They can be modified to trigger a new compilation
  18747. */
  18748. readonly options: IShaderMaterialOptions;
  18749. /**
  18750. * Gets the current class name of the material e.g. "ShaderMaterial"
  18751. * Mainly use in serialization.
  18752. * @returns the class name
  18753. */
  18754. getClassName(): string;
  18755. /**
  18756. * Specifies if the material will require alpha blending
  18757. * @returns a boolean specifying if alpha blending is needed
  18758. */
  18759. needAlphaBlending(): boolean;
  18760. /**
  18761. * Specifies if this material should be rendered in alpha test mode
  18762. * @returns a boolean specifying if an alpha test is needed.
  18763. */
  18764. needAlphaTesting(): boolean;
  18765. private _checkUniform;
  18766. /**
  18767. * Set a texture in the shader.
  18768. * @param name Define the name of the uniform samplers as defined in the shader
  18769. * @param texture Define the texture to bind to this sampler
  18770. * @return the material itself allowing "fluent" like uniform updates
  18771. */
  18772. setTexture(name: string, texture: Texture): ShaderMaterial;
  18773. /**
  18774. * Set a texture array in the shader.
  18775. * @param name Define the name of the uniform sampler array as defined in the shader
  18776. * @param textures Define the list of textures to bind to this sampler
  18777. * @return the material itself allowing "fluent" like uniform updates
  18778. */
  18779. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18780. /**
  18781. * Set a float in the shader.
  18782. * @param name Define the name of the uniform as defined in the shader
  18783. * @param value Define the value to give to the uniform
  18784. * @return the material itself allowing "fluent" like uniform updates
  18785. */
  18786. setFloat(name: string, value: number): ShaderMaterial;
  18787. /**
  18788. * Set a int in the shader.
  18789. * @param name Define the name of the uniform as defined in the shader
  18790. * @param value Define the value to give to the uniform
  18791. * @return the material itself allowing "fluent" like uniform updates
  18792. */
  18793. setInt(name: string, value: number): ShaderMaterial;
  18794. /**
  18795. * Set an array of floats in the shader.
  18796. * @param name Define the name of the uniform as defined in the shader
  18797. * @param value Define the value to give to the uniform
  18798. * @return the material itself allowing "fluent" like uniform updates
  18799. */
  18800. setFloats(name: string, value: number[]): ShaderMaterial;
  18801. /**
  18802. * Set a vec3 in the shader from a Color3.
  18803. * @param name Define the name of the uniform as defined in the shader
  18804. * @param value Define the value to give to the uniform
  18805. * @return the material itself allowing "fluent" like uniform updates
  18806. */
  18807. setColor3(name: string, value: Color3): ShaderMaterial;
  18808. /**
  18809. * Set a vec3 array in the shader from a Color3 array.
  18810. * @param name Define the name of the uniform as defined in the shader
  18811. * @param value Define the value to give to the uniform
  18812. * @return the material itself allowing "fluent" like uniform updates
  18813. */
  18814. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18815. /**
  18816. * Set a vec4 in the shader from a Color4.
  18817. * @param name Define the name of the uniform as defined in the shader
  18818. * @param value Define the value to give to the uniform
  18819. * @return the material itself allowing "fluent" like uniform updates
  18820. */
  18821. setColor4(name: string, value: Color4): ShaderMaterial;
  18822. /**
  18823. * Set a vec4 array in the shader from a Color4 array.
  18824. * @param name Define the name of the uniform as defined in the shader
  18825. * @param value Define the value to give to the uniform
  18826. * @return the material itself allowing "fluent" like uniform updates
  18827. */
  18828. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18829. /**
  18830. * Set a vec2 in the shader from a Vector2.
  18831. * @param name Define the name of the uniform as defined in the shader
  18832. * @param value Define the value to give to the uniform
  18833. * @return the material itself allowing "fluent" like uniform updates
  18834. */
  18835. setVector2(name: string, value: Vector2): ShaderMaterial;
  18836. /**
  18837. * Set a vec3 in the shader from a Vector3.
  18838. * @param name Define the name of the uniform as defined in the shader
  18839. * @param value Define the value to give to the uniform
  18840. * @return the material itself allowing "fluent" like uniform updates
  18841. */
  18842. setVector3(name: string, value: Vector3): ShaderMaterial;
  18843. /**
  18844. * Set a vec4 in the shader from a Vector4.
  18845. * @param name Define the name of the uniform as defined in the shader
  18846. * @param value Define the value to give to the uniform
  18847. * @return the material itself allowing "fluent" like uniform updates
  18848. */
  18849. setVector4(name: string, value: Vector4): ShaderMaterial;
  18850. /**
  18851. * Set a mat4 in the shader from a Matrix.
  18852. * @param name Define the name of the uniform as defined in the shader
  18853. * @param value Define the value to give to the uniform
  18854. * @return the material itself allowing "fluent" like uniform updates
  18855. */
  18856. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18857. /**
  18858. * Set a mat3 in the shader from a Float32Array.
  18859. * @param name Define the name of the uniform as defined in the shader
  18860. * @param value Define the value to give to the uniform
  18861. * @return the material itself allowing "fluent" like uniform updates
  18862. */
  18863. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18864. /**
  18865. * Set a mat2 in the shader from a Float32Array.
  18866. * @param name Define the name of the uniform as defined in the shader
  18867. * @param value Define the value to give to the uniform
  18868. * @return the material itself allowing "fluent" like uniform updates
  18869. */
  18870. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18871. /**
  18872. * Set a vec2 array in the shader from a number array.
  18873. * @param name Define the name of the uniform as defined in the shader
  18874. * @param value Define the value to give to the uniform
  18875. * @return the material itself allowing "fluent" like uniform updates
  18876. */
  18877. setArray2(name: string, value: number[]): ShaderMaterial;
  18878. /**
  18879. * Set a vec3 array in the shader from a number array.
  18880. * @param name Define the name of the uniform as defined in the shader
  18881. * @param value Define the value to give to the uniform
  18882. * @return the material itself allowing "fluent" like uniform updates
  18883. */
  18884. setArray3(name: string, value: number[]): ShaderMaterial;
  18885. /**
  18886. * Set a vec4 array in the shader from a number array.
  18887. * @param name Define the name of the uniform as defined in the shader
  18888. * @param value Define the value to give to the uniform
  18889. * @return the material itself allowing "fluent" like uniform updates
  18890. */
  18891. setArray4(name: string, value: number[]): ShaderMaterial;
  18892. private _checkCache;
  18893. /**
  18894. * Specifies that the submesh is ready to be used
  18895. * @param mesh defines the mesh to check
  18896. * @param subMesh defines which submesh to check
  18897. * @param useInstances specifies that instances should be used
  18898. * @returns a boolean indicating that the submesh is ready or not
  18899. */
  18900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18901. /**
  18902. * Checks if the material is ready to render the requested mesh
  18903. * @param mesh Define the mesh to render
  18904. * @param useInstances Define whether or not the material is used with instances
  18905. * @returns true if ready, otherwise false
  18906. */
  18907. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18908. /**
  18909. * Binds the world matrix to the material
  18910. * @param world defines the world transformation matrix
  18911. */
  18912. bindOnlyWorldMatrix(world: Matrix): void;
  18913. /**
  18914. * Binds the material to the mesh
  18915. * @param world defines the world transformation matrix
  18916. * @param mesh defines the mesh to bind the material to
  18917. */
  18918. bind(world: Matrix, mesh?: Mesh): void;
  18919. /**
  18920. * Gets the active textures from the material
  18921. * @returns an array of textures
  18922. */
  18923. getActiveTextures(): BaseTexture[];
  18924. /**
  18925. * Specifies if the material uses a texture
  18926. * @param texture defines the texture to check against the material
  18927. * @returns a boolean specifying if the material uses the texture
  18928. */
  18929. hasTexture(texture: BaseTexture): boolean;
  18930. /**
  18931. * Makes a duplicate of the material, and gives it a new name
  18932. * @param name defines the new name for the duplicated material
  18933. * @returns the cloned material
  18934. */
  18935. clone(name: string): ShaderMaterial;
  18936. /**
  18937. * Disposes the material
  18938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18940. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18941. */
  18942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18943. /**
  18944. * Serializes this material in a JSON representation
  18945. * @returns the serialized material object
  18946. */
  18947. serialize(): any;
  18948. /**
  18949. * Creates a shader material from parsed shader material data
  18950. * @param source defines the JSON represnetation of the material
  18951. * @param scene defines the hosting scene
  18952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18953. * @returns a new material
  18954. */
  18955. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18956. }
  18957. }
  18958. declare module BABYLON {
  18959. /** @hidden */
  18960. export var colorPixelShader: {
  18961. name: string;
  18962. shader: string;
  18963. };
  18964. }
  18965. declare module BABYLON {
  18966. /** @hidden */
  18967. export var colorVertexShader: {
  18968. name: string;
  18969. shader: string;
  18970. };
  18971. }
  18972. declare module BABYLON {
  18973. /**
  18974. * Line mesh
  18975. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18976. */
  18977. export class LinesMesh extends Mesh {
  18978. /**
  18979. * If vertex color should be applied to the mesh
  18980. */
  18981. readonly useVertexColor?: boolean | undefined;
  18982. /**
  18983. * If vertex alpha should be applied to the mesh
  18984. */
  18985. readonly useVertexAlpha?: boolean | undefined;
  18986. /**
  18987. * Color of the line (Default: White)
  18988. */
  18989. color: Color3;
  18990. /**
  18991. * Alpha of the line (Default: 1)
  18992. */
  18993. alpha: number;
  18994. /**
  18995. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18996. * This margin is expressed in world space coordinates, so its value may vary.
  18997. * Default value is 0.1
  18998. */
  18999. intersectionThreshold: number;
  19000. private _colorShader;
  19001. private color4;
  19002. /**
  19003. * Creates a new LinesMesh
  19004. * @param name defines the name
  19005. * @param scene defines the hosting scene
  19006. * @param parent defines the parent mesh if any
  19007. * @param source defines the optional source LinesMesh used to clone data from
  19008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19009. * When false, achieved by calling a clone(), also passing False.
  19010. * This will make creation of children, recursive.
  19011. * @param useVertexColor defines if this LinesMesh supports vertex color
  19012. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19013. */
  19014. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19015. /**
  19016. * If vertex color should be applied to the mesh
  19017. */
  19018. useVertexColor?: boolean | undefined,
  19019. /**
  19020. * If vertex alpha should be applied to the mesh
  19021. */
  19022. useVertexAlpha?: boolean | undefined);
  19023. private _addClipPlaneDefine;
  19024. private _removeClipPlaneDefine;
  19025. isReady(): boolean;
  19026. /**
  19027. * Returns the string "LineMesh"
  19028. */
  19029. getClassName(): string;
  19030. /**
  19031. * @hidden
  19032. */
  19033. /**
  19034. * @hidden
  19035. */
  19036. material: Material;
  19037. /**
  19038. * @hidden
  19039. */
  19040. readonly checkCollisions: boolean;
  19041. /** @hidden */
  19042. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19043. /** @hidden */
  19044. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19045. /**
  19046. * Disposes of the line mesh
  19047. * @param doNotRecurse If children should be disposed
  19048. */
  19049. dispose(doNotRecurse?: boolean): void;
  19050. /**
  19051. * Returns a new LineMesh object cloned from the current one.
  19052. */
  19053. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19054. /**
  19055. * Creates a new InstancedLinesMesh object from the mesh model.
  19056. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19057. * @param name defines the name of the new instance
  19058. * @returns a new InstancedLinesMesh
  19059. */
  19060. createInstance(name: string): InstancedLinesMesh;
  19061. }
  19062. /**
  19063. * Creates an instance based on a source LinesMesh
  19064. */
  19065. export class InstancedLinesMesh extends InstancedMesh {
  19066. /**
  19067. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19068. * This margin is expressed in world space coordinates, so its value may vary.
  19069. * Initilized with the intersectionThreshold value of the source LinesMesh
  19070. */
  19071. intersectionThreshold: number;
  19072. constructor(name: string, source: LinesMesh);
  19073. /**
  19074. * Returns the string "InstancedLinesMesh".
  19075. */
  19076. getClassName(): string;
  19077. }
  19078. }
  19079. declare module BABYLON {
  19080. /** @hidden */
  19081. export var linePixelShader: {
  19082. name: string;
  19083. shader: string;
  19084. };
  19085. }
  19086. declare module BABYLON {
  19087. /** @hidden */
  19088. export var lineVertexShader: {
  19089. name: string;
  19090. shader: string;
  19091. };
  19092. }
  19093. declare module BABYLON {
  19094. interface AbstractMesh {
  19095. /**
  19096. * Gets the edgesRenderer associated with the mesh
  19097. */
  19098. edgesRenderer: Nullable<EdgesRenderer>;
  19099. }
  19100. interface LinesMesh {
  19101. /**
  19102. * Enables the edge rendering mode on the mesh.
  19103. * This mode makes the mesh edges visible
  19104. * @param epsilon defines the maximal distance between two angles to detect a face
  19105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19106. * @returns the currentAbstractMesh
  19107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19108. */
  19109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19110. }
  19111. interface InstancedLinesMesh {
  19112. /**
  19113. * Enables the edge rendering mode on the mesh.
  19114. * This mode makes the mesh edges visible
  19115. * @param epsilon defines the maximal distance between two angles to detect a face
  19116. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19117. * @returns the current InstancedLinesMesh
  19118. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19119. */
  19120. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19121. }
  19122. /**
  19123. * Defines the minimum contract an Edges renderer should follow.
  19124. */
  19125. export interface IEdgesRenderer extends IDisposable {
  19126. /**
  19127. * Gets or sets a boolean indicating if the edgesRenderer is active
  19128. */
  19129. isEnabled: boolean;
  19130. /**
  19131. * Renders the edges of the attached mesh,
  19132. */
  19133. render(): void;
  19134. /**
  19135. * Checks wether or not the edges renderer is ready to render.
  19136. * @return true if ready, otherwise false.
  19137. */
  19138. isReady(): boolean;
  19139. }
  19140. /**
  19141. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19142. */
  19143. export class EdgesRenderer implements IEdgesRenderer {
  19144. /**
  19145. * Define the size of the edges with an orthographic camera
  19146. */
  19147. edgesWidthScalerForOrthographic: number;
  19148. /**
  19149. * Define the size of the edges with a perspective camera
  19150. */
  19151. edgesWidthScalerForPerspective: number;
  19152. protected _source: AbstractMesh;
  19153. protected _linesPositions: number[];
  19154. protected _linesNormals: number[];
  19155. protected _linesIndices: number[];
  19156. protected _epsilon: number;
  19157. protected _indicesCount: number;
  19158. protected _lineShader: ShaderMaterial;
  19159. protected _ib: DataBuffer;
  19160. protected _buffers: {
  19161. [key: string]: Nullable<VertexBuffer>;
  19162. };
  19163. protected _checkVerticesInsteadOfIndices: boolean;
  19164. private _meshRebuildObserver;
  19165. private _meshDisposeObserver;
  19166. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19167. isEnabled: boolean;
  19168. /**
  19169. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19170. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19171. * @param source Mesh used to create edges
  19172. * @param epsilon sum of angles in adjacency to check for edge
  19173. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19174. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19175. */
  19176. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19177. protected _prepareRessources(): void;
  19178. /** @hidden */
  19179. _rebuild(): void;
  19180. /**
  19181. * Releases the required resources for the edges renderer
  19182. */
  19183. dispose(): void;
  19184. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19185. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19186. /**
  19187. * Checks if the pair of p0 and p1 is en edge
  19188. * @param faceIndex
  19189. * @param edge
  19190. * @param faceNormals
  19191. * @param p0
  19192. * @param p1
  19193. * @private
  19194. */
  19195. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19196. /**
  19197. * push line into the position, normal and index buffer
  19198. * @protected
  19199. */
  19200. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19201. /**
  19202. * Generates lines edges from adjacencjes
  19203. * @private
  19204. */
  19205. _generateEdgesLines(): void;
  19206. /**
  19207. * Checks wether or not the edges renderer is ready to render.
  19208. * @return true if ready, otherwise false.
  19209. */
  19210. isReady(): boolean;
  19211. /**
  19212. * Renders the edges of the attached mesh,
  19213. */
  19214. render(): void;
  19215. }
  19216. /**
  19217. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19218. */
  19219. export class LineEdgesRenderer extends EdgesRenderer {
  19220. /**
  19221. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19222. * @param source LineMesh used to generate edges
  19223. * @param epsilon not important (specified angle for edge detection)
  19224. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19225. */
  19226. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19227. /**
  19228. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19229. */
  19230. _generateEdgesLines(): void;
  19231. }
  19232. }
  19233. declare module BABYLON {
  19234. /**
  19235. * This represents the object necessary to create a rendering group.
  19236. * This is exclusively used and created by the rendering manager.
  19237. * To modify the behavior, you use the available helpers in your scene or meshes.
  19238. * @hidden
  19239. */
  19240. export class RenderingGroup {
  19241. index: number;
  19242. private static _zeroVector;
  19243. private _scene;
  19244. private _opaqueSubMeshes;
  19245. private _transparentSubMeshes;
  19246. private _alphaTestSubMeshes;
  19247. private _depthOnlySubMeshes;
  19248. private _particleSystems;
  19249. private _spriteManagers;
  19250. private _opaqueSortCompareFn;
  19251. private _alphaTestSortCompareFn;
  19252. private _transparentSortCompareFn;
  19253. private _renderOpaque;
  19254. private _renderAlphaTest;
  19255. private _renderTransparent;
  19256. /** @hidden */
  19257. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19258. onBeforeTransparentRendering: () => void;
  19259. /**
  19260. * Set the opaque sort comparison function.
  19261. * If null the sub meshes will be render in the order they were created
  19262. */
  19263. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19264. /**
  19265. * Set the alpha test sort comparison function.
  19266. * If null the sub meshes will be render in the order they were created
  19267. */
  19268. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19269. /**
  19270. * Set the transparent sort comparison function.
  19271. * If null the sub meshes will be render in the order they were created
  19272. */
  19273. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19274. /**
  19275. * Creates a new rendering group.
  19276. * @param index The rendering group index
  19277. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19278. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19279. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19280. */
  19281. 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>);
  19282. /**
  19283. * Render all the sub meshes contained in the group.
  19284. * @param customRenderFunction Used to override the default render behaviour of the group.
  19285. * @returns true if rendered some submeshes.
  19286. */
  19287. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19288. /**
  19289. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19290. * @param subMeshes The submeshes to render
  19291. */
  19292. private renderOpaqueSorted;
  19293. /**
  19294. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19295. * @param subMeshes The submeshes to render
  19296. */
  19297. private renderAlphaTestSorted;
  19298. /**
  19299. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19300. * @param subMeshes The submeshes to render
  19301. */
  19302. private renderTransparentSorted;
  19303. /**
  19304. * Renders the submeshes in a specified order.
  19305. * @param subMeshes The submeshes to sort before render
  19306. * @param sortCompareFn The comparison function use to sort
  19307. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19308. * @param transparent Specifies to activate blending if true
  19309. */
  19310. private static renderSorted;
  19311. /**
  19312. * Renders the submeshes in the order they were dispatched (no sort applied).
  19313. * @param subMeshes The submeshes to render
  19314. */
  19315. private static renderUnsorted;
  19316. /**
  19317. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19318. * are rendered back to front if in the same alpha index.
  19319. *
  19320. * @param a The first submesh
  19321. * @param b The second submesh
  19322. * @returns The result of the comparison
  19323. */
  19324. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19325. /**
  19326. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19327. * are rendered back to front.
  19328. *
  19329. * @param a The first submesh
  19330. * @param b The second submesh
  19331. * @returns The result of the comparison
  19332. */
  19333. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19334. /**
  19335. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19336. * are rendered front to back (prevent overdraw).
  19337. *
  19338. * @param a The first submesh
  19339. * @param b The second submesh
  19340. * @returns The result of the comparison
  19341. */
  19342. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19343. /**
  19344. * Resets the different lists of submeshes to prepare a new frame.
  19345. */
  19346. prepare(): void;
  19347. dispose(): void;
  19348. /**
  19349. * Inserts the submesh in its correct queue depending on its material.
  19350. * @param subMesh The submesh to dispatch
  19351. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19352. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19353. */
  19354. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19355. dispatchSprites(spriteManager: ISpriteManager): void;
  19356. dispatchParticles(particleSystem: IParticleSystem): void;
  19357. private _renderParticles;
  19358. private _renderSprites;
  19359. }
  19360. }
  19361. declare module BABYLON {
  19362. /**
  19363. * Interface describing the different options available in the rendering manager
  19364. * regarding Auto Clear between groups.
  19365. */
  19366. export interface IRenderingManagerAutoClearSetup {
  19367. /**
  19368. * Defines whether or not autoclear is enable.
  19369. */
  19370. autoClear: boolean;
  19371. /**
  19372. * Defines whether or not to autoclear the depth buffer.
  19373. */
  19374. depth: boolean;
  19375. /**
  19376. * Defines whether or not to autoclear the stencil buffer.
  19377. */
  19378. stencil: boolean;
  19379. }
  19380. /**
  19381. * This class is used by the onRenderingGroupObservable
  19382. */
  19383. export class RenderingGroupInfo {
  19384. /**
  19385. * The Scene that being rendered
  19386. */
  19387. scene: Scene;
  19388. /**
  19389. * The camera currently used for the rendering pass
  19390. */
  19391. camera: Nullable<Camera>;
  19392. /**
  19393. * The ID of the renderingGroup being processed
  19394. */
  19395. renderingGroupId: number;
  19396. }
  19397. /**
  19398. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19399. * It is enable to manage the different groups as well as the different necessary sort functions.
  19400. * This should not be used directly aside of the few static configurations
  19401. */
  19402. export class RenderingManager {
  19403. /**
  19404. * The max id used for rendering groups (not included)
  19405. */
  19406. static MAX_RENDERINGGROUPS: number;
  19407. /**
  19408. * The min id used for rendering groups (included)
  19409. */
  19410. static MIN_RENDERINGGROUPS: number;
  19411. /**
  19412. * Used to globally prevent autoclearing scenes.
  19413. */
  19414. static AUTOCLEAR: boolean;
  19415. /**
  19416. * @hidden
  19417. */
  19418. _useSceneAutoClearSetup: boolean;
  19419. private _scene;
  19420. private _renderingGroups;
  19421. private _depthStencilBufferAlreadyCleaned;
  19422. private _autoClearDepthStencil;
  19423. private _customOpaqueSortCompareFn;
  19424. private _customAlphaTestSortCompareFn;
  19425. private _customTransparentSortCompareFn;
  19426. private _renderingGroupInfo;
  19427. /**
  19428. * Instantiates a new rendering group for a particular scene
  19429. * @param scene Defines the scene the groups belongs to
  19430. */
  19431. constructor(scene: Scene);
  19432. private _clearDepthStencilBuffer;
  19433. /**
  19434. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19435. * @hidden
  19436. */
  19437. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19438. /**
  19439. * Resets the different information of the group to prepare a new frame
  19440. * @hidden
  19441. */
  19442. reset(): void;
  19443. /**
  19444. * Dispose and release the group and its associated resources.
  19445. * @hidden
  19446. */
  19447. dispose(): void;
  19448. /**
  19449. * Clear the info related to rendering groups preventing retention points during dispose.
  19450. */
  19451. freeRenderingGroups(): void;
  19452. private _prepareRenderingGroup;
  19453. /**
  19454. * Add a sprite manager to the rendering manager in order to render it this frame.
  19455. * @param spriteManager Define the sprite manager to render
  19456. */
  19457. dispatchSprites(spriteManager: ISpriteManager): void;
  19458. /**
  19459. * Add a particle system to the rendering manager in order to render it this frame.
  19460. * @param particleSystem Define the particle system to render
  19461. */
  19462. dispatchParticles(particleSystem: IParticleSystem): void;
  19463. /**
  19464. * Add a submesh to the manager in order to render it this frame
  19465. * @param subMesh The submesh to dispatch
  19466. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19467. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19468. */
  19469. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19470. /**
  19471. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19472. * This allowed control for front to back rendering or reversly depending of the special needs.
  19473. *
  19474. * @param renderingGroupId The rendering group id corresponding to its index
  19475. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19476. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19477. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19478. */
  19479. 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;
  19480. /**
  19481. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19482. *
  19483. * @param renderingGroupId The rendering group id corresponding to its index
  19484. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19485. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19486. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19487. */
  19488. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19489. /**
  19490. * Gets the current auto clear configuration for one rendering group of the rendering
  19491. * manager.
  19492. * @param index the rendering group index to get the information for
  19493. * @returns The auto clear setup for the requested rendering group
  19494. */
  19495. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19496. }
  19497. }
  19498. declare module BABYLON {
  19499. /**
  19500. * This Helps creating a texture that will be created from a camera in your scene.
  19501. * It is basically a dynamic texture that could be used to create special effects for instance.
  19502. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19503. */
  19504. export class RenderTargetTexture extends Texture {
  19505. isCube: boolean;
  19506. /**
  19507. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19508. */
  19509. static readonly REFRESHRATE_RENDER_ONCE: number;
  19510. /**
  19511. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19512. */
  19513. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19514. /**
  19515. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19516. * the central point of your effect and can save a lot of performances.
  19517. */
  19518. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19519. /**
  19520. * Use this predicate to dynamically define the list of mesh you want to render.
  19521. * If set, the renderList property will be overwritten.
  19522. */
  19523. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19524. private _renderList;
  19525. /**
  19526. * Use this list to define the list of mesh you want to render.
  19527. */
  19528. renderList: Nullable<Array<AbstractMesh>>;
  19529. private _hookArray;
  19530. /**
  19531. * Define if particles should be rendered in your texture.
  19532. */
  19533. renderParticles: boolean;
  19534. /**
  19535. * Define if sprites should be rendered in your texture.
  19536. */
  19537. renderSprites: boolean;
  19538. /**
  19539. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19540. */
  19541. coordinatesMode: number;
  19542. /**
  19543. * Define the camera used to render the texture.
  19544. */
  19545. activeCamera: Nullable<Camera>;
  19546. /**
  19547. * Override the render function of the texture with your own one.
  19548. */
  19549. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19550. /**
  19551. * Define if camera post processes should be use while rendering the texture.
  19552. */
  19553. useCameraPostProcesses: boolean;
  19554. /**
  19555. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19556. */
  19557. ignoreCameraViewport: boolean;
  19558. private _postProcessManager;
  19559. private _postProcesses;
  19560. private _resizeObserver;
  19561. /**
  19562. * An event triggered when the texture is unbind.
  19563. */
  19564. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19565. /**
  19566. * An event triggered when the texture is unbind.
  19567. */
  19568. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19569. private _onAfterUnbindObserver;
  19570. /**
  19571. * Set a after unbind callback in the texture.
  19572. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19573. */
  19574. onAfterUnbind: () => void;
  19575. /**
  19576. * An event triggered before rendering the texture
  19577. */
  19578. onBeforeRenderObservable: Observable<number>;
  19579. private _onBeforeRenderObserver;
  19580. /**
  19581. * Set a before render callback in the texture.
  19582. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19583. */
  19584. onBeforeRender: (faceIndex: number) => void;
  19585. /**
  19586. * An event triggered after rendering the texture
  19587. */
  19588. onAfterRenderObservable: Observable<number>;
  19589. private _onAfterRenderObserver;
  19590. /**
  19591. * Set a after render callback in the texture.
  19592. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19593. */
  19594. onAfterRender: (faceIndex: number) => void;
  19595. /**
  19596. * An event triggered after the texture clear
  19597. */
  19598. onClearObservable: Observable<Engine>;
  19599. private _onClearObserver;
  19600. /**
  19601. * Set a clear callback in the texture.
  19602. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19603. */
  19604. onClear: (Engine: Engine) => void;
  19605. /**
  19606. * Define the clear color of the Render Target if it should be different from the scene.
  19607. */
  19608. clearColor: Color4;
  19609. protected _size: number | {
  19610. width: number;
  19611. height: number;
  19612. };
  19613. protected _initialSizeParameter: number | {
  19614. width: number;
  19615. height: number;
  19616. } | {
  19617. ratio: number;
  19618. };
  19619. protected _sizeRatio: Nullable<number>;
  19620. /** @hidden */
  19621. _generateMipMaps: boolean;
  19622. protected _renderingManager: RenderingManager;
  19623. /** @hidden */
  19624. _waitingRenderList: string[];
  19625. protected _doNotChangeAspectRatio: boolean;
  19626. protected _currentRefreshId: number;
  19627. protected _refreshRate: number;
  19628. protected _textureMatrix: Matrix;
  19629. protected _samples: number;
  19630. protected _renderTargetOptions: RenderTargetCreationOptions;
  19631. /**
  19632. * Gets render target creation options that were used.
  19633. */
  19634. readonly renderTargetOptions: RenderTargetCreationOptions;
  19635. protected _engine: Engine;
  19636. protected _onRatioRescale(): void;
  19637. /**
  19638. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19639. * It must define where the camera used to render the texture is set
  19640. */
  19641. boundingBoxPosition: Vector3;
  19642. private _boundingBoxSize;
  19643. /**
  19644. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19645. * When defined, the cubemap will switch to local mode
  19646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19647. * @example https://www.babylonjs-playground.com/#RNASML
  19648. */
  19649. boundingBoxSize: Vector3;
  19650. /**
  19651. * In case the RTT has been created with a depth texture, get the associated
  19652. * depth texture.
  19653. * Otherwise, return null.
  19654. */
  19655. depthStencilTexture: Nullable<InternalTexture>;
  19656. /**
  19657. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19658. * or used a shadow, depth texture...
  19659. * @param name The friendly name of the texture
  19660. * @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)
  19661. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19662. * @param generateMipMaps True if mip maps need to be generated after render.
  19663. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19664. * @param type The type of the buffer in the RTT (int, half float, float...)
  19665. * @param isCube True if a cube texture needs to be created
  19666. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19667. * @param generateDepthBuffer True to generate a depth buffer
  19668. * @param generateStencilBuffer True to generate a stencil buffer
  19669. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19670. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19671. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19672. */
  19673. constructor(name: string, size: number | {
  19674. width: number;
  19675. height: number;
  19676. } | {
  19677. ratio: number;
  19678. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19679. /**
  19680. * Creates a depth stencil texture.
  19681. * This is only available in WebGL 2 or with the depth texture extension available.
  19682. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19683. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19684. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19685. */
  19686. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19687. private _processSizeParameter;
  19688. /**
  19689. * Define the number of samples to use in case of MSAA.
  19690. * It defaults to one meaning no MSAA has been enabled.
  19691. */
  19692. samples: number;
  19693. /**
  19694. * Resets the refresh counter of the texture and start bak from scratch.
  19695. * Could be useful to regenerate the texture if it is setup to render only once.
  19696. */
  19697. resetRefreshCounter(): void;
  19698. /**
  19699. * Define the refresh rate of the texture or the rendering frequency.
  19700. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19701. */
  19702. refreshRate: number;
  19703. /**
  19704. * Adds a post process to the render target rendering passes.
  19705. * @param postProcess define the post process to add
  19706. */
  19707. addPostProcess(postProcess: PostProcess): void;
  19708. /**
  19709. * Clear all the post processes attached to the render target
  19710. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19711. */
  19712. clearPostProcesses(dispose?: boolean): void;
  19713. /**
  19714. * Remove one of the post process from the list of attached post processes to the texture
  19715. * @param postProcess define the post process to remove from the list
  19716. */
  19717. removePostProcess(postProcess: PostProcess): void;
  19718. /** @hidden */
  19719. _shouldRender(): boolean;
  19720. /**
  19721. * Gets the actual render size of the texture.
  19722. * @returns the width of the render size
  19723. */
  19724. getRenderSize(): number;
  19725. /**
  19726. * Gets the actual render width of the texture.
  19727. * @returns the width of the render size
  19728. */
  19729. getRenderWidth(): number;
  19730. /**
  19731. * Gets the actual render height of the texture.
  19732. * @returns the height of the render size
  19733. */
  19734. getRenderHeight(): number;
  19735. /**
  19736. * Get if the texture can be rescaled or not.
  19737. */
  19738. readonly canRescale: boolean;
  19739. /**
  19740. * Resize the texture using a ratio.
  19741. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19742. */
  19743. scale(ratio: number): void;
  19744. /**
  19745. * Get the texture reflection matrix used to rotate/transform the reflection.
  19746. * @returns the reflection matrix
  19747. */
  19748. getReflectionTextureMatrix(): Matrix;
  19749. /**
  19750. * Resize the texture to a new desired size.
  19751. * Be carrefull as it will recreate all the data in the new texture.
  19752. * @param size Define the new size. It can be:
  19753. * - a number for squared texture,
  19754. * - an object containing { width: number, height: number }
  19755. * - or an object containing a ratio { ratio: number }
  19756. */
  19757. resize(size: number | {
  19758. width: number;
  19759. height: number;
  19760. } | {
  19761. ratio: number;
  19762. }): void;
  19763. /**
  19764. * Renders all the objects from the render list into the texture.
  19765. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19766. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19767. */
  19768. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19769. private _bestReflectionRenderTargetDimension;
  19770. /**
  19771. * @hidden
  19772. * @param faceIndex face index to bind to if this is a cubetexture
  19773. */
  19774. _bindFrameBuffer(faceIndex?: number): void;
  19775. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19776. private renderToTarget;
  19777. /**
  19778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19779. * This allowed control for front to back rendering or reversly depending of the special needs.
  19780. *
  19781. * @param renderingGroupId The rendering group id corresponding to its index
  19782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19785. */
  19786. 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;
  19787. /**
  19788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19789. *
  19790. * @param renderingGroupId The rendering group id corresponding to its index
  19791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19792. */
  19793. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19794. /**
  19795. * Clones the texture.
  19796. * @returns the cloned texture
  19797. */
  19798. clone(): RenderTargetTexture;
  19799. /**
  19800. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19801. * @returns The JSON representation of the texture
  19802. */
  19803. serialize(): any;
  19804. /**
  19805. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19806. */
  19807. disposeFramebufferObjects(): void;
  19808. /**
  19809. * Dispose the texture and release its associated resources.
  19810. */
  19811. dispose(): void;
  19812. /** @hidden */
  19813. _rebuild(): void;
  19814. /**
  19815. * Clear the info related to rendering groups preventing retention point in material dispose.
  19816. */
  19817. freeRenderingGroups(): void;
  19818. /**
  19819. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19820. * @returns the view count
  19821. */
  19822. getViewCount(): number;
  19823. }
  19824. }
  19825. declare module BABYLON {
  19826. /**
  19827. * Base class for the main features of a material in Babylon.js
  19828. */
  19829. export class Material implements IAnimatable {
  19830. /**
  19831. * Returns the triangle fill mode
  19832. */
  19833. static readonly TriangleFillMode: number;
  19834. /**
  19835. * Returns the wireframe mode
  19836. */
  19837. static readonly WireFrameFillMode: number;
  19838. /**
  19839. * Returns the point fill mode
  19840. */
  19841. static readonly PointFillMode: number;
  19842. /**
  19843. * Returns the point list draw mode
  19844. */
  19845. static readonly PointListDrawMode: number;
  19846. /**
  19847. * Returns the line list draw mode
  19848. */
  19849. static readonly LineListDrawMode: number;
  19850. /**
  19851. * Returns the line loop draw mode
  19852. */
  19853. static readonly LineLoopDrawMode: number;
  19854. /**
  19855. * Returns the line strip draw mode
  19856. */
  19857. static readonly LineStripDrawMode: number;
  19858. /**
  19859. * Returns the triangle strip draw mode
  19860. */
  19861. static readonly TriangleStripDrawMode: number;
  19862. /**
  19863. * Returns the triangle fan draw mode
  19864. */
  19865. static readonly TriangleFanDrawMode: number;
  19866. /**
  19867. * Stores the clock-wise side orientation
  19868. */
  19869. static readonly ClockWiseSideOrientation: number;
  19870. /**
  19871. * Stores the counter clock-wise side orientation
  19872. */
  19873. static readonly CounterClockWiseSideOrientation: number;
  19874. /**
  19875. * The dirty texture flag value
  19876. */
  19877. static readonly TextureDirtyFlag: number;
  19878. /**
  19879. * The dirty light flag value
  19880. */
  19881. static readonly LightDirtyFlag: number;
  19882. /**
  19883. * The dirty fresnel flag value
  19884. */
  19885. static readonly FresnelDirtyFlag: number;
  19886. /**
  19887. * The dirty attribute flag value
  19888. */
  19889. static readonly AttributesDirtyFlag: number;
  19890. /**
  19891. * The dirty misc flag value
  19892. */
  19893. static readonly MiscDirtyFlag: number;
  19894. /**
  19895. * The all dirty flag value
  19896. */
  19897. static readonly AllDirtyFlag: number;
  19898. /**
  19899. * The ID of the material
  19900. */
  19901. id: string;
  19902. /**
  19903. * Gets or sets the unique id of the material
  19904. */
  19905. uniqueId: number;
  19906. /**
  19907. * The name of the material
  19908. */
  19909. name: string;
  19910. /**
  19911. * Gets or sets user defined metadata
  19912. */
  19913. metadata: any;
  19914. /**
  19915. * For internal use only. Please do not use.
  19916. */
  19917. reservedDataStore: any;
  19918. /**
  19919. * Specifies if the ready state should be checked on each call
  19920. */
  19921. checkReadyOnEveryCall: boolean;
  19922. /**
  19923. * Specifies if the ready state should be checked once
  19924. */
  19925. checkReadyOnlyOnce: boolean;
  19926. /**
  19927. * The state of the material
  19928. */
  19929. state: string;
  19930. /**
  19931. * The alpha value of the material
  19932. */
  19933. protected _alpha: number;
  19934. /**
  19935. * List of inspectable custom properties (used by the Inspector)
  19936. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19937. */
  19938. inspectableCustomProperties: IInspectable[];
  19939. /**
  19940. * Sets the alpha value of the material
  19941. */
  19942. /**
  19943. * Gets the alpha value of the material
  19944. */
  19945. alpha: number;
  19946. /**
  19947. * Specifies if back face culling is enabled
  19948. */
  19949. protected _backFaceCulling: boolean;
  19950. /**
  19951. * Sets the back-face culling state
  19952. */
  19953. /**
  19954. * Gets the back-face culling state
  19955. */
  19956. backFaceCulling: boolean;
  19957. /**
  19958. * Stores the value for side orientation
  19959. */
  19960. sideOrientation: number;
  19961. /**
  19962. * Callback triggered when the material is compiled
  19963. */
  19964. onCompiled: Nullable<(effect: Effect) => void>;
  19965. /**
  19966. * Callback triggered when an error occurs
  19967. */
  19968. onError: Nullable<(effect: Effect, errors: string) => void>;
  19969. /**
  19970. * Callback triggered to get the render target textures
  19971. */
  19972. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19973. /**
  19974. * Gets a boolean indicating that current material needs to register RTT
  19975. */
  19976. readonly hasRenderTargetTextures: boolean;
  19977. /**
  19978. * Specifies if the material should be serialized
  19979. */
  19980. doNotSerialize: boolean;
  19981. /**
  19982. * @hidden
  19983. */
  19984. _storeEffectOnSubMeshes: boolean;
  19985. /**
  19986. * Stores the animations for the material
  19987. */
  19988. animations: Nullable<Array<Animation>>;
  19989. /**
  19990. * An event triggered when the material is disposed
  19991. */
  19992. onDisposeObservable: Observable<Material>;
  19993. /**
  19994. * An observer which watches for dispose events
  19995. */
  19996. private _onDisposeObserver;
  19997. private _onUnBindObservable;
  19998. /**
  19999. * Called during a dispose event
  20000. */
  20001. onDispose: () => void;
  20002. private _onBindObservable;
  20003. /**
  20004. * An event triggered when the material is bound
  20005. */
  20006. readonly onBindObservable: Observable<AbstractMesh>;
  20007. /**
  20008. * An observer which watches for bind events
  20009. */
  20010. private _onBindObserver;
  20011. /**
  20012. * Called during a bind event
  20013. */
  20014. onBind: (Mesh: AbstractMesh) => void;
  20015. /**
  20016. * An event triggered when the material is unbound
  20017. */
  20018. readonly onUnBindObservable: Observable<Material>;
  20019. /**
  20020. * Stores the value of the alpha mode
  20021. */
  20022. private _alphaMode;
  20023. /**
  20024. * Sets the value of the alpha mode.
  20025. *
  20026. * | Value | Type | Description |
  20027. * | --- | --- | --- |
  20028. * | 0 | ALPHA_DISABLE | |
  20029. * | 1 | ALPHA_ADD | |
  20030. * | 2 | ALPHA_COMBINE | |
  20031. * | 3 | ALPHA_SUBTRACT | |
  20032. * | 4 | ALPHA_MULTIPLY | |
  20033. * | 5 | ALPHA_MAXIMIZED | |
  20034. * | 6 | ALPHA_ONEONE | |
  20035. * | 7 | ALPHA_PREMULTIPLIED | |
  20036. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20037. * | 9 | ALPHA_INTERPOLATE | |
  20038. * | 10 | ALPHA_SCREENMODE | |
  20039. *
  20040. */
  20041. /**
  20042. * Gets the value of the alpha mode
  20043. */
  20044. alphaMode: number;
  20045. /**
  20046. * Stores the state of the need depth pre-pass value
  20047. */
  20048. private _needDepthPrePass;
  20049. /**
  20050. * Sets the need depth pre-pass value
  20051. */
  20052. /**
  20053. * Gets the depth pre-pass value
  20054. */
  20055. needDepthPrePass: boolean;
  20056. /**
  20057. * Specifies if depth writing should be disabled
  20058. */
  20059. disableDepthWrite: boolean;
  20060. /**
  20061. * Specifies if depth writing should be forced
  20062. */
  20063. forceDepthWrite: boolean;
  20064. /**
  20065. * Specifies if there should be a separate pass for culling
  20066. */
  20067. separateCullingPass: boolean;
  20068. /**
  20069. * Stores the state specifing if fog should be enabled
  20070. */
  20071. private _fogEnabled;
  20072. /**
  20073. * Sets the state for enabling fog
  20074. */
  20075. /**
  20076. * Gets the value of the fog enabled state
  20077. */
  20078. fogEnabled: boolean;
  20079. /**
  20080. * Stores the size of points
  20081. */
  20082. pointSize: number;
  20083. /**
  20084. * Stores the z offset value
  20085. */
  20086. zOffset: number;
  20087. /**
  20088. * Gets a value specifying if wireframe mode is enabled
  20089. */
  20090. /**
  20091. * Sets the state of wireframe mode
  20092. */
  20093. wireframe: boolean;
  20094. /**
  20095. * Gets the value specifying if point clouds are enabled
  20096. */
  20097. /**
  20098. * Sets the state of point cloud mode
  20099. */
  20100. pointsCloud: boolean;
  20101. /**
  20102. * Gets the material fill mode
  20103. */
  20104. /**
  20105. * Sets the material fill mode
  20106. */
  20107. fillMode: number;
  20108. /**
  20109. * @hidden
  20110. * Stores the effects for the material
  20111. */
  20112. _effect: Nullable<Effect>;
  20113. /**
  20114. * @hidden
  20115. * Specifies if the material was previously ready
  20116. */
  20117. _wasPreviouslyReady: boolean;
  20118. /**
  20119. * Specifies if uniform buffers should be used
  20120. */
  20121. private _useUBO;
  20122. /**
  20123. * Stores a reference to the scene
  20124. */
  20125. private _scene;
  20126. /**
  20127. * Stores the fill mode state
  20128. */
  20129. private _fillMode;
  20130. /**
  20131. * Specifies if the depth write state should be cached
  20132. */
  20133. private _cachedDepthWriteState;
  20134. /**
  20135. * Stores the uniform buffer
  20136. */
  20137. protected _uniformBuffer: UniformBuffer;
  20138. /** @hidden */
  20139. _indexInSceneMaterialArray: number;
  20140. /** @hidden */
  20141. meshMap: Nullable<{
  20142. [id: string]: AbstractMesh | undefined;
  20143. }>;
  20144. /**
  20145. * Creates a material instance
  20146. * @param name defines the name of the material
  20147. * @param scene defines the scene to reference
  20148. * @param doNotAdd specifies if the material should be added to the scene
  20149. */
  20150. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20151. /**
  20152. * Returns a string representation of the current material
  20153. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20154. * @returns a string with material information
  20155. */
  20156. toString(fullDetails?: boolean): string;
  20157. /**
  20158. * Gets the class name of the material
  20159. * @returns a string with the class name of the material
  20160. */
  20161. getClassName(): string;
  20162. /**
  20163. * Specifies if updates for the material been locked
  20164. */
  20165. readonly isFrozen: boolean;
  20166. /**
  20167. * Locks updates for the material
  20168. */
  20169. freeze(): void;
  20170. /**
  20171. * Unlocks updates for the material
  20172. */
  20173. unfreeze(): void;
  20174. /**
  20175. * Specifies if the material is ready to be used
  20176. * @param mesh defines the mesh to check
  20177. * @param useInstances specifies if instances should be used
  20178. * @returns a boolean indicating if the material is ready to be used
  20179. */
  20180. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20181. /**
  20182. * Specifies that the submesh is ready to be used
  20183. * @param mesh defines the mesh to check
  20184. * @param subMesh defines which submesh to check
  20185. * @param useInstances specifies that instances should be used
  20186. * @returns a boolean indicating that the submesh is ready or not
  20187. */
  20188. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20189. /**
  20190. * Returns the material effect
  20191. * @returns the effect associated with the material
  20192. */
  20193. getEffect(): Nullable<Effect>;
  20194. /**
  20195. * Returns the current scene
  20196. * @returns a Scene
  20197. */
  20198. getScene(): Scene;
  20199. /**
  20200. * Specifies if the material will require alpha blending
  20201. * @returns a boolean specifying if alpha blending is needed
  20202. */
  20203. needAlphaBlending(): boolean;
  20204. /**
  20205. * Specifies if the mesh will require alpha blending
  20206. * @param mesh defines the mesh to check
  20207. * @returns a boolean specifying if alpha blending is needed for the mesh
  20208. */
  20209. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20210. /**
  20211. * Specifies if this material should be rendered in alpha test mode
  20212. * @returns a boolean specifying if an alpha test is needed.
  20213. */
  20214. needAlphaTesting(): boolean;
  20215. /**
  20216. * Gets the texture used for the alpha test
  20217. * @returns the texture to use for alpha testing
  20218. */
  20219. getAlphaTestTexture(): Nullable<BaseTexture>;
  20220. /**
  20221. * Marks the material to indicate that it needs to be re-calculated
  20222. */
  20223. markDirty(): void;
  20224. /** @hidden */
  20225. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20226. /**
  20227. * Binds the material to the mesh
  20228. * @param world defines the world transformation matrix
  20229. * @param mesh defines the mesh to bind the material to
  20230. */
  20231. bind(world: Matrix, mesh?: Mesh): void;
  20232. /**
  20233. * Binds the submesh to the material
  20234. * @param world defines the world transformation matrix
  20235. * @param mesh defines the mesh containing the submesh
  20236. * @param subMesh defines the submesh to bind the material to
  20237. */
  20238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20239. /**
  20240. * Binds the world matrix to the material
  20241. * @param world defines the world transformation matrix
  20242. */
  20243. bindOnlyWorldMatrix(world: Matrix): void;
  20244. /**
  20245. * Binds the scene's uniform buffer to the effect.
  20246. * @param effect defines the effect to bind to the scene uniform buffer
  20247. * @param sceneUbo defines the uniform buffer storing scene data
  20248. */
  20249. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20250. /**
  20251. * Binds the view matrix to the effect
  20252. * @param effect defines the effect to bind the view matrix to
  20253. */
  20254. bindView(effect: Effect): void;
  20255. /**
  20256. * Binds the view projection matrix to the effect
  20257. * @param effect defines the effect to bind the view projection matrix to
  20258. */
  20259. bindViewProjection(effect: Effect): void;
  20260. /**
  20261. * Specifies if material alpha testing should be turned on for the mesh
  20262. * @param mesh defines the mesh to check
  20263. */
  20264. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20265. /**
  20266. * Processes to execute after binding the material to a mesh
  20267. * @param mesh defines the rendered mesh
  20268. */
  20269. protected _afterBind(mesh?: Mesh): void;
  20270. /**
  20271. * Unbinds the material from the mesh
  20272. */
  20273. unbind(): void;
  20274. /**
  20275. * Gets the active textures from the material
  20276. * @returns an array of textures
  20277. */
  20278. getActiveTextures(): BaseTexture[];
  20279. /**
  20280. * Specifies if the material uses a texture
  20281. * @param texture defines the texture to check against the material
  20282. * @returns a boolean specifying if the material uses the texture
  20283. */
  20284. hasTexture(texture: BaseTexture): boolean;
  20285. /**
  20286. * Makes a duplicate of the material, and gives it a new name
  20287. * @param name defines the new name for the duplicated material
  20288. * @returns the cloned material
  20289. */
  20290. clone(name: string): Nullable<Material>;
  20291. /**
  20292. * Gets the meshes bound to the material
  20293. * @returns an array of meshes bound to the material
  20294. */
  20295. getBindedMeshes(): AbstractMesh[];
  20296. /**
  20297. * Force shader compilation
  20298. * @param mesh defines the mesh associated with this material
  20299. * @param onCompiled defines a function to execute once the material is compiled
  20300. * @param options defines the options to configure the compilation
  20301. */
  20302. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20303. clipPlane: boolean;
  20304. }>): void;
  20305. /**
  20306. * Force shader compilation
  20307. * @param mesh defines the mesh that will use this material
  20308. * @param options defines additional options for compiling the shaders
  20309. * @returns a promise that resolves when the compilation completes
  20310. */
  20311. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20312. clipPlane: boolean;
  20313. }>): Promise<void>;
  20314. private static readonly _AllDirtyCallBack;
  20315. private static readonly _ImageProcessingDirtyCallBack;
  20316. private static readonly _TextureDirtyCallBack;
  20317. private static readonly _FresnelDirtyCallBack;
  20318. private static readonly _MiscDirtyCallBack;
  20319. private static readonly _LightsDirtyCallBack;
  20320. private static readonly _AttributeDirtyCallBack;
  20321. private static _FresnelAndMiscDirtyCallBack;
  20322. private static _TextureAndMiscDirtyCallBack;
  20323. private static readonly _DirtyCallbackArray;
  20324. private static readonly _RunDirtyCallBacks;
  20325. /**
  20326. * Marks a define in the material to indicate that it needs to be re-computed
  20327. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20328. */
  20329. markAsDirty(flag: number): void;
  20330. /**
  20331. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20332. * @param func defines a function which checks material defines against the submeshes
  20333. */
  20334. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20335. /**
  20336. * Indicates that we need to re-calculated for all submeshes
  20337. */
  20338. protected _markAllSubMeshesAsAllDirty(): void;
  20339. /**
  20340. * Indicates that image processing needs to be re-calculated for all submeshes
  20341. */
  20342. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20343. /**
  20344. * Indicates that textures need to be re-calculated for all submeshes
  20345. */
  20346. protected _markAllSubMeshesAsTexturesDirty(): void;
  20347. /**
  20348. * Indicates that fresnel needs to be re-calculated for all submeshes
  20349. */
  20350. protected _markAllSubMeshesAsFresnelDirty(): void;
  20351. /**
  20352. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20353. */
  20354. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20355. /**
  20356. * Indicates that lights need to be re-calculated for all submeshes
  20357. */
  20358. protected _markAllSubMeshesAsLightsDirty(): void;
  20359. /**
  20360. * Indicates that attributes need to be re-calculated for all submeshes
  20361. */
  20362. protected _markAllSubMeshesAsAttributesDirty(): void;
  20363. /**
  20364. * Indicates that misc needs to be re-calculated for all submeshes
  20365. */
  20366. protected _markAllSubMeshesAsMiscDirty(): void;
  20367. /**
  20368. * Indicates that textures and misc need to be re-calculated for all submeshes
  20369. */
  20370. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20371. /**
  20372. * Disposes the material
  20373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20375. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20376. */
  20377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20378. /** @hidden */
  20379. private releaseVertexArrayObject;
  20380. /**
  20381. * Serializes this material
  20382. * @returns the serialized material object
  20383. */
  20384. serialize(): any;
  20385. /**
  20386. * Creates a material from parsed material data
  20387. * @param parsedMaterial defines parsed material data
  20388. * @param scene defines the hosting scene
  20389. * @param rootUrl defines the root URL to use to load textures
  20390. * @returns a new material
  20391. */
  20392. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20393. }
  20394. }
  20395. declare module BABYLON {
  20396. /**
  20397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20398. * separate meshes. This can be use to improve performances.
  20399. * @see http://doc.babylonjs.com/how_to/multi_materials
  20400. */
  20401. export class MultiMaterial extends Material {
  20402. private _subMaterials;
  20403. /**
  20404. * Gets or Sets the list of Materials used within the multi material.
  20405. * They need to be ordered according to the submeshes order in the associated mesh
  20406. */
  20407. subMaterials: Nullable<Material>[];
  20408. /**
  20409. * Function used to align with Node.getChildren()
  20410. * @returns the list of Materials used within the multi material
  20411. */
  20412. getChildren(): Nullable<Material>[];
  20413. /**
  20414. * Instantiates a new Multi Material
  20415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20416. * separate meshes. This can be use to improve performances.
  20417. * @see http://doc.babylonjs.com/how_to/multi_materials
  20418. * @param name Define the name in the scene
  20419. * @param scene Define the scene the material belongs to
  20420. */
  20421. constructor(name: string, scene: Scene);
  20422. private _hookArray;
  20423. /**
  20424. * Get one of the submaterial by its index in the submaterials array
  20425. * @param index The index to look the sub material at
  20426. * @returns The Material if the index has been defined
  20427. */
  20428. getSubMaterial(index: number): Nullable<Material>;
  20429. /**
  20430. * Get the list of active textures for the whole sub materials list.
  20431. * @returns All the textures that will be used during the rendering
  20432. */
  20433. getActiveTextures(): BaseTexture[];
  20434. /**
  20435. * Gets the current class name of the material e.g. "MultiMaterial"
  20436. * Mainly use in serialization.
  20437. * @returns the class name
  20438. */
  20439. getClassName(): string;
  20440. /**
  20441. * Checks if the material is ready to render the requested sub mesh
  20442. * @param mesh Define the mesh the submesh belongs to
  20443. * @param subMesh Define the sub mesh to look readyness for
  20444. * @param useInstances Define whether or not the material is used with instances
  20445. * @returns true if ready, otherwise false
  20446. */
  20447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20448. /**
  20449. * Clones the current material and its related sub materials
  20450. * @param name Define the name of the newly cloned material
  20451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20452. * @returns the cloned material
  20453. */
  20454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20455. /**
  20456. * Serializes the materials into a JSON representation.
  20457. * @returns the JSON representation
  20458. */
  20459. serialize(): any;
  20460. /**
  20461. * Dispose the material and release its associated resources
  20462. * @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)
  20463. * @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)
  20464. * @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)
  20465. */
  20466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20467. /**
  20468. * Creates a MultiMaterial from parsed MultiMaterial data.
  20469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20470. * @param scene defines the hosting scene
  20471. * @returns a new MultiMaterial
  20472. */
  20473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. /**
  20478. * Base class for submeshes
  20479. */
  20480. export class BaseSubMesh {
  20481. /** @hidden */
  20482. _materialDefines: Nullable<MaterialDefines>;
  20483. /** @hidden */
  20484. _materialEffect: Nullable<Effect>;
  20485. /**
  20486. * Gets associated effect
  20487. */
  20488. readonly effect: Nullable<Effect>;
  20489. /**
  20490. * Sets associated effect (effect used to render this submesh)
  20491. * @param effect defines the effect to associate with
  20492. * @param defines defines the set of defines used to compile this effect
  20493. */
  20494. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20495. }
  20496. /**
  20497. * Defines a subdivision inside a mesh
  20498. */
  20499. export class SubMesh extends BaseSubMesh implements ICullable {
  20500. /** the material index to use */
  20501. materialIndex: number;
  20502. /** vertex index start */
  20503. verticesStart: number;
  20504. /** vertices count */
  20505. verticesCount: number;
  20506. /** index start */
  20507. indexStart: number;
  20508. /** indices count */
  20509. indexCount: number;
  20510. /** @hidden */
  20511. _linesIndexCount: number;
  20512. private _mesh;
  20513. private _renderingMesh;
  20514. private _boundingInfo;
  20515. private _linesIndexBuffer;
  20516. /** @hidden */
  20517. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20518. /** @hidden */
  20519. _trianglePlanes: Plane[];
  20520. /** @hidden */
  20521. _lastColliderTransformMatrix: Nullable<Matrix>;
  20522. /** @hidden */
  20523. _renderId: number;
  20524. /** @hidden */
  20525. _alphaIndex: number;
  20526. /** @hidden */
  20527. _distanceToCamera: number;
  20528. /** @hidden */
  20529. _id: number;
  20530. private _currentMaterial;
  20531. /**
  20532. * Add a new submesh to a mesh
  20533. * @param materialIndex defines the material index to use
  20534. * @param verticesStart defines vertex index start
  20535. * @param verticesCount defines vertices count
  20536. * @param indexStart defines index start
  20537. * @param indexCount defines indices count
  20538. * @param mesh defines the parent mesh
  20539. * @param renderingMesh defines an optional rendering mesh
  20540. * @param createBoundingBox defines if bounding box should be created for this submesh
  20541. * @returns the new submesh
  20542. */
  20543. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20544. /**
  20545. * Creates a new submesh
  20546. * @param materialIndex defines the material index to use
  20547. * @param verticesStart defines vertex index start
  20548. * @param verticesCount defines vertices count
  20549. * @param indexStart defines index start
  20550. * @param indexCount defines indices count
  20551. * @param mesh defines the parent mesh
  20552. * @param renderingMesh defines an optional rendering mesh
  20553. * @param createBoundingBox defines if bounding box should be created for this submesh
  20554. */
  20555. constructor(
  20556. /** the material index to use */
  20557. materialIndex: number,
  20558. /** vertex index start */
  20559. verticesStart: number,
  20560. /** vertices count */
  20561. verticesCount: number,
  20562. /** index start */
  20563. indexStart: number,
  20564. /** indices count */
  20565. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20566. /**
  20567. * Returns true if this submesh covers the entire parent mesh
  20568. * @ignorenaming
  20569. */
  20570. readonly IsGlobal: boolean;
  20571. /**
  20572. * Returns the submesh BoudingInfo object
  20573. * @returns current bounding info (or mesh's one if the submesh is global)
  20574. */
  20575. getBoundingInfo(): BoundingInfo;
  20576. /**
  20577. * Sets the submesh BoundingInfo
  20578. * @param boundingInfo defines the new bounding info to use
  20579. * @returns the SubMesh
  20580. */
  20581. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20582. /**
  20583. * Returns the mesh of the current submesh
  20584. * @return the parent mesh
  20585. */
  20586. getMesh(): AbstractMesh;
  20587. /**
  20588. * Returns the rendering mesh of the submesh
  20589. * @returns the rendering mesh (could be different from parent mesh)
  20590. */
  20591. getRenderingMesh(): Mesh;
  20592. /**
  20593. * Returns the submesh material
  20594. * @returns null or the current material
  20595. */
  20596. getMaterial(): Nullable<Material>;
  20597. /**
  20598. * Sets a new updated BoundingInfo object to the submesh
  20599. * @param data defines an optional position array to use to determine the bounding info
  20600. * @returns the SubMesh
  20601. */
  20602. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20603. /** @hidden */
  20604. _checkCollision(collider: Collider): boolean;
  20605. /**
  20606. * Updates the submesh BoundingInfo
  20607. * @param world defines the world matrix to use to update the bounding info
  20608. * @returns the submesh
  20609. */
  20610. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20611. /**
  20612. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20613. * @param frustumPlanes defines the frustum planes
  20614. * @returns true if the submesh is intersecting with the frustum
  20615. */
  20616. isInFrustum(frustumPlanes: Plane[]): boolean;
  20617. /**
  20618. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20619. * @param frustumPlanes defines the frustum planes
  20620. * @returns true if the submesh is inside the frustum
  20621. */
  20622. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20623. /**
  20624. * Renders the submesh
  20625. * @param enableAlphaMode defines if alpha needs to be used
  20626. * @returns the submesh
  20627. */
  20628. render(enableAlphaMode: boolean): SubMesh;
  20629. /**
  20630. * @hidden
  20631. */
  20632. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20633. /**
  20634. * Checks if the submesh intersects with a ray
  20635. * @param ray defines the ray to test
  20636. * @returns true is the passed ray intersects the submesh bounding box
  20637. */
  20638. canIntersects(ray: Ray): boolean;
  20639. /**
  20640. * Intersects current submesh with a ray
  20641. * @param ray defines the ray to test
  20642. * @param positions defines mesh's positions array
  20643. * @param indices defines mesh's indices array
  20644. * @param fastCheck defines if only bounding info should be used
  20645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20646. * @returns intersection info or null if no intersection
  20647. */
  20648. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20649. /** @hidden */
  20650. private _intersectLines;
  20651. /** @hidden */
  20652. private _intersectUnIndexedLines;
  20653. /** @hidden */
  20654. private _intersectTriangles;
  20655. /** @hidden */
  20656. private _intersectUnIndexedTriangles;
  20657. /** @hidden */
  20658. _rebuild(): void;
  20659. /**
  20660. * Creates a new submesh from the passed mesh
  20661. * @param newMesh defines the new hosting mesh
  20662. * @param newRenderingMesh defines an optional rendering mesh
  20663. * @returns the new submesh
  20664. */
  20665. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20666. /**
  20667. * Release associated resources
  20668. */
  20669. dispose(): void;
  20670. /**
  20671. * Gets the class name
  20672. * @returns the string "SubMesh".
  20673. */
  20674. getClassName(): string;
  20675. /**
  20676. * Creates a new submesh from indices data
  20677. * @param materialIndex the index of the main mesh material
  20678. * @param startIndex the index where to start the copy in the mesh indices array
  20679. * @param indexCount the number of indices to copy then from the startIndex
  20680. * @param mesh the main mesh to create the submesh from
  20681. * @param renderingMesh the optional rendering mesh
  20682. * @returns a new submesh
  20683. */
  20684. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20685. }
  20686. }
  20687. declare module BABYLON {
  20688. /**
  20689. * Class used to represent data loading progression
  20690. */
  20691. export class SceneLoaderFlags {
  20692. private static _ForceFullSceneLoadingForIncremental;
  20693. private static _ShowLoadingScreen;
  20694. private static _CleanBoneMatrixWeights;
  20695. private static _loggingLevel;
  20696. /**
  20697. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20698. */
  20699. static ForceFullSceneLoadingForIncremental: boolean;
  20700. /**
  20701. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20702. */
  20703. static ShowLoadingScreen: boolean;
  20704. /**
  20705. * Defines the current logging level (while loading the scene)
  20706. * @ignorenaming
  20707. */
  20708. static loggingLevel: number;
  20709. /**
  20710. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20711. */
  20712. static CleanBoneMatrixWeights: boolean;
  20713. }
  20714. }
  20715. declare module BABYLON {
  20716. /**
  20717. * Class used to store geometry data (vertex buffers + index buffer)
  20718. */
  20719. export class Geometry implements IGetSetVerticesData {
  20720. /**
  20721. * Gets or sets the ID of the geometry
  20722. */
  20723. id: string;
  20724. /**
  20725. * Gets or sets the unique ID of the geometry
  20726. */
  20727. uniqueId: number;
  20728. /**
  20729. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20730. */
  20731. delayLoadState: number;
  20732. /**
  20733. * Gets the file containing the data to load when running in delay load state
  20734. */
  20735. delayLoadingFile: Nullable<string>;
  20736. /**
  20737. * Callback called when the geometry is updated
  20738. */
  20739. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20740. private _scene;
  20741. private _engine;
  20742. private _meshes;
  20743. private _totalVertices;
  20744. /** @hidden */
  20745. _indices: IndicesArray;
  20746. /** @hidden */
  20747. _vertexBuffers: {
  20748. [key: string]: VertexBuffer;
  20749. };
  20750. private _isDisposed;
  20751. private _extend;
  20752. private _boundingBias;
  20753. /** @hidden */
  20754. _delayInfo: Array<string>;
  20755. private _indexBuffer;
  20756. private _indexBufferIsUpdatable;
  20757. /** @hidden */
  20758. _boundingInfo: Nullable<BoundingInfo>;
  20759. /** @hidden */
  20760. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20761. /** @hidden */
  20762. _softwareSkinningFrameId: number;
  20763. private _vertexArrayObjects;
  20764. private _updatable;
  20765. /** @hidden */
  20766. _positions: Nullable<Vector3[]>;
  20767. /**
  20768. * 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
  20769. */
  20770. /**
  20771. * 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
  20772. */
  20773. boundingBias: Vector2;
  20774. /**
  20775. * Static function used to attach a new empty geometry to a mesh
  20776. * @param mesh defines the mesh to attach the geometry to
  20777. * @returns the new Geometry
  20778. */
  20779. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20780. /**
  20781. * Creates a new geometry
  20782. * @param id defines the unique ID
  20783. * @param scene defines the hosting scene
  20784. * @param vertexData defines the VertexData used to get geometry data
  20785. * @param updatable defines if geometry must be updatable (false by default)
  20786. * @param mesh defines the mesh that will be associated with the geometry
  20787. */
  20788. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20789. /**
  20790. * Gets the current extend of the geometry
  20791. */
  20792. readonly extend: {
  20793. minimum: Vector3;
  20794. maximum: Vector3;
  20795. };
  20796. /**
  20797. * Gets the hosting scene
  20798. * @returns the hosting Scene
  20799. */
  20800. getScene(): Scene;
  20801. /**
  20802. * Gets the hosting engine
  20803. * @returns the hosting Engine
  20804. */
  20805. getEngine(): Engine;
  20806. /**
  20807. * Defines if the geometry is ready to use
  20808. * @returns true if the geometry is ready to be used
  20809. */
  20810. isReady(): boolean;
  20811. /**
  20812. * Gets a value indicating that the geometry should not be serialized
  20813. */
  20814. readonly doNotSerialize: boolean;
  20815. /** @hidden */
  20816. _rebuild(): void;
  20817. /**
  20818. * Affects all geometry data in one call
  20819. * @param vertexData defines the geometry data
  20820. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20821. */
  20822. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20823. /**
  20824. * Set specific vertex data
  20825. * @param kind defines the data kind (Position, normal, etc...)
  20826. * @param data defines the vertex data to use
  20827. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20828. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20829. */
  20830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20831. /**
  20832. * Removes a specific vertex data
  20833. * @param kind defines the data kind (Position, normal, etc...)
  20834. */
  20835. removeVerticesData(kind: string): void;
  20836. /**
  20837. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20838. * @param buffer defines the vertex buffer to use
  20839. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20840. */
  20841. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20842. /**
  20843. * Update a specific vertex buffer
  20844. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20845. * It will do nothing if the buffer is not updatable
  20846. * @param kind defines the data kind (Position, normal, etc...)
  20847. * @param data defines the data to use
  20848. * @param offset defines the offset in the target buffer where to store the data
  20849. * @param useBytes set to true if the offset is in bytes
  20850. */
  20851. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20852. /**
  20853. * Update a specific vertex buffer
  20854. * This function will create a new buffer if the current one is not updatable
  20855. * @param kind defines the data kind (Position, normal, etc...)
  20856. * @param data defines the data to use
  20857. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20858. */
  20859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20860. private _updateBoundingInfo;
  20861. /** @hidden */
  20862. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20863. /**
  20864. * Gets total number of vertices
  20865. * @returns the total number of vertices
  20866. */
  20867. getTotalVertices(): number;
  20868. /**
  20869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20870. * @param kind defines the data kind (Position, normal, etc...)
  20871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20873. * @returns a float array containing vertex data
  20874. */
  20875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20876. /**
  20877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20878. * @param kind defines the data kind (Position, normal, etc...)
  20879. * @returns true if the vertex buffer with the specified kind is updatable
  20880. */
  20881. isVertexBufferUpdatable(kind: string): boolean;
  20882. /**
  20883. * Gets a specific vertex buffer
  20884. * @param kind defines the data kind (Position, normal, etc...)
  20885. * @returns a VertexBuffer
  20886. */
  20887. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20888. /**
  20889. * Returns all vertex buffers
  20890. * @return an object holding all vertex buffers indexed by kind
  20891. */
  20892. getVertexBuffers(): Nullable<{
  20893. [key: string]: VertexBuffer;
  20894. }>;
  20895. /**
  20896. * Gets a boolean indicating if specific vertex buffer is present
  20897. * @param kind defines the data kind (Position, normal, etc...)
  20898. * @returns true if data is present
  20899. */
  20900. isVerticesDataPresent(kind: string): boolean;
  20901. /**
  20902. * Gets a list of all attached data kinds (Position, normal, etc...)
  20903. * @returns a list of string containing all kinds
  20904. */
  20905. getVerticesDataKinds(): string[];
  20906. /**
  20907. * Update index buffer
  20908. * @param indices defines the indices to store in the index buffer
  20909. * @param offset defines the offset in the target buffer where to store the data
  20910. * @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)
  20911. */
  20912. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20913. /**
  20914. * Creates a new index buffer
  20915. * @param indices defines the indices to store in the index buffer
  20916. * @param totalVertices defines the total number of vertices (could be null)
  20917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20918. */
  20919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20920. /**
  20921. * Return the total number of indices
  20922. * @returns the total number of indices
  20923. */
  20924. getTotalIndices(): number;
  20925. /**
  20926. * Gets the index buffer array
  20927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20929. * @returns the index buffer array
  20930. */
  20931. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20932. /**
  20933. * Gets the index buffer
  20934. * @return the index buffer
  20935. */
  20936. getIndexBuffer(): Nullable<DataBuffer>;
  20937. /** @hidden */
  20938. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20939. /**
  20940. * Release the associated resources for a specific mesh
  20941. * @param mesh defines the source mesh
  20942. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20943. */
  20944. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20945. /**
  20946. * Apply current geometry to a given mesh
  20947. * @param mesh defines the mesh to apply geometry to
  20948. */
  20949. applyToMesh(mesh: Mesh): void;
  20950. private _updateExtend;
  20951. private _applyToMesh;
  20952. private notifyUpdate;
  20953. /**
  20954. * Load the geometry if it was flagged as delay loaded
  20955. * @param scene defines the hosting scene
  20956. * @param onLoaded defines a callback called when the geometry is loaded
  20957. */
  20958. load(scene: Scene, onLoaded?: () => void): void;
  20959. private _queueLoad;
  20960. /**
  20961. * Invert the geometry to move from a right handed system to a left handed one.
  20962. */
  20963. toLeftHanded(): void;
  20964. /** @hidden */
  20965. _resetPointsArrayCache(): void;
  20966. /** @hidden */
  20967. _generatePointsArray(): boolean;
  20968. /**
  20969. * Gets a value indicating if the geometry is disposed
  20970. * @returns true if the geometry was disposed
  20971. */
  20972. isDisposed(): boolean;
  20973. private _disposeVertexArrayObjects;
  20974. /**
  20975. * Free all associated resources
  20976. */
  20977. dispose(): void;
  20978. /**
  20979. * Clone the current geometry into a new geometry
  20980. * @param id defines the unique ID of the new geometry
  20981. * @returns a new geometry object
  20982. */
  20983. copy(id: string): Geometry;
  20984. /**
  20985. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20986. * @return a JSON representation of the current geometry data (without the vertices data)
  20987. */
  20988. serialize(): any;
  20989. private toNumberArray;
  20990. /**
  20991. * Serialize all vertices data into a JSON oject
  20992. * @returns a JSON representation of the current geometry data
  20993. */
  20994. serializeVerticeData(): any;
  20995. /**
  20996. * Extracts a clone of a mesh geometry
  20997. * @param mesh defines the source mesh
  20998. * @param id defines the unique ID of the new geometry object
  20999. * @returns the new geometry object
  21000. */
  21001. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21002. /**
  21003. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21005. * Be aware Math.random() could cause collisions, but:
  21006. * "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"
  21007. * @returns a string containing a new GUID
  21008. */
  21009. static RandomId(): string;
  21010. /** @hidden */
  21011. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21012. private static _CleanMatricesWeights;
  21013. /**
  21014. * Create a new geometry from persisted data (Using .babylon file format)
  21015. * @param parsedVertexData defines the persisted data
  21016. * @param scene defines the hosting scene
  21017. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21018. * @returns the new geometry object
  21019. */
  21020. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21021. }
  21022. }
  21023. declare module BABYLON {
  21024. /**
  21025. * Define an interface for all classes that will get and set the data on vertices
  21026. */
  21027. export interface IGetSetVerticesData {
  21028. /**
  21029. * Gets a boolean indicating if specific vertex data is present
  21030. * @param kind defines the vertex data kind to use
  21031. * @returns true is data kind is present
  21032. */
  21033. isVerticesDataPresent(kind: string): boolean;
  21034. /**
  21035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21036. * @param kind defines the data kind (Position, normal, etc...)
  21037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21039. * @returns a float array containing vertex data
  21040. */
  21041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21042. /**
  21043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21044. * @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.
  21045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21046. * @returns the indices array or an empty array if the mesh has no geometry
  21047. */
  21048. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21049. /**
  21050. * Set specific vertex data
  21051. * @param kind defines the data kind (Position, normal, etc...)
  21052. * @param data defines the vertex data to use
  21053. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21054. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21055. */
  21056. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21057. /**
  21058. * Update a specific associated vertex buffer
  21059. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21060. * - VertexBuffer.PositionKind
  21061. * - VertexBuffer.UVKind
  21062. * - VertexBuffer.UV2Kind
  21063. * - VertexBuffer.UV3Kind
  21064. * - VertexBuffer.UV4Kind
  21065. * - VertexBuffer.UV5Kind
  21066. * - VertexBuffer.UV6Kind
  21067. * - VertexBuffer.ColorKind
  21068. * - VertexBuffer.MatricesIndicesKind
  21069. * - VertexBuffer.MatricesIndicesExtraKind
  21070. * - VertexBuffer.MatricesWeightsKind
  21071. * - VertexBuffer.MatricesWeightsExtraKind
  21072. * @param data defines the data source
  21073. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21074. * @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)
  21075. */
  21076. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21077. /**
  21078. * Creates a new index buffer
  21079. * @param indices defines the indices to store in the index buffer
  21080. * @param totalVertices defines the total number of vertices (could be null)
  21081. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21082. */
  21083. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21084. }
  21085. /**
  21086. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21087. */
  21088. export class VertexData {
  21089. /**
  21090. * Mesh side orientation : usually the external or front surface
  21091. */
  21092. static readonly FRONTSIDE: number;
  21093. /**
  21094. * Mesh side orientation : usually the internal or back surface
  21095. */
  21096. static readonly BACKSIDE: number;
  21097. /**
  21098. * Mesh side orientation : both internal and external or front and back surfaces
  21099. */
  21100. static readonly DOUBLESIDE: number;
  21101. /**
  21102. * Mesh side orientation : by default, `FRONTSIDE`
  21103. */
  21104. static readonly DEFAULTSIDE: number;
  21105. /**
  21106. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21107. */
  21108. positions: Nullable<FloatArray>;
  21109. /**
  21110. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21111. */
  21112. normals: Nullable<FloatArray>;
  21113. /**
  21114. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21115. */
  21116. tangents: Nullable<FloatArray>;
  21117. /**
  21118. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21119. */
  21120. uvs: Nullable<FloatArray>;
  21121. /**
  21122. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21123. */
  21124. uvs2: Nullable<FloatArray>;
  21125. /**
  21126. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21127. */
  21128. uvs3: Nullable<FloatArray>;
  21129. /**
  21130. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21131. */
  21132. uvs4: Nullable<FloatArray>;
  21133. /**
  21134. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21135. */
  21136. uvs5: Nullable<FloatArray>;
  21137. /**
  21138. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21139. */
  21140. uvs6: Nullable<FloatArray>;
  21141. /**
  21142. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21143. */
  21144. colors: Nullable<FloatArray>;
  21145. /**
  21146. * 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).
  21147. */
  21148. matricesIndices: Nullable<FloatArray>;
  21149. /**
  21150. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21151. */
  21152. matricesWeights: Nullable<FloatArray>;
  21153. /**
  21154. * An array extending the number of possible indices
  21155. */
  21156. matricesIndicesExtra: Nullable<FloatArray>;
  21157. /**
  21158. * An array extending the number of possible weights when the number of indices is extended
  21159. */
  21160. matricesWeightsExtra: Nullable<FloatArray>;
  21161. /**
  21162. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21163. */
  21164. indices: Nullable<IndicesArray>;
  21165. /**
  21166. * Uses the passed data array to set the set the values for the specified kind of data
  21167. * @param data a linear array of floating numbers
  21168. * @param kind the type of data that is being set, eg positions, colors etc
  21169. */
  21170. set(data: FloatArray, kind: string): void;
  21171. /**
  21172. * Associates the vertexData to the passed Mesh.
  21173. * Sets it as updatable or not (default `false`)
  21174. * @param mesh the mesh the vertexData is applied to
  21175. * @param updatable when used and having the value true allows new data to update the vertexData
  21176. * @returns the VertexData
  21177. */
  21178. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21179. /**
  21180. * Associates the vertexData to the passed Geometry.
  21181. * Sets it as updatable or not (default `false`)
  21182. * @param geometry the geometry the vertexData is applied to
  21183. * @param updatable when used and having the value true allows new data to update the vertexData
  21184. * @returns VertexData
  21185. */
  21186. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21187. /**
  21188. * Updates the associated mesh
  21189. * @param mesh the mesh to be updated
  21190. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21191. * @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
  21192. * @returns VertexData
  21193. */
  21194. updateMesh(mesh: Mesh): VertexData;
  21195. /**
  21196. * Updates the associated geometry
  21197. * @param geometry the geometry to be updated
  21198. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21199. * @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
  21200. * @returns VertexData.
  21201. */
  21202. updateGeometry(geometry: Geometry): VertexData;
  21203. private _applyTo;
  21204. private _update;
  21205. /**
  21206. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21207. * @param matrix the transforming matrix
  21208. * @returns the VertexData
  21209. */
  21210. transform(matrix: Matrix): VertexData;
  21211. /**
  21212. * Merges the passed VertexData into the current one
  21213. * @param other the VertexData to be merged into the current one
  21214. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21215. * @returns the modified VertexData
  21216. */
  21217. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21218. private _mergeElement;
  21219. private _validate;
  21220. /**
  21221. * Serializes the VertexData
  21222. * @returns a serialized object
  21223. */
  21224. serialize(): any;
  21225. /**
  21226. * Extracts the vertexData from a mesh
  21227. * @param mesh the mesh from which to extract the VertexData
  21228. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21229. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21230. * @returns the object VertexData associated to the passed mesh
  21231. */
  21232. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21233. /**
  21234. * Extracts the vertexData from the geometry
  21235. * @param geometry the geometry from which to extract the VertexData
  21236. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21238. * @returns the object VertexData associated to the passed mesh
  21239. */
  21240. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21241. private static _ExtractFrom;
  21242. /**
  21243. * Creates the VertexData for a Ribbon
  21244. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21245. * * pathArray array of paths, each of which an array of successive Vector3
  21246. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21247. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21248. * * 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
  21249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21250. * * 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)
  21251. * * 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)
  21252. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21253. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21254. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21255. * @returns the VertexData of the ribbon
  21256. */
  21257. static CreateRibbon(options: {
  21258. pathArray: Vector3[][];
  21259. closeArray?: boolean;
  21260. closePath?: boolean;
  21261. offset?: number;
  21262. sideOrientation?: number;
  21263. frontUVs?: Vector4;
  21264. backUVs?: Vector4;
  21265. invertUV?: boolean;
  21266. uvs?: Vector2[];
  21267. colors?: Color4[];
  21268. }): VertexData;
  21269. /**
  21270. * Creates the VertexData for a box
  21271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21272. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21273. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21274. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21275. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21276. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21277. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21279. * * 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)
  21280. * * 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)
  21281. * @returns the VertexData of the box
  21282. */
  21283. static CreateBox(options: {
  21284. size?: number;
  21285. width?: number;
  21286. height?: number;
  21287. depth?: number;
  21288. faceUV?: Vector4[];
  21289. faceColors?: Color4[];
  21290. sideOrientation?: number;
  21291. frontUVs?: Vector4;
  21292. backUVs?: Vector4;
  21293. }): VertexData;
  21294. /**
  21295. * Creates the VertexData for a tiled box
  21296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21297. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21301. * @returns the VertexData of the box
  21302. */
  21303. static CreateTiledBox(options: {
  21304. pattern?: number;
  21305. width?: number;
  21306. height?: number;
  21307. depth?: number;
  21308. tileSize?: number;
  21309. tileWidth?: number;
  21310. tileHeight?: number;
  21311. alignHorizontal?: number;
  21312. alignVertical?: number;
  21313. faceUV?: Vector4[];
  21314. faceColors?: Color4[];
  21315. sideOrientation?: number;
  21316. }): VertexData;
  21317. /**
  21318. * Creates the VertexData for a tiled plane
  21319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21320. * * pattern a limited pattern arrangement depending on the number
  21321. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21322. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21323. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21325. * * 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)
  21326. * * 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)
  21327. * @returns the VertexData of the tiled plane
  21328. */
  21329. static CreateTiledPlane(options: {
  21330. pattern?: number;
  21331. tileSize?: number;
  21332. tileWidth?: number;
  21333. tileHeight?: number;
  21334. size?: number;
  21335. width?: number;
  21336. height?: number;
  21337. alignHorizontal?: number;
  21338. alignVertical?: number;
  21339. sideOrientation?: number;
  21340. frontUVs?: Vector4;
  21341. backUVs?: Vector4;
  21342. }): VertexData;
  21343. /**
  21344. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21346. * * segments sets the number of horizontal strips optional, default 32
  21347. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21348. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21349. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21350. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21351. * * 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
  21352. * * 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
  21353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21354. * * 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)
  21355. * * 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)
  21356. * @returns the VertexData of the ellipsoid
  21357. */
  21358. static CreateSphere(options: {
  21359. segments?: number;
  21360. diameter?: number;
  21361. diameterX?: number;
  21362. diameterY?: number;
  21363. diameterZ?: number;
  21364. arc?: number;
  21365. slice?: number;
  21366. sideOrientation?: number;
  21367. frontUVs?: Vector4;
  21368. backUVs?: Vector4;
  21369. }): VertexData;
  21370. /**
  21371. * Creates the VertexData for a cylinder, cone or prism
  21372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21373. * * height sets the height (y direction) of the cylinder, optional, default 2
  21374. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21375. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21376. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21377. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21378. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21379. * * 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
  21380. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21381. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21382. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21383. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21385. * * 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)
  21386. * * 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)
  21387. * @returns the VertexData of the cylinder, cone or prism
  21388. */
  21389. static CreateCylinder(options: {
  21390. height?: number;
  21391. diameterTop?: number;
  21392. diameterBottom?: number;
  21393. diameter?: number;
  21394. tessellation?: number;
  21395. subdivisions?: number;
  21396. arc?: number;
  21397. faceColors?: Color4[];
  21398. faceUV?: Vector4[];
  21399. hasRings?: boolean;
  21400. enclose?: boolean;
  21401. sideOrientation?: number;
  21402. frontUVs?: Vector4;
  21403. backUVs?: Vector4;
  21404. }): VertexData;
  21405. /**
  21406. * Creates the VertexData for a torus
  21407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21408. * * diameter the diameter of the torus, optional default 1
  21409. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21410. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21412. * * 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)
  21413. * * 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)
  21414. * @returns the VertexData of the torus
  21415. */
  21416. static CreateTorus(options: {
  21417. diameter?: number;
  21418. thickness?: number;
  21419. tessellation?: number;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData of the LineSystem
  21426. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21427. * - lines an array of lines, each line being an array of successive Vector3
  21428. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21429. * @returns the VertexData of the LineSystem
  21430. */
  21431. static CreateLineSystem(options: {
  21432. lines: Vector3[][];
  21433. colors?: Nullable<Color4[][]>;
  21434. }): VertexData;
  21435. /**
  21436. * Create the VertexData for a DashedLines
  21437. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21438. * - points an array successive Vector3
  21439. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21440. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21441. * - dashNb the intended total number of dashes, optional, default 200
  21442. * @returns the VertexData for the DashedLines
  21443. */
  21444. static CreateDashedLines(options: {
  21445. points: Vector3[];
  21446. dashSize?: number;
  21447. gapSize?: number;
  21448. dashNb?: number;
  21449. }): VertexData;
  21450. /**
  21451. * Creates the VertexData for a Ground
  21452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21453. * - width the width (x direction) of the ground, optional, default 1
  21454. * - height the height (z direction) of the ground, optional, default 1
  21455. * - subdivisions the number of subdivisions per side, optional, default 1
  21456. * @returns the VertexData of the Ground
  21457. */
  21458. static CreateGround(options: {
  21459. width?: number;
  21460. height?: number;
  21461. subdivisions?: number;
  21462. subdivisionsX?: number;
  21463. subdivisionsY?: number;
  21464. }): VertexData;
  21465. /**
  21466. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21467. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21468. * * xmin the ground minimum X coordinate, optional, default -1
  21469. * * zmin the ground minimum Z coordinate, optional, default -1
  21470. * * xmax the ground maximum X coordinate, optional, default 1
  21471. * * zmax the ground maximum Z coordinate, optional, default 1
  21472. * * 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}
  21473. * * 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}
  21474. * @returns the VertexData of the TiledGround
  21475. */
  21476. static CreateTiledGround(options: {
  21477. xmin: number;
  21478. zmin: number;
  21479. xmax: number;
  21480. zmax: number;
  21481. subdivisions?: {
  21482. w: number;
  21483. h: number;
  21484. };
  21485. precision?: {
  21486. w: number;
  21487. h: number;
  21488. };
  21489. }): VertexData;
  21490. /**
  21491. * Creates the VertexData of the Ground designed from a heightmap
  21492. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21493. * * width the width (x direction) of the ground
  21494. * * height the height (z direction) of the ground
  21495. * * subdivisions the number of subdivisions per side
  21496. * * minHeight the minimum altitude on the ground, optional, default 0
  21497. * * maxHeight the maximum altitude on the ground, optional default 1
  21498. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21499. * * buffer the array holding the image color data
  21500. * * bufferWidth the width of image
  21501. * * bufferHeight the height of image
  21502. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21503. * @returns the VertexData of the Ground designed from a heightmap
  21504. */
  21505. static CreateGroundFromHeightMap(options: {
  21506. width: number;
  21507. height: number;
  21508. subdivisions: number;
  21509. minHeight: number;
  21510. maxHeight: number;
  21511. colorFilter: Color3;
  21512. buffer: Uint8Array;
  21513. bufferWidth: number;
  21514. bufferHeight: number;
  21515. alphaFilter: number;
  21516. }): VertexData;
  21517. /**
  21518. * Creates the VertexData for a Plane
  21519. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21520. * * size sets the width and height of the plane to the value of size, optional default 1
  21521. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21522. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21524. * * 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)
  21525. * * 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)
  21526. * @returns the VertexData of the box
  21527. */
  21528. static CreatePlane(options: {
  21529. size?: number;
  21530. width?: number;
  21531. height?: number;
  21532. sideOrientation?: number;
  21533. frontUVs?: Vector4;
  21534. backUVs?: Vector4;
  21535. }): VertexData;
  21536. /**
  21537. * Creates the VertexData of the Disc or regular Polygon
  21538. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21539. * * radius the radius of the disc, optional default 0.5
  21540. * * tessellation the number of polygon sides, optional, default 64
  21541. * * 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
  21542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21543. * * 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)
  21544. * * 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)
  21545. * @returns the VertexData of the box
  21546. */
  21547. static CreateDisc(options: {
  21548. radius?: number;
  21549. tessellation?: number;
  21550. arc?: number;
  21551. sideOrientation?: number;
  21552. frontUVs?: Vector4;
  21553. backUVs?: Vector4;
  21554. }): VertexData;
  21555. /**
  21556. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21557. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21558. * @param polygon a mesh built from polygonTriangulation.build()
  21559. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21560. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21561. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21562. * @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)
  21563. * @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)
  21564. * @returns the VertexData of the Polygon
  21565. */
  21566. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21567. /**
  21568. * Creates the VertexData of the IcoSphere
  21569. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21570. * * radius the radius of the IcoSphere, optional default 1
  21571. * * radiusX allows stretching in the x direction, optional, default radius
  21572. * * radiusY allows stretching in the y direction, optional, default radius
  21573. * * radiusZ allows stretching in the z direction, optional, default radius
  21574. * * flat when true creates a flat shaded mesh, optional, default true
  21575. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21577. * * 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)
  21578. * * 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)
  21579. * @returns the VertexData of the IcoSphere
  21580. */
  21581. static CreateIcoSphere(options: {
  21582. radius?: number;
  21583. radiusX?: number;
  21584. radiusY?: number;
  21585. radiusZ?: number;
  21586. flat?: boolean;
  21587. subdivisions?: number;
  21588. sideOrientation?: number;
  21589. frontUVs?: Vector4;
  21590. backUVs?: Vector4;
  21591. }): VertexData;
  21592. /**
  21593. * Creates the VertexData for a Polyhedron
  21594. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21595. * * type provided types are:
  21596. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21597. * * 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)
  21598. * * size the size of the IcoSphere, optional default 1
  21599. * * sizeX allows stretching in the x direction, optional, default size
  21600. * * sizeY allows stretching in the y direction, optional, default size
  21601. * * sizeZ allows stretching in the z direction, optional, default size
  21602. * * 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
  21603. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21604. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21605. * * flat when true creates a flat shaded mesh, optional, default true
  21606. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21608. * * 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)
  21609. * * 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)
  21610. * @returns the VertexData of the Polyhedron
  21611. */
  21612. static CreatePolyhedron(options: {
  21613. type?: number;
  21614. size?: number;
  21615. sizeX?: number;
  21616. sizeY?: number;
  21617. sizeZ?: number;
  21618. custom?: any;
  21619. faceUV?: Vector4[];
  21620. faceColors?: Color4[];
  21621. flat?: boolean;
  21622. sideOrientation?: number;
  21623. frontUVs?: Vector4;
  21624. backUVs?: Vector4;
  21625. }): VertexData;
  21626. /**
  21627. * Creates the VertexData for a TorusKnot
  21628. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21629. * * radius the radius of the torus knot, optional, default 2
  21630. * * tube the thickness of the tube, optional, default 0.5
  21631. * * radialSegments the number of sides on each tube segments, optional, default 32
  21632. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21633. * * p the number of windings around the z axis, optional, default 2
  21634. * * q the number of windings around the x axis, optional, default 3
  21635. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21636. * * 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)
  21637. * * 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)
  21638. * @returns the VertexData of the Torus Knot
  21639. */
  21640. static CreateTorusKnot(options: {
  21641. radius?: number;
  21642. tube?: number;
  21643. radialSegments?: number;
  21644. tubularSegments?: number;
  21645. p?: number;
  21646. q?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Compute normals for given positions and indices
  21653. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21654. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21655. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21656. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21657. * * facetNormals : optional array of facet normals (vector3)
  21658. * * facetPositions : optional array of facet positions (vector3)
  21659. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21660. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21661. * * bInfo : optional bounding info, required for facetPartitioning computation
  21662. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21663. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21664. * * useRightHandedSystem: optional boolean to for right handed system computation
  21665. * * depthSort : optional boolean to enable the facet depth sort computation
  21666. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21667. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21668. */
  21669. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21670. facetNormals?: any;
  21671. facetPositions?: any;
  21672. facetPartitioning?: any;
  21673. ratio?: number;
  21674. bInfo?: any;
  21675. bbSize?: Vector3;
  21676. subDiv?: any;
  21677. useRightHandedSystem?: boolean;
  21678. depthSort?: boolean;
  21679. distanceTo?: Vector3;
  21680. depthSortedFacets?: any;
  21681. }): void;
  21682. /** @hidden */
  21683. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21684. /**
  21685. * Applies VertexData created from the imported parameters to the geometry
  21686. * @param parsedVertexData the parsed data from an imported file
  21687. * @param geometry the geometry to apply the VertexData to
  21688. */
  21689. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. /**
  21694. * Defines a target to use with MorphTargetManager
  21695. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21696. */
  21697. export class MorphTarget implements IAnimatable {
  21698. /** defines the name of the target */
  21699. name: string;
  21700. /**
  21701. * Gets or sets the list of animations
  21702. */
  21703. animations: Animation[];
  21704. private _scene;
  21705. private _positions;
  21706. private _normals;
  21707. private _tangents;
  21708. private _uvs;
  21709. private _influence;
  21710. /**
  21711. * Observable raised when the influence changes
  21712. */
  21713. onInfluenceChanged: Observable<boolean>;
  21714. /** @hidden */
  21715. _onDataLayoutChanged: Observable<void>;
  21716. /**
  21717. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21718. */
  21719. influence: number;
  21720. /**
  21721. * Gets or sets the id of the morph Target
  21722. */
  21723. id: string;
  21724. private _animationPropertiesOverride;
  21725. /**
  21726. * Gets or sets the animation properties override
  21727. */
  21728. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21729. /**
  21730. * Creates a new MorphTarget
  21731. * @param name defines the name of the target
  21732. * @param influence defines the influence to use
  21733. * @param scene defines the scene the morphtarget belongs to
  21734. */
  21735. constructor(
  21736. /** defines the name of the target */
  21737. name: string, influence?: number, scene?: Nullable<Scene>);
  21738. /**
  21739. * Gets a boolean defining if the target contains position data
  21740. */
  21741. readonly hasPositions: boolean;
  21742. /**
  21743. * Gets a boolean defining if the target contains normal data
  21744. */
  21745. readonly hasNormals: boolean;
  21746. /**
  21747. * Gets a boolean defining if the target contains tangent data
  21748. */
  21749. readonly hasTangents: boolean;
  21750. /**
  21751. * Gets a boolean defining if the target contains texture coordinates data
  21752. */
  21753. readonly hasUVs: boolean;
  21754. /**
  21755. * Affects position data to this target
  21756. * @param data defines the position data to use
  21757. */
  21758. setPositions(data: Nullable<FloatArray>): void;
  21759. /**
  21760. * Gets the position data stored in this target
  21761. * @returns a FloatArray containing the position data (or null if not present)
  21762. */
  21763. getPositions(): Nullable<FloatArray>;
  21764. /**
  21765. * Affects normal data to this target
  21766. * @param data defines the normal data to use
  21767. */
  21768. setNormals(data: Nullable<FloatArray>): void;
  21769. /**
  21770. * Gets the normal data stored in this target
  21771. * @returns a FloatArray containing the normal data (or null if not present)
  21772. */
  21773. getNormals(): Nullable<FloatArray>;
  21774. /**
  21775. * Affects tangent data to this target
  21776. * @param data defines the tangent data to use
  21777. */
  21778. setTangents(data: Nullable<FloatArray>): void;
  21779. /**
  21780. * Gets the tangent data stored in this target
  21781. * @returns a FloatArray containing the tangent data (or null if not present)
  21782. */
  21783. getTangents(): Nullable<FloatArray>;
  21784. /**
  21785. * Affects texture coordinates data to this target
  21786. * @param data defines the texture coordinates data to use
  21787. */
  21788. setUVs(data: Nullable<FloatArray>): void;
  21789. /**
  21790. * Gets the texture coordinates data stored in this target
  21791. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21792. */
  21793. getUVs(): Nullable<FloatArray>;
  21794. /**
  21795. * Serializes the current target into a Serialization object
  21796. * @returns the serialized object
  21797. */
  21798. serialize(): any;
  21799. /**
  21800. * Returns the string "MorphTarget"
  21801. * @returns "MorphTarget"
  21802. */
  21803. getClassName(): string;
  21804. /**
  21805. * Creates a new target from serialized data
  21806. * @param serializationObject defines the serialized data to use
  21807. * @returns a new MorphTarget
  21808. */
  21809. static Parse(serializationObject: any): MorphTarget;
  21810. /**
  21811. * Creates a MorphTarget from mesh data
  21812. * @param mesh defines the source mesh
  21813. * @param name defines the name to use for the new target
  21814. * @param influence defines the influence to attach to the target
  21815. * @returns a new MorphTarget
  21816. */
  21817. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21818. }
  21819. }
  21820. declare module BABYLON {
  21821. /**
  21822. * This class is used to deform meshes using morphing between different targets
  21823. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21824. */
  21825. export class MorphTargetManager {
  21826. private _targets;
  21827. private _targetInfluenceChangedObservers;
  21828. private _targetDataLayoutChangedObservers;
  21829. private _activeTargets;
  21830. private _scene;
  21831. private _influences;
  21832. private _supportsNormals;
  21833. private _supportsTangents;
  21834. private _supportsUVs;
  21835. private _vertexCount;
  21836. private _uniqueId;
  21837. private _tempInfluences;
  21838. /**
  21839. * Gets or sets a boolean indicating if normals must be morphed
  21840. */
  21841. enableNormalMorphing: boolean;
  21842. /**
  21843. * Gets or sets a boolean indicating if tangents must be morphed
  21844. */
  21845. enableTangentMorphing: boolean;
  21846. /**
  21847. * Gets or sets a boolean indicating if UV must be morphed
  21848. */
  21849. enableUVMorphing: boolean;
  21850. /**
  21851. * Creates a new MorphTargetManager
  21852. * @param scene defines the current scene
  21853. */
  21854. constructor(scene?: Nullable<Scene>);
  21855. /**
  21856. * Gets the unique ID of this manager
  21857. */
  21858. readonly uniqueId: number;
  21859. /**
  21860. * Gets the number of vertices handled by this manager
  21861. */
  21862. readonly vertexCount: number;
  21863. /**
  21864. * Gets a boolean indicating if this manager supports morphing of normals
  21865. */
  21866. readonly supportsNormals: boolean;
  21867. /**
  21868. * Gets a boolean indicating if this manager supports morphing of tangents
  21869. */
  21870. readonly supportsTangents: boolean;
  21871. /**
  21872. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21873. */
  21874. readonly supportsUVs: boolean;
  21875. /**
  21876. * Gets the number of targets stored in this manager
  21877. */
  21878. readonly numTargets: number;
  21879. /**
  21880. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21881. */
  21882. readonly numInfluencers: number;
  21883. /**
  21884. * Gets the list of influences (one per target)
  21885. */
  21886. readonly influences: Float32Array;
  21887. /**
  21888. * Gets the active target at specified index. An active target is a target with an influence > 0
  21889. * @param index defines the index to check
  21890. * @returns the requested target
  21891. */
  21892. getActiveTarget(index: number): MorphTarget;
  21893. /**
  21894. * Gets the target at specified index
  21895. * @param index defines the index to check
  21896. * @returns the requested target
  21897. */
  21898. getTarget(index: number): MorphTarget;
  21899. /**
  21900. * Add a new target to this manager
  21901. * @param target defines the target to add
  21902. */
  21903. addTarget(target: MorphTarget): void;
  21904. /**
  21905. * Removes a target from the manager
  21906. * @param target defines the target to remove
  21907. */
  21908. removeTarget(target: MorphTarget): void;
  21909. /**
  21910. * Serializes the current manager into a Serialization object
  21911. * @returns the serialized object
  21912. */
  21913. serialize(): any;
  21914. private _syncActiveTargets;
  21915. /**
  21916. * Syncrhonize the targets with all the meshes using this morph target manager
  21917. */
  21918. synchronize(): void;
  21919. /**
  21920. * Creates a new MorphTargetManager from serialized data
  21921. * @param serializationObject defines the serialized data
  21922. * @param scene defines the hosting scene
  21923. * @returns the new MorphTargetManager
  21924. */
  21925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Class used to represent a specific level of detail of a mesh
  21931. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21932. */
  21933. export class MeshLODLevel {
  21934. /** Defines the distance where this level should star being displayed */
  21935. distance: number;
  21936. /** Defines the mesh to use to render this level */
  21937. mesh: Nullable<Mesh>;
  21938. /**
  21939. * Creates a new LOD level
  21940. * @param distance defines the distance where this level should star being displayed
  21941. * @param mesh defines the mesh to use to render this level
  21942. */
  21943. constructor(
  21944. /** Defines the distance where this level should star being displayed */
  21945. distance: number,
  21946. /** Defines the mesh to use to render this level */
  21947. mesh: Nullable<Mesh>);
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Mesh representing the gorund
  21953. */
  21954. export class GroundMesh extends Mesh {
  21955. /** If octree should be generated */
  21956. generateOctree: boolean;
  21957. private _heightQuads;
  21958. /** @hidden */
  21959. _subdivisionsX: number;
  21960. /** @hidden */
  21961. _subdivisionsY: number;
  21962. /** @hidden */
  21963. _width: number;
  21964. /** @hidden */
  21965. _height: number;
  21966. /** @hidden */
  21967. _minX: number;
  21968. /** @hidden */
  21969. _maxX: number;
  21970. /** @hidden */
  21971. _minZ: number;
  21972. /** @hidden */
  21973. _maxZ: number;
  21974. constructor(name: string, scene: Scene);
  21975. /**
  21976. * "GroundMesh"
  21977. * @returns "GroundMesh"
  21978. */
  21979. getClassName(): string;
  21980. /**
  21981. * The minimum of x and y subdivisions
  21982. */
  21983. readonly subdivisions: number;
  21984. /**
  21985. * X subdivisions
  21986. */
  21987. readonly subdivisionsX: number;
  21988. /**
  21989. * Y subdivisions
  21990. */
  21991. readonly subdivisionsY: number;
  21992. /**
  21993. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21995. * @param chunksCount the number of subdivisions for x and y
  21996. * @param octreeBlocksSize (Default: 32)
  21997. */
  21998. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21999. /**
  22000. * Returns a height (y) value in the Worl system :
  22001. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22002. * @param x x coordinate
  22003. * @param z z coordinate
  22004. * @returns the ground y position if (x, z) are outside the ground surface.
  22005. */
  22006. getHeightAtCoordinates(x: number, z: number): number;
  22007. /**
  22008. * Returns a normalized vector (Vector3) orthogonal to the ground
  22009. * at the ground coordinates (x, z) expressed in the World system.
  22010. * @param x x coordinate
  22011. * @param z z coordinate
  22012. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22013. */
  22014. getNormalAtCoordinates(x: number, z: number): Vector3;
  22015. /**
  22016. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22017. * at the ground coordinates (x, z) expressed in the World system.
  22018. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22019. * @param x x coordinate
  22020. * @param z z coordinate
  22021. * @param ref vector to store the result
  22022. * @returns the GroundMesh.
  22023. */
  22024. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22025. /**
  22026. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22027. * if the ground has been updated.
  22028. * This can be used in the render loop.
  22029. * @returns the GroundMesh.
  22030. */
  22031. updateCoordinateHeights(): GroundMesh;
  22032. private _getFacetAt;
  22033. private _initHeightQuads;
  22034. private _computeHeightQuads;
  22035. /**
  22036. * Serializes this ground mesh
  22037. * @param serializationObject object to write serialization to
  22038. */
  22039. serialize(serializationObject: any): void;
  22040. /**
  22041. * Parses a serialized ground mesh
  22042. * @param parsedMesh the serialized mesh
  22043. * @param scene the scene to create the ground mesh in
  22044. * @returns the created ground mesh
  22045. */
  22046. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22047. }
  22048. }
  22049. declare module BABYLON {
  22050. /**
  22051. * Interface for Physics-Joint data
  22052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22053. */
  22054. export interface PhysicsJointData {
  22055. /**
  22056. * The main pivot of the joint
  22057. */
  22058. mainPivot?: Vector3;
  22059. /**
  22060. * The connected pivot of the joint
  22061. */
  22062. connectedPivot?: Vector3;
  22063. /**
  22064. * The main axis of the joint
  22065. */
  22066. mainAxis?: Vector3;
  22067. /**
  22068. * The connected axis of the joint
  22069. */
  22070. connectedAxis?: Vector3;
  22071. /**
  22072. * The collision of the joint
  22073. */
  22074. collision?: boolean;
  22075. /**
  22076. * Native Oimo/Cannon/Energy data
  22077. */
  22078. nativeParams?: any;
  22079. }
  22080. /**
  22081. * This is a holder class for the physics joint created by the physics plugin
  22082. * It holds a set of functions to control the underlying joint
  22083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22084. */
  22085. export class PhysicsJoint {
  22086. /**
  22087. * The type of the physics joint
  22088. */
  22089. type: number;
  22090. /**
  22091. * The data for the physics joint
  22092. */
  22093. jointData: PhysicsJointData;
  22094. private _physicsJoint;
  22095. protected _physicsPlugin: IPhysicsEnginePlugin;
  22096. /**
  22097. * Initializes the physics joint
  22098. * @param type The type of the physics joint
  22099. * @param jointData The data for the physics joint
  22100. */
  22101. constructor(
  22102. /**
  22103. * The type of the physics joint
  22104. */
  22105. type: number,
  22106. /**
  22107. * The data for the physics joint
  22108. */
  22109. jointData: PhysicsJointData);
  22110. /**
  22111. * Gets the physics joint
  22112. */
  22113. /**
  22114. * Sets the physics joint
  22115. */
  22116. physicsJoint: any;
  22117. /**
  22118. * Sets the physics plugin
  22119. */
  22120. physicsPlugin: IPhysicsEnginePlugin;
  22121. /**
  22122. * Execute a function that is physics-plugin specific.
  22123. * @param {Function} func the function that will be executed.
  22124. * It accepts two parameters: the physics world and the physics joint
  22125. */
  22126. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22127. /**
  22128. * Distance-Joint type
  22129. */
  22130. static DistanceJoint: number;
  22131. /**
  22132. * Hinge-Joint type
  22133. */
  22134. static HingeJoint: number;
  22135. /**
  22136. * Ball-and-Socket joint type
  22137. */
  22138. static BallAndSocketJoint: number;
  22139. /**
  22140. * Wheel-Joint type
  22141. */
  22142. static WheelJoint: number;
  22143. /**
  22144. * Slider-Joint type
  22145. */
  22146. static SliderJoint: number;
  22147. /**
  22148. * Prismatic-Joint type
  22149. */
  22150. static PrismaticJoint: number;
  22151. /**
  22152. * Universal-Joint type
  22153. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22154. */
  22155. static UniversalJoint: number;
  22156. /**
  22157. * Hinge-Joint 2 type
  22158. */
  22159. static Hinge2Joint: number;
  22160. /**
  22161. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22162. */
  22163. static PointToPointJoint: number;
  22164. /**
  22165. * Spring-Joint type
  22166. */
  22167. static SpringJoint: number;
  22168. /**
  22169. * Lock-Joint type
  22170. */
  22171. static LockJoint: number;
  22172. }
  22173. /**
  22174. * A class representing a physics distance joint
  22175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22176. */
  22177. export class DistanceJoint extends PhysicsJoint {
  22178. /**
  22179. *
  22180. * @param jointData The data for the Distance-Joint
  22181. */
  22182. constructor(jointData: DistanceJointData);
  22183. /**
  22184. * Update the predefined distance.
  22185. * @param maxDistance The maximum preferred distance
  22186. * @param minDistance The minimum preferred distance
  22187. */
  22188. updateDistance(maxDistance: number, minDistance?: number): void;
  22189. }
  22190. /**
  22191. * Represents a Motor-Enabled Joint
  22192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22193. */
  22194. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22195. /**
  22196. * Initializes the Motor-Enabled Joint
  22197. * @param type The type of the joint
  22198. * @param jointData The physica joint data for the joint
  22199. */
  22200. constructor(type: number, jointData: PhysicsJointData);
  22201. /**
  22202. * Set the motor values.
  22203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22204. * @param force the force to apply
  22205. * @param maxForce max force for this motor.
  22206. */
  22207. setMotor(force?: number, maxForce?: number): void;
  22208. /**
  22209. * Set the motor's limits.
  22210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22211. * @param upperLimit The upper limit of the motor
  22212. * @param lowerLimit The lower limit of the motor
  22213. */
  22214. setLimit(upperLimit: number, lowerLimit?: number): void;
  22215. }
  22216. /**
  22217. * This class represents a single physics Hinge-Joint
  22218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22219. */
  22220. export class HingeJoint extends MotorEnabledJoint {
  22221. /**
  22222. * Initializes the Hinge-Joint
  22223. * @param jointData The joint data for the Hinge-Joint
  22224. */
  22225. constructor(jointData: PhysicsJointData);
  22226. /**
  22227. * Set the motor values.
  22228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22229. * @param {number} force the force to apply
  22230. * @param {number} maxForce max force for this motor.
  22231. */
  22232. setMotor(force?: number, maxForce?: number): void;
  22233. /**
  22234. * Set the motor's limits.
  22235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22236. * @param upperLimit The upper limit of the motor
  22237. * @param lowerLimit The lower limit of the motor
  22238. */
  22239. setLimit(upperLimit: number, lowerLimit?: number): void;
  22240. }
  22241. /**
  22242. * This class represents a dual hinge physics joint (same as wheel joint)
  22243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22244. */
  22245. export class Hinge2Joint extends MotorEnabledJoint {
  22246. /**
  22247. * Initializes the Hinge2-Joint
  22248. * @param jointData The joint data for the Hinge2-Joint
  22249. */
  22250. constructor(jointData: PhysicsJointData);
  22251. /**
  22252. * Set the motor values.
  22253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22254. * @param {number} targetSpeed the speed the motor is to reach
  22255. * @param {number} maxForce max force for this motor.
  22256. * @param {motorIndex} the motor's index, 0 or 1.
  22257. */
  22258. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22259. /**
  22260. * Set the motor limits.
  22261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22262. * @param {number} upperLimit the upper limit
  22263. * @param {number} lowerLimit lower limit
  22264. * @param {motorIndex} the motor's index, 0 or 1.
  22265. */
  22266. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22267. }
  22268. /**
  22269. * Interface for a motor enabled joint
  22270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22271. */
  22272. export interface IMotorEnabledJoint {
  22273. /**
  22274. * Physics joint
  22275. */
  22276. physicsJoint: any;
  22277. /**
  22278. * Sets the motor of the motor-enabled joint
  22279. * @param force The force of the motor
  22280. * @param maxForce The maximum force of the motor
  22281. * @param motorIndex The index of the motor
  22282. */
  22283. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22284. /**
  22285. * Sets the limit of the motor
  22286. * @param upperLimit The upper limit of the motor
  22287. * @param lowerLimit The lower limit of the motor
  22288. * @param motorIndex The index of the motor
  22289. */
  22290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22291. }
  22292. /**
  22293. * Joint data for a Distance-Joint
  22294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22295. */
  22296. export interface DistanceJointData extends PhysicsJointData {
  22297. /**
  22298. * Max distance the 2 joint objects can be apart
  22299. */
  22300. maxDistance: number;
  22301. }
  22302. /**
  22303. * Joint data from a spring joint
  22304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22305. */
  22306. export interface SpringJointData extends PhysicsJointData {
  22307. /**
  22308. * Length of the spring
  22309. */
  22310. length: number;
  22311. /**
  22312. * Stiffness of the spring
  22313. */
  22314. stiffness: number;
  22315. /**
  22316. * Damping of the spring
  22317. */
  22318. damping: number;
  22319. /** this callback will be called when applying the force to the impostors. */
  22320. forceApplicationCallback: () => void;
  22321. }
  22322. }
  22323. declare module BABYLON {
  22324. /**
  22325. * Holds the data for the raycast result
  22326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22327. */
  22328. export class PhysicsRaycastResult {
  22329. private _hasHit;
  22330. private _hitDistance;
  22331. private _hitNormalWorld;
  22332. private _hitPointWorld;
  22333. private _rayFromWorld;
  22334. private _rayToWorld;
  22335. /**
  22336. * Gets if there was a hit
  22337. */
  22338. readonly hasHit: boolean;
  22339. /**
  22340. * Gets the distance from the hit
  22341. */
  22342. readonly hitDistance: number;
  22343. /**
  22344. * Gets the hit normal/direction in the world
  22345. */
  22346. readonly hitNormalWorld: Vector3;
  22347. /**
  22348. * Gets the hit point in the world
  22349. */
  22350. readonly hitPointWorld: Vector3;
  22351. /**
  22352. * Gets the ray "start point" of the ray in the world
  22353. */
  22354. readonly rayFromWorld: Vector3;
  22355. /**
  22356. * Gets the ray "end point" of the ray in the world
  22357. */
  22358. readonly rayToWorld: Vector3;
  22359. /**
  22360. * Sets the hit data (normal & point in world space)
  22361. * @param hitNormalWorld defines the normal in world space
  22362. * @param hitPointWorld defines the point in world space
  22363. */
  22364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22365. /**
  22366. * Sets the distance from the start point to the hit point
  22367. * @param distance
  22368. */
  22369. setHitDistance(distance: number): void;
  22370. /**
  22371. * Calculates the distance manually
  22372. */
  22373. calculateHitDistance(): void;
  22374. /**
  22375. * Resets all the values to default
  22376. * @param from The from point on world space
  22377. * @param to The to point on world space
  22378. */
  22379. reset(from?: Vector3, to?: Vector3): void;
  22380. }
  22381. /**
  22382. * Interface for the size containing width and height
  22383. */
  22384. interface IXYZ {
  22385. /**
  22386. * X
  22387. */
  22388. x: number;
  22389. /**
  22390. * Y
  22391. */
  22392. y: number;
  22393. /**
  22394. * Z
  22395. */
  22396. z: number;
  22397. }
  22398. }
  22399. declare module BABYLON {
  22400. /**
  22401. * Interface used to describe a physics joint
  22402. */
  22403. export interface PhysicsImpostorJoint {
  22404. /** Defines the main impostor to which the joint is linked */
  22405. mainImpostor: PhysicsImpostor;
  22406. /** Defines the impostor that is connected to the main impostor using this joint */
  22407. connectedImpostor: PhysicsImpostor;
  22408. /** Defines the joint itself */
  22409. joint: PhysicsJoint;
  22410. }
  22411. /** @hidden */
  22412. export interface IPhysicsEnginePlugin {
  22413. world: any;
  22414. name: string;
  22415. setGravity(gravity: Vector3): void;
  22416. setTimeStep(timeStep: number): void;
  22417. getTimeStep(): number;
  22418. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22421. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22422. removePhysicsBody(impostor: PhysicsImpostor): void;
  22423. generateJoint(joint: PhysicsImpostorJoint): void;
  22424. removeJoint(joint: PhysicsImpostorJoint): void;
  22425. isSupported(): boolean;
  22426. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22427. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22428. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22429. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22431. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22432. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22433. getBodyMass(impostor: PhysicsImpostor): number;
  22434. getBodyFriction(impostor: PhysicsImpostor): number;
  22435. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22436. getBodyRestitution(impostor: PhysicsImpostor): number;
  22437. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22438. getBodyPressure?(impostor: PhysicsImpostor): number;
  22439. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22440. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22441. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22442. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22443. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22444. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22445. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22446. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22447. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22448. sleepBody(impostor: PhysicsImpostor): void;
  22449. wakeUpBody(impostor: PhysicsImpostor): void;
  22450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22451. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22452. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22454. getRadius(impostor: PhysicsImpostor): number;
  22455. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22456. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22457. dispose(): void;
  22458. }
  22459. /**
  22460. * Interface used to define a physics engine
  22461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22462. */
  22463. export interface IPhysicsEngine {
  22464. /**
  22465. * Gets the gravity vector used by the simulation
  22466. */
  22467. gravity: Vector3;
  22468. /**
  22469. * Sets the gravity vector used by the simulation
  22470. * @param gravity defines the gravity vector to use
  22471. */
  22472. setGravity(gravity: Vector3): void;
  22473. /**
  22474. * Set the time step of the physics engine.
  22475. * Default is 1/60.
  22476. * To slow it down, enter 1/600 for example.
  22477. * To speed it up, 1/30
  22478. * @param newTimeStep the new timestep to apply to this world.
  22479. */
  22480. setTimeStep(newTimeStep: number): void;
  22481. /**
  22482. * Get the time step of the physics engine.
  22483. * @returns the current time step
  22484. */
  22485. getTimeStep(): number;
  22486. /**
  22487. * Release all resources
  22488. */
  22489. dispose(): void;
  22490. /**
  22491. * Gets the name of the current physics plugin
  22492. * @returns the name of the plugin
  22493. */
  22494. getPhysicsPluginName(): string;
  22495. /**
  22496. * Adding a new impostor for the impostor tracking.
  22497. * This will be done by the impostor itself.
  22498. * @param impostor the impostor to add
  22499. */
  22500. addImpostor(impostor: PhysicsImpostor): void;
  22501. /**
  22502. * Remove an impostor from the engine.
  22503. * This impostor and its mesh will not longer be updated by the physics engine.
  22504. * @param impostor the impostor to remove
  22505. */
  22506. removeImpostor(impostor: PhysicsImpostor): void;
  22507. /**
  22508. * Add a joint to the physics engine
  22509. * @param mainImpostor defines the main impostor to which the joint is added.
  22510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22511. * @param joint defines the joint that will connect both impostors.
  22512. */
  22513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22514. /**
  22515. * Removes a joint from the simulation
  22516. * @param mainImpostor defines the impostor used with the joint
  22517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22518. * @param joint defines the joint to remove
  22519. */
  22520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22521. /**
  22522. * Gets the current plugin used to run the simulation
  22523. * @returns current plugin
  22524. */
  22525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22526. /**
  22527. * Gets the list of physic impostors
  22528. * @returns an array of PhysicsImpostor
  22529. */
  22530. getImpostors(): Array<PhysicsImpostor>;
  22531. /**
  22532. * Gets the impostor for a physics enabled object
  22533. * @param object defines the object impersonated by the impostor
  22534. * @returns the PhysicsImpostor or null if not found
  22535. */
  22536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22537. /**
  22538. * Gets the impostor for a physics body object
  22539. * @param body defines physics body used by the impostor
  22540. * @returns the PhysicsImpostor or null if not found
  22541. */
  22542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22543. /**
  22544. * Does a raycast in the physics world
  22545. * @param from when should the ray start?
  22546. * @param to when should the ray end?
  22547. * @returns PhysicsRaycastResult
  22548. */
  22549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22550. /**
  22551. * Called by the scene. No need to call it.
  22552. * @param delta defines the timespam between frames
  22553. */
  22554. _step(delta: number): void;
  22555. }
  22556. }
  22557. declare module BABYLON {
  22558. /**
  22559. * The interface for the physics imposter parameters
  22560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22561. */
  22562. export interface PhysicsImpostorParameters {
  22563. /**
  22564. * The mass of the physics imposter
  22565. */
  22566. mass: number;
  22567. /**
  22568. * The friction of the physics imposter
  22569. */
  22570. friction?: number;
  22571. /**
  22572. * The coefficient of restitution of the physics imposter
  22573. */
  22574. restitution?: number;
  22575. /**
  22576. * The native options of the physics imposter
  22577. */
  22578. nativeOptions?: any;
  22579. /**
  22580. * Specifies if the parent should be ignored
  22581. */
  22582. ignoreParent?: boolean;
  22583. /**
  22584. * Specifies if bi-directional transformations should be disabled
  22585. */
  22586. disableBidirectionalTransformation?: boolean;
  22587. /**
  22588. * The pressure inside the physics imposter, soft object only
  22589. */
  22590. pressure?: number;
  22591. /**
  22592. * The stiffness the physics imposter, soft object only
  22593. */
  22594. stiffness?: number;
  22595. /**
  22596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22597. */
  22598. velocityIterations?: number;
  22599. /**
  22600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22601. */
  22602. positionIterations?: number;
  22603. /**
  22604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22606. * Add to fix multiple points
  22607. */
  22608. fixedPoints?: number;
  22609. /**
  22610. * The collision margin around a soft object
  22611. */
  22612. margin?: number;
  22613. /**
  22614. * The collision margin around a soft object
  22615. */
  22616. damping?: number;
  22617. /**
  22618. * The path for a rope based on an extrusion
  22619. */
  22620. path?: any;
  22621. /**
  22622. * The shape of an extrusion used for a rope based on an extrusion
  22623. */
  22624. shape?: any;
  22625. }
  22626. /**
  22627. * Interface for a physics-enabled object
  22628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22629. */
  22630. export interface IPhysicsEnabledObject {
  22631. /**
  22632. * The position of the physics-enabled object
  22633. */
  22634. position: Vector3;
  22635. /**
  22636. * The rotation of the physics-enabled object
  22637. */
  22638. rotationQuaternion: Nullable<Quaternion>;
  22639. /**
  22640. * The scale of the physics-enabled object
  22641. */
  22642. scaling: Vector3;
  22643. /**
  22644. * The rotation of the physics-enabled object
  22645. */
  22646. rotation?: Vector3;
  22647. /**
  22648. * The parent of the physics-enabled object
  22649. */
  22650. parent?: any;
  22651. /**
  22652. * The bounding info of the physics-enabled object
  22653. * @returns The bounding info of the physics-enabled object
  22654. */
  22655. getBoundingInfo(): BoundingInfo;
  22656. /**
  22657. * Computes the world matrix
  22658. * @param force Specifies if the world matrix should be computed by force
  22659. * @returns A world matrix
  22660. */
  22661. computeWorldMatrix(force: boolean): Matrix;
  22662. /**
  22663. * Gets the world matrix
  22664. * @returns A world matrix
  22665. */
  22666. getWorldMatrix?(): Matrix;
  22667. /**
  22668. * Gets the child meshes
  22669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22670. * @returns An array of abstract meshes
  22671. */
  22672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22673. /**
  22674. * Gets the vertex data
  22675. * @param kind The type of vertex data
  22676. * @returns A nullable array of numbers, or a float32 array
  22677. */
  22678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22679. /**
  22680. * Gets the indices from the mesh
  22681. * @returns A nullable array of index arrays
  22682. */
  22683. getIndices?(): Nullable<IndicesArray>;
  22684. /**
  22685. * Gets the scene from the mesh
  22686. * @returns the indices array or null
  22687. */
  22688. getScene?(): Scene;
  22689. /**
  22690. * Gets the absolute position from the mesh
  22691. * @returns the absolute position
  22692. */
  22693. getAbsolutePosition(): Vector3;
  22694. /**
  22695. * Gets the absolute pivot point from the mesh
  22696. * @returns the absolute pivot point
  22697. */
  22698. getAbsolutePivotPoint(): Vector3;
  22699. /**
  22700. * Rotates the mesh
  22701. * @param axis The axis of rotation
  22702. * @param amount The amount of rotation
  22703. * @param space The space of the rotation
  22704. * @returns The rotation transform node
  22705. */
  22706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22707. /**
  22708. * Translates the mesh
  22709. * @param axis The axis of translation
  22710. * @param distance The distance of translation
  22711. * @param space The space of the translation
  22712. * @returns The transform node
  22713. */
  22714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22715. /**
  22716. * Sets the absolute position of the mesh
  22717. * @param absolutePosition The absolute position of the mesh
  22718. * @returns The transform node
  22719. */
  22720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22721. /**
  22722. * Gets the class name of the mesh
  22723. * @returns The class name
  22724. */
  22725. getClassName(): string;
  22726. }
  22727. /**
  22728. * Represents a physics imposter
  22729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22730. */
  22731. export class PhysicsImpostor {
  22732. /**
  22733. * The physics-enabled object used as the physics imposter
  22734. */
  22735. object: IPhysicsEnabledObject;
  22736. /**
  22737. * The type of the physics imposter
  22738. */
  22739. type: number;
  22740. private _options;
  22741. private _scene?;
  22742. /**
  22743. * The default object size of the imposter
  22744. */
  22745. static DEFAULT_OBJECT_SIZE: Vector3;
  22746. /**
  22747. * The identity quaternion of the imposter
  22748. */
  22749. static IDENTITY_QUATERNION: Quaternion;
  22750. /** @hidden */
  22751. _pluginData: any;
  22752. private _physicsEngine;
  22753. private _physicsBody;
  22754. private _bodyUpdateRequired;
  22755. private _onBeforePhysicsStepCallbacks;
  22756. private _onAfterPhysicsStepCallbacks;
  22757. /** @hidden */
  22758. _onPhysicsCollideCallbacks: Array<{
  22759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22760. otherImpostors: Array<PhysicsImpostor>;
  22761. }>;
  22762. private _deltaPosition;
  22763. private _deltaRotation;
  22764. private _deltaRotationConjugated;
  22765. /** @hidden */
  22766. _isFromLine: boolean;
  22767. private _parent;
  22768. private _isDisposed;
  22769. private static _tmpVecs;
  22770. private static _tmpQuat;
  22771. /**
  22772. * Specifies if the physics imposter is disposed
  22773. */
  22774. readonly isDisposed: boolean;
  22775. /**
  22776. * Gets the mass of the physics imposter
  22777. */
  22778. mass: number;
  22779. /**
  22780. * Gets the coefficient of friction
  22781. */
  22782. /**
  22783. * Sets the coefficient of friction
  22784. */
  22785. friction: number;
  22786. /**
  22787. * Gets the coefficient of restitution
  22788. */
  22789. /**
  22790. * Sets the coefficient of restitution
  22791. */
  22792. restitution: number;
  22793. /**
  22794. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22795. */
  22796. /**
  22797. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22798. */
  22799. pressure: number;
  22800. /**
  22801. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22802. */
  22803. /**
  22804. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22805. */
  22806. stiffness: number;
  22807. /**
  22808. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22809. */
  22810. /**
  22811. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22812. */
  22813. velocityIterations: number;
  22814. /**
  22815. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22816. */
  22817. /**
  22818. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22819. */
  22820. positionIterations: number;
  22821. /**
  22822. * The unique id of the physics imposter
  22823. * set by the physics engine when adding this impostor to the array
  22824. */
  22825. uniqueId: number;
  22826. /**
  22827. * @hidden
  22828. */
  22829. soft: boolean;
  22830. /**
  22831. * @hidden
  22832. */
  22833. segments: number;
  22834. private _joints;
  22835. /**
  22836. * Initializes the physics imposter
  22837. * @param object The physics-enabled object used as the physics imposter
  22838. * @param type The type of the physics imposter
  22839. * @param _options The options for the physics imposter
  22840. * @param _scene The Babylon scene
  22841. */
  22842. constructor(
  22843. /**
  22844. * The physics-enabled object used as the physics imposter
  22845. */
  22846. object: IPhysicsEnabledObject,
  22847. /**
  22848. * The type of the physics imposter
  22849. */
  22850. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22851. /**
  22852. * This function will completly initialize this impostor.
  22853. * It will create a new body - but only if this mesh has no parent.
  22854. * If it has, this impostor will not be used other than to define the impostor
  22855. * of the child mesh.
  22856. * @hidden
  22857. */
  22858. _init(): void;
  22859. private _getPhysicsParent;
  22860. /**
  22861. * Should a new body be generated.
  22862. * @returns boolean specifying if body initialization is required
  22863. */
  22864. isBodyInitRequired(): boolean;
  22865. /**
  22866. * Sets the updated scaling
  22867. * @param updated Specifies if the scaling is updated
  22868. */
  22869. setScalingUpdated(): void;
  22870. /**
  22871. * Force a regeneration of this or the parent's impostor's body.
  22872. * Use under cautious - This will remove all joints already implemented.
  22873. */
  22874. forceUpdate(): void;
  22875. /**
  22876. * Gets the body that holds this impostor. Either its own, or its parent.
  22877. */
  22878. /**
  22879. * Set the physics body. Used mainly by the physics engine/plugin
  22880. */
  22881. physicsBody: any;
  22882. /**
  22883. * Get the parent of the physics imposter
  22884. * @returns Physics imposter or null
  22885. */
  22886. /**
  22887. * Sets the parent of the physics imposter
  22888. */
  22889. parent: Nullable<PhysicsImpostor>;
  22890. /**
  22891. * Resets the update flags
  22892. */
  22893. resetUpdateFlags(): void;
  22894. /**
  22895. * Gets the object extend size
  22896. * @returns the object extend size
  22897. */
  22898. getObjectExtendSize(): Vector3;
  22899. /**
  22900. * Gets the object center
  22901. * @returns The object center
  22902. */
  22903. getObjectCenter(): Vector3;
  22904. /**
  22905. * Get a specific parametes from the options parameter
  22906. * @param paramName The object parameter name
  22907. * @returns The object parameter
  22908. */
  22909. getParam(paramName: string): any;
  22910. /**
  22911. * Sets a specific parameter in the options given to the physics plugin
  22912. * @param paramName The parameter name
  22913. * @param value The value of the parameter
  22914. */
  22915. setParam(paramName: string, value: number): void;
  22916. /**
  22917. * Specifically change the body's mass option. Won't recreate the physics body object
  22918. * @param mass The mass of the physics imposter
  22919. */
  22920. setMass(mass: number): void;
  22921. /**
  22922. * Gets the linear velocity
  22923. * @returns linear velocity or null
  22924. */
  22925. getLinearVelocity(): Nullable<Vector3>;
  22926. /**
  22927. * Sets the linear velocity
  22928. * @param velocity linear velocity or null
  22929. */
  22930. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22931. /**
  22932. * Gets the angular velocity
  22933. * @returns angular velocity or null
  22934. */
  22935. getAngularVelocity(): Nullable<Vector3>;
  22936. /**
  22937. * Sets the angular velocity
  22938. * @param velocity The velocity or null
  22939. */
  22940. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22941. /**
  22942. * Execute a function with the physics plugin native code
  22943. * Provide a function the will have two variables - the world object and the physics body object
  22944. * @param func The function to execute with the physics plugin native code
  22945. */
  22946. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22947. /**
  22948. * Register a function that will be executed before the physics world is stepping forward
  22949. * @param func The function to execute before the physics world is stepped forward
  22950. */
  22951. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22952. /**
  22953. * Unregister a function that will be executed before the physics world is stepping forward
  22954. * @param func The function to execute before the physics world is stepped forward
  22955. */
  22956. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22957. /**
  22958. * Register a function that will be executed after the physics step
  22959. * @param func The function to execute after physics step
  22960. */
  22961. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22962. /**
  22963. * Unregisters a function that will be executed after the physics step
  22964. * @param func The function to execute after physics step
  22965. */
  22966. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22967. /**
  22968. * register a function that will be executed when this impostor collides against a different body
  22969. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22970. * @param func Callback that is executed on collision
  22971. */
  22972. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22973. /**
  22974. * Unregisters the physics imposter on contact
  22975. * @param collideAgainst The physics object to collide against
  22976. * @param func Callback to execute on collision
  22977. */
  22978. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22979. private _tmpQuat;
  22980. private _tmpQuat2;
  22981. /**
  22982. * Get the parent rotation
  22983. * @returns The parent rotation
  22984. */
  22985. getParentsRotation(): Quaternion;
  22986. /**
  22987. * this function is executed by the physics engine.
  22988. */
  22989. beforeStep: () => void;
  22990. /**
  22991. * this function is executed by the physics engine
  22992. */
  22993. afterStep: () => void;
  22994. /**
  22995. * Legacy collision detection event support
  22996. */
  22997. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22998. /**
  22999. * event and body object due to cannon's event-based architecture.
  23000. */
  23001. onCollide: (e: {
  23002. body: any;
  23003. }) => void;
  23004. /**
  23005. * Apply a force
  23006. * @param force The force to apply
  23007. * @param contactPoint The contact point for the force
  23008. * @returns The physics imposter
  23009. */
  23010. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23011. /**
  23012. * Apply an impulse
  23013. * @param force The impulse force
  23014. * @param contactPoint The contact point for the impulse force
  23015. * @returns The physics imposter
  23016. */
  23017. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23018. /**
  23019. * A help function to create a joint
  23020. * @param otherImpostor A physics imposter used to create a joint
  23021. * @param jointType The type of joint
  23022. * @param jointData The data for the joint
  23023. * @returns The physics imposter
  23024. */
  23025. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23026. /**
  23027. * Add a joint to this impostor with a different impostor
  23028. * @param otherImpostor A physics imposter used to add a joint
  23029. * @param joint The joint to add
  23030. * @returns The physics imposter
  23031. */
  23032. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23033. /**
  23034. * Add an anchor to a cloth impostor
  23035. * @param otherImpostor rigid impostor to anchor to
  23036. * @param width ratio across width from 0 to 1
  23037. * @param height ratio up height from 0 to 1
  23038. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23039. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23040. * @returns impostor the soft imposter
  23041. */
  23042. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23043. /**
  23044. * Add a hook to a rope impostor
  23045. * @param otherImpostor rigid impostor to anchor to
  23046. * @param length ratio across rope from 0 to 1
  23047. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23048. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23049. * @returns impostor the rope imposter
  23050. */
  23051. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23052. /**
  23053. * Will keep this body still, in a sleep mode.
  23054. * @returns the physics imposter
  23055. */
  23056. sleep(): PhysicsImpostor;
  23057. /**
  23058. * Wake the body up.
  23059. * @returns The physics imposter
  23060. */
  23061. wakeUp(): PhysicsImpostor;
  23062. /**
  23063. * Clones the physics imposter
  23064. * @param newObject The physics imposter clones to this physics-enabled object
  23065. * @returns A nullable physics imposter
  23066. */
  23067. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23068. /**
  23069. * Disposes the physics imposter
  23070. */
  23071. dispose(): void;
  23072. /**
  23073. * Sets the delta position
  23074. * @param position The delta position amount
  23075. */
  23076. setDeltaPosition(position: Vector3): void;
  23077. /**
  23078. * Sets the delta rotation
  23079. * @param rotation The delta rotation amount
  23080. */
  23081. setDeltaRotation(rotation: Quaternion): void;
  23082. /**
  23083. * Gets the box size of the physics imposter and stores the result in the input parameter
  23084. * @param result Stores the box size
  23085. * @returns The physics imposter
  23086. */
  23087. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23088. /**
  23089. * Gets the radius of the physics imposter
  23090. * @returns Radius of the physics imposter
  23091. */
  23092. getRadius(): number;
  23093. /**
  23094. * Sync a bone with this impostor
  23095. * @param bone The bone to sync to the impostor.
  23096. * @param boneMesh The mesh that the bone is influencing.
  23097. * @param jointPivot The pivot of the joint / bone in local space.
  23098. * @param distToJoint Optional distance from the impostor to the joint.
  23099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23100. */
  23101. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23102. /**
  23103. * Sync impostor to a bone
  23104. * @param bone The bone that the impostor will be synced to.
  23105. * @param boneMesh The mesh that the bone is influencing.
  23106. * @param jointPivot The pivot of the joint / bone in local space.
  23107. * @param distToJoint Optional distance from the impostor to the joint.
  23108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23109. * @param boneAxis Optional vector3 axis the bone is aligned with
  23110. */
  23111. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23112. /**
  23113. * No-Imposter type
  23114. */
  23115. static NoImpostor: number;
  23116. /**
  23117. * Sphere-Imposter type
  23118. */
  23119. static SphereImpostor: number;
  23120. /**
  23121. * Box-Imposter type
  23122. */
  23123. static BoxImpostor: number;
  23124. /**
  23125. * Plane-Imposter type
  23126. */
  23127. static PlaneImpostor: number;
  23128. /**
  23129. * Mesh-imposter type
  23130. */
  23131. static MeshImpostor: number;
  23132. /**
  23133. * Capsule-Impostor type (Ammo.js plugin only)
  23134. */
  23135. static CapsuleImpostor: number;
  23136. /**
  23137. * Cylinder-Imposter type
  23138. */
  23139. static CylinderImpostor: number;
  23140. /**
  23141. * Particle-Imposter type
  23142. */
  23143. static ParticleImpostor: number;
  23144. /**
  23145. * Heightmap-Imposter type
  23146. */
  23147. static HeightmapImpostor: number;
  23148. /**
  23149. * ConvexHull-Impostor type (Ammo.js plugin only)
  23150. */
  23151. static ConvexHullImpostor: number;
  23152. /**
  23153. * Rope-Imposter type
  23154. */
  23155. static RopeImpostor: number;
  23156. /**
  23157. * Cloth-Imposter type
  23158. */
  23159. static ClothImpostor: number;
  23160. /**
  23161. * Softbody-Imposter type
  23162. */
  23163. static SoftbodyImpostor: number;
  23164. }
  23165. }
  23166. declare module BABYLON {
  23167. /**
  23168. * @hidden
  23169. **/
  23170. export class _CreationDataStorage {
  23171. closePath?: boolean;
  23172. closeArray?: boolean;
  23173. idx: number[];
  23174. dashSize: number;
  23175. gapSize: number;
  23176. path3D: Path3D;
  23177. pathArray: Vector3[][];
  23178. arc: number;
  23179. radius: number;
  23180. cap: number;
  23181. tessellation: number;
  23182. }
  23183. /**
  23184. * @hidden
  23185. **/
  23186. class _InstanceDataStorage {
  23187. visibleInstances: any;
  23188. batchCache: _InstancesBatch;
  23189. instancesBufferSize: number;
  23190. instancesBuffer: Nullable<Buffer>;
  23191. instancesData: Float32Array;
  23192. overridenInstanceCount: number;
  23193. isFrozen: boolean;
  23194. previousBatch: Nullable<_InstancesBatch>;
  23195. hardwareInstancedRendering: boolean;
  23196. sideOrientation: number;
  23197. }
  23198. /**
  23199. * @hidden
  23200. **/
  23201. export class _InstancesBatch {
  23202. mustReturn: boolean;
  23203. visibleInstances: Nullable<InstancedMesh[]>[];
  23204. renderSelf: boolean[];
  23205. hardwareInstancedRendering: boolean[];
  23206. }
  23207. /**
  23208. * Class used to represent renderable models
  23209. */
  23210. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23211. /**
  23212. * Mesh side orientation : usually the external or front surface
  23213. */
  23214. static readonly FRONTSIDE: number;
  23215. /**
  23216. * Mesh side orientation : usually the internal or back surface
  23217. */
  23218. static readonly BACKSIDE: number;
  23219. /**
  23220. * Mesh side orientation : both internal and external or front and back surfaces
  23221. */
  23222. static readonly DOUBLESIDE: number;
  23223. /**
  23224. * Mesh side orientation : by default, `FRONTSIDE`
  23225. */
  23226. static readonly DEFAULTSIDE: number;
  23227. /**
  23228. * Mesh cap setting : no cap
  23229. */
  23230. static readonly NO_CAP: number;
  23231. /**
  23232. * Mesh cap setting : one cap at the beginning of the mesh
  23233. */
  23234. static readonly CAP_START: number;
  23235. /**
  23236. * Mesh cap setting : one cap at the end of the mesh
  23237. */
  23238. static readonly CAP_END: number;
  23239. /**
  23240. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23241. */
  23242. static readonly CAP_ALL: number;
  23243. /**
  23244. * Mesh pattern setting : no flip or rotate
  23245. */
  23246. static readonly NO_FLIP: number;
  23247. /**
  23248. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23249. */
  23250. static readonly FLIP_TILE: number;
  23251. /**
  23252. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23253. */
  23254. static readonly ROTATE_TILE: number;
  23255. /**
  23256. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23257. */
  23258. static readonly FLIP_ROW: number;
  23259. /**
  23260. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23261. */
  23262. static readonly ROTATE_ROW: number;
  23263. /**
  23264. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23265. */
  23266. static readonly FLIP_N_ROTATE_TILE: number;
  23267. /**
  23268. * Mesh pattern setting : rotate pattern and rotate
  23269. */
  23270. static readonly FLIP_N_ROTATE_ROW: number;
  23271. /**
  23272. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23273. */
  23274. static readonly CENTER: number;
  23275. /**
  23276. * Mesh tile positioning : part tiles on left
  23277. */
  23278. static readonly LEFT: number;
  23279. /**
  23280. * Mesh tile positioning : part tiles on right
  23281. */
  23282. static readonly RIGHT: number;
  23283. /**
  23284. * Mesh tile positioning : part tiles on top
  23285. */
  23286. static readonly TOP: number;
  23287. /**
  23288. * Mesh tile positioning : part tiles on bottom
  23289. */
  23290. static readonly BOTTOM: number;
  23291. /**
  23292. * Gets the default side orientation.
  23293. * @param orientation the orientation to value to attempt to get
  23294. * @returns the default orientation
  23295. * @hidden
  23296. */
  23297. static _GetDefaultSideOrientation(orientation?: number): number;
  23298. private _internalMeshDataInfo;
  23299. /**
  23300. * An event triggered before rendering the mesh
  23301. */
  23302. readonly onBeforeRenderObservable: Observable<Mesh>;
  23303. /**
  23304. * An event triggered before binding the mesh
  23305. */
  23306. readonly onBeforeBindObservable: Observable<Mesh>;
  23307. /**
  23308. * An event triggered after rendering the mesh
  23309. */
  23310. readonly onAfterRenderObservable: Observable<Mesh>;
  23311. /**
  23312. * An event triggered before drawing the mesh
  23313. */
  23314. readonly onBeforeDrawObservable: Observable<Mesh>;
  23315. private _onBeforeDrawObserver;
  23316. /**
  23317. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23318. */
  23319. onBeforeDraw: () => void;
  23320. /**
  23321. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23322. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23323. */
  23324. delayLoadState: number;
  23325. /**
  23326. * Gets the list of instances created from this mesh
  23327. * it is not supposed to be modified manually.
  23328. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23329. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23330. */
  23331. instances: InstancedMesh[];
  23332. /**
  23333. * Gets the file containing delay loading data for this mesh
  23334. */
  23335. delayLoadingFile: string;
  23336. /** @hidden */
  23337. _binaryInfo: any;
  23338. /**
  23339. * User defined function used to change how LOD level selection is done
  23340. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23341. */
  23342. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23343. /**
  23344. * Gets or sets the morph target manager
  23345. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23346. */
  23347. morphTargetManager: Nullable<MorphTargetManager>;
  23348. /** @hidden */
  23349. _creationDataStorage: Nullable<_CreationDataStorage>;
  23350. /** @hidden */
  23351. _geometry: Nullable<Geometry>;
  23352. /** @hidden */
  23353. _delayInfo: Array<string>;
  23354. /** @hidden */
  23355. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23356. /** @hidden */
  23357. _instanceDataStorage: _InstanceDataStorage;
  23358. private _effectiveMaterial;
  23359. /** @hidden */
  23360. _shouldGenerateFlatShading: boolean;
  23361. /** @hidden */
  23362. _originalBuilderSideOrientation: number;
  23363. /**
  23364. * Use this property to change the original side orientation defined at construction time
  23365. */
  23366. overrideMaterialSideOrientation: Nullable<number>;
  23367. /**
  23368. * Gets the source mesh (the one used to clone this one from)
  23369. */
  23370. readonly source: Nullable<Mesh>;
  23371. /**
  23372. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23373. */
  23374. isUnIndexed: boolean;
  23375. /**
  23376. * @constructor
  23377. * @param name The value used by scene.getMeshByName() to do a lookup.
  23378. * @param scene The scene to add this mesh to.
  23379. * @param parent The parent of this mesh, if it has one
  23380. * @param source An optional Mesh from which geometry is shared, cloned.
  23381. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23382. * When false, achieved by calling a clone(), also passing False.
  23383. * This will make creation of children, recursive.
  23384. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23385. */
  23386. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23387. /**
  23388. * Gets the class name
  23389. * @returns the string "Mesh".
  23390. */
  23391. getClassName(): string;
  23392. /** @hidden */
  23393. readonly _isMesh: boolean;
  23394. /**
  23395. * Returns a description of this mesh
  23396. * @param fullDetails define if full details about this mesh must be used
  23397. * @returns a descriptive string representing this mesh
  23398. */
  23399. toString(fullDetails?: boolean): string;
  23400. /** @hidden */
  23401. _unBindEffect(): void;
  23402. /**
  23403. * Gets a boolean indicating if this mesh has LOD
  23404. */
  23405. readonly hasLODLevels: boolean;
  23406. /**
  23407. * Gets the list of MeshLODLevel associated with the current mesh
  23408. * @returns an array of MeshLODLevel
  23409. */
  23410. getLODLevels(): MeshLODLevel[];
  23411. private _sortLODLevels;
  23412. /**
  23413. * Add a mesh as LOD level triggered at the given distance.
  23414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23415. * @param distance The distance from the center of the object to show this level
  23416. * @param mesh The mesh to be added as LOD level (can be null)
  23417. * @return This mesh (for chaining)
  23418. */
  23419. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23420. /**
  23421. * Returns the LOD level mesh at the passed distance or null if not found.
  23422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23423. * @param distance The distance from the center of the object to show this level
  23424. * @returns a Mesh or `null`
  23425. */
  23426. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23427. /**
  23428. * Remove a mesh from the LOD array
  23429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23430. * @param mesh defines the mesh to be removed
  23431. * @return This mesh (for chaining)
  23432. */
  23433. removeLODLevel(mesh: Mesh): Mesh;
  23434. /**
  23435. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23437. * @param camera defines the camera to use to compute distance
  23438. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23439. * @return This mesh (for chaining)
  23440. */
  23441. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23442. /**
  23443. * Gets the mesh internal Geometry object
  23444. */
  23445. readonly geometry: Nullable<Geometry>;
  23446. /**
  23447. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23448. * @returns the total number of vertices
  23449. */
  23450. getTotalVertices(): number;
  23451. /**
  23452. * Returns the content of an associated vertex buffer
  23453. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23454. * - VertexBuffer.PositionKind
  23455. * - VertexBuffer.UVKind
  23456. * - VertexBuffer.UV2Kind
  23457. * - VertexBuffer.UV3Kind
  23458. * - VertexBuffer.UV4Kind
  23459. * - VertexBuffer.UV5Kind
  23460. * - VertexBuffer.UV6Kind
  23461. * - VertexBuffer.ColorKind
  23462. * - VertexBuffer.MatricesIndicesKind
  23463. * - VertexBuffer.MatricesIndicesExtraKind
  23464. * - VertexBuffer.MatricesWeightsKind
  23465. * - VertexBuffer.MatricesWeightsExtraKind
  23466. * @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
  23467. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23468. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23469. */
  23470. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23471. /**
  23472. * Returns the mesh VertexBuffer object from the requested `kind`
  23473. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23474. * - VertexBuffer.PositionKind
  23475. * - VertexBuffer.NormalKind
  23476. * - VertexBuffer.UVKind
  23477. * - VertexBuffer.UV2Kind
  23478. * - VertexBuffer.UV3Kind
  23479. * - VertexBuffer.UV4Kind
  23480. * - VertexBuffer.UV5Kind
  23481. * - VertexBuffer.UV6Kind
  23482. * - VertexBuffer.ColorKind
  23483. * - VertexBuffer.MatricesIndicesKind
  23484. * - VertexBuffer.MatricesIndicesExtraKind
  23485. * - VertexBuffer.MatricesWeightsKind
  23486. * - VertexBuffer.MatricesWeightsExtraKind
  23487. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23488. */
  23489. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23490. /**
  23491. * Tests if a specific vertex buffer is associated with this mesh
  23492. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23493. * - VertexBuffer.PositionKind
  23494. * - VertexBuffer.NormalKind
  23495. * - VertexBuffer.UVKind
  23496. * - VertexBuffer.UV2Kind
  23497. * - VertexBuffer.UV3Kind
  23498. * - VertexBuffer.UV4Kind
  23499. * - VertexBuffer.UV5Kind
  23500. * - VertexBuffer.UV6Kind
  23501. * - VertexBuffer.ColorKind
  23502. * - VertexBuffer.MatricesIndicesKind
  23503. * - VertexBuffer.MatricesIndicesExtraKind
  23504. * - VertexBuffer.MatricesWeightsKind
  23505. * - VertexBuffer.MatricesWeightsExtraKind
  23506. * @returns a boolean
  23507. */
  23508. isVerticesDataPresent(kind: string): boolean;
  23509. /**
  23510. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23511. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23512. * - VertexBuffer.PositionKind
  23513. * - VertexBuffer.UVKind
  23514. * - VertexBuffer.UV2Kind
  23515. * - VertexBuffer.UV3Kind
  23516. * - VertexBuffer.UV4Kind
  23517. * - VertexBuffer.UV5Kind
  23518. * - VertexBuffer.UV6Kind
  23519. * - VertexBuffer.ColorKind
  23520. * - VertexBuffer.MatricesIndicesKind
  23521. * - VertexBuffer.MatricesIndicesExtraKind
  23522. * - VertexBuffer.MatricesWeightsKind
  23523. * - VertexBuffer.MatricesWeightsExtraKind
  23524. * @returns a boolean
  23525. */
  23526. isVertexBufferUpdatable(kind: string): boolean;
  23527. /**
  23528. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23529. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23530. * - VertexBuffer.PositionKind
  23531. * - VertexBuffer.NormalKind
  23532. * - VertexBuffer.UVKind
  23533. * - VertexBuffer.UV2Kind
  23534. * - VertexBuffer.UV3Kind
  23535. * - VertexBuffer.UV4Kind
  23536. * - VertexBuffer.UV5Kind
  23537. * - VertexBuffer.UV6Kind
  23538. * - VertexBuffer.ColorKind
  23539. * - VertexBuffer.MatricesIndicesKind
  23540. * - VertexBuffer.MatricesIndicesExtraKind
  23541. * - VertexBuffer.MatricesWeightsKind
  23542. * - VertexBuffer.MatricesWeightsExtraKind
  23543. * @returns an array of strings
  23544. */
  23545. getVerticesDataKinds(): string[];
  23546. /**
  23547. * Returns a positive integer : the total number of indices in this mesh geometry.
  23548. * @returns the numner of indices or zero if the mesh has no geometry.
  23549. */
  23550. getTotalIndices(): number;
  23551. /**
  23552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23553. * @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.
  23554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23555. * @returns the indices array or an empty array if the mesh has no geometry
  23556. */
  23557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23558. readonly isBlocked: boolean;
  23559. /**
  23560. * Determine if the current mesh is ready to be rendered
  23561. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23562. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23563. * @returns true if all associated assets are ready (material, textures, shaders)
  23564. */
  23565. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23566. /**
  23567. * 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.
  23568. */
  23569. readonly areNormalsFrozen: boolean;
  23570. /**
  23571. * 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.
  23572. * @returns the current mesh
  23573. */
  23574. freezeNormals(): Mesh;
  23575. /**
  23576. * 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
  23577. * @returns the current mesh
  23578. */
  23579. unfreezeNormals(): Mesh;
  23580. /**
  23581. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23582. */
  23583. overridenInstanceCount: number;
  23584. /** @hidden */
  23585. _preActivate(): Mesh;
  23586. /** @hidden */
  23587. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23588. /** @hidden */
  23589. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23590. /**
  23591. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23592. * This means the mesh underlying bounding box and sphere are recomputed.
  23593. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23594. * @returns the current mesh
  23595. */
  23596. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23597. /** @hidden */
  23598. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23599. /**
  23600. * This function will subdivide the mesh into multiple submeshes
  23601. * @param count defines the expected number of submeshes
  23602. */
  23603. subdivide(count: number): void;
  23604. /**
  23605. * Copy a FloatArray into a specific associated vertex buffer
  23606. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23607. * - VertexBuffer.PositionKind
  23608. * - VertexBuffer.UVKind
  23609. * - VertexBuffer.UV2Kind
  23610. * - VertexBuffer.UV3Kind
  23611. * - VertexBuffer.UV4Kind
  23612. * - VertexBuffer.UV5Kind
  23613. * - VertexBuffer.UV6Kind
  23614. * - VertexBuffer.ColorKind
  23615. * - VertexBuffer.MatricesIndicesKind
  23616. * - VertexBuffer.MatricesIndicesExtraKind
  23617. * - VertexBuffer.MatricesWeightsKind
  23618. * - VertexBuffer.MatricesWeightsExtraKind
  23619. * @param data defines the data source
  23620. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23621. * @param stride defines the data stride size (can be null)
  23622. * @returns the current mesh
  23623. */
  23624. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23625. /**
  23626. * Flags an associated vertex buffer as updatable
  23627. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23628. * - VertexBuffer.PositionKind
  23629. * - VertexBuffer.UVKind
  23630. * - VertexBuffer.UV2Kind
  23631. * - VertexBuffer.UV3Kind
  23632. * - VertexBuffer.UV4Kind
  23633. * - VertexBuffer.UV5Kind
  23634. * - VertexBuffer.UV6Kind
  23635. * - VertexBuffer.ColorKind
  23636. * - VertexBuffer.MatricesIndicesKind
  23637. * - VertexBuffer.MatricesIndicesExtraKind
  23638. * - VertexBuffer.MatricesWeightsKind
  23639. * - VertexBuffer.MatricesWeightsExtraKind
  23640. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23641. */
  23642. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23643. /**
  23644. * Sets the mesh global Vertex Buffer
  23645. * @param buffer defines the buffer to use
  23646. * @returns the current mesh
  23647. */
  23648. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23649. /**
  23650. * Update a specific associated vertex buffer
  23651. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23652. * - VertexBuffer.PositionKind
  23653. * - VertexBuffer.UVKind
  23654. * - VertexBuffer.UV2Kind
  23655. * - VertexBuffer.UV3Kind
  23656. * - VertexBuffer.UV4Kind
  23657. * - VertexBuffer.UV5Kind
  23658. * - VertexBuffer.UV6Kind
  23659. * - VertexBuffer.ColorKind
  23660. * - VertexBuffer.MatricesIndicesKind
  23661. * - VertexBuffer.MatricesIndicesExtraKind
  23662. * - VertexBuffer.MatricesWeightsKind
  23663. * - VertexBuffer.MatricesWeightsExtraKind
  23664. * @param data defines the data source
  23665. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23666. * @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)
  23667. * @returns the current mesh
  23668. */
  23669. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23670. /**
  23671. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23672. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23673. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23674. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23675. * @returns the current mesh
  23676. */
  23677. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23678. /**
  23679. * Creates a un-shared specific occurence of the geometry for the mesh.
  23680. * @returns the current mesh
  23681. */
  23682. makeGeometryUnique(): Mesh;
  23683. /**
  23684. * Set the index buffer of this mesh
  23685. * @param indices defines the source data
  23686. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23687. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23688. * @returns the current mesh
  23689. */
  23690. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23691. /**
  23692. * Update the current index buffer
  23693. * @param indices defines the source data
  23694. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23695. * @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)
  23696. * @returns the current mesh
  23697. */
  23698. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23699. /**
  23700. * Invert the geometry to move from a right handed system to a left handed one.
  23701. * @returns the current mesh
  23702. */
  23703. toLeftHanded(): Mesh;
  23704. /** @hidden */
  23705. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23706. /** @hidden */
  23707. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23708. /**
  23709. * Registers for this mesh a javascript function called just before the rendering process
  23710. * @param func defines the function to call before rendering this mesh
  23711. * @returns the current mesh
  23712. */
  23713. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23714. /**
  23715. * Disposes a previously registered javascript function called before the rendering
  23716. * @param func defines the function to remove
  23717. * @returns the current mesh
  23718. */
  23719. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23720. /**
  23721. * Registers for this mesh a javascript function called just after the rendering is complete
  23722. * @param func defines the function to call after rendering this mesh
  23723. * @returns the current mesh
  23724. */
  23725. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23726. /**
  23727. * Disposes a previously registered javascript function called after the rendering.
  23728. * @param func defines the function to remove
  23729. * @returns the current mesh
  23730. */
  23731. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23732. /** @hidden */
  23733. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23734. /** @hidden */
  23735. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23736. /** @hidden */
  23737. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23738. /** @hidden */
  23739. _rebuild(): void;
  23740. /** @hidden */
  23741. _freeze(): void;
  23742. /** @hidden */
  23743. _unFreeze(): void;
  23744. /**
  23745. * 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
  23746. * @param subMesh defines the subMesh to render
  23747. * @param enableAlphaMode defines if alpha mode can be changed
  23748. * @returns the current mesh
  23749. */
  23750. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23751. private _onBeforeDraw;
  23752. /**
  23753. * Renormalize the mesh and patch it up if there are no weights
  23754. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23755. * However in the case of zero weights then we set just a single influence to 1.
  23756. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23757. */
  23758. cleanMatrixWeights(): void;
  23759. private normalizeSkinFourWeights;
  23760. private normalizeSkinWeightsAndExtra;
  23761. /**
  23762. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23763. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23764. * the user know there was an issue with importing the mesh
  23765. * @returns a validation object with skinned, valid and report string
  23766. */
  23767. validateSkinning(): {
  23768. skinned: boolean;
  23769. valid: boolean;
  23770. report: string;
  23771. };
  23772. /** @hidden */
  23773. _checkDelayState(): Mesh;
  23774. private _queueLoad;
  23775. /**
  23776. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23777. * A mesh is in the frustum if its bounding box intersects the frustum
  23778. * @param frustumPlanes defines the frustum to test
  23779. * @returns true if the mesh is in the frustum planes
  23780. */
  23781. isInFrustum(frustumPlanes: Plane[]): boolean;
  23782. /**
  23783. * Sets the mesh material by the material or multiMaterial `id` property
  23784. * @param id is a string identifying the material or the multiMaterial
  23785. * @returns the current mesh
  23786. */
  23787. setMaterialByID(id: string): Mesh;
  23788. /**
  23789. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23790. * @returns an array of IAnimatable
  23791. */
  23792. getAnimatables(): IAnimatable[];
  23793. /**
  23794. * Modifies the mesh geometry according to the passed transformation matrix.
  23795. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23796. * The mesh normals are modified using the same transformation.
  23797. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23798. * @param transform defines the transform matrix to use
  23799. * @see http://doc.babylonjs.com/resources/baking_transformations
  23800. * @returns the current mesh
  23801. */
  23802. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23803. /**
  23804. * Modifies the mesh geometry according to its own current World Matrix.
  23805. * The mesh World Matrix is then reset.
  23806. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23807. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23808. * @see http://doc.babylonjs.com/resources/baking_transformations
  23809. * @returns the current mesh
  23810. */
  23811. bakeCurrentTransformIntoVertices(): Mesh;
  23812. /** @hidden */
  23813. readonly _positions: Nullable<Vector3[]>;
  23814. /** @hidden */
  23815. _resetPointsArrayCache(): Mesh;
  23816. /** @hidden */
  23817. _generatePointsArray(): boolean;
  23818. /**
  23819. * Returns a new Mesh object generated from the current mesh properties.
  23820. * This method must not get confused with createInstance()
  23821. * @param name is a string, the name given to the new mesh
  23822. * @param newParent can be any Node object (default `null`)
  23823. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23824. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23825. * @returns a new mesh
  23826. */
  23827. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23828. /**
  23829. * Releases resources associated with this mesh.
  23830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23832. */
  23833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23834. /**
  23835. * Modifies the mesh geometry according to a displacement map.
  23836. * 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.
  23837. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23838. * @param url is a string, the URL from the image file is to be downloaded.
  23839. * @param minHeight is the lower limit of the displacement.
  23840. * @param maxHeight is the upper limit of the displacement.
  23841. * @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.
  23842. * @param uvOffset is an optional vector2 used to offset UV.
  23843. * @param uvScale is an optional vector2 used to scale UV.
  23844. * @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.
  23845. * @returns the Mesh.
  23846. */
  23847. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23848. /**
  23849. * Modifies the mesh geometry according to a displacementMap buffer.
  23850. * 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.
  23851. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23852. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23853. * @param heightMapWidth is the width of the buffer image.
  23854. * @param heightMapHeight is the height of the buffer image.
  23855. * @param minHeight is the lower limit of the displacement.
  23856. * @param maxHeight is the upper limit of the displacement.
  23857. * @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.
  23858. * @param uvOffset is an optional vector2 used to offset UV.
  23859. * @param uvScale is an optional vector2 used to scale UV.
  23860. * @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.
  23861. * @returns the Mesh.
  23862. */
  23863. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23864. /**
  23865. * Modify the mesh to get a flat shading rendering.
  23866. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23867. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23868. * @returns current mesh
  23869. */
  23870. convertToFlatShadedMesh(): Mesh;
  23871. /**
  23872. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23873. * In other words, more vertices, no more indices and a single bigger VBO.
  23874. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23875. * @returns current mesh
  23876. */
  23877. convertToUnIndexedMesh(): Mesh;
  23878. /**
  23879. * Inverses facet orientations.
  23880. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23881. * @param flipNormals will also inverts the normals
  23882. * @returns current mesh
  23883. */
  23884. flipFaces(flipNormals?: boolean): Mesh;
  23885. /**
  23886. * Increase the number of facets and hence vertices in a mesh
  23887. * Vertex normals are interpolated from existing vertex normals
  23888. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23889. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23890. */
  23891. increaseVertices(numberPerEdge: number): void;
  23892. /**
  23893. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23894. * This will undo any application of covertToFlatShadedMesh
  23895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23896. */
  23897. forceSharedVertices(): void;
  23898. /** @hidden */
  23899. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23900. /** @hidden */
  23901. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23902. /**
  23903. * Creates a new InstancedMesh object from the mesh model.
  23904. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23905. * @param name defines the name of the new instance
  23906. * @returns a new InstancedMesh
  23907. */
  23908. createInstance(name: string): InstancedMesh;
  23909. /**
  23910. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23911. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23912. * @returns the current mesh
  23913. */
  23914. synchronizeInstances(): Mesh;
  23915. /**
  23916. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23917. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23918. * This should be used together with the simplification to avoid disappearing triangles.
  23919. * @param successCallback an optional success callback to be called after the optimization finished.
  23920. * @returns the current mesh
  23921. */
  23922. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23923. /**
  23924. * Serialize current mesh
  23925. * @param serializationObject defines the object which will receive the serialization data
  23926. */
  23927. serialize(serializationObject: any): void;
  23928. /** @hidden */
  23929. _syncGeometryWithMorphTargetManager(): void;
  23930. /** @hidden */
  23931. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23932. /**
  23933. * Returns a new Mesh object parsed from the source provided.
  23934. * @param parsedMesh is the source
  23935. * @param scene defines the hosting scene
  23936. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23937. * @returns a new Mesh
  23938. */
  23939. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23940. /**
  23941. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23942. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23943. * @param name defines the name of the mesh to create
  23944. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23945. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23946. * @param closePath creates a seam between the first and the last points of each path of the path array
  23947. * @param offset is taken in account only if the `pathArray` is containing a single path
  23948. * @param scene defines the hosting scene
  23949. * @param updatable defines if the mesh must be flagged as updatable
  23950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23951. * @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)
  23952. * @returns a new Mesh
  23953. */
  23954. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23955. /**
  23956. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23957. * @param name defines the name of the mesh to create
  23958. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23959. * @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
  23960. * @param scene defines the hosting scene
  23961. * @param updatable defines if the mesh must be flagged as updatable
  23962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23963. * @returns a new Mesh
  23964. */
  23965. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23966. /**
  23967. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23968. * @param name defines the name of the mesh to create
  23969. * @param size sets the size (float) of each box side (default 1)
  23970. * @param scene defines the hosting scene
  23971. * @param updatable defines if the mesh must be flagged as updatable
  23972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23973. * @returns a new Mesh
  23974. */
  23975. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23976. /**
  23977. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23978. * @param name defines the name of the mesh to create
  23979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23981. * @param scene defines the hosting scene
  23982. * @param updatable defines if the mesh must be flagged as updatable
  23983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23984. * @returns a new Mesh
  23985. */
  23986. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23987. /**
  23988. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23989. * @param name defines the name of the mesh to create
  23990. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23991. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23992. * @param scene defines the hosting scene
  23993. * @returns a new Mesh
  23994. */
  23995. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23996. /**
  23997. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23998. * @param name defines the name of the mesh to create
  23999. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24000. * @param diameterTop set the top cap diameter (floats, default 1)
  24001. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24002. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24003. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24004. * @param scene defines the hosting scene
  24005. * @param updatable defines if the mesh must be flagged as updatable
  24006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24007. * @returns a new Mesh
  24008. */
  24009. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24010. /**
  24011. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24012. * @param name defines the name of the mesh to create
  24013. * @param diameter sets the diameter size (float) of the torus (default 1)
  24014. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24015. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24016. * @param scene defines the hosting scene
  24017. * @param updatable defines if the mesh must be flagged as updatable
  24018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24019. * @returns a new Mesh
  24020. */
  24021. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24022. /**
  24023. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24024. * @param name defines the name of the mesh to create
  24025. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24026. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24027. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24028. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24029. * @param p the number of windings on X axis (positive integers, default 2)
  24030. * @param q the number of windings on Y axis (positive integers, default 3)
  24031. * @param scene defines the hosting scene
  24032. * @param updatable defines if the mesh must be flagged as updatable
  24033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24034. * @returns a new Mesh
  24035. */
  24036. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24037. /**
  24038. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24039. * @param name defines the name of the mesh to create
  24040. * @param points is an array successive Vector3
  24041. * @param scene defines the hosting scene
  24042. * @param updatable defines if the mesh must be flagged as updatable
  24043. * @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).
  24044. * @returns a new Mesh
  24045. */
  24046. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24047. /**
  24048. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24049. * @param name defines the name of the mesh to create
  24050. * @param points is an array successive Vector3
  24051. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24052. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24053. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24054. * @param scene defines the hosting scene
  24055. * @param updatable defines if the mesh must be flagged as updatable
  24056. * @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)
  24057. * @returns a new Mesh
  24058. */
  24059. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24060. /**
  24061. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24063. * 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.
  24064. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24065. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24066. * Remember you can only change the shape positions, not their number when updating a polygon.
  24067. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24068. * @param name defines the name of the mesh to create
  24069. * @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
  24070. * @param scene defines the hosting scene
  24071. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24072. * @param updatable defines if the mesh must be flagged as updatable
  24073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24074. * @param earcutInjection can be used to inject your own earcut reference
  24075. * @returns a new Mesh
  24076. */
  24077. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24078. /**
  24079. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24080. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24081. * @param name defines the name of the mesh to create
  24082. * @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
  24083. * @param depth defines the height of extrusion
  24084. * @param scene defines the hosting scene
  24085. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24088. * @param earcutInjection can be used to inject your own earcut reference
  24089. * @returns a new Mesh
  24090. */
  24091. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24092. /**
  24093. * Creates an extruded shape mesh.
  24094. * 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
  24095. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24096. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24097. * @param name defines the name of the mesh to create
  24098. * @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
  24099. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24100. * @param scale is the value to scale the shape
  24101. * @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
  24102. * @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
  24103. * @param scene defines the hosting scene
  24104. * @param updatable defines if the mesh must be flagged as updatable
  24105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24106. * @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)
  24107. * @returns a new Mesh
  24108. */
  24109. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24110. /**
  24111. * Creates an custom extruded shape mesh.
  24112. * The custom extrusion is a parametric shape.
  24113. * It has no predefined shape. Its final shape will depend on the input parameters.
  24114. * Please consider using the same method from the MeshBuilder class instead
  24115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24116. * @param name defines the name of the mesh to create
  24117. * @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
  24118. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24119. * @param scaleFunction is a custom Javascript function called on each path point
  24120. * @param rotationFunction is a custom Javascript function called on each path point
  24121. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24122. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24123. * @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
  24124. * @param scene defines the hosting scene
  24125. * @param updatable defines if the mesh must be flagged as updatable
  24126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24127. * @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)
  24128. * @returns a new Mesh
  24129. */
  24130. 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;
  24131. /**
  24132. * Creates lathe mesh.
  24133. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24134. * Please consider using the same method from the MeshBuilder class instead
  24135. * @param name defines the name of the mesh to create
  24136. * @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
  24137. * @param radius is the radius value of the lathe
  24138. * @param tessellation is the side number of the lathe.
  24139. * @param scene defines the hosting scene
  24140. * @param updatable defines if the mesh must be flagged as updatable
  24141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24142. * @returns a new Mesh
  24143. */
  24144. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24145. /**
  24146. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24147. * @param name defines the name of the mesh to create
  24148. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24149. * @param scene defines the hosting scene
  24150. * @param updatable defines if the mesh must be flagged as updatable
  24151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24152. * @returns a new Mesh
  24153. */
  24154. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24155. /**
  24156. * Creates a ground mesh.
  24157. * Please consider using the same method from the MeshBuilder class instead
  24158. * @param name defines the name of the mesh to create
  24159. * @param width set the width of the ground
  24160. * @param height set the height of the ground
  24161. * @param subdivisions sets the number of subdivisions per side
  24162. * @param scene defines the hosting scene
  24163. * @param updatable defines if the mesh must be flagged as updatable
  24164. * @returns a new Mesh
  24165. */
  24166. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24167. /**
  24168. * Creates a tiled ground mesh.
  24169. * Please consider using the same method from the MeshBuilder class instead
  24170. * @param name defines the name of the mesh to create
  24171. * @param xmin set the ground minimum X coordinate
  24172. * @param zmin set the ground minimum Y coordinate
  24173. * @param xmax set the ground maximum X coordinate
  24174. * @param zmax set the ground maximum Z coordinate
  24175. * @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
  24176. * @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
  24177. * @param scene defines the hosting scene
  24178. * @param updatable defines if the mesh must be flagged as updatable
  24179. * @returns a new Mesh
  24180. */
  24181. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24182. w: number;
  24183. h: number;
  24184. }, precision: {
  24185. w: number;
  24186. h: number;
  24187. }, scene: Scene, updatable?: boolean): Mesh;
  24188. /**
  24189. * Creates a ground mesh from a height map.
  24190. * Please consider using the same method from the MeshBuilder class instead
  24191. * @see http://doc.babylonjs.com/babylon101/height_map
  24192. * @param name defines the name of the mesh to create
  24193. * @param url sets the URL of the height map image resource
  24194. * @param width set the ground width size
  24195. * @param height set the ground height size
  24196. * @param subdivisions sets the number of subdivision per side
  24197. * @param minHeight is the minimum altitude on the ground
  24198. * @param maxHeight is the maximum altitude on the ground
  24199. * @param scene defines the hosting scene
  24200. * @param updatable defines if the mesh must be flagged as updatable
  24201. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24202. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24203. * @returns a new Mesh
  24204. */
  24205. 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;
  24206. /**
  24207. * Creates a tube mesh.
  24208. * The tube is a parametric shape.
  24209. * It has no predefined shape. Its final shape will depend on the input parameters.
  24210. * Please consider using the same method from the MeshBuilder class instead
  24211. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24212. * @param name defines the name of the mesh to create
  24213. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24214. * @param radius sets the tube radius size
  24215. * @param tessellation is the number of sides on the tubular surface
  24216. * @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
  24217. * @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
  24218. * @param scene defines the hosting scene
  24219. * @param updatable defines if the mesh must be flagged as updatable
  24220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24221. * @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)
  24222. * @returns a new Mesh
  24223. */
  24224. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24225. (i: number, distance: number): number;
  24226. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24227. /**
  24228. * Creates a polyhedron mesh.
  24229. * Please consider using the same method from the MeshBuilder class instead.
  24230. * * 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
  24231. * * The parameter `size` (positive float, default 1) sets the polygon size
  24232. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24233. * * 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`
  24234. * * 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
  24235. * * 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)`)
  24236. * * 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
  24237. * * 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
  24238. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24239. * * 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
  24240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24241. * @param name defines the name of the mesh to create
  24242. * @param options defines the options used to create the mesh
  24243. * @param scene defines the hosting scene
  24244. * @returns a new Mesh
  24245. */
  24246. static CreatePolyhedron(name: string, options: {
  24247. type?: number;
  24248. size?: number;
  24249. sizeX?: number;
  24250. sizeY?: number;
  24251. sizeZ?: number;
  24252. custom?: any;
  24253. faceUV?: Vector4[];
  24254. faceColors?: Color4[];
  24255. updatable?: boolean;
  24256. sideOrientation?: number;
  24257. }, scene: Scene): Mesh;
  24258. /**
  24259. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24260. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24261. * * 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`)
  24262. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24263. * * 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
  24264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24265. * * 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
  24266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24267. * @param name defines the name of the mesh
  24268. * @param options defines the options used to create the mesh
  24269. * @param scene defines the hosting scene
  24270. * @returns a new Mesh
  24271. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24272. */
  24273. static CreateIcoSphere(name: string, options: {
  24274. radius?: number;
  24275. flat?: boolean;
  24276. subdivisions?: number;
  24277. sideOrientation?: number;
  24278. updatable?: boolean;
  24279. }, scene: Scene): Mesh;
  24280. /**
  24281. * Creates a decal mesh.
  24282. * Please consider using the same method from the MeshBuilder class instead.
  24283. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24284. * @param name defines the name of the mesh
  24285. * @param sourceMesh defines the mesh receiving the decal
  24286. * @param position sets the position of the decal in world coordinates
  24287. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24288. * @param size sets the decal scaling
  24289. * @param angle sets the angle to rotate the decal
  24290. * @returns a new Mesh
  24291. */
  24292. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24293. /**
  24294. * Prepare internal position array for software CPU skinning
  24295. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24296. */
  24297. setPositionsForCPUSkinning(): Float32Array;
  24298. /**
  24299. * Prepare internal normal array for software CPU skinning
  24300. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24301. */
  24302. setNormalsForCPUSkinning(): Float32Array;
  24303. /**
  24304. * Updates the vertex buffer by applying transformation from the bones
  24305. * @param skeleton defines the skeleton to apply to current mesh
  24306. * @returns the current mesh
  24307. */
  24308. applySkeleton(skeleton: Skeleton): Mesh;
  24309. /**
  24310. * 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
  24311. * @param meshes defines the list of meshes to scan
  24312. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24313. */
  24314. static MinMax(meshes: AbstractMesh[]): {
  24315. min: Vector3;
  24316. max: Vector3;
  24317. };
  24318. /**
  24319. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24320. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24321. * @returns a vector3
  24322. */
  24323. static Center(meshesOrMinMaxVector: {
  24324. min: Vector3;
  24325. max: Vector3;
  24326. } | AbstractMesh[]): Vector3;
  24327. /**
  24328. * Merge the array of meshes into a single mesh for performance reasons.
  24329. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24330. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24331. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24332. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24333. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24334. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24335. * @returns a new mesh
  24336. */
  24337. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24338. /** @hidden */
  24339. addInstance(instance: InstancedMesh): void;
  24340. /** @hidden */
  24341. removeInstance(instance: InstancedMesh): void;
  24342. }
  24343. }
  24344. declare module BABYLON {
  24345. /**
  24346. * This is the base class of all the camera used in the application.
  24347. * @see http://doc.babylonjs.com/features/cameras
  24348. */
  24349. export class Camera extends Node {
  24350. /** @hidden */
  24351. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24352. /**
  24353. * This is the default projection mode used by the cameras.
  24354. * It helps recreating a feeling of perspective and better appreciate depth.
  24355. * This is the best way to simulate real life cameras.
  24356. */
  24357. static readonly PERSPECTIVE_CAMERA: number;
  24358. /**
  24359. * This helps creating camera with an orthographic mode.
  24360. * 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.
  24361. */
  24362. static readonly ORTHOGRAPHIC_CAMERA: number;
  24363. /**
  24364. * This is the default FOV mode for perspective cameras.
  24365. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24366. */
  24367. static readonly FOVMODE_VERTICAL_FIXED: number;
  24368. /**
  24369. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24370. */
  24371. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24372. /**
  24373. * This specifies ther is no need for a camera rig.
  24374. * Basically only one eye is rendered corresponding to the camera.
  24375. */
  24376. static readonly RIG_MODE_NONE: number;
  24377. /**
  24378. * Simulates a camera Rig with one blue eye and one red eye.
  24379. * This can be use with 3d blue and red glasses.
  24380. */
  24381. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24382. /**
  24383. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24384. */
  24385. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24386. /**
  24387. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24388. */
  24389. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24390. /**
  24391. * Defines that both eyes of the camera will be rendered over under each other.
  24392. */
  24393. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24394. /**
  24395. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24396. */
  24397. static readonly RIG_MODE_VR: number;
  24398. /**
  24399. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24400. */
  24401. static readonly RIG_MODE_WEBVR: number;
  24402. /**
  24403. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24404. */
  24405. static readonly RIG_MODE_CUSTOM: number;
  24406. /**
  24407. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24408. */
  24409. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24410. /**
  24411. * Define the input manager associated with the camera.
  24412. */
  24413. inputs: CameraInputsManager<Camera>;
  24414. /** @hidden */
  24415. _position: Vector3;
  24416. /**
  24417. * Define the current local position of the camera in the scene
  24418. */
  24419. position: Vector3;
  24420. /**
  24421. * The vector the camera should consider as up.
  24422. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24423. */
  24424. upVector: Vector3;
  24425. /**
  24426. * Define the current limit on the left side for an orthographic camera
  24427. * In scene unit
  24428. */
  24429. orthoLeft: Nullable<number>;
  24430. /**
  24431. * Define the current limit on the right side for an orthographic camera
  24432. * In scene unit
  24433. */
  24434. orthoRight: Nullable<number>;
  24435. /**
  24436. * Define the current limit on the bottom side for an orthographic camera
  24437. * In scene unit
  24438. */
  24439. orthoBottom: Nullable<number>;
  24440. /**
  24441. * Define the current limit on the top side for an orthographic camera
  24442. * In scene unit
  24443. */
  24444. orthoTop: Nullable<number>;
  24445. /**
  24446. * Field Of View is set in Radians. (default is 0.8)
  24447. */
  24448. fov: number;
  24449. /**
  24450. * Define the minimum distance the camera can see from.
  24451. * This is important to note that the depth buffer are not infinite and the closer it starts
  24452. * the more your scene might encounter depth fighting issue.
  24453. */
  24454. minZ: number;
  24455. /**
  24456. * Define the maximum distance the camera can see to.
  24457. * This is important to note that the depth buffer are not infinite and the further it end
  24458. * the more your scene might encounter depth fighting issue.
  24459. */
  24460. maxZ: number;
  24461. /**
  24462. * Define the default inertia of the camera.
  24463. * This helps giving a smooth feeling to the camera movement.
  24464. */
  24465. inertia: number;
  24466. /**
  24467. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24468. */
  24469. mode: number;
  24470. /**
  24471. * Define wether the camera is intermediate.
  24472. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24473. */
  24474. isIntermediate: boolean;
  24475. /**
  24476. * Define the viewport of the camera.
  24477. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24478. */
  24479. viewport: Viewport;
  24480. /**
  24481. * Restricts the camera to viewing objects with the same layerMask.
  24482. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24483. */
  24484. layerMask: number;
  24485. /**
  24486. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24487. */
  24488. fovMode: number;
  24489. /**
  24490. * Rig mode of the camera.
  24491. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24492. * This is normally controlled byt the camera themselves as internal use.
  24493. */
  24494. cameraRigMode: number;
  24495. /**
  24496. * Defines the distance between both "eyes" in case of a RIG
  24497. */
  24498. interaxialDistance: number;
  24499. /**
  24500. * Defines if stereoscopic rendering is done side by side or over under.
  24501. */
  24502. isStereoscopicSideBySide: boolean;
  24503. /**
  24504. * 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
  24505. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24506. * else in the scene. (Eg. security camera)
  24507. *
  24508. * 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)
  24509. */
  24510. customRenderTargets: RenderTargetTexture[];
  24511. /**
  24512. * When set, the camera will render to this render target instead of the default canvas
  24513. *
  24514. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24515. */
  24516. outputRenderTarget: Nullable<RenderTargetTexture>;
  24517. /**
  24518. * Observable triggered when the camera view matrix has changed.
  24519. */
  24520. onViewMatrixChangedObservable: Observable<Camera>;
  24521. /**
  24522. * Observable triggered when the camera Projection matrix has changed.
  24523. */
  24524. onProjectionMatrixChangedObservable: Observable<Camera>;
  24525. /**
  24526. * Observable triggered when the inputs have been processed.
  24527. */
  24528. onAfterCheckInputsObservable: Observable<Camera>;
  24529. /**
  24530. * Observable triggered when reset has been called and applied to the camera.
  24531. */
  24532. onRestoreStateObservable: Observable<Camera>;
  24533. /** @hidden */
  24534. _cameraRigParams: any;
  24535. /** @hidden */
  24536. _rigCameras: Camera[];
  24537. /** @hidden */
  24538. _rigPostProcess: Nullable<PostProcess>;
  24539. protected _webvrViewMatrix: Matrix;
  24540. /** @hidden */
  24541. _skipRendering: boolean;
  24542. /** @hidden */
  24543. _projectionMatrix: Matrix;
  24544. /** @hidden */
  24545. _postProcesses: Nullable<PostProcess>[];
  24546. /** @hidden */
  24547. _activeMeshes: SmartArray<AbstractMesh>;
  24548. protected _globalPosition: Vector3;
  24549. /** @hidden */
  24550. _computedViewMatrix: Matrix;
  24551. private _doNotComputeProjectionMatrix;
  24552. private _transformMatrix;
  24553. private _frustumPlanes;
  24554. private _refreshFrustumPlanes;
  24555. private _storedFov;
  24556. private _stateStored;
  24557. /**
  24558. * Instantiates a new camera object.
  24559. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24560. * @see http://doc.babylonjs.com/features/cameras
  24561. * @param name Defines the name of the camera in the scene
  24562. * @param position Defines the position of the camera
  24563. * @param scene Defines the scene the camera belongs too
  24564. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24565. */
  24566. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24567. /**
  24568. * Store current camera state (fov, position, etc..)
  24569. * @returns the camera
  24570. */
  24571. storeState(): Camera;
  24572. /**
  24573. * Restores the camera state values if it has been stored. You must call storeState() first
  24574. */
  24575. protected _restoreStateValues(): boolean;
  24576. /**
  24577. * Restored camera state. You must call storeState() first.
  24578. * @returns true if restored and false otherwise
  24579. */
  24580. restoreState(): boolean;
  24581. /**
  24582. * Gets the class name of the camera.
  24583. * @returns the class name
  24584. */
  24585. getClassName(): string;
  24586. /** @hidden */
  24587. readonly _isCamera: boolean;
  24588. /**
  24589. * Gets a string representation of the camera useful for debug purpose.
  24590. * @param fullDetails Defines that a more verboe level of logging is required
  24591. * @returns the string representation
  24592. */
  24593. toString(fullDetails?: boolean): string;
  24594. /**
  24595. * Gets the current world space position of the camera.
  24596. */
  24597. readonly globalPosition: Vector3;
  24598. /**
  24599. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24600. * @returns the active meshe list
  24601. */
  24602. getActiveMeshes(): SmartArray<AbstractMesh>;
  24603. /**
  24604. * Check wether a mesh is part of the current active mesh list of the camera
  24605. * @param mesh Defines the mesh to check
  24606. * @returns true if active, false otherwise
  24607. */
  24608. isActiveMesh(mesh: Mesh): boolean;
  24609. /**
  24610. * Is this camera ready to be used/rendered
  24611. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24612. * @return true if the camera is ready
  24613. */
  24614. isReady(completeCheck?: boolean): boolean;
  24615. /** @hidden */
  24616. _initCache(): void;
  24617. /** @hidden */
  24618. _updateCache(ignoreParentClass?: boolean): void;
  24619. /** @hidden */
  24620. _isSynchronized(): boolean;
  24621. /** @hidden */
  24622. _isSynchronizedViewMatrix(): boolean;
  24623. /** @hidden */
  24624. _isSynchronizedProjectionMatrix(): boolean;
  24625. /**
  24626. * Attach the input controls to a specific dom element to get the input from.
  24627. * @param element Defines the element the controls should be listened from
  24628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24629. */
  24630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24631. /**
  24632. * Detach the current controls from the specified dom element.
  24633. * @param element Defines the element to stop listening the inputs from
  24634. */
  24635. detachControl(element: HTMLElement): void;
  24636. /**
  24637. * Update the camera state according to the different inputs gathered during the frame.
  24638. */
  24639. update(): void;
  24640. /** @hidden */
  24641. _checkInputs(): void;
  24642. /** @hidden */
  24643. readonly rigCameras: Camera[];
  24644. /**
  24645. * Gets the post process used by the rig cameras
  24646. */
  24647. readonly rigPostProcess: Nullable<PostProcess>;
  24648. /**
  24649. * Internal, gets the first post proces.
  24650. * @returns the first post process to be run on this camera.
  24651. */
  24652. _getFirstPostProcess(): Nullable<PostProcess>;
  24653. private _cascadePostProcessesToRigCams;
  24654. /**
  24655. * Attach a post process to the camera.
  24656. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24657. * @param postProcess The post process to attach to the camera
  24658. * @param insertAt The position of the post process in case several of them are in use in the scene
  24659. * @returns the position the post process has been inserted at
  24660. */
  24661. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24662. /**
  24663. * Detach a post process to the camera.
  24664. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24665. * @param postProcess The post process to detach from the camera
  24666. */
  24667. detachPostProcess(postProcess: PostProcess): void;
  24668. /**
  24669. * Gets the current world matrix of the camera
  24670. */
  24671. getWorldMatrix(): Matrix;
  24672. /** @hidden */
  24673. _getViewMatrix(): Matrix;
  24674. /**
  24675. * Gets the current view matrix of the camera.
  24676. * @param force forces the camera to recompute the matrix without looking at the cached state
  24677. * @returns the view matrix
  24678. */
  24679. getViewMatrix(force?: boolean): Matrix;
  24680. /**
  24681. * Freeze the projection matrix.
  24682. * It will prevent the cache check of the camera projection compute and can speed up perf
  24683. * if no parameter of the camera are meant to change
  24684. * @param projection Defines manually a projection if necessary
  24685. */
  24686. freezeProjectionMatrix(projection?: Matrix): void;
  24687. /**
  24688. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24689. */
  24690. unfreezeProjectionMatrix(): void;
  24691. /**
  24692. * Gets the current projection matrix of the camera.
  24693. * @param force forces the camera to recompute the matrix without looking at the cached state
  24694. * @returns the projection matrix
  24695. */
  24696. getProjectionMatrix(force?: boolean): Matrix;
  24697. /**
  24698. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24699. * @returns a Matrix
  24700. */
  24701. getTransformationMatrix(): Matrix;
  24702. private _updateFrustumPlanes;
  24703. /**
  24704. * Checks if a cullable object (mesh...) is in the camera frustum
  24705. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24706. * @param target The object to check
  24707. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24708. * @returns true if the object is in frustum otherwise false
  24709. */
  24710. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24711. /**
  24712. * Checks if a cullable object (mesh...) is in the camera frustum
  24713. * Unlike isInFrustum this cheks the full bounding box
  24714. * @param target The object to check
  24715. * @returns true if the object is in frustum otherwise false
  24716. */
  24717. isCompletelyInFrustum(target: ICullable): boolean;
  24718. /**
  24719. * Gets a ray in the forward direction from the camera.
  24720. * @param length Defines the length of the ray to create
  24721. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24722. * @param origin Defines the start point of the ray which defaults to the camera position
  24723. * @returns the forward ray
  24724. */
  24725. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24726. /**
  24727. * Releases resources associated with this node.
  24728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24730. */
  24731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24732. /** @hidden */
  24733. _isLeftCamera: boolean;
  24734. /**
  24735. * Gets the left camera of a rig setup in case of Rigged Camera
  24736. */
  24737. readonly isLeftCamera: boolean;
  24738. /** @hidden */
  24739. _isRightCamera: boolean;
  24740. /**
  24741. * Gets the right camera of a rig setup in case of Rigged Camera
  24742. */
  24743. readonly isRightCamera: boolean;
  24744. /**
  24745. * Gets the left camera of a rig setup in case of Rigged Camera
  24746. */
  24747. readonly leftCamera: Nullable<FreeCamera>;
  24748. /**
  24749. * Gets the right camera of a rig setup in case of Rigged Camera
  24750. */
  24751. readonly rightCamera: Nullable<FreeCamera>;
  24752. /**
  24753. * Gets the left camera target of a rig setup in case of Rigged Camera
  24754. * @returns the target position
  24755. */
  24756. getLeftTarget(): Nullable<Vector3>;
  24757. /**
  24758. * Gets the right camera target of a rig setup in case of Rigged Camera
  24759. * @returns the target position
  24760. */
  24761. getRightTarget(): Nullable<Vector3>;
  24762. /**
  24763. * @hidden
  24764. */
  24765. setCameraRigMode(mode: number, rigParams: any): void;
  24766. /** @hidden */
  24767. static _setStereoscopicRigMode(camera: Camera): void;
  24768. /** @hidden */
  24769. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24770. /** @hidden */
  24771. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24772. /** @hidden */
  24773. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24774. /** @hidden */
  24775. _getVRProjectionMatrix(): Matrix;
  24776. protected _updateCameraRotationMatrix(): void;
  24777. protected _updateWebVRCameraRotationMatrix(): void;
  24778. /**
  24779. * This function MUST be overwritten by the different WebVR cameras available.
  24780. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24781. * @hidden
  24782. */
  24783. _getWebVRProjectionMatrix(): Matrix;
  24784. /**
  24785. * This function MUST be overwritten by the different WebVR cameras available.
  24786. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24787. * @hidden
  24788. */
  24789. _getWebVRViewMatrix(): Matrix;
  24790. /** @hidden */
  24791. setCameraRigParameter(name: string, value: any): void;
  24792. /**
  24793. * needs to be overridden by children so sub has required properties to be copied
  24794. * @hidden
  24795. */
  24796. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24797. /**
  24798. * May need to be overridden by children
  24799. * @hidden
  24800. */
  24801. _updateRigCameras(): void;
  24802. /** @hidden */
  24803. _setupInputs(): void;
  24804. /**
  24805. * Serialiaze the camera setup to a json represention
  24806. * @returns the JSON representation
  24807. */
  24808. serialize(): any;
  24809. /**
  24810. * Clones the current camera.
  24811. * @param name The cloned camera name
  24812. * @returns the cloned camera
  24813. */
  24814. clone(name: string): Camera;
  24815. /**
  24816. * Gets the direction of the camera relative to a given local axis.
  24817. * @param localAxis Defines the reference axis to provide a relative direction.
  24818. * @return the direction
  24819. */
  24820. getDirection(localAxis: Vector3): Vector3;
  24821. /**
  24822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24823. * @param localAxis Defines the reference axis to provide a relative direction.
  24824. * @param result Defines the vector to store the result in
  24825. */
  24826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24827. /**
  24828. * Gets a camera constructor for a given camera type
  24829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24830. * @param name The name of the camera the result will be able to instantiate
  24831. * @param scene The scene the result will construct the camera in
  24832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24834. * @returns a factory method to construc the camera
  24835. */
  24836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24837. /**
  24838. * Compute the world matrix of the camera.
  24839. * @returns the camera workd matrix
  24840. */
  24841. computeWorldMatrix(): Matrix;
  24842. /**
  24843. * Parse a JSON and creates the camera from the parsed information
  24844. * @param parsedCamera The JSON to parse
  24845. * @param scene The scene to instantiate the camera in
  24846. * @returns the newly constructed camera
  24847. */
  24848. static Parse(parsedCamera: any, scene: Scene): Camera;
  24849. }
  24850. }
  24851. declare module BABYLON {
  24852. /**
  24853. * Class containing static functions to help procedurally build meshes
  24854. */
  24855. export class DiscBuilder {
  24856. /**
  24857. * Creates a plane polygonal mesh. By default, this is a disc
  24858. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24859. * * 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
  24860. * * 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
  24861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24862. * * 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
  24863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24864. * @param name defines the name of the mesh
  24865. * @param options defines the options used to create the mesh
  24866. * @param scene defines the hosting scene
  24867. * @returns the plane polygonal mesh
  24868. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24869. */
  24870. static CreateDisc(name: string, options: {
  24871. radius?: number;
  24872. tessellation?: number;
  24873. arc?: number;
  24874. updatable?: boolean;
  24875. sideOrientation?: number;
  24876. frontUVs?: Vector4;
  24877. backUVs?: Vector4;
  24878. }, scene?: Nullable<Scene>): Mesh;
  24879. }
  24880. }
  24881. declare module BABYLON {
  24882. /**
  24883. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24884. *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.
  24885. * The SPS is also a particle system. It provides some methods to manage the particles.
  24886. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24887. *
  24888. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24889. */
  24890. export class SolidParticleSystem implements IDisposable {
  24891. /**
  24892. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24893. * Example : var p = SPS.particles[i];
  24894. */
  24895. particles: SolidParticle[];
  24896. /**
  24897. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24898. */
  24899. nbParticles: number;
  24900. /**
  24901. * If the particles must ever face the camera (default false). Useful for planar particles.
  24902. */
  24903. billboard: boolean;
  24904. /**
  24905. * Recompute normals when adding a shape
  24906. */
  24907. recomputeNormals: boolean;
  24908. /**
  24909. * This a counter ofr your own usage. It's not set by any SPS functions.
  24910. */
  24911. counter: number;
  24912. /**
  24913. * The SPS name. This name is also given to the underlying mesh.
  24914. */
  24915. name: string;
  24916. /**
  24917. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24918. */
  24919. mesh: Mesh;
  24920. /**
  24921. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24922. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24923. */
  24924. vars: any;
  24925. /**
  24926. * This array is populated when the SPS is set as 'pickable'.
  24927. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24928. * Each element of this array is an object `{idx: int, faceId: int}`.
  24929. * `idx` is the picked particle index in the `SPS.particles` array
  24930. * `faceId` is the picked face index counted within this particle.
  24931. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24932. */
  24933. pickedParticles: {
  24934. idx: number;
  24935. faceId: number;
  24936. }[];
  24937. /**
  24938. * This array is populated when `enableDepthSort` is set to true.
  24939. * Each element of this array is an instance of the class DepthSortedParticle.
  24940. */
  24941. depthSortedParticles: DepthSortedParticle[];
  24942. /**
  24943. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24944. * @hidden
  24945. */
  24946. _bSphereOnly: boolean;
  24947. /**
  24948. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24949. * @hidden
  24950. */
  24951. _bSphereRadiusFactor: number;
  24952. private _scene;
  24953. private _positions;
  24954. private _indices;
  24955. private _normals;
  24956. private _colors;
  24957. private _uvs;
  24958. private _indices32;
  24959. private _positions32;
  24960. private _normals32;
  24961. private _fixedNormal32;
  24962. private _colors32;
  24963. private _uvs32;
  24964. private _index;
  24965. private _updatable;
  24966. private _pickable;
  24967. private _isVisibilityBoxLocked;
  24968. private _alwaysVisible;
  24969. private _depthSort;
  24970. private _shapeCounter;
  24971. private _copy;
  24972. private _color;
  24973. private _computeParticleColor;
  24974. private _computeParticleTexture;
  24975. private _computeParticleRotation;
  24976. private _computeParticleVertex;
  24977. private _computeBoundingBox;
  24978. private _depthSortParticles;
  24979. private _camera;
  24980. private _mustUnrotateFixedNormals;
  24981. private _particlesIntersect;
  24982. private _needs32Bits;
  24983. /**
  24984. * Creates a SPS (Solid Particle System) object.
  24985. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24986. * @param scene (Scene) is the scene in which the SPS is added.
  24987. * @param options defines the options of the sps e.g.
  24988. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24989. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24990. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24991. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24992. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24993. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24994. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24995. */
  24996. constructor(name: string, scene: Scene, options?: {
  24997. updatable?: boolean;
  24998. isPickable?: boolean;
  24999. enableDepthSort?: boolean;
  25000. particleIntersection?: boolean;
  25001. boundingSphereOnly?: boolean;
  25002. bSphereRadiusFactor?: number;
  25003. });
  25004. /**
  25005. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25006. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25007. * @returns the created mesh
  25008. */
  25009. buildMesh(): Mesh;
  25010. /**
  25011. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25012. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25013. * Thus the particles generated from `digest()` have their property `position` set yet.
  25014. * @param mesh ( Mesh ) is the mesh to be digested
  25015. * @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
  25016. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25017. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25018. * @returns the current SPS
  25019. */
  25020. digest(mesh: Mesh, options?: {
  25021. facetNb?: number;
  25022. number?: number;
  25023. delta?: number;
  25024. }): SolidParticleSystem;
  25025. private _unrotateFixedNormals;
  25026. private _resetCopy;
  25027. private _meshBuilder;
  25028. private _posToShape;
  25029. private _uvsToShapeUV;
  25030. private _addParticle;
  25031. /**
  25032. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25033. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25034. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25035. * @param nb (positive integer) the number of particles to be created from this model
  25036. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25037. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25038. * @returns the number of shapes in the system
  25039. */
  25040. addShape(mesh: Mesh, nb: number, options?: {
  25041. positionFunction?: any;
  25042. vertexFunction?: any;
  25043. }): number;
  25044. private _rebuildParticle;
  25045. /**
  25046. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25047. * @returns the SPS.
  25048. */
  25049. rebuildMesh(): SolidParticleSystem;
  25050. /**
  25051. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25052. * This method calls `updateParticle()` for each particle of the SPS.
  25053. * For an animated SPS, it is usually called within the render loop.
  25054. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25055. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25056. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25057. * @returns the SPS.
  25058. */
  25059. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25060. /**
  25061. * Disposes the SPS.
  25062. */
  25063. dispose(): void;
  25064. /**
  25065. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25067. * @returns the SPS.
  25068. */
  25069. refreshVisibleSize(): SolidParticleSystem;
  25070. /**
  25071. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25072. * @param size the size (float) of the visibility box
  25073. * note : this doesn't lock the SPS mesh bounding box.
  25074. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25075. */
  25076. setVisibilityBox(size: number): void;
  25077. /**
  25078. * Gets whether the SPS as always visible or not
  25079. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25080. */
  25081. /**
  25082. * Sets the SPS as always visible or not
  25083. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25084. */
  25085. isAlwaysVisible: boolean;
  25086. /**
  25087. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25089. */
  25090. /**
  25091. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25093. */
  25094. isVisibilityBoxLocked: boolean;
  25095. /**
  25096. * Tells to `setParticles()` to compute the particle rotations or not.
  25097. * Default value : true. The SPS is faster when it's set to false.
  25098. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25099. */
  25100. /**
  25101. * Gets if `setParticles()` computes the particle rotations or not.
  25102. * Default value : true. The SPS is faster when it's set to false.
  25103. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25104. */
  25105. computeParticleRotation: boolean;
  25106. /**
  25107. * Tells to `setParticles()` to compute the particle colors or not.
  25108. * Default value : true. The SPS is faster when it's set to false.
  25109. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25110. */
  25111. /**
  25112. * Gets if `setParticles()` computes the particle colors or not.
  25113. * Default value : true. The SPS is faster when it's set to false.
  25114. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25115. */
  25116. computeParticleColor: boolean;
  25117. /**
  25118. * Gets if `setParticles()` computes the particle textures or not.
  25119. * Default value : true. The SPS is faster when it's set to false.
  25120. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25121. */
  25122. computeParticleTexture: boolean;
  25123. /**
  25124. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25125. * Default value : false. The SPS is faster when it's set to false.
  25126. * Note : the particle custom vertex positions aren't stored values.
  25127. */
  25128. /**
  25129. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25130. * Default value : false. The SPS is faster when it's set to false.
  25131. * Note : the particle custom vertex positions aren't stored values.
  25132. */
  25133. computeParticleVertex: boolean;
  25134. /**
  25135. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25136. */
  25137. /**
  25138. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25139. */
  25140. computeBoundingBox: boolean;
  25141. /**
  25142. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25143. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25144. * Default : `true`
  25145. */
  25146. /**
  25147. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25148. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25149. * Default : `true`
  25150. */
  25151. depthSortParticles: boolean;
  25152. /**
  25153. * This function does nothing. It may be overwritten to set all the particle first values.
  25154. * The SPS doesn't call this function, you may have to call it by your own.
  25155. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25156. */
  25157. initParticles(): void;
  25158. /**
  25159. * This function does nothing. It may be overwritten to recycle a particle.
  25160. * The SPS doesn't call this function, you may have to call it by your own.
  25161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25162. * @param particle The particle to recycle
  25163. * @returns the recycled particle
  25164. */
  25165. recycleParticle(particle: SolidParticle): SolidParticle;
  25166. /**
  25167. * Updates a particle : this function should be overwritten by the user.
  25168. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25169. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25170. * @example : just set a particle position or velocity and recycle conditions
  25171. * @param particle The particle to update
  25172. * @returns the updated particle
  25173. */
  25174. updateParticle(particle: SolidParticle): SolidParticle;
  25175. /**
  25176. * Updates a vertex of a particle : it can be overwritten by the user.
  25177. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25178. * @param particle the current particle
  25179. * @param vertex the current index of the current particle
  25180. * @param pt the index of the current vertex in the particle shape
  25181. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25182. * @example : just set a vertex particle position
  25183. * @returns the updated vertex
  25184. */
  25185. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25186. /**
  25187. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25188. * This does nothing and may be overwritten by the user.
  25189. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25191. * @param update the boolean update value actually passed to setParticles()
  25192. */
  25193. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25194. /**
  25195. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25196. * This will be passed three parameters.
  25197. * This does nothing and may be overwritten by the user.
  25198. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25199. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25200. * @param update the boolean update value actually passed to setParticles()
  25201. */
  25202. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25203. }
  25204. }
  25205. declare module BABYLON {
  25206. /**
  25207. * Represents one particle of a solid particle system.
  25208. */
  25209. export class SolidParticle {
  25210. /**
  25211. * particle global index
  25212. */
  25213. idx: number;
  25214. /**
  25215. * The color of the particle
  25216. */
  25217. color: Nullable<Color4>;
  25218. /**
  25219. * The world space position of the particle.
  25220. */
  25221. position: Vector3;
  25222. /**
  25223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25224. */
  25225. rotation: Vector3;
  25226. /**
  25227. * The world space rotation quaternion of the particle.
  25228. */
  25229. rotationQuaternion: Nullable<Quaternion>;
  25230. /**
  25231. * The scaling of the particle.
  25232. */
  25233. scaling: Vector3;
  25234. /**
  25235. * The uvs of the particle.
  25236. */
  25237. uvs: Vector4;
  25238. /**
  25239. * The current speed of the particle.
  25240. */
  25241. velocity: Vector3;
  25242. /**
  25243. * The pivot point in the particle local space.
  25244. */
  25245. pivot: Vector3;
  25246. /**
  25247. * Must the particle be translated from its pivot point in its local space ?
  25248. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25249. * Default : false
  25250. */
  25251. translateFromPivot: boolean;
  25252. /**
  25253. * Is the particle active or not ?
  25254. */
  25255. alive: boolean;
  25256. /**
  25257. * Is the particle visible or not ?
  25258. */
  25259. isVisible: boolean;
  25260. /**
  25261. * Index of this particle in the global "positions" array (Internal use)
  25262. * @hidden
  25263. */
  25264. _pos: number;
  25265. /**
  25266. * @hidden Index of this particle in the global "indices" array (Internal use)
  25267. */
  25268. _ind: number;
  25269. /**
  25270. * @hidden ModelShape of this particle (Internal use)
  25271. */
  25272. _model: ModelShape;
  25273. /**
  25274. * ModelShape id of this particle
  25275. */
  25276. shapeId: number;
  25277. /**
  25278. * Index of the particle in its shape id (Internal use)
  25279. */
  25280. idxInShape: number;
  25281. /**
  25282. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25283. */
  25284. _modelBoundingInfo: BoundingInfo;
  25285. /**
  25286. * @hidden Particle BoundingInfo object (Internal use)
  25287. */
  25288. _boundingInfo: BoundingInfo;
  25289. /**
  25290. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25291. */
  25292. _sps: SolidParticleSystem;
  25293. /**
  25294. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25295. */
  25296. _stillInvisible: boolean;
  25297. /**
  25298. * @hidden Last computed particle rotation matrix
  25299. */
  25300. _rotationMatrix: number[];
  25301. /**
  25302. * Parent particle Id, if any.
  25303. * Default null.
  25304. */
  25305. parentId: Nullable<number>;
  25306. /**
  25307. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25308. * The possible values are :
  25309. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25310. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25313. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25314. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25315. * */
  25316. cullingStrategy: number;
  25317. /**
  25318. * @hidden Internal global position in the SPS.
  25319. */
  25320. _globalPosition: Vector3;
  25321. /**
  25322. * Creates a Solid Particle object.
  25323. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25324. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25328. * @param shapeId (integer) is the model shape identifier in the SPS.
  25329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25330. * @param sps defines the sps it is associated to
  25331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25332. */
  25333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25334. /**
  25335. * Legacy support, changed scale to scaling
  25336. */
  25337. /**
  25338. * Legacy support, changed scale to scaling
  25339. */
  25340. scale: Vector3;
  25341. /**
  25342. * Legacy support, changed quaternion to rotationQuaternion
  25343. */
  25344. /**
  25345. * Legacy support, changed quaternion to rotationQuaternion
  25346. */
  25347. quaternion: Nullable<Quaternion>;
  25348. /**
  25349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25352. * @returns true if it intersects
  25353. */
  25354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25355. /**
  25356. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25357. * A particle is in the frustum if its bounding box intersects the frustum
  25358. * @param frustumPlanes defines the frustum to test
  25359. * @returns true if the particle is in the frustum planes
  25360. */
  25361. isInFrustum(frustumPlanes: Plane[]): boolean;
  25362. /**
  25363. * get the rotation matrix of the particle
  25364. * @hidden
  25365. */
  25366. getRotationMatrix(m: Matrix): void;
  25367. }
  25368. /**
  25369. * Represents the shape of the model used by one particle of a solid particle system.
  25370. * SPS internal tool, don't use it manually.
  25371. */
  25372. export class ModelShape {
  25373. /**
  25374. * The shape id
  25375. * @hidden
  25376. */
  25377. shapeID: number;
  25378. /**
  25379. * flat array of model positions (internal use)
  25380. * @hidden
  25381. */
  25382. _shape: Vector3[];
  25383. /**
  25384. * flat array of model UVs (internal use)
  25385. * @hidden
  25386. */
  25387. _shapeUV: number[];
  25388. /**
  25389. * length of the shape in the model indices array (internal use)
  25390. * @hidden
  25391. */
  25392. _indicesLength: number;
  25393. /**
  25394. * Custom position function (internal use)
  25395. * @hidden
  25396. */
  25397. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25398. /**
  25399. * Custom vertex function (internal use)
  25400. * @hidden
  25401. */
  25402. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25403. /**
  25404. * 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.
  25405. * SPS internal tool, don't use it manually.
  25406. * @hidden
  25407. */
  25408. 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>);
  25409. }
  25410. /**
  25411. * Represents a Depth Sorted Particle in the solid particle system.
  25412. */
  25413. export class DepthSortedParticle {
  25414. /**
  25415. * Index of the particle in the "indices" array
  25416. */
  25417. ind: number;
  25418. /**
  25419. * Length of the particle shape in the "indices" array
  25420. */
  25421. indicesLength: number;
  25422. /**
  25423. * Squared distance from the particle to the camera
  25424. */
  25425. sqDistance: number;
  25426. }
  25427. }
  25428. declare module BABYLON {
  25429. /**
  25430. * @hidden
  25431. */
  25432. export class _MeshCollisionData {
  25433. _checkCollisions: boolean;
  25434. _collisionMask: number;
  25435. _collisionGroup: number;
  25436. _collider: Nullable<Collider>;
  25437. _oldPositionForCollisions: Vector3;
  25438. _diffPositionForCollisions: Vector3;
  25439. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25440. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25441. }
  25442. }
  25443. declare module BABYLON {
  25444. /** @hidden */
  25445. class _FacetDataStorage {
  25446. facetPositions: Vector3[];
  25447. facetNormals: Vector3[];
  25448. facetPartitioning: number[][];
  25449. facetNb: number;
  25450. partitioningSubdivisions: number;
  25451. partitioningBBoxRatio: number;
  25452. facetDataEnabled: boolean;
  25453. facetParameters: any;
  25454. bbSize: Vector3;
  25455. subDiv: {
  25456. max: number;
  25457. X: number;
  25458. Y: number;
  25459. Z: number;
  25460. };
  25461. facetDepthSort: boolean;
  25462. facetDepthSortEnabled: boolean;
  25463. depthSortedIndices: IndicesArray;
  25464. depthSortedFacets: {
  25465. ind: number;
  25466. sqDistance: number;
  25467. }[];
  25468. facetDepthSortFunction: (f1: {
  25469. ind: number;
  25470. sqDistance: number;
  25471. }, f2: {
  25472. ind: number;
  25473. sqDistance: number;
  25474. }) => number;
  25475. facetDepthSortFrom: Vector3;
  25476. facetDepthSortOrigin: Vector3;
  25477. invertedMatrix: Matrix;
  25478. }
  25479. /**
  25480. * @hidden
  25481. **/
  25482. class _InternalAbstractMeshDataInfo {
  25483. _hasVertexAlpha: boolean;
  25484. _useVertexColors: boolean;
  25485. _numBoneInfluencers: number;
  25486. _applyFog: boolean;
  25487. _receiveShadows: boolean;
  25488. _facetData: _FacetDataStorage;
  25489. _visibility: number;
  25490. _skeleton: Nullable<Skeleton>;
  25491. _layerMask: number;
  25492. _computeBonesUsingShaders: boolean;
  25493. _isActive: boolean;
  25494. _onlyForInstances: boolean;
  25495. _isActiveIntermediate: boolean;
  25496. _onlyForInstancesIntermediate: boolean;
  25497. }
  25498. /**
  25499. * Class used to store all common mesh properties
  25500. */
  25501. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25502. /** No occlusion */
  25503. static OCCLUSION_TYPE_NONE: number;
  25504. /** Occlusion set to optimisitic */
  25505. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25506. /** Occlusion set to strict */
  25507. static OCCLUSION_TYPE_STRICT: number;
  25508. /** Use an accurante occlusion algorithm */
  25509. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25510. /** Use a conservative occlusion algorithm */
  25511. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25512. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25513. * Test order :
  25514. * Is the bounding sphere outside the frustum ?
  25515. * If not, are the bounding box vertices outside the frustum ?
  25516. * It not, then the cullable object is in the frustum.
  25517. */
  25518. static readonly CULLINGSTRATEGY_STANDARD: number;
  25519. /** Culling strategy : Bounding Sphere Only.
  25520. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25521. * It's also less accurate than the standard because some not visible objects can still be selected.
  25522. * Test : is the bounding sphere outside the frustum ?
  25523. * If not, then the cullable object is in the frustum.
  25524. */
  25525. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25526. /** Culling strategy : Optimistic Inclusion.
  25527. * This in an inclusion test first, then the standard exclusion test.
  25528. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25529. * 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.
  25530. * Anyway, it's as accurate as the standard strategy.
  25531. * Test :
  25532. * Is the cullable object bounding sphere center in the frustum ?
  25533. * If not, apply the default culling strategy.
  25534. */
  25535. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25536. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25537. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25538. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25539. * 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.
  25540. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25541. * Test :
  25542. * Is the cullable object bounding sphere center in the frustum ?
  25543. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25544. */
  25545. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25546. /**
  25547. * No billboard
  25548. */
  25549. static readonly BILLBOARDMODE_NONE: number;
  25550. /** Billboard on X axis */
  25551. static readonly BILLBOARDMODE_X: number;
  25552. /** Billboard on Y axis */
  25553. static readonly BILLBOARDMODE_Y: number;
  25554. /** Billboard on Z axis */
  25555. static readonly BILLBOARDMODE_Z: number;
  25556. /** Billboard on all axes */
  25557. static readonly BILLBOARDMODE_ALL: number;
  25558. /** @hidden */
  25559. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25560. /**
  25561. * The culling strategy to use to check whether the mesh must be rendered or not.
  25562. * This value can be changed at any time and will be used on the next render mesh selection.
  25563. * The possible values are :
  25564. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25565. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25566. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25568. * Please read each static variable documentation to get details about the culling process.
  25569. * */
  25570. cullingStrategy: number;
  25571. /**
  25572. * Gets the number of facets in the mesh
  25573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25574. */
  25575. readonly facetNb: number;
  25576. /**
  25577. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25579. */
  25580. partitioningSubdivisions: number;
  25581. /**
  25582. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25583. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25585. */
  25586. partitioningBBoxRatio: number;
  25587. /**
  25588. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25589. * Works only for updatable meshes.
  25590. * Doesn't work with multi-materials
  25591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25592. */
  25593. mustDepthSortFacets: boolean;
  25594. /**
  25595. * The location (Vector3) where the facet depth sort must be computed from.
  25596. * By default, the active camera position.
  25597. * Used only when facet depth sort is enabled
  25598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25599. */
  25600. facetDepthSortFrom: Vector3;
  25601. /**
  25602. * gets a boolean indicating if facetData is enabled
  25603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25604. */
  25605. readonly isFacetDataEnabled: boolean;
  25606. /** @hidden */
  25607. _updateNonUniformScalingState(value: boolean): boolean;
  25608. /**
  25609. * An event triggered when this mesh collides with another one
  25610. */
  25611. onCollideObservable: Observable<AbstractMesh>;
  25612. /** Set a function to call when this mesh collides with another one */
  25613. onCollide: () => void;
  25614. /**
  25615. * An event triggered when the collision's position changes
  25616. */
  25617. onCollisionPositionChangeObservable: Observable<Vector3>;
  25618. /** Set a function to call when the collision's position changes */
  25619. onCollisionPositionChange: () => void;
  25620. /**
  25621. * An event triggered when material is changed
  25622. */
  25623. onMaterialChangedObservable: Observable<AbstractMesh>;
  25624. /**
  25625. * Gets or sets the orientation for POV movement & rotation
  25626. */
  25627. definedFacingForward: boolean;
  25628. /** @hidden */
  25629. _occlusionQuery: Nullable<WebGLQuery>;
  25630. /** @hidden */
  25631. _renderingGroup: Nullable<RenderingGroup>;
  25632. /**
  25633. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25634. */
  25635. /**
  25636. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25637. */
  25638. visibility: number;
  25639. /** Gets or sets the alpha index used to sort transparent meshes
  25640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25641. */
  25642. alphaIndex: number;
  25643. /**
  25644. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25645. */
  25646. isVisible: boolean;
  25647. /**
  25648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25649. */
  25650. isPickable: boolean;
  25651. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25652. showSubMeshesBoundingBox: boolean;
  25653. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25655. */
  25656. isBlocker: boolean;
  25657. /**
  25658. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25659. */
  25660. enablePointerMoveEvents: boolean;
  25661. /**
  25662. * Specifies the rendering group id for this mesh (0 by default)
  25663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25664. */
  25665. renderingGroupId: number;
  25666. private _material;
  25667. /** Gets or sets current material */
  25668. material: Nullable<Material>;
  25669. /**
  25670. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25671. * @see http://doc.babylonjs.com/babylon101/shadows
  25672. */
  25673. receiveShadows: boolean;
  25674. /** Defines color to use when rendering outline */
  25675. outlineColor: Color3;
  25676. /** Define width to use when rendering outline */
  25677. outlineWidth: number;
  25678. /** Defines color to use when rendering overlay */
  25679. overlayColor: Color3;
  25680. /** Defines alpha to use when rendering overlay */
  25681. overlayAlpha: number;
  25682. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25683. hasVertexAlpha: boolean;
  25684. /** 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) */
  25685. useVertexColors: boolean;
  25686. /**
  25687. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25688. */
  25689. computeBonesUsingShaders: boolean;
  25690. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25691. numBoneInfluencers: number;
  25692. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25693. applyFog: boolean;
  25694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25695. useOctreeForRenderingSelection: boolean;
  25696. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25697. useOctreeForPicking: boolean;
  25698. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25699. useOctreeForCollisions: boolean;
  25700. /**
  25701. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25702. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25703. */
  25704. layerMask: number;
  25705. /**
  25706. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25707. */
  25708. alwaysSelectAsActiveMesh: boolean;
  25709. /**
  25710. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25711. */
  25712. doNotSyncBoundingInfo: boolean;
  25713. /**
  25714. * Gets or sets the current action manager
  25715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25716. */
  25717. actionManager: Nullable<AbstractActionManager>;
  25718. private _meshCollisionData;
  25719. /**
  25720. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25722. */
  25723. ellipsoid: Vector3;
  25724. /**
  25725. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25727. */
  25728. ellipsoidOffset: Vector3;
  25729. /**
  25730. * Gets or sets a collision mask used to mask collisions (default is -1).
  25731. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25732. */
  25733. collisionMask: number;
  25734. /**
  25735. * Gets or sets the current collision group mask (-1 by default).
  25736. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25737. */
  25738. collisionGroup: number;
  25739. /**
  25740. * Defines edge width used when edgesRenderer is enabled
  25741. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25742. */
  25743. edgesWidth: number;
  25744. /**
  25745. * Defines edge color used when edgesRenderer is enabled
  25746. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25747. */
  25748. edgesColor: Color4;
  25749. /** @hidden */
  25750. _edgesRenderer: Nullable<IEdgesRenderer>;
  25751. /** @hidden */
  25752. _masterMesh: Nullable<AbstractMesh>;
  25753. /** @hidden */
  25754. _boundingInfo: Nullable<BoundingInfo>;
  25755. /** @hidden */
  25756. _renderId: number;
  25757. /**
  25758. * Gets or sets the list of subMeshes
  25759. * @see http://doc.babylonjs.com/how_to/multi_materials
  25760. */
  25761. subMeshes: SubMesh[];
  25762. /** @hidden */
  25763. _intersectionsInProgress: AbstractMesh[];
  25764. /** @hidden */
  25765. _unIndexed: boolean;
  25766. /** @hidden */
  25767. _lightSources: Light[];
  25768. /** Gets the list of lights affecting that mesh */
  25769. readonly lightSources: Light[];
  25770. /** @hidden */
  25771. readonly _positions: Nullable<Vector3[]>;
  25772. /** @hidden */
  25773. _waitingData: {
  25774. lods: Nullable<any>;
  25775. actions: Nullable<any>;
  25776. freezeWorldMatrix: Nullable<boolean>;
  25777. };
  25778. /** @hidden */
  25779. _bonesTransformMatrices: Nullable<Float32Array>;
  25780. /** @hidden */
  25781. _transformMatrixTexture: Nullable<RawTexture>;
  25782. /**
  25783. * Gets or sets a skeleton to apply skining transformations
  25784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25785. */
  25786. skeleton: Nullable<Skeleton>;
  25787. /**
  25788. * An event triggered when the mesh is rebuilt.
  25789. */
  25790. onRebuildObservable: Observable<AbstractMesh>;
  25791. /**
  25792. * Creates a new AbstractMesh
  25793. * @param name defines the name of the mesh
  25794. * @param scene defines the hosting scene
  25795. */
  25796. constructor(name: string, scene?: Nullable<Scene>);
  25797. /**
  25798. * Returns the string "AbstractMesh"
  25799. * @returns "AbstractMesh"
  25800. */
  25801. getClassName(): string;
  25802. /**
  25803. * Gets a string representation of the current mesh
  25804. * @param fullDetails defines a boolean indicating if full details must be included
  25805. * @returns a string representation of the current mesh
  25806. */
  25807. toString(fullDetails?: boolean): string;
  25808. /**
  25809. * @hidden
  25810. */
  25811. protected _getEffectiveParent(): Nullable<Node>;
  25812. /** @hidden */
  25813. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25814. /** @hidden */
  25815. _rebuild(): void;
  25816. /** @hidden */
  25817. _resyncLightSources(): void;
  25818. /** @hidden */
  25819. _resyncLighSource(light: Light): void;
  25820. /** @hidden */
  25821. _unBindEffect(): void;
  25822. /** @hidden */
  25823. _removeLightSource(light: Light): void;
  25824. private _markSubMeshesAsDirty;
  25825. /** @hidden */
  25826. _markSubMeshesAsLightDirty(): void;
  25827. /** @hidden */
  25828. _markSubMeshesAsAttributesDirty(): void;
  25829. /** @hidden */
  25830. _markSubMeshesAsMiscDirty(): void;
  25831. /**
  25832. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25833. */
  25834. scaling: Vector3;
  25835. /**
  25836. * Returns true if the mesh is blocked. Implemented by child classes
  25837. */
  25838. readonly isBlocked: boolean;
  25839. /**
  25840. * Returns the mesh itself by default. Implemented by child classes
  25841. * @param camera defines the camera to use to pick the right LOD level
  25842. * @returns the currentAbstractMesh
  25843. */
  25844. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25845. /**
  25846. * Returns 0 by default. Implemented by child classes
  25847. * @returns an integer
  25848. */
  25849. getTotalVertices(): number;
  25850. /**
  25851. * Returns a positive integer : the total number of indices in this mesh geometry.
  25852. * @returns the numner of indices or zero if the mesh has no geometry.
  25853. */
  25854. getTotalIndices(): number;
  25855. /**
  25856. * Returns null by default. Implemented by child classes
  25857. * @returns null
  25858. */
  25859. getIndices(): Nullable<IndicesArray>;
  25860. /**
  25861. * Returns the array of the requested vertex data kind. Implemented by child classes
  25862. * @param kind defines the vertex data kind to use
  25863. * @returns null
  25864. */
  25865. getVerticesData(kind: string): Nullable<FloatArray>;
  25866. /**
  25867. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25868. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25869. * Note that a new underlying VertexBuffer object is created each call.
  25870. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25871. * @param kind defines vertex data kind:
  25872. * * VertexBuffer.PositionKind
  25873. * * VertexBuffer.UVKind
  25874. * * VertexBuffer.UV2Kind
  25875. * * VertexBuffer.UV3Kind
  25876. * * VertexBuffer.UV4Kind
  25877. * * VertexBuffer.UV5Kind
  25878. * * VertexBuffer.UV6Kind
  25879. * * VertexBuffer.ColorKind
  25880. * * VertexBuffer.MatricesIndicesKind
  25881. * * VertexBuffer.MatricesIndicesExtraKind
  25882. * * VertexBuffer.MatricesWeightsKind
  25883. * * VertexBuffer.MatricesWeightsExtraKind
  25884. * @param data defines the data source
  25885. * @param updatable defines if the data must be flagged as updatable (or static)
  25886. * @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
  25887. * @returns the current mesh
  25888. */
  25889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25890. /**
  25891. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25892. * If the mesh has no geometry, it is simply returned as it is.
  25893. * @param kind defines vertex data kind:
  25894. * * VertexBuffer.PositionKind
  25895. * * VertexBuffer.UVKind
  25896. * * VertexBuffer.UV2Kind
  25897. * * VertexBuffer.UV3Kind
  25898. * * VertexBuffer.UV4Kind
  25899. * * VertexBuffer.UV5Kind
  25900. * * VertexBuffer.UV6Kind
  25901. * * VertexBuffer.ColorKind
  25902. * * VertexBuffer.MatricesIndicesKind
  25903. * * VertexBuffer.MatricesIndicesExtraKind
  25904. * * VertexBuffer.MatricesWeightsKind
  25905. * * VertexBuffer.MatricesWeightsExtraKind
  25906. * @param data defines the data source
  25907. * @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
  25908. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25909. * @returns the current mesh
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25912. /**
  25913. * Sets the mesh indices,
  25914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25915. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25916. * @param totalVertices Defines the total number of vertices
  25917. * @returns the current mesh
  25918. */
  25919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25920. /**
  25921. * Gets a boolean indicating if specific vertex data is present
  25922. * @param kind defines the vertex data kind to use
  25923. * @returns true is data kind is present
  25924. */
  25925. isVerticesDataPresent(kind: string): boolean;
  25926. /**
  25927. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25928. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25929. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25930. * @returns a BoundingInfo
  25931. */
  25932. getBoundingInfo(): BoundingInfo;
  25933. /**
  25934. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25935. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25936. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25937. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25938. * @returns the current mesh
  25939. */
  25940. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25941. /**
  25942. * Overwrite the current bounding info
  25943. * @param boundingInfo defines the new bounding info
  25944. * @returns the current mesh
  25945. */
  25946. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25947. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25948. readonly useBones: boolean;
  25949. /** @hidden */
  25950. _preActivate(): void;
  25951. /** @hidden */
  25952. _preActivateForIntermediateRendering(renderId: number): void;
  25953. /** @hidden */
  25954. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25955. /** @hidden */
  25956. _postActivate(): void;
  25957. /** @hidden */
  25958. _freeze(): void;
  25959. /** @hidden */
  25960. _unFreeze(): void;
  25961. /**
  25962. * Gets the current world matrix
  25963. * @returns a Matrix
  25964. */
  25965. getWorldMatrix(): Matrix;
  25966. /** @hidden */
  25967. _getWorldMatrixDeterminant(): number;
  25968. /**
  25969. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25970. */
  25971. readonly isAnInstance: boolean;
  25972. /**
  25973. * Perform relative position change from the point of view of behind the front of the mesh.
  25974. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25975. * Supports definition of mesh facing forward or backward
  25976. * @param amountRight defines the distance on the right axis
  25977. * @param amountUp defines the distance on the up axis
  25978. * @param amountForward defines the distance on the forward axis
  25979. * @returns the current mesh
  25980. */
  25981. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25982. /**
  25983. * Calculate relative position change from the point of view of behind the front of the mesh.
  25984. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25985. * Supports definition of mesh facing forward or backward
  25986. * @param amountRight defines the distance on the right axis
  25987. * @param amountUp defines the distance on the up axis
  25988. * @param amountForward defines the distance on the forward axis
  25989. * @returns the new displacement vector
  25990. */
  25991. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25992. /**
  25993. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25994. * Supports definition of mesh facing forward or backward
  25995. * @param flipBack defines the flip
  25996. * @param twirlClockwise defines the twirl
  25997. * @param tiltRight defines the tilt
  25998. * @returns the current mesh
  25999. */
  26000. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26001. /**
  26002. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26003. * Supports definition of mesh facing forward or backward.
  26004. * @param flipBack defines the flip
  26005. * @param twirlClockwise defines the twirl
  26006. * @param tiltRight defines the tilt
  26007. * @returns the new rotation vector
  26008. */
  26009. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26010. /**
  26011. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26012. * This means the mesh underlying bounding box and sphere are recomputed.
  26013. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26014. * @returns the current mesh
  26015. */
  26016. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26017. /** @hidden */
  26018. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26019. /** @hidden */
  26020. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26021. /** @hidden */
  26022. _updateBoundingInfo(): AbstractMesh;
  26023. /** @hidden */
  26024. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26025. /** @hidden */
  26026. protected _afterComputeWorldMatrix(): void;
  26027. /** @hidden */
  26028. readonly _effectiveMesh: AbstractMesh;
  26029. /**
  26030. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26031. * A mesh is in the frustum if its bounding box intersects the frustum
  26032. * @param frustumPlanes defines the frustum to test
  26033. * @returns true if the mesh is in the frustum planes
  26034. */
  26035. isInFrustum(frustumPlanes: Plane[]): boolean;
  26036. /**
  26037. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26038. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26039. * @param frustumPlanes defines the frustum to test
  26040. * @returns true if the mesh is completely in the frustum planes
  26041. */
  26042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26043. /**
  26044. * True if the mesh intersects another mesh or a SolidParticle object
  26045. * @param mesh defines a target mesh or SolidParticle to test
  26046. * @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)
  26047. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26048. * @returns true if there is an intersection
  26049. */
  26050. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26051. /**
  26052. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26053. * @param point defines the point to test
  26054. * @returns true if there is an intersection
  26055. */
  26056. intersectsPoint(point: Vector3): boolean;
  26057. /**
  26058. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26060. */
  26061. checkCollisions: boolean;
  26062. /**
  26063. * Gets Collider object used to compute collisions (not physics)
  26064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26065. */
  26066. readonly collider: Nullable<Collider>;
  26067. /**
  26068. * Move the mesh using collision engine
  26069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26070. * @param displacement defines the requested displacement vector
  26071. * @returns the current mesh
  26072. */
  26073. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26074. private _onCollisionPositionChange;
  26075. /** @hidden */
  26076. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26077. /** @hidden */
  26078. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26079. /** @hidden */
  26080. _checkCollision(collider: Collider): AbstractMesh;
  26081. /** @hidden */
  26082. _generatePointsArray(): boolean;
  26083. /**
  26084. * Checks if the passed Ray intersects with the mesh
  26085. * @param ray defines the ray to use
  26086. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26088. * @returns the picking info
  26089. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26090. */
  26091. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26092. /**
  26093. * Clones the current mesh
  26094. * @param name defines the mesh name
  26095. * @param newParent defines the new mesh parent
  26096. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26097. * @returns the new mesh
  26098. */
  26099. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26100. /**
  26101. * Disposes all the submeshes of the current meshnp
  26102. * @returns the current mesh
  26103. */
  26104. releaseSubMeshes(): AbstractMesh;
  26105. /**
  26106. * Releases resources associated with this abstract mesh.
  26107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26109. */
  26110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26111. /**
  26112. * Adds the passed mesh as a child to the current mesh
  26113. * @param mesh defines the child mesh
  26114. * @returns the current mesh
  26115. */
  26116. addChild(mesh: AbstractMesh): AbstractMesh;
  26117. /**
  26118. * Removes the passed mesh from the current mesh children list
  26119. * @param mesh defines the child mesh
  26120. * @returns the current mesh
  26121. */
  26122. removeChild(mesh: AbstractMesh): AbstractMesh;
  26123. /** @hidden */
  26124. private _initFacetData;
  26125. /**
  26126. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26127. * This method can be called within the render loop.
  26128. * 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
  26129. * @returns the current mesh
  26130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26131. */
  26132. updateFacetData(): AbstractMesh;
  26133. /**
  26134. * Returns the facetLocalNormals array.
  26135. * The normals are expressed in the mesh local spac
  26136. * @returns an array of Vector3
  26137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26138. */
  26139. getFacetLocalNormals(): Vector3[];
  26140. /**
  26141. * Returns the facetLocalPositions array.
  26142. * The facet positions are expressed in the mesh local space
  26143. * @returns an array of Vector3
  26144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26145. */
  26146. getFacetLocalPositions(): Vector3[];
  26147. /**
  26148. * Returns the facetLocalPartioning array
  26149. * @returns an array of array of numbers
  26150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26151. */
  26152. getFacetLocalPartitioning(): number[][];
  26153. /**
  26154. * Returns the i-th facet position in the world system.
  26155. * This method allocates a new Vector3 per call
  26156. * @param i defines the facet index
  26157. * @returns a new Vector3
  26158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26159. */
  26160. getFacetPosition(i: number): Vector3;
  26161. /**
  26162. * Sets the reference Vector3 with the i-th facet position in the world system
  26163. * @param i defines the facet index
  26164. * @param ref defines the target vector
  26165. * @returns the current mesh
  26166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26167. */
  26168. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26169. /**
  26170. * Returns the i-th facet normal in the world system.
  26171. * This method allocates a new Vector3 per call
  26172. * @param i defines the facet index
  26173. * @returns a new Vector3
  26174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26175. */
  26176. getFacetNormal(i: number): Vector3;
  26177. /**
  26178. * Sets the reference Vector3 with the i-th facet normal in the world system
  26179. * @param i defines the facet index
  26180. * @param ref defines the target vector
  26181. * @returns the current mesh
  26182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26183. */
  26184. getFacetNormalToRef(i: number, ref: Vector3): this;
  26185. /**
  26186. * 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)
  26187. * @param x defines x coordinate
  26188. * @param y defines y coordinate
  26189. * @param z defines z coordinate
  26190. * @returns the array of facet indexes
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26192. */
  26193. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26194. /**
  26195. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26196. * @param projected sets as the (x,y,z) world projection on the facet
  26197. * @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
  26198. * @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
  26199. * @param x defines x coordinate
  26200. * @param y defines y coordinate
  26201. * @param z defines z coordinate
  26202. * @returns the face index if found (or null instead)
  26203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26204. */
  26205. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26206. /**
  26207. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26208. * @param projected sets as the (x,y,z) local projection on the facet
  26209. * @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
  26210. * @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
  26211. * @param x defines x coordinate
  26212. * @param y defines y coordinate
  26213. * @param z defines z coordinate
  26214. * @returns the face index if found (or null instead)
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26216. */
  26217. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26218. /**
  26219. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26220. * @returns the parameters
  26221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26222. */
  26223. getFacetDataParameters(): any;
  26224. /**
  26225. * Disables the feature FacetData and frees the related memory
  26226. * @returns the current mesh
  26227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26228. */
  26229. disableFacetData(): AbstractMesh;
  26230. /**
  26231. * Updates the AbstractMesh indices array
  26232. * @param indices defines the data source
  26233. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26234. * @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)
  26235. * @returns the current mesh
  26236. */
  26237. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26238. /**
  26239. * Creates new normals data for the mesh
  26240. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26241. * @returns the current mesh
  26242. */
  26243. createNormals(updatable: boolean): AbstractMesh;
  26244. /**
  26245. * Align the mesh with a normal
  26246. * @param normal defines the normal to use
  26247. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26248. * @returns the current mesh
  26249. */
  26250. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26251. /** @hidden */
  26252. _checkOcclusionQuery(): boolean;
  26253. /**
  26254. * Disables the mesh edge rendering mode
  26255. * @returns the currentAbstractMesh
  26256. */
  26257. disableEdgesRendering(): AbstractMesh;
  26258. /**
  26259. * Enables the edge rendering mode on the mesh.
  26260. * This mode makes the mesh edges visible
  26261. * @param epsilon defines the maximal distance between two angles to detect a face
  26262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26263. * @returns the currentAbstractMesh
  26264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26265. */
  26266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26267. }
  26268. }
  26269. declare module BABYLON {
  26270. /**
  26271. * Interface used to define ActionEvent
  26272. */
  26273. export interface IActionEvent {
  26274. /** The mesh or sprite that triggered the action */
  26275. source: any;
  26276. /** The X mouse cursor position at the time of the event */
  26277. pointerX: number;
  26278. /** The Y mouse cursor position at the time of the event */
  26279. pointerY: number;
  26280. /** The mesh that is currently pointed at (can be null) */
  26281. meshUnderPointer: Nullable<AbstractMesh>;
  26282. /** the original (browser) event that triggered the ActionEvent */
  26283. sourceEvent?: any;
  26284. /** additional data for the event */
  26285. additionalData?: any;
  26286. }
  26287. /**
  26288. * ActionEvent is the event being sent when an action is triggered.
  26289. */
  26290. export class ActionEvent implements IActionEvent {
  26291. /** The mesh or sprite that triggered the action */
  26292. source: any;
  26293. /** The X mouse cursor position at the time of the event */
  26294. pointerX: number;
  26295. /** The Y mouse cursor position at the time of the event */
  26296. pointerY: number;
  26297. /** The mesh that is currently pointed at (can be null) */
  26298. meshUnderPointer: Nullable<AbstractMesh>;
  26299. /** the original (browser) event that triggered the ActionEvent */
  26300. sourceEvent?: any;
  26301. /** additional data for the event */
  26302. additionalData?: any;
  26303. /**
  26304. * Creates a new ActionEvent
  26305. * @param source The mesh or sprite that triggered the action
  26306. * @param pointerX The X mouse cursor position at the time of the event
  26307. * @param pointerY The Y mouse cursor position at the time of the event
  26308. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26309. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26310. * @param additionalData additional data for the event
  26311. */
  26312. constructor(
  26313. /** The mesh or sprite that triggered the action */
  26314. source: any,
  26315. /** The X mouse cursor position at the time of the event */
  26316. pointerX: number,
  26317. /** The Y mouse cursor position at the time of the event */
  26318. pointerY: number,
  26319. /** The mesh that is currently pointed at (can be null) */
  26320. meshUnderPointer: Nullable<AbstractMesh>,
  26321. /** the original (browser) event that triggered the ActionEvent */
  26322. sourceEvent?: any,
  26323. /** additional data for the event */
  26324. additionalData?: any);
  26325. /**
  26326. * Helper function to auto-create an ActionEvent from a source mesh.
  26327. * @param source The source mesh that triggered the event
  26328. * @param evt The original (browser) event
  26329. * @param additionalData additional data for the event
  26330. * @returns the new ActionEvent
  26331. */
  26332. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26333. /**
  26334. * Helper function to auto-create an ActionEvent from a source sprite
  26335. * @param source The source sprite that triggered the event
  26336. * @param scene Scene associated with the sprite
  26337. * @param evt The original (browser) event
  26338. * @param additionalData additional data for the event
  26339. * @returns the new ActionEvent
  26340. */
  26341. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26342. /**
  26343. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26344. * @param scene the scene where the event occurred
  26345. * @param evt The original (browser) event
  26346. * @returns the new ActionEvent
  26347. */
  26348. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26349. /**
  26350. * Helper function to auto-create an ActionEvent from a primitive
  26351. * @param prim defines the target primitive
  26352. * @param pointerPos defines the pointer position
  26353. * @param evt The original (browser) event
  26354. * @param additionalData additional data for the event
  26355. * @returns the new ActionEvent
  26356. */
  26357. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Abstract class used to decouple action Manager from scene and meshes.
  26363. * Do not instantiate.
  26364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26365. */
  26366. export abstract class AbstractActionManager implements IDisposable {
  26367. /** Gets the list of active triggers */
  26368. static Triggers: {
  26369. [key: string]: number;
  26370. };
  26371. /** Gets the cursor to use when hovering items */
  26372. hoverCursor: string;
  26373. /** Gets the list of actions */
  26374. actions: IAction[];
  26375. /**
  26376. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26377. */
  26378. isRecursive: boolean;
  26379. /**
  26380. * Releases all associated resources
  26381. */
  26382. abstract dispose(): void;
  26383. /**
  26384. * Does this action manager has pointer triggers
  26385. */
  26386. abstract readonly hasPointerTriggers: boolean;
  26387. /**
  26388. * Does this action manager has pick triggers
  26389. */
  26390. abstract readonly hasPickTriggers: boolean;
  26391. /**
  26392. * Process a specific trigger
  26393. * @param trigger defines the trigger to process
  26394. * @param evt defines the event details to be processed
  26395. */
  26396. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26397. /**
  26398. * Does this action manager handles actions of any of the given triggers
  26399. * @param triggers defines the triggers to be tested
  26400. * @return a boolean indicating whether one (or more) of the triggers is handled
  26401. */
  26402. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26403. /**
  26404. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26405. * speed.
  26406. * @param triggerA defines the trigger to be tested
  26407. * @param triggerB defines the trigger to be tested
  26408. * @return a boolean indicating whether one (or more) of the triggers is handled
  26409. */
  26410. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26411. /**
  26412. * Does this action manager handles actions of a given trigger
  26413. * @param trigger defines the trigger to be tested
  26414. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26415. * @return whether the trigger is handled
  26416. */
  26417. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26418. /**
  26419. * Serialize this manager to a JSON object
  26420. * @param name defines the property name to store this manager
  26421. * @returns a JSON representation of this manager
  26422. */
  26423. abstract serialize(name: string): any;
  26424. /**
  26425. * Registers an action to this action manager
  26426. * @param action defines the action to be registered
  26427. * @return the action amended (prepared) after registration
  26428. */
  26429. abstract registerAction(action: IAction): Nullable<IAction>;
  26430. /**
  26431. * Unregisters an action to this action manager
  26432. * @param action defines the action to be unregistered
  26433. * @return a boolean indicating whether the action has been unregistered
  26434. */
  26435. abstract unregisterAction(action: IAction): Boolean;
  26436. /**
  26437. * Does exist one action manager with at least one trigger
  26438. **/
  26439. static readonly HasTriggers: boolean;
  26440. /**
  26441. * Does exist one action manager with at least one pick trigger
  26442. **/
  26443. static readonly HasPickTriggers: boolean;
  26444. /**
  26445. * Does exist one action manager that handles actions of a given trigger
  26446. * @param trigger defines the trigger to be tested
  26447. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26448. **/
  26449. static HasSpecificTrigger(trigger: number): boolean;
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. /**
  26454. * Defines how a node can be built from a string name.
  26455. */
  26456. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26457. /**
  26458. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26459. */
  26460. export class Node implements IBehaviorAware<Node> {
  26461. /** @hidden */
  26462. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26463. private static _NodeConstructors;
  26464. /**
  26465. * Add a new node constructor
  26466. * @param type defines the type name of the node to construct
  26467. * @param constructorFunc defines the constructor function
  26468. */
  26469. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26470. /**
  26471. * Returns a node constructor based on type name
  26472. * @param type defines the type name
  26473. * @param name defines the new node name
  26474. * @param scene defines the hosting scene
  26475. * @param options defines optional options to transmit to constructors
  26476. * @returns the new constructor or null
  26477. */
  26478. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26479. /**
  26480. * Gets or sets the name of the node
  26481. */
  26482. name: string;
  26483. /**
  26484. * Gets or sets the id of the node
  26485. */
  26486. id: string;
  26487. /**
  26488. * Gets or sets the unique id of the node
  26489. */
  26490. uniqueId: number;
  26491. /**
  26492. * Gets or sets a string used to store user defined state for the node
  26493. */
  26494. state: string;
  26495. /**
  26496. * Gets or sets an object used to store user defined information for the node
  26497. */
  26498. metadata: any;
  26499. /**
  26500. * For internal use only. Please do not use.
  26501. */
  26502. reservedDataStore: any;
  26503. /**
  26504. * List of inspectable custom properties (used by the Inspector)
  26505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26506. */
  26507. inspectableCustomProperties: IInspectable[];
  26508. /**
  26509. * Gets or sets a boolean used to define if the node must be serialized
  26510. */
  26511. doNotSerialize: boolean;
  26512. /** @hidden */
  26513. _isDisposed: boolean;
  26514. /**
  26515. * Gets a list of Animations associated with the node
  26516. */
  26517. animations: Animation[];
  26518. protected _ranges: {
  26519. [name: string]: Nullable<AnimationRange>;
  26520. };
  26521. /**
  26522. * Callback raised when the node is ready to be used
  26523. */
  26524. onReady: Nullable<(node: Node) => void>;
  26525. private _isEnabled;
  26526. private _isParentEnabled;
  26527. private _isReady;
  26528. /** @hidden */
  26529. _currentRenderId: number;
  26530. private _parentUpdateId;
  26531. /** @hidden */
  26532. _childUpdateId: number;
  26533. /** @hidden */
  26534. _waitingParentId: Nullable<string>;
  26535. /** @hidden */
  26536. _scene: Scene;
  26537. /** @hidden */
  26538. _cache: any;
  26539. private _parentNode;
  26540. private _children;
  26541. /** @hidden */
  26542. _worldMatrix: Matrix;
  26543. /** @hidden */
  26544. _worldMatrixDeterminant: number;
  26545. /** @hidden */
  26546. _worldMatrixDeterminantIsDirty: boolean;
  26547. /** @hidden */
  26548. private _sceneRootNodesIndex;
  26549. /**
  26550. * Gets a boolean indicating if the node has been disposed
  26551. * @returns true if the node was disposed
  26552. */
  26553. isDisposed(): boolean;
  26554. /**
  26555. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26556. * @see https://doc.babylonjs.com/how_to/parenting
  26557. */
  26558. parent: Nullable<Node>;
  26559. private addToSceneRootNodes;
  26560. private removeFromSceneRootNodes;
  26561. private _animationPropertiesOverride;
  26562. /**
  26563. * Gets or sets the animation properties override
  26564. */
  26565. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26566. /**
  26567. * Gets a string idenfifying the name of the class
  26568. * @returns "Node" string
  26569. */
  26570. getClassName(): string;
  26571. /** @hidden */
  26572. readonly _isNode: boolean;
  26573. /**
  26574. * An event triggered when the mesh is disposed
  26575. */
  26576. onDisposeObservable: Observable<Node>;
  26577. private _onDisposeObserver;
  26578. /**
  26579. * Sets a callback that will be raised when the node will be disposed
  26580. */
  26581. onDispose: () => void;
  26582. /**
  26583. * Creates a new Node
  26584. * @param name the name and id to be given to this node
  26585. * @param scene the scene this node will be added to
  26586. * @param addToRootNodes the node will be added to scene.rootNodes
  26587. */
  26588. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26589. /**
  26590. * Gets the scene of the node
  26591. * @returns a scene
  26592. */
  26593. getScene(): Scene;
  26594. /**
  26595. * Gets the engine of the node
  26596. * @returns a Engine
  26597. */
  26598. getEngine(): Engine;
  26599. private _behaviors;
  26600. /**
  26601. * Attach a behavior to the node
  26602. * @see http://doc.babylonjs.com/features/behaviour
  26603. * @param behavior defines the behavior to attach
  26604. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26605. * @returns the current Node
  26606. */
  26607. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26608. /**
  26609. * Remove an attached behavior
  26610. * @see http://doc.babylonjs.com/features/behaviour
  26611. * @param behavior defines the behavior to attach
  26612. * @returns the current Node
  26613. */
  26614. removeBehavior(behavior: Behavior<Node>): Node;
  26615. /**
  26616. * Gets the list of attached behaviors
  26617. * @see http://doc.babylonjs.com/features/behaviour
  26618. */
  26619. readonly behaviors: Behavior<Node>[];
  26620. /**
  26621. * Gets an attached behavior by name
  26622. * @param name defines the name of the behavior to look for
  26623. * @see http://doc.babylonjs.com/features/behaviour
  26624. * @returns null if behavior was not found else the requested behavior
  26625. */
  26626. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26627. /**
  26628. * Returns the latest update of the World matrix
  26629. * @returns a Matrix
  26630. */
  26631. getWorldMatrix(): Matrix;
  26632. /** @hidden */
  26633. _getWorldMatrixDeterminant(): number;
  26634. /**
  26635. * Returns directly the latest state of the mesh World matrix.
  26636. * A Matrix is returned.
  26637. */
  26638. readonly worldMatrixFromCache: Matrix;
  26639. /** @hidden */
  26640. _initCache(): void;
  26641. /** @hidden */
  26642. updateCache(force?: boolean): void;
  26643. /** @hidden */
  26644. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26645. /** @hidden */
  26646. _updateCache(ignoreParentClass?: boolean): void;
  26647. /** @hidden */
  26648. _isSynchronized(): boolean;
  26649. /** @hidden */
  26650. _markSyncedWithParent(): void;
  26651. /** @hidden */
  26652. isSynchronizedWithParent(): boolean;
  26653. /** @hidden */
  26654. isSynchronized(): boolean;
  26655. /**
  26656. * Is this node ready to be used/rendered
  26657. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26658. * @return true if the node is ready
  26659. */
  26660. isReady(completeCheck?: boolean): boolean;
  26661. /**
  26662. * Is this node enabled?
  26663. * 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
  26664. * @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
  26665. * @return whether this node (and its parent) is enabled
  26666. */
  26667. isEnabled(checkAncestors?: boolean): boolean;
  26668. /** @hidden */
  26669. protected _syncParentEnabledState(): void;
  26670. /**
  26671. * Set the enabled state of this node
  26672. * @param value defines the new enabled state
  26673. */
  26674. setEnabled(value: boolean): void;
  26675. /**
  26676. * Is this node a descendant of the given node?
  26677. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26678. * @param ancestor defines the parent node to inspect
  26679. * @returns a boolean indicating if this node is a descendant of the given node
  26680. */
  26681. isDescendantOf(ancestor: Node): boolean;
  26682. /** @hidden */
  26683. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26684. /**
  26685. * Will return all nodes that have this node as ascendant
  26686. * @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
  26687. * @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
  26688. * @return all children nodes of all types
  26689. */
  26690. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26691. /**
  26692. * Get all child-meshes of this node
  26693. * @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)
  26694. * @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
  26695. * @returns an array of AbstractMesh
  26696. */
  26697. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26698. /**
  26699. * Get all direct children of this node
  26700. * @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
  26701. * @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)
  26702. * @returns an array of Node
  26703. */
  26704. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26705. /** @hidden */
  26706. _setReady(state: boolean): void;
  26707. /**
  26708. * Get an animation by name
  26709. * @param name defines the name of the animation to look for
  26710. * @returns null if not found else the requested animation
  26711. */
  26712. getAnimationByName(name: string): Nullable<Animation>;
  26713. /**
  26714. * Creates an animation range for this node
  26715. * @param name defines the name of the range
  26716. * @param from defines the starting key
  26717. * @param to defines the end key
  26718. */
  26719. createAnimationRange(name: string, from: number, to: number): void;
  26720. /**
  26721. * Delete a specific animation range
  26722. * @param name defines the name of the range to delete
  26723. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26724. */
  26725. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26726. /**
  26727. * Get an animation range by name
  26728. * @param name defines the name of the animation range to look for
  26729. * @returns null if not found else the requested animation range
  26730. */
  26731. getAnimationRange(name: string): Nullable<AnimationRange>;
  26732. /**
  26733. * Gets the list of all animation ranges defined on this node
  26734. * @returns an array
  26735. */
  26736. getAnimationRanges(): Nullable<AnimationRange>[];
  26737. /**
  26738. * Will start the animation sequence
  26739. * @param name defines the range frames for animation sequence
  26740. * @param loop defines if the animation should loop (false by default)
  26741. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26742. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26743. * @returns the object created for this animation. If range does not exist, it will return null
  26744. */
  26745. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26746. /**
  26747. * Serialize animation ranges into a JSON compatible object
  26748. * @returns serialization object
  26749. */
  26750. serializeAnimationRanges(): any;
  26751. /**
  26752. * Computes the world matrix of the node
  26753. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26754. * @returns the world matrix
  26755. */
  26756. computeWorldMatrix(force?: boolean): Matrix;
  26757. /**
  26758. * Releases resources associated with this node.
  26759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26761. */
  26762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26763. /**
  26764. * Parse animation range data from a serialization object and store them into a given node
  26765. * @param node defines where to store the animation ranges
  26766. * @param parsedNode defines the serialization object to read data from
  26767. * @param scene defines the hosting scene
  26768. */
  26769. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26770. /**
  26771. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26772. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26773. * @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
  26774. * @returns the new bounding vectors
  26775. */
  26776. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26777. min: Vector3;
  26778. max: Vector3;
  26779. };
  26780. }
  26781. }
  26782. declare module BABYLON {
  26783. /**
  26784. * @hidden
  26785. */
  26786. export class _IAnimationState {
  26787. key: number;
  26788. repeatCount: number;
  26789. workValue?: any;
  26790. loopMode?: number;
  26791. offsetValue?: any;
  26792. highLimitValue?: any;
  26793. }
  26794. /**
  26795. * Class used to store any kind of animation
  26796. */
  26797. export class Animation {
  26798. /**Name of the animation */
  26799. name: string;
  26800. /**Property to animate */
  26801. targetProperty: string;
  26802. /**The frames per second of the animation */
  26803. framePerSecond: number;
  26804. /**The data type of the animation */
  26805. dataType: number;
  26806. /**The loop mode of the animation */
  26807. loopMode?: number | undefined;
  26808. /**Specifies if blending should be enabled */
  26809. enableBlending?: boolean | undefined;
  26810. /**
  26811. * Use matrix interpolation instead of using direct key value when animating matrices
  26812. */
  26813. static AllowMatricesInterpolation: boolean;
  26814. /**
  26815. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26816. */
  26817. static AllowMatrixDecomposeForInterpolation: boolean;
  26818. /**
  26819. * Stores the key frames of the animation
  26820. */
  26821. private _keys;
  26822. /**
  26823. * Stores the easing function of the animation
  26824. */
  26825. private _easingFunction;
  26826. /**
  26827. * @hidden Internal use only
  26828. */
  26829. _runtimeAnimations: RuntimeAnimation[];
  26830. /**
  26831. * The set of event that will be linked to this animation
  26832. */
  26833. private _events;
  26834. /**
  26835. * Stores an array of target property paths
  26836. */
  26837. targetPropertyPath: string[];
  26838. /**
  26839. * Stores the blending speed of the animation
  26840. */
  26841. blendingSpeed: number;
  26842. /**
  26843. * Stores the animation ranges for the animation
  26844. */
  26845. private _ranges;
  26846. /**
  26847. * @hidden Internal use
  26848. */
  26849. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26850. /**
  26851. * Sets up an animation
  26852. * @param property The property to animate
  26853. * @param animationType The animation type to apply
  26854. * @param framePerSecond The frames per second of the animation
  26855. * @param easingFunction The easing function used in the animation
  26856. * @returns The created animation
  26857. */
  26858. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26859. /**
  26860. * Create and start an animation on a node
  26861. * @param name defines the name of the global animation that will be run on all nodes
  26862. * @param node defines the root node where the animation will take place
  26863. * @param targetProperty defines property to animate
  26864. * @param framePerSecond defines the number of frame per second yo use
  26865. * @param totalFrame defines the number of frames in total
  26866. * @param from defines the initial value
  26867. * @param to defines the final value
  26868. * @param loopMode defines which loop mode you want to use (off by default)
  26869. * @param easingFunction defines the easing function to use (linear by default)
  26870. * @param onAnimationEnd defines the callback to call when animation end
  26871. * @returns the animatable created for this animation
  26872. */
  26873. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26874. /**
  26875. * Create and start an animation on a node and its descendants
  26876. * @param name defines the name of the global animation that will be run on all nodes
  26877. * @param node defines the root node where the animation will take place
  26878. * @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
  26879. * @param targetProperty defines property to animate
  26880. * @param framePerSecond defines the number of frame per second to use
  26881. * @param totalFrame defines the number of frames in total
  26882. * @param from defines the initial value
  26883. * @param to defines the final value
  26884. * @param loopMode defines which loop mode you want to use (off by default)
  26885. * @param easingFunction defines the easing function to use (linear by default)
  26886. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26887. * @returns the list of animatables created for all nodes
  26888. * @example https://www.babylonjs-playground.com/#MH0VLI
  26889. */
  26890. 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[]>;
  26891. /**
  26892. * Creates a new animation, merges it with the existing animations and starts it
  26893. * @param name Name of the animation
  26894. * @param node Node which contains the scene that begins the animations
  26895. * @param targetProperty Specifies which property to animate
  26896. * @param framePerSecond The frames per second of the animation
  26897. * @param totalFrame The total number of frames
  26898. * @param from The frame at the beginning of the animation
  26899. * @param to The frame at the end of the animation
  26900. * @param loopMode Specifies the loop mode of the animation
  26901. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26902. * @param onAnimationEnd Callback to run once the animation is complete
  26903. * @returns Nullable animation
  26904. */
  26905. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26906. /**
  26907. * Transition property of an host to the target Value
  26908. * @param property The property to transition
  26909. * @param targetValue The target Value of the property
  26910. * @param host The object where the property to animate belongs
  26911. * @param scene Scene used to run the animation
  26912. * @param frameRate Framerate (in frame/s) to use
  26913. * @param transition The transition type we want to use
  26914. * @param duration The duration of the animation, in milliseconds
  26915. * @param onAnimationEnd Callback trigger at the end of the animation
  26916. * @returns Nullable animation
  26917. */
  26918. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26919. /**
  26920. * Return the array of runtime animations currently using this animation
  26921. */
  26922. readonly runtimeAnimations: RuntimeAnimation[];
  26923. /**
  26924. * Specifies if any of the runtime animations are currently running
  26925. */
  26926. readonly hasRunningRuntimeAnimations: boolean;
  26927. /**
  26928. * Initializes the animation
  26929. * @param name Name of the animation
  26930. * @param targetProperty Property to animate
  26931. * @param framePerSecond The frames per second of the animation
  26932. * @param dataType The data type of the animation
  26933. * @param loopMode The loop mode of the animation
  26934. * @param enableBlending Specifies if blending should be enabled
  26935. */
  26936. constructor(
  26937. /**Name of the animation */
  26938. name: string,
  26939. /**Property to animate */
  26940. targetProperty: string,
  26941. /**The frames per second of the animation */
  26942. framePerSecond: number,
  26943. /**The data type of the animation */
  26944. dataType: number,
  26945. /**The loop mode of the animation */
  26946. loopMode?: number | undefined,
  26947. /**Specifies if blending should be enabled */
  26948. enableBlending?: boolean | undefined);
  26949. /**
  26950. * Converts the animation to a string
  26951. * @param fullDetails support for multiple levels of logging within scene loading
  26952. * @returns String form of the animation
  26953. */
  26954. toString(fullDetails?: boolean): string;
  26955. /**
  26956. * Add an event to this animation
  26957. * @param event Event to add
  26958. */
  26959. addEvent(event: AnimationEvent): void;
  26960. /**
  26961. * Remove all events found at the given frame
  26962. * @param frame The frame to remove events from
  26963. */
  26964. removeEvents(frame: number): void;
  26965. /**
  26966. * Retrieves all the events from the animation
  26967. * @returns Events from the animation
  26968. */
  26969. getEvents(): AnimationEvent[];
  26970. /**
  26971. * Creates an animation range
  26972. * @param name Name of the animation range
  26973. * @param from Starting frame of the animation range
  26974. * @param to Ending frame of the animation
  26975. */
  26976. createRange(name: string, from: number, to: number): void;
  26977. /**
  26978. * Deletes an animation range by name
  26979. * @param name Name of the animation range to delete
  26980. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26981. */
  26982. deleteRange(name: string, deleteFrames?: boolean): void;
  26983. /**
  26984. * Gets the animation range by name, or null if not defined
  26985. * @param name Name of the animation range
  26986. * @returns Nullable animation range
  26987. */
  26988. getRange(name: string): Nullable<AnimationRange>;
  26989. /**
  26990. * Gets the key frames from the animation
  26991. * @returns The key frames of the animation
  26992. */
  26993. getKeys(): Array<IAnimationKey>;
  26994. /**
  26995. * Gets the highest frame rate of the animation
  26996. * @returns Highest frame rate of the animation
  26997. */
  26998. getHighestFrame(): number;
  26999. /**
  27000. * Gets the easing function of the animation
  27001. * @returns Easing function of the animation
  27002. */
  27003. getEasingFunction(): IEasingFunction;
  27004. /**
  27005. * Sets the easing function of the animation
  27006. * @param easingFunction A custom mathematical formula for animation
  27007. */
  27008. setEasingFunction(easingFunction: EasingFunction): void;
  27009. /**
  27010. * Interpolates a scalar linearly
  27011. * @param startValue Start value of the animation curve
  27012. * @param endValue End value of the animation curve
  27013. * @param gradient Scalar amount to interpolate
  27014. * @returns Interpolated scalar value
  27015. */
  27016. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27017. /**
  27018. * Interpolates a scalar cubically
  27019. * @param startValue Start value of the animation curve
  27020. * @param outTangent End tangent of the animation
  27021. * @param endValue End value of the animation curve
  27022. * @param inTangent Start tangent of the animation curve
  27023. * @param gradient Scalar amount to interpolate
  27024. * @returns Interpolated scalar value
  27025. */
  27026. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27027. /**
  27028. * Interpolates a quaternion using a spherical linear interpolation
  27029. * @param startValue Start value of the animation curve
  27030. * @param endValue End value of the animation curve
  27031. * @param gradient Scalar amount to interpolate
  27032. * @returns Interpolated quaternion value
  27033. */
  27034. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27035. /**
  27036. * Interpolates a quaternion cubically
  27037. * @param startValue Start value of the animation curve
  27038. * @param outTangent End tangent of the animation curve
  27039. * @param endValue End value of the animation curve
  27040. * @param inTangent Start tangent of the animation curve
  27041. * @param gradient Scalar amount to interpolate
  27042. * @returns Interpolated quaternion value
  27043. */
  27044. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27045. /**
  27046. * Interpolates a Vector3 linearl
  27047. * @param startValue Start value of the animation curve
  27048. * @param endValue End value of the animation curve
  27049. * @param gradient Scalar amount to interpolate
  27050. * @returns Interpolated scalar value
  27051. */
  27052. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27053. /**
  27054. * Interpolates a Vector3 cubically
  27055. * @param startValue Start value of the animation curve
  27056. * @param outTangent End tangent of the animation
  27057. * @param endValue End value of the animation curve
  27058. * @param inTangent Start tangent of the animation curve
  27059. * @param gradient Scalar amount to interpolate
  27060. * @returns InterpolatedVector3 value
  27061. */
  27062. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27063. /**
  27064. * Interpolates a Vector2 linearly
  27065. * @param startValue Start value of the animation curve
  27066. * @param endValue End value of the animation curve
  27067. * @param gradient Scalar amount to interpolate
  27068. * @returns Interpolated Vector2 value
  27069. */
  27070. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27071. /**
  27072. * Interpolates a Vector2 cubically
  27073. * @param startValue Start value of the animation curve
  27074. * @param outTangent End tangent of the animation
  27075. * @param endValue End value of the animation curve
  27076. * @param inTangent Start tangent of the animation curve
  27077. * @param gradient Scalar amount to interpolate
  27078. * @returns Interpolated Vector2 value
  27079. */
  27080. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27081. /**
  27082. * Interpolates a size linearly
  27083. * @param startValue Start value of the animation curve
  27084. * @param endValue End value of the animation curve
  27085. * @param gradient Scalar amount to interpolate
  27086. * @returns Interpolated Size value
  27087. */
  27088. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27089. /**
  27090. * Interpolates a Color3 linearly
  27091. * @param startValue Start value of the animation curve
  27092. * @param endValue End value of the animation curve
  27093. * @param gradient Scalar amount to interpolate
  27094. * @returns Interpolated Color3 value
  27095. */
  27096. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27097. /**
  27098. * @hidden Internal use only
  27099. */
  27100. _getKeyValue(value: any): any;
  27101. /**
  27102. * @hidden Internal use only
  27103. */
  27104. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27105. /**
  27106. * Defines the function to use to interpolate matrices
  27107. * @param startValue defines the start matrix
  27108. * @param endValue defines the end matrix
  27109. * @param gradient defines the gradient between both matrices
  27110. * @param result defines an optional target matrix where to store the interpolation
  27111. * @returns the interpolated matrix
  27112. */
  27113. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27114. /**
  27115. * Makes a copy of the animation
  27116. * @returns Cloned animation
  27117. */
  27118. clone(): Animation;
  27119. /**
  27120. * Sets the key frames of the animation
  27121. * @param values The animation key frames to set
  27122. */
  27123. setKeys(values: Array<IAnimationKey>): void;
  27124. /**
  27125. * Serializes the animation to an object
  27126. * @returns Serialized object
  27127. */
  27128. serialize(): any;
  27129. /**
  27130. * Float animation type
  27131. */
  27132. private static _ANIMATIONTYPE_FLOAT;
  27133. /**
  27134. * Vector3 animation type
  27135. */
  27136. private static _ANIMATIONTYPE_VECTOR3;
  27137. /**
  27138. * Quaternion animation type
  27139. */
  27140. private static _ANIMATIONTYPE_QUATERNION;
  27141. /**
  27142. * Matrix animation type
  27143. */
  27144. private static _ANIMATIONTYPE_MATRIX;
  27145. /**
  27146. * Color3 animation type
  27147. */
  27148. private static _ANIMATIONTYPE_COLOR3;
  27149. /**
  27150. * Vector2 animation type
  27151. */
  27152. private static _ANIMATIONTYPE_VECTOR2;
  27153. /**
  27154. * Size animation type
  27155. */
  27156. private static _ANIMATIONTYPE_SIZE;
  27157. /**
  27158. * Relative Loop Mode
  27159. */
  27160. private static _ANIMATIONLOOPMODE_RELATIVE;
  27161. /**
  27162. * Cycle Loop Mode
  27163. */
  27164. private static _ANIMATIONLOOPMODE_CYCLE;
  27165. /**
  27166. * Constant Loop Mode
  27167. */
  27168. private static _ANIMATIONLOOPMODE_CONSTANT;
  27169. /**
  27170. * Get the float animation type
  27171. */
  27172. static readonly ANIMATIONTYPE_FLOAT: number;
  27173. /**
  27174. * Get the Vector3 animation type
  27175. */
  27176. static readonly ANIMATIONTYPE_VECTOR3: number;
  27177. /**
  27178. * Get the Vector2 animation type
  27179. */
  27180. static readonly ANIMATIONTYPE_VECTOR2: number;
  27181. /**
  27182. * Get the Size animation type
  27183. */
  27184. static readonly ANIMATIONTYPE_SIZE: number;
  27185. /**
  27186. * Get the Quaternion animation type
  27187. */
  27188. static readonly ANIMATIONTYPE_QUATERNION: number;
  27189. /**
  27190. * Get the Matrix animation type
  27191. */
  27192. static readonly ANIMATIONTYPE_MATRIX: number;
  27193. /**
  27194. * Get the Color3 animation type
  27195. */
  27196. static readonly ANIMATIONTYPE_COLOR3: number;
  27197. /**
  27198. * Get the Relative Loop Mode
  27199. */
  27200. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27201. /**
  27202. * Get the Cycle Loop Mode
  27203. */
  27204. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27205. /**
  27206. * Get the Constant Loop Mode
  27207. */
  27208. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27209. /** @hidden */
  27210. static _UniversalLerp(left: any, right: any, amount: number): any;
  27211. /**
  27212. * Parses an animation object and creates an animation
  27213. * @param parsedAnimation Parsed animation object
  27214. * @returns Animation object
  27215. */
  27216. static Parse(parsedAnimation: any): Animation;
  27217. /**
  27218. * Appends the serialized animations from the source animations
  27219. * @param source Source containing the animations
  27220. * @param destination Target to store the animations
  27221. */
  27222. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27223. }
  27224. }
  27225. declare module BABYLON {
  27226. /**
  27227. * Interface containing an array of animations
  27228. */
  27229. export interface IAnimatable {
  27230. /**
  27231. * Array of animations
  27232. */
  27233. animations: Nullable<Array<Animation>>;
  27234. }
  27235. }
  27236. declare module BABYLON {
  27237. /**
  27238. * This represents all the required information to add a fresnel effect on a material:
  27239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27240. */
  27241. export class FresnelParameters {
  27242. private _isEnabled;
  27243. /**
  27244. * Define if the fresnel effect is enable or not.
  27245. */
  27246. isEnabled: boolean;
  27247. /**
  27248. * Define the color used on edges (grazing angle)
  27249. */
  27250. leftColor: Color3;
  27251. /**
  27252. * Define the color used on center
  27253. */
  27254. rightColor: Color3;
  27255. /**
  27256. * Define bias applied to computed fresnel term
  27257. */
  27258. bias: number;
  27259. /**
  27260. * Defined the power exponent applied to fresnel term
  27261. */
  27262. power: number;
  27263. /**
  27264. * Clones the current fresnel and its valuues
  27265. * @returns a clone fresnel configuration
  27266. */
  27267. clone(): FresnelParameters;
  27268. /**
  27269. * Serializes the current fresnel parameters to a JSON representation.
  27270. * @return the JSON serialization
  27271. */
  27272. serialize(): any;
  27273. /**
  27274. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27275. * @param parsedFresnelParameters Define the JSON representation
  27276. * @returns the parsed parameters
  27277. */
  27278. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27279. }
  27280. }
  27281. declare module BABYLON {
  27282. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27283. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27284. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27285. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27286. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27287. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27288. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27289. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27290. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27291. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27292. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27293. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27294. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27295. /**
  27296. * Decorator used to define property that can be serialized as reference to a camera
  27297. * @param sourceName defines the name of the property to decorate
  27298. */
  27299. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27300. /**
  27301. * Class used to help serialization objects
  27302. */
  27303. export class SerializationHelper {
  27304. /** @hidden */
  27305. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27306. /** @hidden */
  27307. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27308. /** @hidden */
  27309. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27310. /** @hidden */
  27311. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27312. /**
  27313. * Appends the serialized animations from the source animations
  27314. * @param source Source containing the animations
  27315. * @param destination Target to store the animations
  27316. */
  27317. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27318. /**
  27319. * Static function used to serialized a specific entity
  27320. * @param entity defines the entity to serialize
  27321. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27322. * @returns a JSON compatible object representing the serialization of the entity
  27323. */
  27324. static Serialize<T>(entity: T, serializationObject?: any): any;
  27325. /**
  27326. * Creates a new entity from a serialization data object
  27327. * @param creationFunction defines a function used to instanciated the new entity
  27328. * @param source defines the source serialization data
  27329. * @param scene defines the hosting scene
  27330. * @param rootUrl defines the root url for resources
  27331. * @returns a new entity
  27332. */
  27333. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27334. /**
  27335. * Clones an object
  27336. * @param creationFunction defines the function used to instanciate the new object
  27337. * @param source defines the source object
  27338. * @returns the cloned object
  27339. */
  27340. static Clone<T>(creationFunction: () => T, source: T): T;
  27341. /**
  27342. * Instanciates a new object based on a source one (some data will be shared between both object)
  27343. * @param creationFunction defines the function used to instanciate the new object
  27344. * @param source defines the source object
  27345. * @returns the new object
  27346. */
  27347. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27348. }
  27349. }
  27350. declare module BABYLON {
  27351. /**
  27352. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27353. */
  27354. export interface CubeMapInfo {
  27355. /**
  27356. * The pixel array for the front face.
  27357. * This is stored in format, left to right, up to down format.
  27358. */
  27359. front: Nullable<ArrayBufferView>;
  27360. /**
  27361. * The pixel array for the back face.
  27362. * This is stored in format, left to right, up to down format.
  27363. */
  27364. back: Nullable<ArrayBufferView>;
  27365. /**
  27366. * The pixel array for the left face.
  27367. * This is stored in format, left to right, up to down format.
  27368. */
  27369. left: Nullable<ArrayBufferView>;
  27370. /**
  27371. * The pixel array for the right face.
  27372. * This is stored in format, left to right, up to down format.
  27373. */
  27374. right: Nullable<ArrayBufferView>;
  27375. /**
  27376. * The pixel array for the up face.
  27377. * This is stored in format, left to right, up to down format.
  27378. */
  27379. up: Nullable<ArrayBufferView>;
  27380. /**
  27381. * The pixel array for the down face.
  27382. * This is stored in format, left to right, up to down format.
  27383. */
  27384. down: Nullable<ArrayBufferView>;
  27385. /**
  27386. * The size of the cubemap stored.
  27387. *
  27388. * Each faces will be size * size pixels.
  27389. */
  27390. size: number;
  27391. /**
  27392. * The format of the texture.
  27393. *
  27394. * RGBA, RGB.
  27395. */
  27396. format: number;
  27397. /**
  27398. * The type of the texture data.
  27399. *
  27400. * UNSIGNED_INT, FLOAT.
  27401. */
  27402. type: number;
  27403. /**
  27404. * Specifies whether the texture is in gamma space.
  27405. */
  27406. gammaSpace: boolean;
  27407. }
  27408. /**
  27409. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27410. */
  27411. export class PanoramaToCubeMapTools {
  27412. private static FACE_FRONT;
  27413. private static FACE_BACK;
  27414. private static FACE_RIGHT;
  27415. private static FACE_LEFT;
  27416. private static FACE_DOWN;
  27417. private static FACE_UP;
  27418. /**
  27419. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27420. *
  27421. * @param float32Array The source data.
  27422. * @param inputWidth The width of the input panorama.
  27423. * @param inputHeight The height of the input panorama.
  27424. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27425. * @return The cubemap data
  27426. */
  27427. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27428. private static CreateCubemapTexture;
  27429. private static CalcProjectionSpherical;
  27430. }
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * Helper class dealing with the extraction of spherical polynomial dataArray
  27435. * from a cube map.
  27436. */
  27437. export class CubeMapToSphericalPolynomialTools {
  27438. private static FileFaces;
  27439. /**
  27440. * Converts a texture to the according Spherical Polynomial data.
  27441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27442. *
  27443. * @param texture The texture to extract the information from.
  27444. * @return The Spherical Polynomial data.
  27445. */
  27446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27447. /**
  27448. * Converts a cubemap to the according Spherical Polynomial data.
  27449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27450. *
  27451. * @param cubeInfo The Cube map to extract the information from.
  27452. * @return The Spherical Polynomial data.
  27453. */
  27454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27455. }
  27456. }
  27457. declare module BABYLON {
  27458. /**
  27459. * Class used to manipulate GUIDs
  27460. */
  27461. export class GUID {
  27462. /**
  27463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27464. * Be aware Math.random() could cause collisions, but:
  27465. * "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"
  27466. * @returns a pseudo random id
  27467. */
  27468. static RandomId(): string;
  27469. }
  27470. }
  27471. declare module BABYLON {
  27472. /**
  27473. * Base class of all the textures in babylon.
  27474. * It groups all the common properties the materials, post process, lights... might need
  27475. * in order to make a correct use of the texture.
  27476. */
  27477. export class BaseTexture implements IAnimatable {
  27478. /**
  27479. * Default anisotropic filtering level for the application.
  27480. * It is set to 4 as a good tradeoff between perf and quality.
  27481. */
  27482. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27483. /**
  27484. * Gets or sets the unique id of the texture
  27485. */
  27486. uniqueId: number;
  27487. /**
  27488. * Define the name of the texture.
  27489. */
  27490. name: string;
  27491. /**
  27492. * Gets or sets an object used to store user defined information.
  27493. */
  27494. metadata: any;
  27495. /**
  27496. * For internal use only. Please do not use.
  27497. */
  27498. reservedDataStore: any;
  27499. private _hasAlpha;
  27500. /**
  27501. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27502. */
  27503. hasAlpha: boolean;
  27504. /**
  27505. * Defines if the alpha value should be determined via the rgb values.
  27506. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27507. */
  27508. getAlphaFromRGB: boolean;
  27509. /**
  27510. * Intensity or strength of the texture.
  27511. * It is commonly used by materials to fine tune the intensity of the texture
  27512. */
  27513. level: number;
  27514. /**
  27515. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27516. * This is part of the texture as textures usually maps to one uv set.
  27517. */
  27518. coordinatesIndex: number;
  27519. private _coordinatesMode;
  27520. /**
  27521. * How a texture is mapped.
  27522. *
  27523. * | Value | Type | Description |
  27524. * | ----- | ----------------------------------- | ----------- |
  27525. * | 0 | EXPLICIT_MODE | |
  27526. * | 1 | SPHERICAL_MODE | |
  27527. * | 2 | PLANAR_MODE | |
  27528. * | 3 | CUBIC_MODE | |
  27529. * | 4 | PROJECTION_MODE | |
  27530. * | 5 | SKYBOX_MODE | |
  27531. * | 6 | INVCUBIC_MODE | |
  27532. * | 7 | EQUIRECTANGULAR_MODE | |
  27533. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27534. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27535. */
  27536. coordinatesMode: number;
  27537. /**
  27538. * | Value | Type | Description |
  27539. * | ----- | ------------------ | ----------- |
  27540. * | 0 | CLAMP_ADDRESSMODE | |
  27541. * | 1 | WRAP_ADDRESSMODE | |
  27542. * | 2 | MIRROR_ADDRESSMODE | |
  27543. */
  27544. wrapU: number;
  27545. /**
  27546. * | Value | Type | Description |
  27547. * | ----- | ------------------ | ----------- |
  27548. * | 0 | CLAMP_ADDRESSMODE | |
  27549. * | 1 | WRAP_ADDRESSMODE | |
  27550. * | 2 | MIRROR_ADDRESSMODE | |
  27551. */
  27552. wrapV: number;
  27553. /**
  27554. * | Value | Type | Description |
  27555. * | ----- | ------------------ | ----------- |
  27556. * | 0 | CLAMP_ADDRESSMODE | |
  27557. * | 1 | WRAP_ADDRESSMODE | |
  27558. * | 2 | MIRROR_ADDRESSMODE | |
  27559. */
  27560. wrapR: number;
  27561. /**
  27562. * With compliant hardware and browser (supporting anisotropic filtering)
  27563. * this defines the level of anisotropic filtering in the texture.
  27564. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27565. */
  27566. anisotropicFilteringLevel: number;
  27567. /**
  27568. * Define if the texture is a cube texture or if false a 2d texture.
  27569. */
  27570. isCube: boolean;
  27571. /**
  27572. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27573. */
  27574. is3D: boolean;
  27575. /**
  27576. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27577. * HDR texture are usually stored in linear space.
  27578. * This only impacts the PBR and Background materials
  27579. */
  27580. gammaSpace: boolean;
  27581. /**
  27582. * Gets whether or not the texture contains RGBD data.
  27583. */
  27584. readonly isRGBD: boolean;
  27585. /**
  27586. * Is Z inverted in the texture (useful in a cube texture).
  27587. */
  27588. invertZ: boolean;
  27589. /**
  27590. * Are mip maps generated for this texture or not.
  27591. */
  27592. readonly noMipmap: boolean;
  27593. /**
  27594. * @hidden
  27595. */
  27596. lodLevelInAlpha: boolean;
  27597. /**
  27598. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27599. */
  27600. lodGenerationOffset: number;
  27601. /**
  27602. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27603. */
  27604. lodGenerationScale: number;
  27605. /**
  27606. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27607. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27608. * average roughness values.
  27609. */
  27610. linearSpecularLOD: boolean;
  27611. /**
  27612. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27613. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27614. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27615. */
  27616. irradianceTexture: Nullable<BaseTexture>;
  27617. /**
  27618. * Define if the texture is a render target.
  27619. */
  27620. isRenderTarget: boolean;
  27621. /**
  27622. * Define the unique id of the texture in the scene.
  27623. */
  27624. readonly uid: string;
  27625. /**
  27626. * Return a string representation of the texture.
  27627. * @returns the texture as a string
  27628. */
  27629. toString(): string;
  27630. /**
  27631. * Get the class name of the texture.
  27632. * @returns "BaseTexture"
  27633. */
  27634. getClassName(): string;
  27635. /**
  27636. * Define the list of animation attached to the texture.
  27637. */
  27638. animations: Animation[];
  27639. /**
  27640. * An event triggered when the texture is disposed.
  27641. */
  27642. onDisposeObservable: Observable<BaseTexture>;
  27643. private _onDisposeObserver;
  27644. /**
  27645. * Callback triggered when the texture has been disposed.
  27646. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27647. */
  27648. onDispose: () => void;
  27649. /**
  27650. * Define the current state of the loading sequence when in delayed load mode.
  27651. */
  27652. delayLoadState: number;
  27653. private _scene;
  27654. /** @hidden */
  27655. _texture: Nullable<InternalTexture>;
  27656. private _uid;
  27657. /**
  27658. * Define if the texture is preventinga material to render or not.
  27659. * If not and the texture is not ready, the engine will use a default black texture instead.
  27660. */
  27661. readonly isBlocking: boolean;
  27662. /**
  27663. * Instantiates a new BaseTexture.
  27664. * Base class of all the textures in babylon.
  27665. * It groups all the common properties the materials, post process, lights... might need
  27666. * in order to make a correct use of the texture.
  27667. * @param scene Define the scene the texture blongs to
  27668. */
  27669. constructor(scene: Nullable<Scene>);
  27670. /**
  27671. * Get the scene the texture belongs to.
  27672. * @returns the scene or null if undefined
  27673. */
  27674. getScene(): Nullable<Scene>;
  27675. /**
  27676. * Get the texture transform matrix used to offset tile the texture for istance.
  27677. * @returns the transformation matrix
  27678. */
  27679. getTextureMatrix(): Matrix;
  27680. /**
  27681. * Get the texture reflection matrix used to rotate/transform the reflection.
  27682. * @returns the reflection matrix
  27683. */
  27684. getReflectionTextureMatrix(): Matrix;
  27685. /**
  27686. * Get the underlying lower level texture from Babylon.
  27687. * @returns the insternal texture
  27688. */
  27689. getInternalTexture(): Nullable<InternalTexture>;
  27690. /**
  27691. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27692. * @returns true if ready or not blocking
  27693. */
  27694. isReadyOrNotBlocking(): boolean;
  27695. /**
  27696. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27697. * @returns true if fully ready
  27698. */
  27699. isReady(): boolean;
  27700. private _cachedSize;
  27701. /**
  27702. * Get the size of the texture.
  27703. * @returns the texture size.
  27704. */
  27705. getSize(): ISize;
  27706. /**
  27707. * Get the base size of the texture.
  27708. * It can be different from the size if the texture has been resized for POT for instance
  27709. * @returns the base size
  27710. */
  27711. getBaseSize(): ISize;
  27712. /**
  27713. * Update the sampling mode of the texture.
  27714. * Default is Trilinear mode.
  27715. *
  27716. * | Value | Type | Description |
  27717. * | ----- | ------------------ | ----------- |
  27718. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27719. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27720. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27721. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27722. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27723. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27724. * | 7 | NEAREST_LINEAR | |
  27725. * | 8 | NEAREST_NEAREST | |
  27726. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27727. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27728. * | 11 | LINEAR_LINEAR | |
  27729. * | 12 | LINEAR_NEAREST | |
  27730. *
  27731. * > _mag_: magnification filter (close to the viewer)
  27732. * > _min_: minification filter (far from the viewer)
  27733. * > _mip_: filter used between mip map levels
  27734. *@param samplingMode Define the new sampling mode of the texture
  27735. */
  27736. updateSamplingMode(samplingMode: number): void;
  27737. /**
  27738. * Scales the texture if is `canRescale()`
  27739. * @param ratio the resize factor we want to use to rescale
  27740. */
  27741. scale(ratio: number): void;
  27742. /**
  27743. * Get if the texture can rescale.
  27744. */
  27745. readonly canRescale: boolean;
  27746. /** @hidden */
  27747. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27748. /** @hidden */
  27749. _rebuild(): void;
  27750. /**
  27751. * Triggers the load sequence in delayed load mode.
  27752. */
  27753. delayLoad(): void;
  27754. /**
  27755. * Clones the texture.
  27756. * @returns the cloned texture
  27757. */
  27758. clone(): Nullable<BaseTexture>;
  27759. /**
  27760. * Get the texture underlying type (INT, FLOAT...)
  27761. */
  27762. readonly textureType: number;
  27763. /**
  27764. * Get the texture underlying format (RGB, RGBA...)
  27765. */
  27766. readonly textureFormat: number;
  27767. /**
  27768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27769. * This will returns an RGBA array buffer containing either in values (0-255) or
  27770. * float values (0-1) depending of the underlying buffer type.
  27771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27773. * @param buffer defines a user defined buffer to fill with data (can be null)
  27774. * @returns The Array buffer containing the pixels data.
  27775. */
  27776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27777. /**
  27778. * Release and destroy the underlying lower level texture aka internalTexture.
  27779. */
  27780. releaseInternalTexture(): void;
  27781. /**
  27782. * Get the polynomial representation of the texture data.
  27783. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27784. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27785. */
  27786. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27787. /** @hidden */
  27788. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27789. /** @hidden */
  27790. readonly _lodTextureMid: Nullable<BaseTexture>;
  27791. /** @hidden */
  27792. readonly _lodTextureLow: Nullable<BaseTexture>;
  27793. /**
  27794. * Dispose the texture and release its associated resources.
  27795. */
  27796. dispose(): void;
  27797. /**
  27798. * Serialize the texture into a JSON representation that can be parsed later on.
  27799. * @returns the JSON representation of the texture
  27800. */
  27801. serialize(): any;
  27802. /**
  27803. * Helper function to be called back once a list of texture contains only ready textures.
  27804. * @param textures Define the list of textures to wait for
  27805. * @param callback Define the callback triggered once the entire list will be ready
  27806. */
  27807. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27808. }
  27809. }
  27810. declare module BABYLON {
  27811. /**
  27812. * Class used to store data associated with WebGL texture data for the engine
  27813. * This class should not be used directly
  27814. */
  27815. export class InternalTexture {
  27816. /** @hidden */
  27817. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27818. /**
  27819. * The source of the texture data is unknown
  27820. */
  27821. static DATASOURCE_UNKNOWN: number;
  27822. /**
  27823. * Texture data comes from an URL
  27824. */
  27825. static DATASOURCE_URL: number;
  27826. /**
  27827. * Texture data is only used for temporary storage
  27828. */
  27829. static DATASOURCE_TEMP: number;
  27830. /**
  27831. * Texture data comes from raw data (ArrayBuffer)
  27832. */
  27833. static DATASOURCE_RAW: number;
  27834. /**
  27835. * Texture content is dynamic (video or dynamic texture)
  27836. */
  27837. static DATASOURCE_DYNAMIC: number;
  27838. /**
  27839. * Texture content is generated by rendering to it
  27840. */
  27841. static DATASOURCE_RENDERTARGET: number;
  27842. /**
  27843. * Texture content is part of a multi render target process
  27844. */
  27845. static DATASOURCE_MULTIRENDERTARGET: number;
  27846. /**
  27847. * Texture data comes from a cube data file
  27848. */
  27849. static DATASOURCE_CUBE: number;
  27850. /**
  27851. * Texture data comes from a raw cube data
  27852. */
  27853. static DATASOURCE_CUBERAW: number;
  27854. /**
  27855. * Texture data come from a prefiltered cube data file
  27856. */
  27857. static DATASOURCE_CUBEPREFILTERED: number;
  27858. /**
  27859. * Texture content is raw 3D data
  27860. */
  27861. static DATASOURCE_RAW3D: number;
  27862. /**
  27863. * Texture content is a depth texture
  27864. */
  27865. static DATASOURCE_DEPTHTEXTURE: number;
  27866. /**
  27867. * Texture data comes from a raw cube data encoded with RGBD
  27868. */
  27869. static DATASOURCE_CUBERAW_RGBD: number;
  27870. /**
  27871. * Defines if the texture is ready
  27872. */
  27873. isReady: boolean;
  27874. /**
  27875. * Defines if the texture is a cube texture
  27876. */
  27877. isCube: boolean;
  27878. /**
  27879. * Defines if the texture contains 3D data
  27880. */
  27881. is3D: boolean;
  27882. /**
  27883. * Defines if the texture contains multiview data
  27884. */
  27885. isMultiview: boolean;
  27886. /**
  27887. * Gets the URL used to load this texture
  27888. */
  27889. url: string;
  27890. /**
  27891. * Gets the sampling mode of the texture
  27892. */
  27893. samplingMode: number;
  27894. /**
  27895. * Gets a boolean indicating if the texture needs mipmaps generation
  27896. */
  27897. generateMipMaps: boolean;
  27898. /**
  27899. * Gets the number of samples used by the texture (WebGL2+ only)
  27900. */
  27901. samples: number;
  27902. /**
  27903. * Gets the type of the texture (int, float...)
  27904. */
  27905. type: number;
  27906. /**
  27907. * Gets the format of the texture (RGB, RGBA...)
  27908. */
  27909. format: number;
  27910. /**
  27911. * Observable called when the texture is loaded
  27912. */
  27913. onLoadedObservable: Observable<InternalTexture>;
  27914. /**
  27915. * Gets the width of the texture
  27916. */
  27917. width: number;
  27918. /**
  27919. * Gets the height of the texture
  27920. */
  27921. height: number;
  27922. /**
  27923. * Gets the depth of the texture
  27924. */
  27925. depth: number;
  27926. /**
  27927. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27928. */
  27929. baseWidth: number;
  27930. /**
  27931. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27932. */
  27933. baseHeight: number;
  27934. /**
  27935. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27936. */
  27937. baseDepth: number;
  27938. /**
  27939. * Gets a boolean indicating if the texture is inverted on Y axis
  27940. */
  27941. invertY: boolean;
  27942. /** @hidden */
  27943. _invertVScale: boolean;
  27944. /** @hidden */
  27945. _associatedChannel: number;
  27946. /** @hidden */
  27947. _dataSource: number;
  27948. /** @hidden */
  27949. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27950. /** @hidden */
  27951. _bufferView: Nullable<ArrayBufferView>;
  27952. /** @hidden */
  27953. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27954. /** @hidden */
  27955. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27956. /** @hidden */
  27957. _size: number;
  27958. /** @hidden */
  27959. _extension: string;
  27960. /** @hidden */
  27961. _files: Nullable<string[]>;
  27962. /** @hidden */
  27963. _workingCanvas: Nullable<HTMLCanvasElement>;
  27964. /** @hidden */
  27965. _workingContext: Nullable<CanvasRenderingContext2D>;
  27966. /** @hidden */
  27967. _framebuffer: Nullable<WebGLFramebuffer>;
  27968. /** @hidden */
  27969. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27970. /** @hidden */
  27971. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27972. /** @hidden */
  27973. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27974. /** @hidden */
  27975. _attachments: Nullable<number[]>;
  27976. /** @hidden */
  27977. _cachedCoordinatesMode: Nullable<number>;
  27978. /** @hidden */
  27979. _cachedWrapU: Nullable<number>;
  27980. /** @hidden */
  27981. _cachedWrapV: Nullable<number>;
  27982. /** @hidden */
  27983. _cachedWrapR: Nullable<number>;
  27984. /** @hidden */
  27985. _cachedAnisotropicFilteringLevel: Nullable<number>;
  27986. /** @hidden */
  27987. _isDisabled: boolean;
  27988. /** @hidden */
  27989. _compression: Nullable<string>;
  27990. /** @hidden */
  27991. _generateStencilBuffer: boolean;
  27992. /** @hidden */
  27993. _generateDepthBuffer: boolean;
  27994. /** @hidden */
  27995. _comparisonFunction: number;
  27996. /** @hidden */
  27997. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27998. /** @hidden */
  27999. _lodGenerationScale: number;
  28000. /** @hidden */
  28001. _lodGenerationOffset: number;
  28002. /** @hidden */
  28003. _colorTextureArray: Nullable<WebGLTexture>;
  28004. /** @hidden */
  28005. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28006. /** @hidden */
  28007. _lodTextureHigh: Nullable<BaseTexture>;
  28008. /** @hidden */
  28009. _lodTextureMid: Nullable<BaseTexture>;
  28010. /** @hidden */
  28011. _lodTextureLow: Nullable<BaseTexture>;
  28012. /** @hidden */
  28013. _isRGBD: boolean;
  28014. /** @hidden */
  28015. _linearSpecularLOD: boolean;
  28016. /** @hidden */
  28017. _irradianceTexture: Nullable<BaseTexture>;
  28018. /** @hidden */
  28019. _webGLTexture: Nullable<WebGLTexture>;
  28020. /** @hidden */
  28021. _references: number;
  28022. private _engine;
  28023. /**
  28024. * Gets the Engine the texture belongs to.
  28025. * @returns The babylon engine
  28026. */
  28027. getEngine(): Engine;
  28028. /**
  28029. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28030. */
  28031. readonly dataSource: number;
  28032. /**
  28033. * Creates a new InternalTexture
  28034. * @param engine defines the engine to use
  28035. * @param dataSource defines the type of data that will be used
  28036. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28037. */
  28038. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28039. /**
  28040. * Increments the number of references (ie. the number of Texture that point to it)
  28041. */
  28042. incrementReferences(): void;
  28043. /**
  28044. * Change the size of the texture (not the size of the content)
  28045. * @param width defines the new width
  28046. * @param height defines the new height
  28047. * @param depth defines the new depth (1 by default)
  28048. */
  28049. updateSize(width: int, height: int, depth?: int): void;
  28050. /** @hidden */
  28051. _rebuild(): void;
  28052. /** @hidden */
  28053. _swapAndDie(target: InternalTexture): void;
  28054. /**
  28055. * Dispose the current allocated resources
  28056. */
  28057. dispose(): void;
  28058. }
  28059. }
  28060. declare module BABYLON {
  28061. /**
  28062. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28063. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28064. */
  28065. export class EffectFallbacks {
  28066. private _defines;
  28067. private _currentRank;
  28068. private _maxRank;
  28069. private _mesh;
  28070. /**
  28071. * Removes the fallback from the bound mesh.
  28072. */
  28073. unBindMesh(): void;
  28074. /**
  28075. * Adds a fallback on the specified property.
  28076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28077. * @param define The name of the define in the shader
  28078. */
  28079. addFallback(rank: number, define: string): void;
  28080. /**
  28081. * Sets the mesh to use CPU skinning when needing to fallback.
  28082. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28083. * @param mesh The mesh to use the fallbacks.
  28084. */
  28085. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28086. /**
  28087. * Checks to see if more fallbacks are still availible.
  28088. */
  28089. readonly isMoreFallbacks: boolean;
  28090. /**
  28091. * Removes the defines that should be removed when falling back.
  28092. * @param currentDefines defines the current define statements for the shader.
  28093. * @param effect defines the current effect we try to compile
  28094. * @returns The resulting defines with defines of the current rank removed.
  28095. */
  28096. reduce(currentDefines: string, effect: Effect): string;
  28097. }
  28098. /**
  28099. * Options to be used when creating an effect.
  28100. */
  28101. export class EffectCreationOptions {
  28102. /**
  28103. * Atrributes that will be used in the shader.
  28104. */
  28105. attributes: string[];
  28106. /**
  28107. * Uniform varible names that will be set in the shader.
  28108. */
  28109. uniformsNames: string[];
  28110. /**
  28111. * Uniform buffer varible names that will be set in the shader.
  28112. */
  28113. uniformBuffersNames: string[];
  28114. /**
  28115. * Sampler texture variable names that will be set in the shader.
  28116. */
  28117. samplers: string[];
  28118. /**
  28119. * Define statements that will be set in the shader.
  28120. */
  28121. defines: any;
  28122. /**
  28123. * Possible fallbacks for this effect to improve performance when needed.
  28124. */
  28125. fallbacks: Nullable<EffectFallbacks>;
  28126. /**
  28127. * Callback that will be called when the shader is compiled.
  28128. */
  28129. onCompiled: Nullable<(effect: Effect) => void>;
  28130. /**
  28131. * Callback that will be called if an error occurs during shader compilation.
  28132. */
  28133. onError: Nullable<(effect: Effect, errors: string) => void>;
  28134. /**
  28135. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28136. */
  28137. indexParameters: any;
  28138. /**
  28139. * Max number of lights that can be used in the shader.
  28140. */
  28141. maxSimultaneousLights: number;
  28142. /**
  28143. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28144. */
  28145. transformFeedbackVaryings: Nullable<string[]>;
  28146. }
  28147. /**
  28148. * Effect containing vertex and fragment shader that can be executed on an object.
  28149. */
  28150. export class Effect implements IDisposable {
  28151. /**
  28152. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28153. */
  28154. static ShadersRepository: string;
  28155. /**
  28156. * Name of the effect.
  28157. */
  28158. name: any;
  28159. /**
  28160. * String container all the define statements that should be set on the shader.
  28161. */
  28162. defines: string;
  28163. /**
  28164. * Callback that will be called when the shader is compiled.
  28165. */
  28166. onCompiled: Nullable<(effect: Effect) => void>;
  28167. /**
  28168. * Callback that will be called if an error occurs during shader compilation.
  28169. */
  28170. onError: Nullable<(effect: Effect, errors: string) => void>;
  28171. /**
  28172. * Callback that will be called when effect is bound.
  28173. */
  28174. onBind: Nullable<(effect: Effect) => void>;
  28175. /**
  28176. * Unique ID of the effect.
  28177. */
  28178. uniqueId: number;
  28179. /**
  28180. * Observable that will be called when the shader is compiled.
  28181. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28182. */
  28183. onCompileObservable: Observable<Effect>;
  28184. /**
  28185. * Observable that will be called if an error occurs during shader compilation.
  28186. */
  28187. onErrorObservable: Observable<Effect>;
  28188. /** @hidden */
  28189. _onBindObservable: Nullable<Observable<Effect>>;
  28190. /**
  28191. * Observable that will be called when effect is bound.
  28192. */
  28193. readonly onBindObservable: Observable<Effect>;
  28194. /** @hidden */
  28195. _bonesComputationForcedToCPU: boolean;
  28196. private static _uniqueIdSeed;
  28197. private _engine;
  28198. private _uniformBuffersNames;
  28199. private _uniformsNames;
  28200. private _samplerList;
  28201. private _samplers;
  28202. private _isReady;
  28203. private _compilationError;
  28204. private _attributesNames;
  28205. private _attributes;
  28206. private _uniforms;
  28207. /**
  28208. * Key for the effect.
  28209. * @hidden
  28210. */
  28211. _key: string;
  28212. private _indexParameters;
  28213. private _fallbacks;
  28214. private _vertexSourceCode;
  28215. private _fragmentSourceCode;
  28216. private _vertexSourceCodeOverride;
  28217. private _fragmentSourceCodeOverride;
  28218. private _transformFeedbackVaryings;
  28219. /**
  28220. * Compiled shader to webGL program.
  28221. * @hidden
  28222. */
  28223. _pipelineContext: Nullable<IPipelineContext>;
  28224. private _valueCache;
  28225. private static _baseCache;
  28226. /**
  28227. * Instantiates an effect.
  28228. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28229. * @param baseName Name of the effect.
  28230. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28231. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28232. * @param samplers List of sampler variables that will be passed to the shader.
  28233. * @param engine Engine to be used to render the effect
  28234. * @param defines Define statements to be added to the shader.
  28235. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28236. * @param onCompiled Callback that will be called when the shader is compiled.
  28237. * @param onError Callback that will be called if an error occurs during shader compilation.
  28238. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28239. */
  28240. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28241. private _useFinalCode;
  28242. /**
  28243. * Unique key for this effect
  28244. */
  28245. readonly key: string;
  28246. /**
  28247. * If the effect has been compiled and prepared.
  28248. * @returns if the effect is compiled and prepared.
  28249. */
  28250. isReady(): boolean;
  28251. /**
  28252. * The engine the effect was initialized with.
  28253. * @returns the engine.
  28254. */
  28255. getEngine(): Engine;
  28256. /**
  28257. * The pipeline context for this effect
  28258. * @returns the associated pipeline context
  28259. */
  28260. getPipelineContext(): Nullable<IPipelineContext>;
  28261. /**
  28262. * The set of names of attribute variables for the shader.
  28263. * @returns An array of attribute names.
  28264. */
  28265. getAttributesNames(): string[];
  28266. /**
  28267. * Returns the attribute at the given index.
  28268. * @param index The index of the attribute.
  28269. * @returns The location of the attribute.
  28270. */
  28271. getAttributeLocation(index: number): number;
  28272. /**
  28273. * Returns the attribute based on the name of the variable.
  28274. * @param name of the attribute to look up.
  28275. * @returns the attribute location.
  28276. */
  28277. getAttributeLocationByName(name: string): number;
  28278. /**
  28279. * The number of attributes.
  28280. * @returns the numnber of attributes.
  28281. */
  28282. getAttributesCount(): number;
  28283. /**
  28284. * Gets the index of a uniform variable.
  28285. * @param uniformName of the uniform to look up.
  28286. * @returns the index.
  28287. */
  28288. getUniformIndex(uniformName: string): number;
  28289. /**
  28290. * Returns the attribute based on the name of the variable.
  28291. * @param uniformName of the uniform to look up.
  28292. * @returns the location of the uniform.
  28293. */
  28294. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28295. /**
  28296. * Returns an array of sampler variable names
  28297. * @returns The array of sampler variable neames.
  28298. */
  28299. getSamplers(): string[];
  28300. /**
  28301. * The error from the last compilation.
  28302. * @returns the error string.
  28303. */
  28304. getCompilationError(): string;
  28305. /**
  28306. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28307. * @param func The callback to be used.
  28308. */
  28309. executeWhenCompiled(func: (effect: Effect) => void): void;
  28310. private _checkIsReady;
  28311. /** @hidden */
  28312. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28313. /** @hidden */
  28314. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28315. /** @hidden */
  28316. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28317. /**
  28318. * Recompiles the webGL program
  28319. * @param vertexSourceCode The source code for the vertex shader.
  28320. * @param fragmentSourceCode The source code for the fragment shader.
  28321. * @param onCompiled Callback called when completed.
  28322. * @param onError Callback called on error.
  28323. * @hidden
  28324. */
  28325. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28326. /**
  28327. * Prepares the effect
  28328. * @hidden
  28329. */
  28330. _prepareEffect(): void;
  28331. /**
  28332. * Checks if the effect is supported. (Must be called after compilation)
  28333. */
  28334. readonly isSupported: boolean;
  28335. /**
  28336. * Binds a texture to the engine to be used as output of the shader.
  28337. * @param channel Name of the output variable.
  28338. * @param texture Texture to bind.
  28339. * @hidden
  28340. */
  28341. _bindTexture(channel: string, texture: InternalTexture): void;
  28342. /**
  28343. * Sets a texture on the engine to be used in the shader.
  28344. * @param channel Name of the sampler variable.
  28345. * @param texture Texture to set.
  28346. */
  28347. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28348. /**
  28349. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28350. * @param channel Name of the sampler variable.
  28351. * @param texture Texture to set.
  28352. */
  28353. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28354. /**
  28355. * Sets an array of textures on the engine to be used in the shader.
  28356. * @param channel Name of the variable.
  28357. * @param textures Textures to set.
  28358. */
  28359. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28360. /**
  28361. * 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)
  28362. * @param channel Name of the sampler variable.
  28363. * @param postProcess Post process to get the input texture from.
  28364. */
  28365. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28366. /**
  28367. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28368. * 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)
  28369. * @param channel Name of the sampler variable.
  28370. * @param postProcess Post process to get the output texture from.
  28371. */
  28372. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28373. /** @hidden */
  28374. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28375. /** @hidden */
  28376. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28377. /** @hidden */
  28378. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28379. /** @hidden */
  28380. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28381. /**
  28382. * Binds a buffer to a uniform.
  28383. * @param buffer Buffer to bind.
  28384. * @param name Name of the uniform variable to bind to.
  28385. */
  28386. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28387. /**
  28388. * Binds block to a uniform.
  28389. * @param blockName Name of the block to bind.
  28390. * @param index Index to bind.
  28391. */
  28392. bindUniformBlock(blockName: string, index: number): void;
  28393. /**
  28394. * Sets an interger value on a uniform variable.
  28395. * @param uniformName Name of the variable.
  28396. * @param value Value to be set.
  28397. * @returns this effect.
  28398. */
  28399. setInt(uniformName: string, value: number): Effect;
  28400. /**
  28401. * Sets an int array on a uniform variable.
  28402. * @param uniformName Name of the variable.
  28403. * @param array array to be set.
  28404. * @returns this effect.
  28405. */
  28406. setIntArray(uniformName: string, array: Int32Array): Effect;
  28407. /**
  28408. * 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)
  28409. * @param uniformName Name of the variable.
  28410. * @param array array to be set.
  28411. * @returns this effect.
  28412. */
  28413. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28414. /**
  28415. * 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)
  28416. * @param uniformName Name of the variable.
  28417. * @param array array to be set.
  28418. * @returns this effect.
  28419. */
  28420. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28421. /**
  28422. * 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)
  28423. * @param uniformName Name of the variable.
  28424. * @param array array to be set.
  28425. * @returns this effect.
  28426. */
  28427. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28428. /**
  28429. * Sets an float array on a uniform variable.
  28430. * @param uniformName Name of the variable.
  28431. * @param array array to be set.
  28432. * @returns this effect.
  28433. */
  28434. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28435. /**
  28436. * 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)
  28437. * @param uniformName Name of the variable.
  28438. * @param array array to be set.
  28439. * @returns this effect.
  28440. */
  28441. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28442. /**
  28443. * 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)
  28444. * @param uniformName Name of the variable.
  28445. * @param array array to be set.
  28446. * @returns this effect.
  28447. */
  28448. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28449. /**
  28450. * 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)
  28451. * @param uniformName Name of the variable.
  28452. * @param array array to be set.
  28453. * @returns this effect.
  28454. */
  28455. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28456. /**
  28457. * Sets an array on a uniform variable.
  28458. * @param uniformName Name of the variable.
  28459. * @param array array to be set.
  28460. * @returns this effect.
  28461. */
  28462. setArray(uniformName: string, array: number[]): Effect;
  28463. /**
  28464. * 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)
  28465. * @param uniformName Name of the variable.
  28466. * @param array array to be set.
  28467. * @returns this effect.
  28468. */
  28469. setArray2(uniformName: string, array: number[]): Effect;
  28470. /**
  28471. * 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)
  28472. * @param uniformName Name of the variable.
  28473. * @param array array to be set.
  28474. * @returns this effect.
  28475. */
  28476. setArray3(uniformName: string, array: number[]): Effect;
  28477. /**
  28478. * 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)
  28479. * @param uniformName Name of the variable.
  28480. * @param array array to be set.
  28481. * @returns this effect.
  28482. */
  28483. setArray4(uniformName: string, array: number[]): Effect;
  28484. /**
  28485. * Sets matrices on a uniform variable.
  28486. * @param uniformName Name of the variable.
  28487. * @param matrices matrices to be set.
  28488. * @returns this effect.
  28489. */
  28490. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28491. /**
  28492. * Sets matrix on a uniform variable.
  28493. * @param uniformName Name of the variable.
  28494. * @param matrix matrix to be set.
  28495. * @returns this effect.
  28496. */
  28497. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28498. /**
  28499. * 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)
  28500. * @param uniformName Name of the variable.
  28501. * @param matrix matrix to be set.
  28502. * @returns this effect.
  28503. */
  28504. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28505. /**
  28506. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28507. * @param uniformName Name of the variable.
  28508. * @param matrix matrix to be set.
  28509. * @returns this effect.
  28510. */
  28511. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28512. /**
  28513. * Sets a float on a uniform variable.
  28514. * @param uniformName Name of the variable.
  28515. * @param value value to be set.
  28516. * @returns this effect.
  28517. */
  28518. setFloat(uniformName: string, value: number): Effect;
  28519. /**
  28520. * Sets a boolean on a uniform variable.
  28521. * @param uniformName Name of the variable.
  28522. * @param bool value to be set.
  28523. * @returns this effect.
  28524. */
  28525. setBool(uniformName: string, bool: boolean): Effect;
  28526. /**
  28527. * Sets a Vector2 on a uniform variable.
  28528. * @param uniformName Name of the variable.
  28529. * @param vector2 vector2 to be set.
  28530. * @returns this effect.
  28531. */
  28532. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28533. /**
  28534. * Sets a float2 on a uniform variable.
  28535. * @param uniformName Name of the variable.
  28536. * @param x First float in float2.
  28537. * @param y Second float in float2.
  28538. * @returns this effect.
  28539. */
  28540. setFloat2(uniformName: string, x: number, y: number): Effect;
  28541. /**
  28542. * Sets a Vector3 on a uniform variable.
  28543. * @param uniformName Name of the variable.
  28544. * @param vector3 Value to be set.
  28545. * @returns this effect.
  28546. */
  28547. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28548. /**
  28549. * Sets a float3 on a uniform variable.
  28550. * @param uniformName Name of the variable.
  28551. * @param x First float in float3.
  28552. * @param y Second float in float3.
  28553. * @param z Third float in float3.
  28554. * @returns this effect.
  28555. */
  28556. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28557. /**
  28558. * Sets a Vector4 on a uniform variable.
  28559. * @param uniformName Name of the variable.
  28560. * @param vector4 Value to be set.
  28561. * @returns this effect.
  28562. */
  28563. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28564. /**
  28565. * Sets a float4 on a uniform variable.
  28566. * @param uniformName Name of the variable.
  28567. * @param x First float in float4.
  28568. * @param y Second float in float4.
  28569. * @param z Third float in float4.
  28570. * @param w Fourth float in float4.
  28571. * @returns this effect.
  28572. */
  28573. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28574. /**
  28575. * Sets a Color3 on a uniform variable.
  28576. * @param uniformName Name of the variable.
  28577. * @param color3 Value to be set.
  28578. * @returns this effect.
  28579. */
  28580. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28581. /**
  28582. * Sets a Color4 on a uniform variable.
  28583. * @param uniformName Name of the variable.
  28584. * @param color3 Value to be set.
  28585. * @param alpha Alpha value to be set.
  28586. * @returns this effect.
  28587. */
  28588. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28589. /**
  28590. * Sets a Color4 on a uniform variable
  28591. * @param uniformName defines the name of the variable
  28592. * @param color4 defines the value to be set
  28593. * @returns this effect.
  28594. */
  28595. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28596. /** Release all associated resources */
  28597. dispose(): void;
  28598. /**
  28599. * This function will add a new shader to the shader store
  28600. * @param name the name of the shader
  28601. * @param pixelShader optional pixel shader content
  28602. * @param vertexShader optional vertex shader content
  28603. */
  28604. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28605. /**
  28606. * Store of each shader (The can be looked up using effect.key)
  28607. */
  28608. static ShadersStore: {
  28609. [key: string]: string;
  28610. };
  28611. /**
  28612. * Store of each included file for a shader (The can be looked up using effect.key)
  28613. */
  28614. static IncludesShadersStore: {
  28615. [key: string]: string;
  28616. };
  28617. /**
  28618. * Resets the cache of effects.
  28619. */
  28620. static ResetCache(): void;
  28621. }
  28622. }
  28623. declare module BABYLON {
  28624. /**
  28625. * Uniform buffer objects.
  28626. *
  28627. * Handles blocks of uniform on the GPU.
  28628. *
  28629. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28630. *
  28631. * For more information, please refer to :
  28632. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28633. */
  28634. export class UniformBuffer {
  28635. private _engine;
  28636. private _buffer;
  28637. private _data;
  28638. private _bufferData;
  28639. private _dynamic?;
  28640. private _uniformLocations;
  28641. private _uniformSizes;
  28642. private _uniformLocationPointer;
  28643. private _needSync;
  28644. private _noUBO;
  28645. private _currentEffect;
  28646. private static _MAX_UNIFORM_SIZE;
  28647. private static _tempBuffer;
  28648. /**
  28649. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28650. * This is dynamic to allow compat with webgl 1 and 2.
  28651. * You will need to pass the name of the uniform as well as the value.
  28652. */
  28653. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28654. /**
  28655. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28656. * This is dynamic to allow compat with webgl 1 and 2.
  28657. * You will need to pass the name of the uniform as well as the value.
  28658. */
  28659. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28660. /**
  28661. * Lambda to Update a single float in a uniform buffer.
  28662. * This is dynamic to allow compat with webgl 1 and 2.
  28663. * You will need to pass the name of the uniform as well as the value.
  28664. */
  28665. updateFloat: (name: string, x: number) => void;
  28666. /**
  28667. * Lambda to Update a vec2 of float in a uniform buffer.
  28668. * This is dynamic to allow compat with webgl 1 and 2.
  28669. * You will need to pass the name of the uniform as well as the value.
  28670. */
  28671. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28672. /**
  28673. * Lambda to Update a vec3 of float in a uniform buffer.
  28674. * This is dynamic to allow compat with webgl 1 and 2.
  28675. * You will need to pass the name of the uniform as well as the value.
  28676. */
  28677. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28678. /**
  28679. * Lambda to Update a vec4 of float in a uniform buffer.
  28680. * This is dynamic to allow compat with webgl 1 and 2.
  28681. * You will need to pass the name of the uniform as well as the value.
  28682. */
  28683. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28684. /**
  28685. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28686. * This is dynamic to allow compat with webgl 1 and 2.
  28687. * You will need to pass the name of the uniform as well as the value.
  28688. */
  28689. updateMatrix: (name: string, mat: Matrix) => void;
  28690. /**
  28691. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28692. * This is dynamic to allow compat with webgl 1 and 2.
  28693. * You will need to pass the name of the uniform as well as the value.
  28694. */
  28695. updateVector3: (name: string, vector: Vector3) => void;
  28696. /**
  28697. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28698. * This is dynamic to allow compat with webgl 1 and 2.
  28699. * You will need to pass the name of the uniform as well as the value.
  28700. */
  28701. updateVector4: (name: string, vector: Vector4) => void;
  28702. /**
  28703. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28704. * This is dynamic to allow compat with webgl 1 and 2.
  28705. * You will need to pass the name of the uniform as well as the value.
  28706. */
  28707. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28708. /**
  28709. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28710. * This is dynamic to allow compat with webgl 1 and 2.
  28711. * You will need to pass the name of the uniform as well as the value.
  28712. */
  28713. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28714. /**
  28715. * Instantiates a new Uniform buffer objects.
  28716. *
  28717. * Handles blocks of uniform on the GPU.
  28718. *
  28719. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28720. *
  28721. * For more information, please refer to :
  28722. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28723. * @param engine Define the engine the buffer is associated with
  28724. * @param data Define the data contained in the buffer
  28725. * @param dynamic Define if the buffer is updatable
  28726. */
  28727. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28728. /**
  28729. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28730. * or just falling back on setUniformXXX calls.
  28731. */
  28732. readonly useUbo: boolean;
  28733. /**
  28734. * Indicates if the WebGL underlying uniform buffer is in sync
  28735. * with the javascript cache data.
  28736. */
  28737. readonly isSync: boolean;
  28738. /**
  28739. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28740. * Also, a dynamic UniformBuffer will disable cache verification and always
  28741. * update the underlying WebGL uniform buffer to the GPU.
  28742. * @returns if Dynamic, otherwise false
  28743. */
  28744. isDynamic(): boolean;
  28745. /**
  28746. * The data cache on JS side.
  28747. * @returns the underlying data as a float array
  28748. */
  28749. getData(): Float32Array;
  28750. /**
  28751. * The underlying WebGL Uniform buffer.
  28752. * @returns the webgl buffer
  28753. */
  28754. getBuffer(): Nullable<DataBuffer>;
  28755. /**
  28756. * std140 layout specifies how to align data within an UBO structure.
  28757. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28758. * for specs.
  28759. */
  28760. private _fillAlignment;
  28761. /**
  28762. * Adds an uniform in the buffer.
  28763. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28764. * for the layout to be correct !
  28765. * @param name Name of the uniform, as used in the uniform block in the shader.
  28766. * @param size Data size, or data directly.
  28767. */
  28768. addUniform(name: string, size: number | number[]): void;
  28769. /**
  28770. * Adds a Matrix 4x4 to the uniform buffer.
  28771. * @param name Name of the uniform, as used in the uniform block in the shader.
  28772. * @param mat A 4x4 matrix.
  28773. */
  28774. addMatrix(name: string, mat: Matrix): void;
  28775. /**
  28776. * Adds a vec2 to the uniform buffer.
  28777. * @param name Name of the uniform, as used in the uniform block in the shader.
  28778. * @param x Define the x component value of the vec2
  28779. * @param y Define the y component value of the vec2
  28780. */
  28781. addFloat2(name: string, x: number, y: number): void;
  28782. /**
  28783. * Adds a vec3 to the uniform buffer.
  28784. * @param name Name of the uniform, as used in the uniform block in the shader.
  28785. * @param x Define the x component value of the vec3
  28786. * @param y Define the y component value of the vec3
  28787. * @param z Define the z component value of the vec3
  28788. */
  28789. addFloat3(name: string, x: number, y: number, z: number): void;
  28790. /**
  28791. * Adds a vec3 to the uniform buffer.
  28792. * @param name Name of the uniform, as used in the uniform block in the shader.
  28793. * @param color Define the vec3 from a Color
  28794. */
  28795. addColor3(name: string, color: Color3): void;
  28796. /**
  28797. * Adds a vec4 to the uniform buffer.
  28798. * @param name Name of the uniform, as used in the uniform block in the shader.
  28799. * @param color Define the rgb components from a Color
  28800. * @param alpha Define the a component of the vec4
  28801. */
  28802. addColor4(name: string, color: Color3, alpha: number): void;
  28803. /**
  28804. * Adds a vec3 to the uniform buffer.
  28805. * @param name Name of the uniform, as used in the uniform block in the shader.
  28806. * @param vector Define the vec3 components from a Vector
  28807. */
  28808. addVector3(name: string, vector: Vector3): void;
  28809. /**
  28810. * Adds a Matrix 3x3 to the uniform buffer.
  28811. * @param name Name of the uniform, as used in the uniform block in the shader.
  28812. */
  28813. addMatrix3x3(name: string): void;
  28814. /**
  28815. * Adds a Matrix 2x2 to the uniform buffer.
  28816. * @param name Name of the uniform, as used in the uniform block in the shader.
  28817. */
  28818. addMatrix2x2(name: string): void;
  28819. /**
  28820. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28821. */
  28822. create(): void;
  28823. /** @hidden */
  28824. _rebuild(): void;
  28825. /**
  28826. * Updates the WebGL Uniform Buffer on the GPU.
  28827. * If the `dynamic` flag is set to true, no cache comparison is done.
  28828. * Otherwise, the buffer will be updated only if the cache differs.
  28829. */
  28830. update(): void;
  28831. /**
  28832. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28833. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28834. * @param data Define the flattened data
  28835. * @param size Define the size of the data.
  28836. */
  28837. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28838. private _updateMatrix3x3ForUniform;
  28839. private _updateMatrix3x3ForEffect;
  28840. private _updateMatrix2x2ForEffect;
  28841. private _updateMatrix2x2ForUniform;
  28842. private _updateFloatForEffect;
  28843. private _updateFloatForUniform;
  28844. private _updateFloat2ForEffect;
  28845. private _updateFloat2ForUniform;
  28846. private _updateFloat3ForEffect;
  28847. private _updateFloat3ForUniform;
  28848. private _updateFloat4ForEffect;
  28849. private _updateFloat4ForUniform;
  28850. private _updateMatrixForEffect;
  28851. private _updateMatrixForUniform;
  28852. private _updateVector3ForEffect;
  28853. private _updateVector3ForUniform;
  28854. private _updateVector4ForEffect;
  28855. private _updateVector4ForUniform;
  28856. private _updateColor3ForEffect;
  28857. private _updateColor3ForUniform;
  28858. private _updateColor4ForEffect;
  28859. private _updateColor4ForUniform;
  28860. /**
  28861. * Sets a sampler uniform on the effect.
  28862. * @param name Define the name of the sampler.
  28863. * @param texture Define the texture to set in the sampler
  28864. */
  28865. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28866. /**
  28867. * Directly updates the value of the uniform in the cache AND on the GPU.
  28868. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28869. * @param data Define the flattened data
  28870. */
  28871. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28872. /**
  28873. * Binds this uniform buffer to an effect.
  28874. * @param effect Define the effect to bind the buffer to
  28875. * @param name Name of the uniform block in the shader.
  28876. */
  28877. bindToEffect(effect: Effect, name: string): void;
  28878. /**
  28879. * Disposes the uniform buffer.
  28880. */
  28881. dispose(): void;
  28882. }
  28883. }
  28884. declare module BABYLON {
  28885. /**
  28886. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28888. */
  28889. export class Analyser {
  28890. /**
  28891. * Gets or sets the smoothing
  28892. * @ignorenaming
  28893. */
  28894. SMOOTHING: number;
  28895. /**
  28896. * Gets or sets the FFT table size
  28897. * @ignorenaming
  28898. */
  28899. FFT_SIZE: number;
  28900. /**
  28901. * Gets or sets the bar graph amplitude
  28902. * @ignorenaming
  28903. */
  28904. BARGRAPHAMPLITUDE: number;
  28905. /**
  28906. * Gets or sets the position of the debug canvas
  28907. * @ignorenaming
  28908. */
  28909. DEBUGCANVASPOS: {
  28910. x: number;
  28911. y: number;
  28912. };
  28913. /**
  28914. * Gets or sets the debug canvas size
  28915. * @ignorenaming
  28916. */
  28917. DEBUGCANVASSIZE: {
  28918. width: number;
  28919. height: number;
  28920. };
  28921. private _byteFreqs;
  28922. private _byteTime;
  28923. private _floatFreqs;
  28924. private _webAudioAnalyser;
  28925. private _debugCanvas;
  28926. private _debugCanvasContext;
  28927. private _scene;
  28928. private _registerFunc;
  28929. private _audioEngine;
  28930. /**
  28931. * Creates a new analyser
  28932. * @param scene defines hosting scene
  28933. */
  28934. constructor(scene: Scene);
  28935. /**
  28936. * Get the number of data values you will have to play with for the visualization
  28937. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28938. * @returns a number
  28939. */
  28940. getFrequencyBinCount(): number;
  28941. /**
  28942. * Gets the current frequency data as a byte array
  28943. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28944. * @returns a Uint8Array
  28945. */
  28946. getByteFrequencyData(): Uint8Array;
  28947. /**
  28948. * Gets the current waveform as a byte array
  28949. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28950. * @returns a Uint8Array
  28951. */
  28952. getByteTimeDomainData(): Uint8Array;
  28953. /**
  28954. * Gets the current frequency data as a float array
  28955. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28956. * @returns a Float32Array
  28957. */
  28958. getFloatFrequencyData(): Float32Array;
  28959. /**
  28960. * Renders the debug canvas
  28961. */
  28962. drawDebugCanvas(): void;
  28963. /**
  28964. * Stops rendering the debug canvas and removes it
  28965. */
  28966. stopDebugCanvas(): void;
  28967. /**
  28968. * Connects two audio nodes
  28969. * @param inputAudioNode defines first node to connect
  28970. * @param outputAudioNode defines second node to connect
  28971. */
  28972. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28973. /**
  28974. * Releases all associated resources
  28975. */
  28976. dispose(): void;
  28977. }
  28978. }
  28979. declare module BABYLON {
  28980. /**
  28981. * This represents an audio engine and it is responsible
  28982. * to play, synchronize and analyse sounds throughout the application.
  28983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28984. */
  28985. export interface IAudioEngine extends IDisposable {
  28986. /**
  28987. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28988. */
  28989. readonly canUseWebAudio: boolean;
  28990. /**
  28991. * Gets the current AudioContext if available.
  28992. */
  28993. readonly audioContext: Nullable<AudioContext>;
  28994. /**
  28995. * The master gain node defines the global audio volume of your audio engine.
  28996. */
  28997. readonly masterGain: GainNode;
  28998. /**
  28999. * Gets whether or not mp3 are supported by your browser.
  29000. */
  29001. readonly isMP3supported: boolean;
  29002. /**
  29003. * Gets whether or not ogg are supported by your browser.
  29004. */
  29005. readonly isOGGsupported: boolean;
  29006. /**
  29007. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29008. * @ignoreNaming
  29009. */
  29010. WarnedWebAudioUnsupported: boolean;
  29011. /**
  29012. * Defines if the audio engine relies on a custom unlocked button.
  29013. * In this case, the embedded button will not be displayed.
  29014. */
  29015. useCustomUnlockedButton: boolean;
  29016. /**
  29017. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29018. */
  29019. readonly unlocked: boolean;
  29020. /**
  29021. * Event raised when audio has been unlocked on the browser.
  29022. */
  29023. onAudioUnlockedObservable: Observable<AudioEngine>;
  29024. /**
  29025. * Event raised when audio has been locked on the browser.
  29026. */
  29027. onAudioLockedObservable: Observable<AudioEngine>;
  29028. /**
  29029. * Flags the audio engine in Locked state.
  29030. * This happens due to new browser policies preventing audio to autoplay.
  29031. */
  29032. lock(): void;
  29033. /**
  29034. * Unlocks the audio engine once a user action has been done on the dom.
  29035. * This is helpful to resume play once browser policies have been satisfied.
  29036. */
  29037. unlock(): void;
  29038. }
  29039. /**
  29040. * This represents the default audio engine used in babylon.
  29041. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29043. */
  29044. export class AudioEngine implements IAudioEngine {
  29045. private _audioContext;
  29046. private _audioContextInitialized;
  29047. private _muteButton;
  29048. private _hostElement;
  29049. /**
  29050. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29051. */
  29052. canUseWebAudio: boolean;
  29053. /**
  29054. * The master gain node defines the global audio volume of your audio engine.
  29055. */
  29056. masterGain: GainNode;
  29057. /**
  29058. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29059. * @ignoreNaming
  29060. */
  29061. WarnedWebAudioUnsupported: boolean;
  29062. /**
  29063. * Gets whether or not mp3 are supported by your browser.
  29064. */
  29065. isMP3supported: boolean;
  29066. /**
  29067. * Gets whether or not ogg are supported by your browser.
  29068. */
  29069. isOGGsupported: boolean;
  29070. /**
  29071. * Gets whether audio has been unlocked on the device.
  29072. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29073. * a user interaction has happened.
  29074. */
  29075. unlocked: boolean;
  29076. /**
  29077. * Defines if the audio engine relies on a custom unlocked button.
  29078. * In this case, the embedded button will not be displayed.
  29079. */
  29080. useCustomUnlockedButton: boolean;
  29081. /**
  29082. * Event raised when audio has been unlocked on the browser.
  29083. */
  29084. onAudioUnlockedObservable: Observable<AudioEngine>;
  29085. /**
  29086. * Event raised when audio has been locked on the browser.
  29087. */
  29088. onAudioLockedObservable: Observable<AudioEngine>;
  29089. /**
  29090. * Gets the current AudioContext if available.
  29091. */
  29092. readonly audioContext: Nullable<AudioContext>;
  29093. private _connectedAnalyser;
  29094. /**
  29095. * Instantiates a new audio engine.
  29096. *
  29097. * There should be only one per page as some browsers restrict the number
  29098. * of audio contexts you can create.
  29099. * @param hostElement defines the host element where to display the mute icon if necessary
  29100. */
  29101. constructor(hostElement?: Nullable<HTMLElement>);
  29102. /**
  29103. * Flags the audio engine in Locked state.
  29104. * This happens due to new browser policies preventing audio to autoplay.
  29105. */
  29106. lock(): void;
  29107. /**
  29108. * Unlocks the audio engine once a user action has been done on the dom.
  29109. * This is helpful to resume play once browser policies have been satisfied.
  29110. */
  29111. unlock(): void;
  29112. private _resumeAudioContext;
  29113. private _initializeAudioContext;
  29114. private _tryToRun;
  29115. private _triggerRunningState;
  29116. private _triggerSuspendedState;
  29117. private _displayMuteButton;
  29118. private _moveButtonToTopLeft;
  29119. private _onResize;
  29120. private _hideMuteButton;
  29121. /**
  29122. * Destroy and release the resources associated with the audio ccontext.
  29123. */
  29124. dispose(): void;
  29125. /**
  29126. * Gets the global volume sets on the master gain.
  29127. * @returns the global volume if set or -1 otherwise
  29128. */
  29129. getGlobalVolume(): number;
  29130. /**
  29131. * Sets the global volume of your experience (sets on the master gain).
  29132. * @param newVolume Defines the new global volume of the application
  29133. */
  29134. setGlobalVolume(newVolume: number): void;
  29135. /**
  29136. * Connect the audio engine to an audio analyser allowing some amazing
  29137. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29139. * @param analyser The analyser to connect to the engine
  29140. */
  29141. connectToAnalyser(analyser: Analyser): void;
  29142. }
  29143. }
  29144. declare module BABYLON {
  29145. /**
  29146. * Interface used to present a loading screen while loading a scene
  29147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29148. */
  29149. export interface ILoadingScreen {
  29150. /**
  29151. * Function called to display the loading screen
  29152. */
  29153. displayLoadingUI: () => void;
  29154. /**
  29155. * Function called to hide the loading screen
  29156. */
  29157. hideLoadingUI: () => void;
  29158. /**
  29159. * Gets or sets the color to use for the background
  29160. */
  29161. loadingUIBackgroundColor: string;
  29162. /**
  29163. * Gets or sets the text to display while loading
  29164. */
  29165. loadingUIText: string;
  29166. }
  29167. /**
  29168. * Class used for the default loading screen
  29169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29170. */
  29171. export class DefaultLoadingScreen implements ILoadingScreen {
  29172. private _renderingCanvas;
  29173. private _loadingText;
  29174. private _loadingDivBackgroundColor;
  29175. private _loadingDiv;
  29176. private _loadingTextDiv;
  29177. /** Gets or sets the logo url to use for the default loading screen */
  29178. static DefaultLogoUrl: string;
  29179. /** Gets or sets the spinner url to use for the default loading screen */
  29180. static DefaultSpinnerUrl: string;
  29181. /**
  29182. * Creates a new default loading screen
  29183. * @param _renderingCanvas defines the canvas used to render the scene
  29184. * @param _loadingText defines the default text to display
  29185. * @param _loadingDivBackgroundColor defines the default background color
  29186. */
  29187. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29188. /**
  29189. * Function called to display the loading screen
  29190. */
  29191. displayLoadingUI(): void;
  29192. /**
  29193. * Function called to hide the loading screen
  29194. */
  29195. hideLoadingUI(): void;
  29196. /**
  29197. * Gets or sets the text to display while loading
  29198. */
  29199. loadingUIText: string;
  29200. /**
  29201. * Gets or sets the color to use for the background
  29202. */
  29203. loadingUIBackgroundColor: string;
  29204. private _resizeLoadingUI;
  29205. }
  29206. }
  29207. declare module BABYLON {
  29208. /** @hidden */
  29209. export class WebGLPipelineContext implements IPipelineContext {
  29210. engine: Engine;
  29211. program: Nullable<WebGLProgram>;
  29212. context?: WebGLRenderingContext;
  29213. vertexShader?: WebGLShader;
  29214. fragmentShader?: WebGLShader;
  29215. isParallelCompiled: boolean;
  29216. onCompiled?: () => void;
  29217. transformFeedback?: WebGLTransformFeedback | null;
  29218. readonly isAsync: boolean;
  29219. readonly isReady: boolean;
  29220. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29221. }
  29222. }
  29223. declare module BABYLON {
  29224. /** @hidden */
  29225. export class WebGLDataBuffer extends DataBuffer {
  29226. private _buffer;
  29227. constructor(resource: WebGLBuffer);
  29228. readonly underlyingResource: any;
  29229. }
  29230. }
  29231. declare module BABYLON {
  29232. /** @hidden */
  29233. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29234. attributeProcessor(attribute: string): string;
  29235. varyingProcessor(varying: string, isFragment: boolean): string;
  29236. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29237. }
  29238. }
  29239. declare module BABYLON {
  29240. /**
  29241. * This class is used to track a performance counter which is number based.
  29242. * The user has access to many properties which give statistics of different nature.
  29243. *
  29244. * The implementer can track two kinds of Performance Counter: time and count.
  29245. * 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.
  29246. * 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.
  29247. */
  29248. export class PerfCounter {
  29249. /**
  29250. * Gets or sets a global boolean to turn on and off all the counters
  29251. */
  29252. static Enabled: boolean;
  29253. /**
  29254. * Returns the smallest value ever
  29255. */
  29256. readonly min: number;
  29257. /**
  29258. * Returns the biggest value ever
  29259. */
  29260. readonly max: number;
  29261. /**
  29262. * Returns the average value since the performance counter is running
  29263. */
  29264. readonly average: number;
  29265. /**
  29266. * Returns the average value of the last second the counter was monitored
  29267. */
  29268. readonly lastSecAverage: number;
  29269. /**
  29270. * Returns the current value
  29271. */
  29272. readonly current: number;
  29273. /**
  29274. * Gets the accumulated total
  29275. */
  29276. readonly total: number;
  29277. /**
  29278. * Gets the total value count
  29279. */
  29280. readonly count: number;
  29281. /**
  29282. * Creates a new counter
  29283. */
  29284. constructor();
  29285. /**
  29286. * Call this method to start monitoring a new frame.
  29287. * 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.
  29288. */
  29289. fetchNewFrame(): void;
  29290. /**
  29291. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29292. * @param newCount the count value to add to the monitored count
  29293. * @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.
  29294. */
  29295. addCount(newCount: number, fetchResult: boolean): void;
  29296. /**
  29297. * Start monitoring this performance counter
  29298. */
  29299. beginMonitoring(): void;
  29300. /**
  29301. * Compute the time lapsed since the previous beginMonitoring() call.
  29302. * @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
  29303. */
  29304. endMonitoring(newFrame?: boolean): void;
  29305. private _fetchResult;
  29306. private _startMonitoringTime;
  29307. private _min;
  29308. private _max;
  29309. private _average;
  29310. private _current;
  29311. private _totalValueCount;
  29312. private _totalAccumulated;
  29313. private _lastSecAverage;
  29314. private _lastSecAccumulated;
  29315. private _lastSecTime;
  29316. private _lastSecValueCount;
  29317. }
  29318. }
  29319. declare module BABYLON {
  29320. /**
  29321. * Interface for any object that can request an animation frame
  29322. */
  29323. export interface ICustomAnimationFrameRequester {
  29324. /**
  29325. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29326. */
  29327. renderFunction?: Function;
  29328. /**
  29329. * Called to request the next frame to render to
  29330. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29331. */
  29332. requestAnimationFrame: Function;
  29333. /**
  29334. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29335. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29336. */
  29337. requestID?: number;
  29338. }
  29339. }
  29340. declare module BABYLON {
  29341. /**
  29342. * Settings for finer control over video usage
  29343. */
  29344. export interface VideoTextureSettings {
  29345. /**
  29346. * Applies `autoplay` to video, if specified
  29347. */
  29348. autoPlay?: boolean;
  29349. /**
  29350. * Applies `loop` to video, if specified
  29351. */
  29352. loop?: boolean;
  29353. /**
  29354. * Automatically updates internal texture from video at every frame in the render loop
  29355. */
  29356. autoUpdateTexture: boolean;
  29357. /**
  29358. * Image src displayed during the video loading or until the user interacts with the video.
  29359. */
  29360. poster?: string;
  29361. }
  29362. /**
  29363. * If you want to display a video in your scene, this is the special texture for that.
  29364. * This special texture works similar to other textures, with the exception of a few parameters.
  29365. * @see https://doc.babylonjs.com/how_to/video_texture
  29366. */
  29367. export class VideoTexture extends Texture {
  29368. /**
  29369. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29370. */
  29371. readonly autoUpdateTexture: boolean;
  29372. /**
  29373. * The video instance used by the texture internally
  29374. */
  29375. readonly video: HTMLVideoElement;
  29376. private _onUserActionRequestedObservable;
  29377. /**
  29378. * Event triggerd when a dom action is required by the user to play the video.
  29379. * This happens due to recent changes in browser policies preventing video to auto start.
  29380. */
  29381. readonly onUserActionRequestedObservable: Observable<Texture>;
  29382. private _generateMipMaps;
  29383. private _engine;
  29384. private _stillImageCaptured;
  29385. private _displayingPosterTexture;
  29386. private _settings;
  29387. private _createInternalTextureOnEvent;
  29388. /**
  29389. * Creates a video texture.
  29390. * If you want to display a video in your scene, this is the special texture for that.
  29391. * This special texture works similar to other textures, with the exception of a few parameters.
  29392. * @see https://doc.babylonjs.com/how_to/video_texture
  29393. * @param name optional name, will detect from video source, if not defined
  29394. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29395. * @param scene is obviously the current scene.
  29396. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29397. * @param invertY is false by default but can be used to invert video on Y axis
  29398. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29399. * @param settings allows finer control over video usage
  29400. */
  29401. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29402. private _getName;
  29403. private _getVideo;
  29404. private _createInternalTexture;
  29405. private reset;
  29406. /**
  29407. * @hidden Internal method to initiate `update`.
  29408. */
  29409. _rebuild(): void;
  29410. /**
  29411. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29412. */
  29413. update(): void;
  29414. /**
  29415. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29416. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29417. */
  29418. updateTexture(isVisible: boolean): void;
  29419. protected _updateInternalTexture: () => void;
  29420. /**
  29421. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29422. * @param url New url.
  29423. */
  29424. updateURL(url: string): void;
  29425. /**
  29426. * Dispose the texture and release its associated resources.
  29427. */
  29428. dispose(): void;
  29429. /**
  29430. * Creates a video texture straight from a stream.
  29431. * @param scene Define the scene the texture should be created in
  29432. * @param stream Define the stream the texture should be created from
  29433. * @returns The created video texture as a promise
  29434. */
  29435. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29436. /**
  29437. * Creates a video texture straight from your WebCam video feed.
  29438. * @param scene Define the scene the texture should be created in
  29439. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29440. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29441. * @returns The created video texture as a promise
  29442. */
  29443. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29444. minWidth: number;
  29445. maxWidth: number;
  29446. minHeight: number;
  29447. maxHeight: number;
  29448. deviceId: string;
  29449. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29450. /**
  29451. * Creates a video texture straight from your WebCam video feed.
  29452. * @param scene Define the scene the texture should be created in
  29453. * @param onReady Define a callback to triggered once the texture will be ready
  29454. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29455. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29456. */
  29457. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29458. minWidth: number;
  29459. maxWidth: number;
  29460. minHeight: number;
  29461. maxHeight: number;
  29462. deviceId: string;
  29463. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29464. }
  29465. }
  29466. declare module BABYLON {
  29467. /**
  29468. * Defines the interface used by objects containing a viewport (like a camera)
  29469. */
  29470. interface IViewportOwnerLike {
  29471. /**
  29472. * Gets or sets the viewport
  29473. */
  29474. viewport: IViewportLike;
  29475. }
  29476. /**
  29477. * Interface for attribute information associated with buffer instanciation
  29478. */
  29479. export class InstancingAttributeInfo {
  29480. /**
  29481. * Index/offset of the attribute in the vertex shader
  29482. */
  29483. index: number;
  29484. /**
  29485. * size of the attribute, 1, 2, 3 or 4
  29486. */
  29487. attributeSize: number;
  29488. /**
  29489. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29490. * default is FLOAT
  29491. */
  29492. attribyteType: number;
  29493. /**
  29494. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29495. */
  29496. normalized: boolean;
  29497. /**
  29498. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29499. */
  29500. offset: number;
  29501. /**
  29502. * Name of the GLSL attribute, for debugging purpose only
  29503. */
  29504. attributeName: string;
  29505. }
  29506. /**
  29507. * Define options used to create a depth texture
  29508. */
  29509. export class DepthTextureCreationOptions {
  29510. /** Specifies whether or not a stencil should be allocated in the texture */
  29511. generateStencil?: boolean;
  29512. /** Specifies whether or not bilinear filtering is enable on the texture */
  29513. bilinearFiltering?: boolean;
  29514. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29515. comparisonFunction?: number;
  29516. /** Specifies if the created texture is a cube texture */
  29517. isCube?: boolean;
  29518. }
  29519. /**
  29520. * Class used to describe the capabilities of the engine relatively to the current browser
  29521. */
  29522. export class EngineCapabilities {
  29523. /** Maximum textures units per fragment shader */
  29524. maxTexturesImageUnits: number;
  29525. /** Maximum texture units per vertex shader */
  29526. maxVertexTextureImageUnits: number;
  29527. /** Maximum textures units in the entire pipeline */
  29528. maxCombinedTexturesImageUnits: number;
  29529. /** Maximum texture size */
  29530. maxTextureSize: number;
  29531. /** Maximum cube texture size */
  29532. maxCubemapTextureSize: number;
  29533. /** Maximum render texture size */
  29534. maxRenderTextureSize: number;
  29535. /** Maximum number of vertex attributes */
  29536. maxVertexAttribs: number;
  29537. /** Maximum number of varyings */
  29538. maxVaryingVectors: number;
  29539. /** Maximum number of uniforms per vertex shader */
  29540. maxVertexUniformVectors: number;
  29541. /** Maximum number of uniforms per fragment shader */
  29542. maxFragmentUniformVectors: number;
  29543. /** Defines if standard derivates (dx/dy) are supported */
  29544. standardDerivatives: boolean;
  29545. /** Defines if s3tc texture compression is supported */
  29546. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29547. /** Defines if pvrtc texture compression is supported */
  29548. pvrtc: any;
  29549. /** Defines if etc1 texture compression is supported */
  29550. etc1: any;
  29551. /** Defines if etc2 texture compression is supported */
  29552. etc2: any;
  29553. /** Defines if astc texture compression is supported */
  29554. astc: any;
  29555. /** Defines if float textures are supported */
  29556. textureFloat: boolean;
  29557. /** Defines if vertex array objects are supported */
  29558. vertexArrayObject: boolean;
  29559. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29560. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29561. /** Gets the maximum level of anisotropy supported */
  29562. maxAnisotropy: number;
  29563. /** Defines if instancing is supported */
  29564. instancedArrays: boolean;
  29565. /** Defines if 32 bits indices are supported */
  29566. uintIndices: boolean;
  29567. /** Defines if high precision shaders are supported */
  29568. highPrecisionShaderSupported: boolean;
  29569. /** Defines if depth reading in the fragment shader is supported */
  29570. fragmentDepthSupported: boolean;
  29571. /** Defines if float texture linear filtering is supported*/
  29572. textureFloatLinearFiltering: boolean;
  29573. /** Defines if rendering to float textures is supported */
  29574. textureFloatRender: boolean;
  29575. /** Defines if half float textures are supported*/
  29576. textureHalfFloat: boolean;
  29577. /** Defines if half float texture linear filtering is supported*/
  29578. textureHalfFloatLinearFiltering: boolean;
  29579. /** Defines if rendering to half float textures is supported */
  29580. textureHalfFloatRender: boolean;
  29581. /** Defines if textureLOD shader command is supported */
  29582. textureLOD: boolean;
  29583. /** Defines if draw buffers extension is supported */
  29584. drawBuffersExtension: boolean;
  29585. /** Defines if depth textures are supported */
  29586. depthTextureExtension: boolean;
  29587. /** Defines if float color buffer are supported */
  29588. colorBufferFloat: boolean;
  29589. /** Gets disjoint timer query extension (null if not supported) */
  29590. timerQuery: EXT_disjoint_timer_query;
  29591. /** Defines if timestamp can be used with timer query */
  29592. canUseTimestampForTimerQuery: boolean;
  29593. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29594. multiview: any;
  29595. /** Function used to let the system compiles shaders in background */
  29596. parallelShaderCompile: {
  29597. COMPLETION_STATUS_KHR: number;
  29598. };
  29599. }
  29600. /** Interface defining initialization parameters for Engine class */
  29601. export interface EngineOptions extends WebGLContextAttributes {
  29602. /**
  29603. * Defines if the engine should no exceed a specified device ratio
  29604. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29605. */
  29606. limitDeviceRatio?: number;
  29607. /**
  29608. * Defines if webvr should be enabled automatically
  29609. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29610. */
  29611. autoEnableWebVR?: boolean;
  29612. /**
  29613. * Defines if webgl2 should be turned off even if supported
  29614. * @see http://doc.babylonjs.com/features/webgl2
  29615. */
  29616. disableWebGL2Support?: boolean;
  29617. /**
  29618. * Defines if webaudio should be initialized as well
  29619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29620. */
  29621. audioEngine?: boolean;
  29622. /**
  29623. * Defines if animations should run using a deterministic lock step
  29624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29625. */
  29626. deterministicLockstep?: boolean;
  29627. /** Defines the maximum steps to use with deterministic lock step mode */
  29628. lockstepMaxSteps?: number;
  29629. /**
  29630. * Defines that engine should ignore context lost events
  29631. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29632. */
  29633. doNotHandleContextLost?: boolean;
  29634. /**
  29635. * Defines that engine should ignore modifying touch action attribute and style
  29636. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29637. */
  29638. doNotHandleTouchAction?: boolean;
  29639. /**
  29640. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29641. */
  29642. useHighPrecisionFloats?: boolean;
  29643. }
  29644. /**
  29645. * Defines the interface used by display changed events
  29646. */
  29647. export interface IDisplayChangedEventArgs {
  29648. /** Gets the vrDisplay object (if any) */
  29649. vrDisplay: Nullable<any>;
  29650. /** Gets a boolean indicating if webVR is supported */
  29651. vrSupported: boolean;
  29652. }
  29653. /**
  29654. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29655. */
  29656. export class Engine {
  29657. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29658. static ExceptionList: ({
  29659. key: string;
  29660. capture: string;
  29661. captureConstraint: number;
  29662. targets: string[];
  29663. } | {
  29664. key: string;
  29665. capture: null;
  29666. captureConstraint: null;
  29667. targets: string[];
  29668. })[];
  29669. /** Gets the list of created engines */
  29670. static readonly Instances: Engine[];
  29671. /**
  29672. * Gets the latest created engine
  29673. */
  29674. static readonly LastCreatedEngine: Nullable<Engine>;
  29675. /**
  29676. * Gets the latest created scene
  29677. */
  29678. static readonly LastCreatedScene: Nullable<Scene>;
  29679. /**
  29680. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29681. * @param flag defines which part of the materials must be marked as dirty
  29682. * @param predicate defines a predicate used to filter which materials should be affected
  29683. */
  29684. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29685. /** @hidden */
  29686. static _TextureLoaders: IInternalTextureLoader[];
  29687. /** Defines that alpha blending is disabled */
  29688. static readonly ALPHA_DISABLE: number;
  29689. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29690. static readonly ALPHA_ADD: number;
  29691. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29692. static readonly ALPHA_COMBINE: number;
  29693. /** Defines that alpha blending to DEST - SRC * DEST */
  29694. static readonly ALPHA_SUBTRACT: number;
  29695. /** Defines that alpha blending to SRC * DEST */
  29696. static readonly ALPHA_MULTIPLY: number;
  29697. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29698. static readonly ALPHA_MAXIMIZED: number;
  29699. /** Defines that alpha blending to SRC + DEST */
  29700. static readonly ALPHA_ONEONE: number;
  29701. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29702. static readonly ALPHA_PREMULTIPLIED: number;
  29703. /**
  29704. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29705. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29706. */
  29707. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29708. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29709. static readonly ALPHA_INTERPOLATE: number;
  29710. /**
  29711. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29712. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29713. */
  29714. static readonly ALPHA_SCREENMODE: number;
  29715. /** Defines that the ressource is not delayed*/
  29716. static readonly DELAYLOADSTATE_NONE: number;
  29717. /** Defines that the ressource was successfully delay loaded */
  29718. static readonly DELAYLOADSTATE_LOADED: number;
  29719. /** Defines that the ressource is currently delay loading */
  29720. static readonly DELAYLOADSTATE_LOADING: number;
  29721. /** Defines that the ressource is delayed and has not started loading */
  29722. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29724. static readonly NEVER: number;
  29725. /** 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 */
  29726. static readonly ALWAYS: number;
  29727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29728. static readonly LESS: number;
  29729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29730. static readonly EQUAL: number;
  29731. /** 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 */
  29732. static readonly LEQUAL: number;
  29733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29734. static readonly GREATER: number;
  29735. /** 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 */
  29736. static readonly GEQUAL: number;
  29737. /** 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 */
  29738. static readonly NOTEQUAL: number;
  29739. /** Passed to stencilOperation to specify that stencil value must be kept */
  29740. static readonly KEEP: number;
  29741. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29742. static readonly REPLACE: number;
  29743. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29744. static readonly INCR: number;
  29745. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29746. static readonly DECR: number;
  29747. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29748. static readonly INVERT: number;
  29749. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29750. static readonly INCR_WRAP: number;
  29751. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29752. static readonly DECR_WRAP: number;
  29753. /** Texture is not repeating outside of 0..1 UVs */
  29754. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29755. /** Texture is repeating outside of 0..1 UVs */
  29756. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29757. /** Texture is repeating and mirrored */
  29758. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29759. /** ALPHA */
  29760. static readonly TEXTUREFORMAT_ALPHA: number;
  29761. /** LUMINANCE */
  29762. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29763. /** LUMINANCE_ALPHA */
  29764. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29765. /** RGB */
  29766. static readonly TEXTUREFORMAT_RGB: number;
  29767. /** RGBA */
  29768. static readonly TEXTUREFORMAT_RGBA: number;
  29769. /** RED */
  29770. static readonly TEXTUREFORMAT_RED: number;
  29771. /** RED (2nd reference) */
  29772. static readonly TEXTUREFORMAT_R: number;
  29773. /** RG */
  29774. static readonly TEXTUREFORMAT_RG: number;
  29775. /** RED_INTEGER */
  29776. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29777. /** RED_INTEGER (2nd reference) */
  29778. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29779. /** RG_INTEGER */
  29780. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29781. /** RGB_INTEGER */
  29782. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29783. /** RGBA_INTEGER */
  29784. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29785. /** UNSIGNED_BYTE */
  29786. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29787. /** UNSIGNED_BYTE (2nd reference) */
  29788. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29789. /** FLOAT */
  29790. static readonly TEXTURETYPE_FLOAT: number;
  29791. /** HALF_FLOAT */
  29792. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29793. /** BYTE */
  29794. static readonly TEXTURETYPE_BYTE: number;
  29795. /** SHORT */
  29796. static readonly TEXTURETYPE_SHORT: number;
  29797. /** UNSIGNED_SHORT */
  29798. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29799. /** INT */
  29800. static readonly TEXTURETYPE_INT: number;
  29801. /** UNSIGNED_INT */
  29802. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29803. /** UNSIGNED_SHORT_4_4_4_4 */
  29804. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29805. /** UNSIGNED_SHORT_5_5_5_1 */
  29806. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29807. /** UNSIGNED_SHORT_5_6_5 */
  29808. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29809. /** UNSIGNED_INT_2_10_10_10_REV */
  29810. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29811. /** UNSIGNED_INT_24_8 */
  29812. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29813. /** UNSIGNED_INT_10F_11F_11F_REV */
  29814. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29815. /** UNSIGNED_INT_5_9_9_9_REV */
  29816. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29817. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29818. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29819. /** nearest is mag = nearest and min = nearest and mip = linear */
  29820. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29822. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29823. /** Trilinear is mag = linear and min = linear and mip = linear */
  29824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29825. /** nearest is mag = nearest and min = nearest and mip = linear */
  29826. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29827. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29828. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29829. /** Trilinear is mag = linear and min = linear and mip = linear */
  29830. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29831. /** mag = nearest and min = nearest and mip = nearest */
  29832. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29833. /** mag = nearest and min = linear and mip = nearest */
  29834. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29835. /** mag = nearest and min = linear and mip = linear */
  29836. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29837. /** mag = nearest and min = linear and mip = none */
  29838. static readonly TEXTURE_NEAREST_LINEAR: number;
  29839. /** mag = nearest and min = nearest and mip = none */
  29840. static readonly TEXTURE_NEAREST_NEAREST: number;
  29841. /** mag = linear and min = nearest and mip = nearest */
  29842. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29843. /** mag = linear and min = nearest and mip = linear */
  29844. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29845. /** mag = linear and min = linear and mip = none */
  29846. static readonly TEXTURE_LINEAR_LINEAR: number;
  29847. /** mag = linear and min = nearest and mip = none */
  29848. static readonly TEXTURE_LINEAR_NEAREST: number;
  29849. /** Explicit coordinates mode */
  29850. static readonly TEXTURE_EXPLICIT_MODE: number;
  29851. /** Spherical coordinates mode */
  29852. static readonly TEXTURE_SPHERICAL_MODE: number;
  29853. /** Planar coordinates mode */
  29854. static readonly TEXTURE_PLANAR_MODE: number;
  29855. /** Cubic coordinates mode */
  29856. static readonly TEXTURE_CUBIC_MODE: number;
  29857. /** Projection coordinates mode */
  29858. static readonly TEXTURE_PROJECTION_MODE: number;
  29859. /** Skybox coordinates mode */
  29860. static readonly TEXTURE_SKYBOX_MODE: number;
  29861. /** Inverse Cubic coordinates mode */
  29862. static readonly TEXTURE_INVCUBIC_MODE: number;
  29863. /** Equirectangular coordinates mode */
  29864. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29865. /** Equirectangular Fixed coordinates mode */
  29866. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29867. /** Equirectangular Fixed Mirrored coordinates mode */
  29868. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29870. static readonly SCALEMODE_FLOOR: number;
  29871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29872. static readonly SCALEMODE_NEAREST: number;
  29873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29874. static readonly SCALEMODE_CEILING: number;
  29875. /**
  29876. * Returns the current npm package of the sdk
  29877. */
  29878. static readonly NpmPackage: string;
  29879. /**
  29880. * Returns the current version of the framework
  29881. */
  29882. static readonly Version: string;
  29883. /**
  29884. * Returns a string describing the current engine
  29885. */
  29886. readonly description: string;
  29887. /**
  29888. * Gets or sets the epsilon value used by collision engine
  29889. */
  29890. static CollisionsEpsilon: number;
  29891. /**
  29892. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29893. */
  29894. static ShadersRepository: string;
  29895. /**
  29896. * Method called to create the default loading screen.
  29897. * This can be overriden in your own app.
  29898. * @param canvas The rendering canvas element
  29899. * @returns The loading screen
  29900. */
  29901. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29902. /**
  29903. * Method called to create the default rescale post process on each engine.
  29904. */
  29905. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29906. /** @hidden */
  29907. _shaderProcessor: IShaderProcessor;
  29908. /**
  29909. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29910. */
  29911. forcePOTTextures: boolean;
  29912. /**
  29913. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29914. */
  29915. isFullscreen: boolean;
  29916. /**
  29917. * Gets a boolean indicating if the pointer is currently locked
  29918. */
  29919. isPointerLock: boolean;
  29920. /**
  29921. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29922. */
  29923. cullBackFaces: boolean;
  29924. /**
  29925. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29926. */
  29927. renderEvenInBackground: boolean;
  29928. /**
  29929. * Gets or sets a boolean indicating that cache can be kept between frames
  29930. */
  29931. preventCacheWipeBetweenFrames: boolean;
  29932. /**
  29933. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29934. **/
  29935. enableOfflineSupport: boolean;
  29936. /**
  29937. * 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)
  29938. **/
  29939. disableManifestCheck: boolean;
  29940. /**
  29941. * Gets the list of created scenes
  29942. */
  29943. scenes: Scene[];
  29944. /**
  29945. * Event raised when a new scene is created
  29946. */
  29947. onNewSceneAddedObservable: Observable<Scene>;
  29948. /**
  29949. * Gets the list of created postprocesses
  29950. */
  29951. postProcesses: PostProcess[];
  29952. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29953. validateShaderPrograms: boolean;
  29954. /**
  29955. * Observable event triggered each time the rendering canvas is resized
  29956. */
  29957. onResizeObservable: Observable<Engine>;
  29958. /**
  29959. * Observable event triggered each time the canvas loses focus
  29960. */
  29961. onCanvasBlurObservable: Observable<Engine>;
  29962. /**
  29963. * Observable event triggered each time the canvas gains focus
  29964. */
  29965. onCanvasFocusObservable: Observable<Engine>;
  29966. /**
  29967. * Observable event triggered each time the canvas receives pointerout event
  29968. */
  29969. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29970. /**
  29971. * Observable event triggered before each texture is initialized
  29972. */
  29973. onBeforeTextureInitObservable: Observable<Texture>;
  29974. /**
  29975. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29976. */
  29977. disableUniformBuffers: boolean;
  29978. /** @hidden */
  29979. _uniformBuffers: UniformBuffer[];
  29980. /**
  29981. * Gets a boolean indicating that the engine supports uniform buffers
  29982. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29983. */
  29984. readonly supportsUniformBuffers: boolean;
  29985. /**
  29986. * Observable raised when the engine begins a new frame
  29987. */
  29988. onBeginFrameObservable: Observable<Engine>;
  29989. /**
  29990. * If set, will be used to request the next animation frame for the render loop
  29991. */
  29992. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29993. /**
  29994. * Observable raised when the engine ends the current frame
  29995. */
  29996. onEndFrameObservable: Observable<Engine>;
  29997. /**
  29998. * Observable raised when the engine is about to compile a shader
  29999. */
  30000. onBeforeShaderCompilationObservable: Observable<Engine>;
  30001. /**
  30002. * Observable raised when the engine has jsut compiled a shader
  30003. */
  30004. onAfterShaderCompilationObservable: Observable<Engine>;
  30005. /** @hidden */
  30006. _gl: WebGLRenderingContext;
  30007. private _renderingCanvas;
  30008. private _windowIsBackground;
  30009. private _webGLVersion;
  30010. protected _highPrecisionShadersAllowed: boolean;
  30011. /** @hidden */
  30012. readonly _shouldUseHighPrecisionShader: boolean;
  30013. /**
  30014. * Gets a boolean indicating that only power of 2 textures are supported
  30015. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30016. */
  30017. readonly needPOTTextures: boolean;
  30018. /** @hidden */
  30019. _badOS: boolean;
  30020. /** @hidden */
  30021. _badDesktopOS: boolean;
  30022. /**
  30023. * Gets the audio engine
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. * @ignorenaming
  30026. */
  30027. static audioEngine: IAudioEngine;
  30028. /**
  30029. * Default AudioEngine factory responsible of creating the Audio Engine.
  30030. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30031. */
  30032. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30033. /**
  30034. * Default offline support factory responsible of creating a tool used to store data locally.
  30035. * By default, this will create a Database object if the workload has been embedded.
  30036. */
  30037. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30038. private _onFocus;
  30039. private _onBlur;
  30040. private _onCanvasPointerOut;
  30041. private _onCanvasBlur;
  30042. private _onCanvasFocus;
  30043. private _onFullscreenChange;
  30044. private _onPointerLockChange;
  30045. private _hardwareScalingLevel;
  30046. /** @hidden */
  30047. _caps: EngineCapabilities;
  30048. private _pointerLockRequested;
  30049. private _isStencilEnable;
  30050. private _colorWrite;
  30051. private _loadingScreen;
  30052. /** @hidden */
  30053. _drawCalls: PerfCounter;
  30054. private _glVersion;
  30055. private _glRenderer;
  30056. private _glVendor;
  30057. private _videoTextureSupported;
  30058. private _renderingQueueLaunched;
  30059. private _activeRenderLoops;
  30060. private _deterministicLockstep;
  30061. private _lockstepMaxSteps;
  30062. /**
  30063. * Observable signaled when a context lost event is raised
  30064. */
  30065. onContextLostObservable: Observable<Engine>;
  30066. /**
  30067. * Observable signaled when a context restored event is raised
  30068. */
  30069. onContextRestoredObservable: Observable<Engine>;
  30070. private _onContextLost;
  30071. private _onContextRestored;
  30072. private _contextWasLost;
  30073. /** @hidden */
  30074. _doNotHandleContextLost: boolean;
  30075. /**
  30076. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30078. */
  30079. doNotHandleContextLost: boolean;
  30080. private _performanceMonitor;
  30081. private _fps;
  30082. private _deltaTime;
  30083. /**
  30084. * Turn this value on if you want to pause FPS computation when in background
  30085. */
  30086. disablePerformanceMonitorInBackground: boolean;
  30087. /**
  30088. * Gets the performance monitor attached to this engine
  30089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30090. */
  30091. readonly performanceMonitor: PerformanceMonitor;
  30092. /**
  30093. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30094. */
  30095. disableVertexArrayObjects: boolean;
  30096. /** @hidden */
  30097. protected _depthCullingState: _DepthCullingState;
  30098. /** @hidden */
  30099. protected _stencilState: _StencilState;
  30100. /** @hidden */
  30101. protected _alphaState: _AlphaState;
  30102. /** @hidden */
  30103. protected _alphaMode: number;
  30104. /** @hidden */
  30105. _internalTexturesCache: InternalTexture[];
  30106. /** @hidden */
  30107. protected _activeChannel: number;
  30108. private _currentTextureChannel;
  30109. /** @hidden */
  30110. protected _boundTexturesCache: {
  30111. [key: string]: Nullable<InternalTexture>;
  30112. };
  30113. /** @hidden */
  30114. protected _currentEffect: Nullable<Effect>;
  30115. /** @hidden */
  30116. protected _currentProgram: Nullable<WebGLProgram>;
  30117. private _compiledEffects;
  30118. private _vertexAttribArraysEnabled;
  30119. /** @hidden */
  30120. protected _cachedViewport: Nullable<IViewportLike>;
  30121. private _cachedVertexArrayObject;
  30122. /** @hidden */
  30123. protected _cachedVertexBuffers: any;
  30124. /** @hidden */
  30125. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30126. /** @hidden */
  30127. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30128. /** @hidden */
  30129. _currentRenderTarget: Nullable<InternalTexture>;
  30130. private _uintIndicesCurrentlySet;
  30131. private _currentBoundBuffer;
  30132. /** @hidden */
  30133. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30134. private _currentBufferPointers;
  30135. private _currentInstanceLocations;
  30136. private _currentInstanceBuffers;
  30137. private _textureUnits;
  30138. /** @hidden */
  30139. _workingCanvas: Nullable<HTMLCanvasElement>;
  30140. /** @hidden */
  30141. _workingContext: Nullable<CanvasRenderingContext2D>;
  30142. private _rescalePostProcess;
  30143. private _dummyFramebuffer;
  30144. private _externalData;
  30145. /** @hidden */
  30146. _bindedRenderFunction: any;
  30147. private _vaoRecordInProgress;
  30148. private _mustWipeVertexAttributes;
  30149. private _emptyTexture;
  30150. private _emptyCubeTexture;
  30151. private _emptyTexture3D;
  30152. /** @hidden */
  30153. _frameHandler: number;
  30154. private _nextFreeTextureSlots;
  30155. private _maxSimultaneousTextures;
  30156. private _activeRequests;
  30157. private _texturesSupported;
  30158. /** @hidden */
  30159. _textureFormatInUse: Nullable<string>;
  30160. /**
  30161. * Gets the list of texture formats supported
  30162. */
  30163. readonly texturesSupported: Array<string>;
  30164. /**
  30165. * Gets the list of texture formats in use
  30166. */
  30167. readonly textureFormatInUse: Nullable<string>;
  30168. /**
  30169. * Gets the current viewport
  30170. */
  30171. readonly currentViewport: Nullable<IViewportLike>;
  30172. /**
  30173. * Gets the default empty texture
  30174. */
  30175. readonly emptyTexture: InternalTexture;
  30176. /**
  30177. * Gets the default empty 3D texture
  30178. */
  30179. readonly emptyTexture3D: InternalTexture;
  30180. /**
  30181. * Gets the default empty cube texture
  30182. */
  30183. readonly emptyCubeTexture: InternalTexture;
  30184. /**
  30185. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30186. */
  30187. readonly premultipliedAlpha: boolean;
  30188. /**
  30189. * Creates a new engine
  30190. * @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
  30191. * @param antialias defines enable antialiasing (default: false)
  30192. * @param options defines further options to be sent to the getContext() function
  30193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30194. */
  30195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30196. /**
  30197. * Initializes a webVR display and starts listening to display change events
  30198. * The onVRDisplayChangedObservable will be notified upon these changes
  30199. * @returns The onVRDisplayChangedObservable
  30200. */
  30201. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30202. /** @hidden */
  30203. _prepareVRComponent(): void;
  30204. /** @hidden */
  30205. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30206. /** @hidden */
  30207. _submitVRFrame(): void;
  30208. /**
  30209. * Call this function to leave webVR mode
  30210. * Will do nothing if webVR is not supported or if there is no webVR device
  30211. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30212. */
  30213. disableVR(): void;
  30214. /**
  30215. * Gets a boolean indicating that the system is in VR mode and is presenting
  30216. * @returns true if VR mode is engaged
  30217. */
  30218. isVRPresenting(): boolean;
  30219. /** @hidden */
  30220. _requestVRFrame(): void;
  30221. private _disableTouchAction;
  30222. private _rebuildInternalTextures;
  30223. private _rebuildEffects;
  30224. /**
  30225. * Gets a boolean indicating if all created effects are ready
  30226. * @returns true if all effects are ready
  30227. */
  30228. areAllEffectsReady(): boolean;
  30229. private _rebuildBuffers;
  30230. private _initGLContext;
  30231. /**
  30232. * Gets version of the current webGL context
  30233. */
  30234. readonly webGLVersion: number;
  30235. /**
  30236. * Gets a string idenfifying the name of the class
  30237. * @returns "Engine" string
  30238. */
  30239. getClassName(): string;
  30240. /**
  30241. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30242. */
  30243. readonly isStencilEnable: boolean;
  30244. /** @hidden */
  30245. _prepareWorkingCanvas(): void;
  30246. /**
  30247. * Reset the texture cache to empty state
  30248. */
  30249. resetTextureCache(): void;
  30250. /**
  30251. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30253. * @returns true if engine is in deterministic lock step mode
  30254. */
  30255. isDeterministicLockStep(): boolean;
  30256. /**
  30257. * Gets the max steps when engine is running in deterministic lock step
  30258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30259. * @returns the max steps
  30260. */
  30261. getLockstepMaxSteps(): number;
  30262. /**
  30263. * Gets an object containing information about the current webGL context
  30264. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30265. */
  30266. getGlInfo(): {
  30267. vendor: string;
  30268. renderer: string;
  30269. version: string;
  30270. };
  30271. /**
  30272. * Gets current aspect ratio
  30273. * @param viewportOwner defines the camera to use to get the aspect ratio
  30274. * @param useScreen defines if screen size must be used (or the current render target if any)
  30275. * @returns a number defining the aspect ratio
  30276. */
  30277. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30278. /**
  30279. * Gets current screen aspect ratio
  30280. * @returns a number defining the aspect ratio
  30281. */
  30282. getScreenAspectRatio(): number;
  30283. /**
  30284. * Gets the current render width
  30285. * @param useScreen defines if screen size must be used (or the current render target if any)
  30286. * @returns a number defining the current render width
  30287. */
  30288. getRenderWidth(useScreen?: boolean): number;
  30289. /**
  30290. * Gets the current render height
  30291. * @param useScreen defines if screen size must be used (or the current render target if any)
  30292. * @returns a number defining the current render height
  30293. */
  30294. getRenderHeight(useScreen?: boolean): number;
  30295. /**
  30296. * Gets the HTML canvas attached with the current webGL context
  30297. * @returns a HTML canvas
  30298. */
  30299. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30300. /**
  30301. * Gets the client rect of the HTML canvas attached with the current webGL context
  30302. * @returns a client rectanglee
  30303. */
  30304. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30305. /**
  30306. * Defines the hardware scaling level.
  30307. * By default the hardware scaling level is computed from the window device ratio.
  30308. * 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.
  30309. * @param level defines the level to use
  30310. */
  30311. setHardwareScalingLevel(level: number): void;
  30312. /**
  30313. * Gets the current hardware scaling level.
  30314. * By default the hardware scaling level is computed from the window device ratio.
  30315. * 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.
  30316. * @returns a number indicating the current hardware scaling level
  30317. */
  30318. getHardwareScalingLevel(): number;
  30319. /**
  30320. * Gets the list of loaded textures
  30321. * @returns an array containing all loaded textures
  30322. */
  30323. getLoadedTexturesCache(): InternalTexture[];
  30324. /**
  30325. * Gets the object containing all engine capabilities
  30326. * @returns the EngineCapabilities object
  30327. */
  30328. getCaps(): EngineCapabilities;
  30329. /**
  30330. * Gets the current depth function
  30331. * @returns a number defining the depth function
  30332. */
  30333. getDepthFunction(): Nullable<number>;
  30334. /**
  30335. * Sets the current depth function
  30336. * @param depthFunc defines the function to use
  30337. */
  30338. setDepthFunction(depthFunc: number): void;
  30339. /**
  30340. * Sets the current depth function to GREATER
  30341. */
  30342. setDepthFunctionToGreater(): void;
  30343. /**
  30344. * Sets the current depth function to GEQUAL
  30345. */
  30346. setDepthFunctionToGreaterOrEqual(): void;
  30347. /**
  30348. * Sets the current depth function to LESS
  30349. */
  30350. setDepthFunctionToLess(): void;
  30351. private _cachedStencilBuffer;
  30352. private _cachedStencilFunction;
  30353. private _cachedStencilMask;
  30354. private _cachedStencilOperationPass;
  30355. private _cachedStencilOperationFail;
  30356. private _cachedStencilOperationDepthFail;
  30357. private _cachedStencilReference;
  30358. /**
  30359. * Caches the the state of the stencil buffer
  30360. */
  30361. cacheStencilState(): void;
  30362. /**
  30363. * Restores the state of the stencil buffer
  30364. */
  30365. restoreStencilState(): void;
  30366. /**
  30367. * Sets the current depth function to LEQUAL
  30368. */
  30369. setDepthFunctionToLessOrEqual(): void;
  30370. /**
  30371. * Gets a boolean indicating if stencil buffer is enabled
  30372. * @returns the current stencil buffer state
  30373. */
  30374. getStencilBuffer(): boolean;
  30375. /**
  30376. * Enable or disable the stencil buffer
  30377. * @param enable defines if the stencil buffer must be enabled or disabled
  30378. */
  30379. setStencilBuffer(enable: boolean): void;
  30380. /**
  30381. * Gets the current stencil mask
  30382. * @returns a number defining the new stencil mask to use
  30383. */
  30384. getStencilMask(): number;
  30385. /**
  30386. * Sets the current stencil mask
  30387. * @param mask defines the new stencil mask to use
  30388. */
  30389. setStencilMask(mask: number): void;
  30390. /**
  30391. * Gets the current stencil function
  30392. * @returns a number defining the stencil function to use
  30393. */
  30394. getStencilFunction(): number;
  30395. /**
  30396. * Gets the current stencil reference value
  30397. * @returns a number defining the stencil reference value to use
  30398. */
  30399. getStencilFunctionReference(): number;
  30400. /**
  30401. * Gets the current stencil mask
  30402. * @returns a number defining the stencil mask to use
  30403. */
  30404. getStencilFunctionMask(): number;
  30405. /**
  30406. * Sets the current stencil function
  30407. * @param stencilFunc defines the new stencil function to use
  30408. */
  30409. setStencilFunction(stencilFunc: number): void;
  30410. /**
  30411. * Sets the current stencil reference
  30412. * @param reference defines the new stencil reference to use
  30413. */
  30414. setStencilFunctionReference(reference: number): void;
  30415. /**
  30416. * Sets the current stencil mask
  30417. * @param mask defines the new stencil mask to use
  30418. */
  30419. setStencilFunctionMask(mask: number): void;
  30420. /**
  30421. * Gets the current stencil operation when stencil fails
  30422. * @returns a number defining stencil operation to use when stencil fails
  30423. */
  30424. getStencilOperationFail(): number;
  30425. /**
  30426. * Gets the current stencil operation when depth fails
  30427. * @returns a number defining stencil operation to use when depth fails
  30428. */
  30429. getStencilOperationDepthFail(): number;
  30430. /**
  30431. * Gets the current stencil operation when stencil passes
  30432. * @returns a number defining stencil operation to use when stencil passes
  30433. */
  30434. getStencilOperationPass(): number;
  30435. /**
  30436. * Sets the stencil operation to use when stencil fails
  30437. * @param operation defines the stencil operation to use when stencil fails
  30438. */
  30439. setStencilOperationFail(operation: number): void;
  30440. /**
  30441. * Sets the stencil operation to use when depth fails
  30442. * @param operation defines the stencil operation to use when depth fails
  30443. */
  30444. setStencilOperationDepthFail(operation: number): void;
  30445. /**
  30446. * Sets the stencil operation to use when stencil passes
  30447. * @param operation defines the stencil operation to use when stencil passes
  30448. */
  30449. setStencilOperationPass(operation: number): void;
  30450. /**
  30451. * Sets a boolean indicating if the dithering state is enabled or disabled
  30452. * @param value defines the dithering state
  30453. */
  30454. setDitheringState(value: boolean): void;
  30455. /**
  30456. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30457. * @param value defines the rasterizer state
  30458. */
  30459. setRasterizerState(value: boolean): void;
  30460. /**
  30461. * stop executing a render loop function and remove it from the execution array
  30462. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30463. */
  30464. stopRenderLoop(renderFunction?: () => void): void;
  30465. /** @hidden */
  30466. _renderLoop(): void;
  30467. /**
  30468. * Register and execute a render loop. The engine can have more than one render function
  30469. * @param renderFunction defines the function to continuously execute
  30470. */
  30471. runRenderLoop(renderFunction: () => void): void;
  30472. /**
  30473. * Toggle full screen mode
  30474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30475. */
  30476. switchFullscreen(requestPointerLock: boolean): void;
  30477. /**
  30478. * Enters full screen mode
  30479. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30480. */
  30481. enterFullscreen(requestPointerLock: boolean): void;
  30482. /**
  30483. * Exits full screen mode
  30484. */
  30485. exitFullscreen(): void;
  30486. /**
  30487. * Enters Pointerlock mode
  30488. */
  30489. enterPointerlock(): void;
  30490. /**
  30491. * Exits Pointerlock mode
  30492. */
  30493. exitPointerlock(): void;
  30494. /**
  30495. * Clear the current render buffer or the current render target (if any is set up)
  30496. * @param color defines the color to use
  30497. * @param backBuffer defines if the back buffer must be cleared
  30498. * @param depth defines if the depth buffer must be cleared
  30499. * @param stencil defines if the stencil buffer must be cleared
  30500. */
  30501. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30502. /**
  30503. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30505. * @param y defines the y-coordinate of the corner of the clear rectangle
  30506. * @param width defines the width of the clear rectangle
  30507. * @param height defines the height of the clear rectangle
  30508. * @param clearColor defines the clear color
  30509. */
  30510. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30511. /**
  30512. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30513. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30514. * @param y defines the y-coordinate of the corner of the clear rectangle
  30515. * @param width defines the width of the clear rectangle
  30516. * @param height defines the height of the clear rectangle
  30517. */
  30518. enableScissor(x: number, y: number, width: number, height: number): void;
  30519. /**
  30520. * Disable previously set scissor test rectangle
  30521. */
  30522. disableScissor(): void;
  30523. private _viewportCached;
  30524. /** @hidden */
  30525. _viewport(x: number, y: number, width: number, height: number): void;
  30526. /**
  30527. * Set the WebGL's viewport
  30528. * @param viewport defines the viewport element to be used
  30529. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30530. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30531. */
  30532. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30533. /**
  30534. * Directly set the WebGL Viewport
  30535. * @param x defines the x coordinate of the viewport (in screen space)
  30536. * @param y defines the y coordinate of the viewport (in screen space)
  30537. * @param width defines the width of the viewport (in screen space)
  30538. * @param height defines the height of the viewport (in screen space)
  30539. * @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
  30540. */
  30541. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30542. /**
  30543. * Begin a new frame
  30544. */
  30545. beginFrame(): void;
  30546. /**
  30547. * Enf the current frame
  30548. */
  30549. endFrame(): void;
  30550. /**
  30551. * Resize the view according to the canvas' size
  30552. */
  30553. resize(): void;
  30554. /**
  30555. * Force a specific size of the canvas
  30556. * @param width defines the new canvas' width
  30557. * @param height defines the new canvas' height
  30558. */
  30559. setSize(width: number, height: number): void;
  30560. /**
  30561. * Binds the frame buffer to the specified texture.
  30562. * @param texture The texture to render to or null for the default canvas
  30563. * @param faceIndex The face of the texture to render to in case of cube texture
  30564. * @param requiredWidth The width of the target to render to
  30565. * @param requiredHeight The height of the target to render to
  30566. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30567. * @param depthStencilTexture The depth stencil texture to use to render
  30568. * @param lodLevel defines le lod level to bind to the frame buffer
  30569. */
  30570. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30571. /** @hidden */
  30572. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30573. /**
  30574. * Unbind the current render target texture from the webGL context
  30575. * @param texture defines the render target texture to unbind
  30576. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30577. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30578. */
  30579. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30580. /**
  30581. * Force the mipmap generation for the given render target texture
  30582. * @param texture defines the render target texture to use
  30583. */
  30584. generateMipMapsForCubemap(texture: InternalTexture): void;
  30585. /**
  30586. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30587. */
  30588. flushFramebuffer(): void;
  30589. /**
  30590. * Unbind the current render target and bind the default framebuffer
  30591. */
  30592. restoreDefaultFramebuffer(): void;
  30593. /**
  30594. * Create an uniform buffer
  30595. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30596. * @param elements defines the content of the uniform buffer
  30597. * @returns the webGL uniform buffer
  30598. */
  30599. createUniformBuffer(elements: FloatArray): DataBuffer;
  30600. /**
  30601. * Create a dynamic uniform buffer
  30602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30603. * @param elements defines the content of the uniform buffer
  30604. * @returns the webGL uniform buffer
  30605. */
  30606. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30607. /**
  30608. * Update an existing uniform buffer
  30609. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30610. * @param uniformBuffer defines the target uniform buffer
  30611. * @param elements defines the content to update
  30612. * @param offset defines the offset in the uniform buffer where update should start
  30613. * @param count defines the size of the data to update
  30614. */
  30615. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30616. private _resetVertexBufferBinding;
  30617. /**
  30618. * Creates a vertex buffer
  30619. * @param data the data for the vertex buffer
  30620. * @returns the new WebGL static buffer
  30621. */
  30622. createVertexBuffer(data: DataArray): DataBuffer;
  30623. /**
  30624. * Creates a dynamic vertex buffer
  30625. * @param data the data for the dynamic vertex buffer
  30626. * @returns the new WebGL dynamic buffer
  30627. */
  30628. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30629. /**
  30630. * Update a dynamic index buffer
  30631. * @param indexBuffer defines the target index buffer
  30632. * @param indices defines the data to update
  30633. * @param offset defines the offset in the target index buffer where update should start
  30634. */
  30635. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30636. /**
  30637. * Updates a dynamic vertex buffer.
  30638. * @param vertexBuffer the vertex buffer to update
  30639. * @param data the data used to update the vertex buffer
  30640. * @param byteOffset the byte offset of the data
  30641. * @param byteLength the byte length of the data
  30642. */
  30643. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30644. private _resetIndexBufferBinding;
  30645. /**
  30646. * Creates a new index buffer
  30647. * @param indices defines the content of the index buffer
  30648. * @param updatable defines if the index buffer must be updatable
  30649. * @returns a new webGL buffer
  30650. */
  30651. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30652. /**
  30653. * Bind a webGL buffer to the webGL context
  30654. * @param buffer defines the buffer to bind
  30655. */
  30656. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30657. /**
  30658. * Bind an uniform buffer to the current webGL context
  30659. * @param buffer defines the buffer to bind
  30660. */
  30661. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30662. /**
  30663. * Bind a buffer to the current webGL context at a given location
  30664. * @param buffer defines the buffer to bind
  30665. * @param location defines the index where to bind the buffer
  30666. */
  30667. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30668. /**
  30669. * Bind a specific block at a given index in a specific shader program
  30670. * @param pipelineContext defines the pipeline context to use
  30671. * @param blockName defines the block name
  30672. * @param index defines the index where to bind the block
  30673. */
  30674. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30675. private bindIndexBuffer;
  30676. private bindBuffer;
  30677. /**
  30678. * update the bound buffer with the given data
  30679. * @param data defines the data to update
  30680. */
  30681. updateArrayBuffer(data: Float32Array): void;
  30682. private _vertexAttribPointer;
  30683. private _bindIndexBufferWithCache;
  30684. private _bindVertexBuffersAttributes;
  30685. /**
  30686. * Records a vertex array object
  30687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30688. * @param vertexBuffers defines the list of vertex buffers to store
  30689. * @param indexBuffer defines the index buffer to store
  30690. * @param effect defines the effect to store
  30691. * @returns the new vertex array object
  30692. */
  30693. recordVertexArrayObject(vertexBuffers: {
  30694. [key: string]: VertexBuffer;
  30695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30696. /**
  30697. * Bind a specific vertex array object
  30698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30699. * @param vertexArrayObject defines the vertex array object to bind
  30700. * @param indexBuffer defines the index buffer to bind
  30701. */
  30702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30703. /**
  30704. * Bind webGl buffers directly to the webGL context
  30705. * @param vertexBuffer defines the vertex buffer to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30709. * @param effect defines the effect associated with the vertex buffer
  30710. */
  30711. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30712. private _unbindVertexArrayObject;
  30713. /**
  30714. * Bind a list of vertex buffers to the webGL context
  30715. * @param vertexBuffers defines the list of vertex buffers to bind
  30716. * @param indexBuffer defines the index buffer to bind
  30717. * @param effect defines the effect associated with the vertex buffers
  30718. */
  30719. bindBuffers(vertexBuffers: {
  30720. [key: string]: Nullable<VertexBuffer>;
  30721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30722. /**
  30723. * Unbind all instance attributes
  30724. */
  30725. unbindInstanceAttributes(): void;
  30726. /**
  30727. * Release and free the memory of a vertex array object
  30728. * @param vao defines the vertex array object to delete
  30729. */
  30730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30731. /** @hidden */
  30732. _releaseBuffer(buffer: DataBuffer): boolean;
  30733. /**
  30734. * Creates a webGL buffer to use with instanciation
  30735. * @param capacity defines the size of the buffer
  30736. * @returns the webGL buffer
  30737. */
  30738. createInstancesBuffer(capacity: number): DataBuffer;
  30739. /**
  30740. * Delete a webGL buffer used with instanciation
  30741. * @param buffer defines the webGL buffer to delete
  30742. */
  30743. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30744. /**
  30745. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30746. * @param instancesBuffer defines the webGL buffer to update and bind
  30747. * @param data defines the data to store in the buffer
  30748. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30749. */
  30750. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30751. /**
  30752. * Apply all cached states (depth, culling, stencil and alpha)
  30753. */
  30754. applyStates(): void;
  30755. /**
  30756. * Send a draw order
  30757. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30758. * @param indexStart defines the starting index
  30759. * @param indexCount defines the number of index to draw
  30760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30761. */
  30762. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30763. /**
  30764. * Draw a list of points
  30765. * @param verticesStart defines the index of first vertex to draw
  30766. * @param verticesCount defines the count of vertices to draw
  30767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30768. */
  30769. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30770. /**
  30771. * Draw a list of unindexed primitives
  30772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30773. * @param verticesStart defines the index of first vertex to draw
  30774. * @param verticesCount defines the count of vertices to draw
  30775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30776. */
  30777. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30778. /**
  30779. * Draw a list of indexed primitives
  30780. * @param fillMode defines the primitive to use
  30781. * @param indexStart defines the starting index
  30782. * @param indexCount defines the number of index to draw
  30783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30784. */
  30785. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30786. /**
  30787. * Draw a list of unindexed primitives
  30788. * @param fillMode defines the primitive to use
  30789. * @param verticesStart defines the index of first vertex to draw
  30790. * @param verticesCount defines the count of vertices to draw
  30791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30792. */
  30793. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30794. private _drawMode;
  30795. /** @hidden */
  30796. _releaseEffect(effect: Effect): void;
  30797. /** @hidden */
  30798. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30799. /**
  30800. * Create a new effect (used to store vertex/fragment shaders)
  30801. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30802. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30803. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30804. * @param samplers defines an array of string used to represent textures
  30805. * @param defines defines the string containing the defines to use to compile the shaders
  30806. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30807. * @param onCompiled defines a function to call when the effect creation is successful
  30808. * @param onError defines a function to call when the effect creation has failed
  30809. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30810. * @returns the new Effect
  30811. */
  30812. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30813. private _compileShader;
  30814. private _compileRawShader;
  30815. /**
  30816. * Directly creates a webGL program
  30817. * @param pipelineContext defines the pipeline context to attach to
  30818. * @param vertexCode defines the vertex shader code to use
  30819. * @param fragmentCode defines the fragment shader code to use
  30820. * @param context defines the webGL context to use (if not set, the current one will be used)
  30821. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30822. * @returns the new webGL program
  30823. */
  30824. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30825. /**
  30826. * Creates a webGL program
  30827. * @param pipelineContext defines the pipeline context to attach to
  30828. * @param vertexCode defines the vertex shader code to use
  30829. * @param fragmentCode defines the fragment shader code to use
  30830. * @param defines defines the string containing the defines to use to compile the shaders
  30831. * @param context defines the webGL context to use (if not set, the current one will be used)
  30832. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30833. * @returns the new webGL program
  30834. */
  30835. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30836. /**
  30837. * Creates a new pipeline context
  30838. * @returns the new pipeline
  30839. */
  30840. createPipelineContext(): WebGLPipelineContext;
  30841. private _createShaderProgram;
  30842. private _finalizePipelineContext;
  30843. /** @hidden */
  30844. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30845. /** @hidden */
  30846. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30847. /** @hidden */
  30848. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30849. /**
  30850. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30851. * @param pipelineContext defines the pipeline context to use
  30852. * @param uniformsNames defines the list of uniform names
  30853. * @returns an array of webGL uniform locations
  30854. */
  30855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30856. /**
  30857. * Gets the lsit of active attributes for a given webGL program
  30858. * @param pipelineContext defines the pipeline context to use
  30859. * @param attributesNames defines the list of attribute names to get
  30860. * @returns an array of indices indicating the offset of each attribute
  30861. */
  30862. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30863. /**
  30864. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30865. * @param effect defines the effect to activate
  30866. */
  30867. enableEffect(effect: Nullable<Effect>): void;
  30868. /**
  30869. * Set the value of an uniform to an array of int32
  30870. * @param uniform defines the webGL uniform location where to store the value
  30871. * @param array defines the array of int32 to store
  30872. */
  30873. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30874. /**
  30875. * Set the value of an uniform to an array of int32 (stored as vec2)
  30876. * @param uniform defines the webGL uniform location where to store the value
  30877. * @param array defines the array of int32 to store
  30878. */
  30879. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30880. /**
  30881. * Set the value of an uniform to an array of int32 (stored as vec3)
  30882. * @param uniform defines the webGL uniform location where to store the value
  30883. * @param array defines the array of int32 to store
  30884. */
  30885. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30886. /**
  30887. * Set the value of an uniform to an array of int32 (stored as vec4)
  30888. * @param uniform defines the webGL uniform location where to store the value
  30889. * @param array defines the array of int32 to store
  30890. */
  30891. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30892. /**
  30893. * Set the value of an uniform to an array of float32
  30894. * @param uniform defines the webGL uniform location where to store the value
  30895. * @param array defines the array of float32 to store
  30896. */
  30897. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30898. /**
  30899. * Set the value of an uniform to an array of float32 (stored as vec2)
  30900. * @param uniform defines the webGL uniform location where to store the value
  30901. * @param array defines the array of float32 to store
  30902. */
  30903. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30904. /**
  30905. * Set the value of an uniform to an array of float32 (stored as vec3)
  30906. * @param uniform defines the webGL uniform location where to store the value
  30907. * @param array defines the array of float32 to store
  30908. */
  30909. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30910. /**
  30911. * Set the value of an uniform to an array of float32 (stored as vec4)
  30912. * @param uniform defines the webGL uniform location where to store the value
  30913. * @param array defines the array of float32 to store
  30914. */
  30915. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30916. /**
  30917. * Set the value of an uniform to an array of number
  30918. * @param uniform defines the webGL uniform location where to store the value
  30919. * @param array defines the array of number to store
  30920. */
  30921. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30922. /**
  30923. * Set the value of an uniform to an array of number (stored as vec2)
  30924. * @param uniform defines the webGL uniform location where to store the value
  30925. * @param array defines the array of number to store
  30926. */
  30927. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30928. /**
  30929. * Set the value of an uniform to an array of number (stored as vec3)
  30930. * @param uniform defines the webGL uniform location where to store the value
  30931. * @param array defines the array of number to store
  30932. */
  30933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30934. /**
  30935. * Set the value of an uniform to an array of number (stored as vec4)
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param array defines the array of number to store
  30938. */
  30939. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30940. /**
  30941. * Set the value of an uniform to an array of float32 (stored as matrices)
  30942. * @param uniform defines the webGL uniform location where to store the value
  30943. * @param matrices defines the array of float32 to store
  30944. */
  30945. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30946. /**
  30947. * Set the value of an uniform to a matrix (3x3)
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30950. */
  30951. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30952. /**
  30953. * Set the value of an uniform to a matrix (2x2)
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30956. */
  30957. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30958. /**
  30959. * Set the value of an uniform to a number (int)
  30960. * @param uniform defines the webGL uniform location where to store the value
  30961. * @param value defines the int number to store
  30962. */
  30963. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30964. /**
  30965. * Set the value of an uniform to a number (float)
  30966. * @param uniform defines the webGL uniform location where to store the value
  30967. * @param value defines the float number to store
  30968. */
  30969. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30970. /**
  30971. * Set the value of an uniform to a vec2
  30972. * @param uniform defines the webGL uniform location where to store the value
  30973. * @param x defines the 1st component of the value
  30974. * @param y defines the 2nd component of the value
  30975. */
  30976. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30977. /**
  30978. * Set the value of an uniform to a vec3
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param x defines the 1st component of the value
  30981. * @param y defines the 2nd component of the value
  30982. * @param z defines the 3rd component of the value
  30983. */
  30984. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30985. /**
  30986. * Set the value of an uniform to a boolean
  30987. * @param uniform defines the webGL uniform location where to store the value
  30988. * @param bool defines the boolean to store
  30989. */
  30990. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30991. /**
  30992. * Set the value of an uniform to a vec4
  30993. * @param uniform defines the webGL uniform location where to store the value
  30994. * @param x defines the 1st component of the value
  30995. * @param y defines the 2nd component of the value
  30996. * @param z defines the 3rd component of the value
  30997. * @param w defines the 4th component of the value
  30998. */
  30999. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31000. /**
  31001. * Sets a Color4 on a uniform variable
  31002. * @param uniform defines the uniform location
  31003. * @param color4 defines the value to be set
  31004. */
  31005. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31006. /**
  31007. * Set various states to the webGL context
  31008. * @param culling defines backface culling state
  31009. * @param zOffset defines the value to apply to zOffset (0 by default)
  31010. * @param force defines if states must be applied even if cache is up to date
  31011. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31012. */
  31013. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31014. /**
  31015. * Set the z offset to apply to current rendering
  31016. * @param value defines the offset to apply
  31017. */
  31018. setZOffset(value: number): void;
  31019. /**
  31020. * Gets the current value of the zOffset
  31021. * @returns the current zOffset state
  31022. */
  31023. getZOffset(): number;
  31024. /**
  31025. * Enable or disable depth buffering
  31026. * @param enable defines the state to set
  31027. */
  31028. setDepthBuffer(enable: boolean): void;
  31029. /**
  31030. * Gets a boolean indicating if depth writing is enabled
  31031. * @returns the current depth writing state
  31032. */
  31033. getDepthWrite(): boolean;
  31034. /**
  31035. * Enable or disable depth writing
  31036. * @param enable defines the state to set
  31037. */
  31038. setDepthWrite(enable: boolean): void;
  31039. /**
  31040. * Enable or disable color writing
  31041. * @param enable defines the state to set
  31042. */
  31043. setColorWrite(enable: boolean): void;
  31044. /**
  31045. * Gets a boolean indicating if color writing is enabled
  31046. * @returns the current color writing state
  31047. */
  31048. getColorWrite(): boolean;
  31049. /**
  31050. * Sets alpha constants used by some alpha blending modes
  31051. * @param r defines the red component
  31052. * @param g defines the green component
  31053. * @param b defines the blue component
  31054. * @param a defines the alpha component
  31055. */
  31056. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31057. /**
  31058. * Sets the current alpha mode
  31059. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31060. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31061. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31062. */
  31063. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31064. /**
  31065. * Gets the current alpha mode
  31066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31067. * @returns the current alpha mode
  31068. */
  31069. getAlphaMode(): number;
  31070. /**
  31071. * Clears the list of texture accessible through engine.
  31072. * This can help preventing texture load conflict due to name collision.
  31073. */
  31074. clearInternalTexturesCache(): void;
  31075. /**
  31076. * Force the entire cache to be cleared
  31077. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31078. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31079. */
  31080. wipeCaches(bruteForce?: boolean): void;
  31081. /**
  31082. * Set the compressed texture format to use, based on the formats you have, and the formats
  31083. * supported by the hardware / browser.
  31084. *
  31085. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31086. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31087. * to API arguments needed to compressed textures. This puts the burden on the container
  31088. * generator to house the arcane code for determining these for current & future formats.
  31089. *
  31090. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31091. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31092. *
  31093. * Note: The result of this call is not taken into account when a texture is base64.
  31094. *
  31095. * @param formatsAvailable defines the list of those format families you have created
  31096. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31097. *
  31098. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31099. * @returns The extension selected.
  31100. */
  31101. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31102. /** @hidden */
  31103. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31104. min: number;
  31105. mag: number;
  31106. };
  31107. /** @hidden */
  31108. _createTexture(): WebGLTexture;
  31109. /**
  31110. * Usually called from Texture.ts.
  31111. * Passed information to create a WebGLTexture
  31112. * @param urlArg defines a value which contains one of the following:
  31113. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31114. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31115. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31116. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31117. * @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)
  31118. * @param scene needed for loading to the correct scene
  31119. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31120. * @param onLoad optional callback to be called upon successful completion
  31121. * @param onError optional callback to be called upon failure
  31122. * @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
  31123. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31124. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31125. * @param forcedExtension defines the extension to use to pick the right loader
  31126. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31127. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31128. */
  31129. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31130. /**
  31131. * @hidden
  31132. * Rescales a texture
  31133. * @param source input texutre
  31134. * @param destination destination texture
  31135. * @param scene scene to use to render the resize
  31136. * @param internalFormat format to use when resizing
  31137. * @param onComplete callback to be called when resize has completed
  31138. */
  31139. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31140. private _unpackFlipYCached;
  31141. /**
  31142. * In case you are sharing the context with other applications, it might
  31143. * be interested to not cache the unpack flip y state to ensure a consistent
  31144. * value would be set.
  31145. */
  31146. enableUnpackFlipYCached: boolean;
  31147. /** @hidden */
  31148. _unpackFlipY(value: boolean): void;
  31149. /** @hidden */
  31150. _getUnpackAlignement(): number;
  31151. /**
  31152. * Creates a dynamic texture
  31153. * @param width defines the width of the texture
  31154. * @param height defines the height of the texture
  31155. * @param generateMipMaps defines if the engine should generate the mip levels
  31156. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31157. * @returns the dynamic texture inside an InternalTexture
  31158. */
  31159. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31160. /**
  31161. * Update the sampling mode of a given texture
  31162. * @param samplingMode defines the required sampling mode
  31163. * @param texture defines the texture to update
  31164. */
  31165. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31166. /**
  31167. * Update the content of a dynamic texture
  31168. * @param texture defines the texture to update
  31169. * @param canvas defines the canvas containing the source
  31170. * @param invertY defines if data must be stored with Y axis inverted
  31171. * @param premulAlpha defines if alpha is stored as premultiplied
  31172. * @param format defines the format of the data
  31173. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31174. */
  31175. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31176. /**
  31177. * Update a video texture
  31178. * @param texture defines the texture to update
  31179. * @param video defines the video element to use
  31180. * @param invertY defines if data must be stored with Y axis inverted
  31181. */
  31182. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31183. /**
  31184. * Updates a depth texture Comparison Mode and Function.
  31185. * If the comparison Function is equal to 0, the mode will be set to none.
  31186. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31187. * @param texture The texture to set the comparison function for
  31188. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31189. */
  31190. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31191. /** @hidden */
  31192. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31193. width: number;
  31194. height: number;
  31195. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31196. /**
  31197. * Creates a depth stencil texture.
  31198. * This is only available in WebGL 2 or with the depth texture extension available.
  31199. * @param size The size of face edge in the texture.
  31200. * @param options The options defining the texture.
  31201. * @returns The texture
  31202. */
  31203. createDepthStencilTexture(size: number | {
  31204. width: number;
  31205. height: number;
  31206. }, options: DepthTextureCreationOptions): InternalTexture;
  31207. /**
  31208. * Creates a depth stencil texture.
  31209. * This is only available in WebGL 2 or with the depth texture extension available.
  31210. * @param size The size of face edge in the texture.
  31211. * @param options The options defining the texture.
  31212. * @returns The texture
  31213. */
  31214. private _createDepthStencilTexture;
  31215. /**
  31216. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31217. * @param renderTarget The render target to set the frame buffer for
  31218. */
  31219. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31220. /**
  31221. * Creates a new render target texture
  31222. * @param size defines the size of the texture
  31223. * @param options defines the options used to create the texture
  31224. * @returns a new render target texture stored in an InternalTexture
  31225. */
  31226. createRenderTargetTexture(size: number | {
  31227. width: number;
  31228. height: number;
  31229. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31230. /** @hidden */
  31231. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31232. /**
  31233. * Updates the sample count of a render target texture
  31234. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31235. * @param texture defines the texture to update
  31236. * @param samples defines the sample count to set
  31237. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31238. */
  31239. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31240. /** @hidden */
  31241. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31242. /** @hidden */
  31243. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31244. /** @hidden */
  31245. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31246. /** @hidden */
  31247. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31248. /**
  31249. * @hidden
  31250. */
  31251. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31252. private _prepareWebGLTextureContinuation;
  31253. private _prepareWebGLTexture;
  31254. /** @hidden */
  31255. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31256. /** @hidden */
  31257. _releaseFramebufferObjects(texture: InternalTexture): void;
  31258. /** @hidden */
  31259. _releaseTexture(texture: InternalTexture): void;
  31260. private setProgram;
  31261. private _boundUniforms;
  31262. /**
  31263. * Binds an effect to the webGL context
  31264. * @param effect defines the effect to bind
  31265. */
  31266. bindSamplers(effect: Effect): void;
  31267. private _activateCurrentTexture;
  31268. /** @hidden */
  31269. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31270. /** @hidden */
  31271. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31272. /**
  31273. * Sets a texture to the webGL context from a postprocess
  31274. * @param channel defines the channel to use
  31275. * @param postProcess defines the source postprocess
  31276. */
  31277. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31278. /**
  31279. * Binds the output of the passed in post process to the texture channel specified
  31280. * @param channel The channel the texture should be bound to
  31281. * @param postProcess The post process which's output should be bound
  31282. */
  31283. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31284. /**
  31285. * Unbind all textures from the webGL context
  31286. */
  31287. unbindAllTextures(): void;
  31288. /**
  31289. * Sets a texture to the according uniform.
  31290. * @param channel The texture channel
  31291. * @param uniform The uniform to set
  31292. * @param texture The texture to apply
  31293. */
  31294. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31295. /**
  31296. * Sets a depth stencil texture from a render target to the according uniform.
  31297. * @param channel The texture channel
  31298. * @param uniform The uniform to set
  31299. * @param texture The render target texture containing the depth stencil texture to apply
  31300. */
  31301. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31302. private _bindSamplerUniformToChannel;
  31303. private _getTextureWrapMode;
  31304. private _setTexture;
  31305. /**
  31306. * Sets an array of texture to the webGL context
  31307. * @param channel defines the channel where the texture array must be set
  31308. * @param uniform defines the associated uniform location
  31309. * @param textures defines the array of textures to bind
  31310. */
  31311. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31312. /** @hidden */
  31313. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31314. private _setTextureParameterFloat;
  31315. private _setTextureParameterInteger;
  31316. /**
  31317. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31318. * @param x defines the x coordinate of the rectangle where pixels must be read
  31319. * @param y defines the y coordinate of the rectangle where pixels must be read
  31320. * @param width defines the width of the rectangle where pixels must be read
  31321. * @param height defines the height of the rectangle where pixels must be read
  31322. * @returns a Uint8Array containing RGBA colors
  31323. */
  31324. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31325. /**
  31326. * Add an externaly attached data from its key.
  31327. * This method call will fail and return false, if such key already exists.
  31328. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31329. * @param key the unique key that identifies the data
  31330. * @param data the data object to associate to the key for this Engine instance
  31331. * @return true if no such key were already present and the data was added successfully, false otherwise
  31332. */
  31333. addExternalData<T>(key: string, data: T): boolean;
  31334. /**
  31335. * Get an externaly attached data from its key
  31336. * @param key the unique key that identifies the data
  31337. * @return the associated data, if present (can be null), or undefined if not present
  31338. */
  31339. getExternalData<T>(key: string): T;
  31340. /**
  31341. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31342. * @param key the unique key that identifies the data
  31343. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31344. * @return the associated data, can be null if the factory returned null.
  31345. */
  31346. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31347. /**
  31348. * Remove an externaly attached data from the Engine instance
  31349. * @param key the unique key that identifies the data
  31350. * @return true if the data was successfully removed, false if it doesn't exist
  31351. */
  31352. removeExternalData(key: string): boolean;
  31353. /**
  31354. * Unbind all vertex attributes from the webGL context
  31355. */
  31356. unbindAllAttributes(): void;
  31357. /**
  31358. * 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
  31359. */
  31360. releaseEffects(): void;
  31361. /**
  31362. * Dispose and release all associated resources
  31363. */
  31364. dispose(): void;
  31365. /**
  31366. * Display the loading screen
  31367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31368. */
  31369. displayLoadingUI(): void;
  31370. /**
  31371. * Hide the loading screen
  31372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31373. */
  31374. hideLoadingUI(): void;
  31375. /**
  31376. * Gets the current loading screen object
  31377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31378. */
  31379. /**
  31380. * Sets the current loading screen object
  31381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31382. */
  31383. loadingScreen: ILoadingScreen;
  31384. /**
  31385. * Sets the current loading screen text
  31386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31387. */
  31388. loadingUIText: string;
  31389. /**
  31390. * Sets the current loading screen background color
  31391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31392. */
  31393. loadingUIBackgroundColor: string;
  31394. /**
  31395. * Attach a new callback raised when context lost event is fired
  31396. * @param callback defines the callback to call
  31397. */
  31398. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31399. /**
  31400. * Attach a new callback raised when context restored event is fired
  31401. * @param callback defines the callback to call
  31402. */
  31403. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31404. /**
  31405. * Gets the source code of the vertex shader associated with a specific webGL program
  31406. * @param program defines the program to use
  31407. * @returns a string containing the source code of the vertex shader associated with the program
  31408. */
  31409. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31410. /**
  31411. * Gets the source code of the fragment shader associated with a specific webGL program
  31412. * @param program defines the program to use
  31413. * @returns a string containing the source code of the fragment shader associated with the program
  31414. */
  31415. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31416. /**
  31417. * Get the current error code of the webGL context
  31418. * @returns the error code
  31419. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31420. */
  31421. getError(): number;
  31422. /**
  31423. * Gets the current framerate
  31424. * @returns a number representing the framerate
  31425. */
  31426. getFps(): number;
  31427. /**
  31428. * Gets the time spent between current and previous frame
  31429. * @returns a number representing the delta time in ms
  31430. */
  31431. getDeltaTime(): number;
  31432. private _measureFps;
  31433. /** @hidden */
  31434. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31435. private _canRenderToFloatFramebuffer;
  31436. private _canRenderToHalfFloatFramebuffer;
  31437. private _canRenderToFramebuffer;
  31438. /** @hidden */
  31439. _getWebGLTextureType(type: number): number;
  31440. /** @hidden */
  31441. _getInternalFormat(format: number): number;
  31442. /** @hidden */
  31443. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31444. /** @hidden */
  31445. _getRGBAMultiSampleBufferFormat(type: number): number;
  31446. /** @hidden */
  31447. _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;
  31448. /** @hidden */
  31449. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31450. /**
  31451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31452. * @returns true if the engine can be created
  31453. * @ignorenaming
  31454. */
  31455. static isSupported(): boolean;
  31456. /**
  31457. * Find the next highest power of two.
  31458. * @param x Number to start search from.
  31459. * @return Next highest power of two.
  31460. */
  31461. static CeilingPOT(x: number): number;
  31462. /**
  31463. * Find the next lowest power of two.
  31464. * @param x Number to start search from.
  31465. * @return Next lowest power of two.
  31466. */
  31467. static FloorPOT(x: number): number;
  31468. /**
  31469. * Find the nearest power of two.
  31470. * @param x Number to start search from.
  31471. * @return Next nearest power of two.
  31472. */
  31473. static NearestPOT(x: number): number;
  31474. /**
  31475. * Get the closest exponent of two
  31476. * @param value defines the value to approximate
  31477. * @param max defines the maximum value to return
  31478. * @param mode defines how to define the closest value
  31479. * @returns closest exponent of two of the given value
  31480. */
  31481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31482. /**
  31483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31484. * @param func - the function to be called
  31485. * @param requester - the object that will request the next frame. Falls back to window.
  31486. * @returns frame number
  31487. */
  31488. static QueueNewFrame(func: () => void, requester?: any): number;
  31489. /**
  31490. * Ask the browser to promote the current element to pointerlock mode
  31491. * @param element defines the DOM element to promote
  31492. */
  31493. static _RequestPointerlock(element: HTMLElement): void;
  31494. /**
  31495. * Asks the browser to exit pointerlock mode
  31496. */
  31497. static _ExitPointerlock(): void;
  31498. /**
  31499. * Ask the browser to promote the current element to fullscreen rendering mode
  31500. * @param element defines the DOM element to promote
  31501. */
  31502. static _RequestFullscreen(element: HTMLElement): void;
  31503. /**
  31504. * Asks the browser to exit fullscreen mode
  31505. */
  31506. static _ExitFullscreen(): void;
  31507. }
  31508. }
  31509. declare module BABYLON {
  31510. /**
  31511. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31512. * during the life time of the application.
  31513. */
  31514. export class EngineStore {
  31515. /** Gets the list of created engines */
  31516. static Instances: Engine[];
  31517. /** @hidden */
  31518. static _LastCreatedScene: Nullable<Scene>;
  31519. /**
  31520. * Gets the latest created engine
  31521. */
  31522. static readonly LastCreatedEngine: Nullable<Engine>;
  31523. /**
  31524. * Gets the latest created scene
  31525. */
  31526. static readonly LastCreatedScene: Nullable<Scene>;
  31527. /**
  31528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31529. * @ignorenaming
  31530. */
  31531. static UseFallbackTexture: boolean;
  31532. /**
  31533. * Texture content used if a texture cannot loaded
  31534. * @ignorenaming
  31535. */
  31536. static FallbackTexture: string;
  31537. }
  31538. }
  31539. declare module BABYLON {
  31540. /**
  31541. * Helper class that provides a small promise polyfill
  31542. */
  31543. export class PromisePolyfill {
  31544. /**
  31545. * Static function used to check if the polyfill is required
  31546. * If this is the case then the function will inject the polyfill to window.Promise
  31547. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31548. */
  31549. static Apply(force?: boolean): void;
  31550. }
  31551. }
  31552. declare module BABYLON {
  31553. interface IColor4Like {
  31554. r: float;
  31555. g: float;
  31556. b: float;
  31557. a: float;
  31558. }
  31559. /**
  31560. * Class containing a set of static utilities functions
  31561. */
  31562. export class Tools {
  31563. /**
  31564. * Gets or sets the base URL to use to load assets
  31565. */
  31566. static BaseUrl: string;
  31567. /**
  31568. * Enable/Disable Custom HTTP Request Headers globally.
  31569. * default = false
  31570. * @see CustomRequestHeaders
  31571. */
  31572. static UseCustomRequestHeaders: boolean;
  31573. /**
  31574. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31575. * i.e. when loading files, where the server/service expects an Authorization header
  31576. */
  31577. static CustomRequestHeaders: {
  31578. [key: string]: string;
  31579. };
  31580. /**
  31581. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31582. */
  31583. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31584. /**
  31585. * Default behaviour for cors in the application.
  31586. * It can be a string if the expected behavior is identical in the entire app.
  31587. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31588. */
  31589. static CorsBehavior: string | ((url: string | string[]) => string);
  31590. /**
  31591. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31592. * @ignorenaming
  31593. */
  31594. static UseFallbackTexture: boolean;
  31595. /**
  31596. * Use this object to register external classes like custom textures or material
  31597. * to allow the laoders to instantiate them
  31598. */
  31599. static RegisteredExternalClasses: {
  31600. [key: string]: Object;
  31601. };
  31602. /**
  31603. * Texture content used if a texture cannot loaded
  31604. * @ignorenaming
  31605. */
  31606. static fallbackTexture: string;
  31607. /**
  31608. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31609. * @param u defines the coordinate on X axis
  31610. * @param v defines the coordinate on Y axis
  31611. * @param width defines the width of the source data
  31612. * @param height defines the height of the source data
  31613. * @param pixels defines the source byte array
  31614. * @param color defines the output color
  31615. */
  31616. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31617. /**
  31618. * Interpolates between a and b via alpha
  31619. * @param a The lower value (returned when alpha = 0)
  31620. * @param b The upper value (returned when alpha = 1)
  31621. * @param alpha The interpolation-factor
  31622. * @return The mixed value
  31623. */
  31624. static Mix(a: number, b: number, alpha: number): number;
  31625. /**
  31626. * Tries to instantiate a new object from a given class name
  31627. * @param className defines the class name to instantiate
  31628. * @returns the new object or null if the system was not able to do the instantiation
  31629. */
  31630. static Instantiate(className: string): any;
  31631. /**
  31632. * Provides a slice function that will work even on IE
  31633. * @param data defines the array to slice
  31634. * @param start defines the start of the data (optional)
  31635. * @param end defines the end of the data (optional)
  31636. * @returns the new sliced array
  31637. */
  31638. static Slice<T>(data: T, start?: number, end?: number): T;
  31639. /**
  31640. * Polyfill for setImmediate
  31641. * @param action defines the action to execute after the current execution block
  31642. */
  31643. static SetImmediate(action: () => void): void;
  31644. /**
  31645. * Function indicating if a number is an exponent of 2
  31646. * @param value defines the value to test
  31647. * @returns true if the value is an exponent of 2
  31648. */
  31649. static IsExponentOfTwo(value: number): boolean;
  31650. private static _tmpFloatArray;
  31651. /**
  31652. * Returns the nearest 32-bit single precision float representation of a Number
  31653. * @param value A Number. If the parameter is of a different type, it will get converted
  31654. * to a number or to NaN if it cannot be converted
  31655. * @returns number
  31656. */
  31657. static FloatRound(value: number): number;
  31658. /**
  31659. * Extracts the filename from a path
  31660. * @param path defines the path to use
  31661. * @returns the filename
  31662. */
  31663. static GetFilename(path: string): string;
  31664. /**
  31665. * Extracts the "folder" part of a path (everything before the filename).
  31666. * @param uri The URI to extract the info from
  31667. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31668. * @returns The "folder" part of the path
  31669. */
  31670. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31671. /**
  31672. * Extracts text content from a DOM element hierarchy
  31673. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31674. */
  31675. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31676. /**
  31677. * Convert an angle in radians to degrees
  31678. * @param angle defines the angle to convert
  31679. * @returns the angle in degrees
  31680. */
  31681. static ToDegrees(angle: number): number;
  31682. /**
  31683. * Convert an angle in degrees to radians
  31684. * @param angle defines the angle to convert
  31685. * @returns the angle in radians
  31686. */
  31687. static ToRadians(angle: number): number;
  31688. /**
  31689. * Encode a buffer to a base64 string
  31690. * @param buffer defines the buffer to encode
  31691. * @returns the encoded string
  31692. */
  31693. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31694. /**
  31695. * Returns an array if obj is not an array
  31696. * @param obj defines the object to evaluate as an array
  31697. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31698. * @returns either obj directly if obj is an array or a new array containing obj
  31699. */
  31700. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31701. /**
  31702. * Gets the pointer prefix to use
  31703. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31704. */
  31705. static GetPointerPrefix(): string;
  31706. /**
  31707. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31708. * @param url define the url we are trying
  31709. * @param element define the dom element where to configure the cors policy
  31710. */
  31711. static SetCorsBehavior(url: string | string[], element: {
  31712. crossOrigin: string | null;
  31713. }): void;
  31714. /**
  31715. * Removes unwanted characters from an url
  31716. * @param url defines the url to clean
  31717. * @returns the cleaned url
  31718. */
  31719. static CleanUrl(url: string): string;
  31720. /**
  31721. * Gets or sets a function used to pre-process url before using them to load assets
  31722. */
  31723. static PreprocessUrl: (url: string) => string;
  31724. /**
  31725. * Loads an image as an HTMLImageElement.
  31726. * @param input url string, ArrayBuffer, or Blob to load
  31727. * @param onLoad callback called when the image successfully loads
  31728. * @param onError callback called when the image fails to load
  31729. * @param offlineProvider offline provider for caching
  31730. * @returns the HTMLImageElement of the loaded image
  31731. */
  31732. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31733. /**
  31734. * Loads a file
  31735. * @param url url string, ArrayBuffer, or Blob to load
  31736. * @param onSuccess callback called when the file successfully loads
  31737. * @param onProgress callback called while file is loading (if the server supports this mode)
  31738. * @param offlineProvider defines the offline provider for caching
  31739. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31740. * @param onError callback called when the file fails to load
  31741. * @returns a file request object
  31742. */
  31743. 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;
  31744. /**
  31745. * Loads a file from a url
  31746. * @param url the file url to load
  31747. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31748. */
  31749. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31750. /**
  31751. * Load a script (identified by an url). When the url returns, the
  31752. * content of this file is added into a new script element, attached to the DOM (body element)
  31753. * @param scriptUrl defines the url of the script to laod
  31754. * @param onSuccess defines the callback called when the script is loaded
  31755. * @param onError defines the callback to call if an error occurs
  31756. * @param scriptId defines the id of the script element
  31757. */
  31758. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31759. /**
  31760. * Load an asynchronous script (identified by an url). When the url returns, the
  31761. * content of this file is added into a new script element, attached to the DOM (body element)
  31762. * @param scriptUrl defines the url of the script to laod
  31763. * @param scriptId defines the id of the script element
  31764. * @returns a promise request object
  31765. */
  31766. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31767. /**
  31768. * Loads a file from a blob
  31769. * @param fileToLoad defines the blob to use
  31770. * @param callback defines the callback to call when data is loaded
  31771. * @param progressCallback defines the callback to call during loading process
  31772. * @returns a file request object
  31773. */
  31774. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31775. /**
  31776. * Loads a file
  31777. * @param fileToLoad defines the file to load
  31778. * @param callback defines the callback to call when data is loaded
  31779. * @param progressCallBack defines the callback to call during loading process
  31780. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31781. * @returns a file request object
  31782. */
  31783. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31784. /**
  31785. * Creates a data url from a given string content
  31786. * @param content defines the content to convert
  31787. * @returns the new data url link
  31788. */
  31789. static FileAsURL(content: string): string;
  31790. /**
  31791. * Format the given number to a specific decimal format
  31792. * @param value defines the number to format
  31793. * @param decimals defines the number of decimals to use
  31794. * @returns the formatted string
  31795. */
  31796. static Format(value: number, decimals?: number): string;
  31797. /**
  31798. * Tries to copy an object by duplicating every property
  31799. * @param source defines the source object
  31800. * @param destination defines the target object
  31801. * @param doNotCopyList defines a list of properties to avoid
  31802. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31803. */
  31804. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31805. /**
  31806. * Gets a boolean indicating if the given object has no own property
  31807. * @param obj defines the object to test
  31808. * @returns true if object has no own property
  31809. */
  31810. static IsEmpty(obj: any): boolean;
  31811. /**
  31812. * Function used to register events at window level
  31813. * @param events defines the events to register
  31814. */
  31815. static RegisterTopRootEvents(events: {
  31816. name: string;
  31817. handler: Nullable<(e: FocusEvent) => any>;
  31818. }[]): void;
  31819. /**
  31820. * Function used to unregister events from window level
  31821. * @param events defines the events to unregister
  31822. */
  31823. static UnregisterTopRootEvents(events: {
  31824. name: string;
  31825. handler: Nullable<(e: FocusEvent) => any>;
  31826. }[]): void;
  31827. /**
  31828. * @ignore
  31829. */
  31830. static _ScreenshotCanvas: HTMLCanvasElement;
  31831. /**
  31832. * Dumps the current bound framebuffer
  31833. * @param width defines the rendering width
  31834. * @param height defines the rendering height
  31835. * @param engine defines the hosting engine
  31836. * @param successCallback defines the callback triggered once the data are available
  31837. * @param mimeType defines the mime type of the result
  31838. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31839. */
  31840. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31841. /**
  31842. * Converts the canvas data to blob.
  31843. * This acts as a polyfill for browsers not supporting the to blob function.
  31844. * @param canvas Defines the canvas to extract the data from
  31845. * @param successCallback Defines the callback triggered once the data are available
  31846. * @param mimeType Defines the mime type of the result
  31847. */
  31848. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31849. /**
  31850. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31851. * @param successCallback defines the callback triggered once the data are available
  31852. * @param mimeType defines the mime type of the result
  31853. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31854. */
  31855. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31856. /**
  31857. * Downloads a blob in the browser
  31858. * @param blob defines the blob to download
  31859. * @param fileName defines the name of the downloaded file
  31860. */
  31861. static Download(blob: Blob, fileName: string): void;
  31862. /**
  31863. * Captures a screenshot of the current rendering
  31864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31865. * @param engine defines the rendering engine
  31866. * @param camera defines the source camera
  31867. * @param size This parameter can be set to a single number or to an object with the
  31868. * following (optional) properties: precision, width, height. If a single number is passed,
  31869. * it will be used for both width and height. If an object is passed, the screenshot size
  31870. * will be derived from the parameters. The precision property is a multiplier allowing
  31871. * rendering at a higher or lower resolution
  31872. * @param successCallback defines the callback receives a single parameter which contains the
  31873. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31874. * src parameter of an <img> to display it
  31875. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31876. * Check your browser for supported MIME types
  31877. */
  31878. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31879. /**
  31880. * Generates an image screenshot from the specified camera.
  31881. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31882. * @param engine The engine to use for rendering
  31883. * @param camera The camera to use for rendering
  31884. * @param size This parameter can be set to a single number or to an object with the
  31885. * following (optional) properties: precision, width, height. If a single number is passed,
  31886. * it will be used for both width and height. If an object is passed, the screenshot size
  31887. * will be derived from the parameters. The precision property is a multiplier allowing
  31888. * rendering at a higher or lower resolution
  31889. * @param successCallback The callback receives a single parameter which contains the
  31890. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31891. * src parameter of an <img> to display it
  31892. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31893. * Check your browser for supported MIME types
  31894. * @param samples Texture samples (default: 1)
  31895. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31896. * @param fileName A name for for the downloaded file.
  31897. */
  31898. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31899. /**
  31900. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31901. * Be aware Math.random() could cause collisions, but:
  31902. * "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"
  31903. * @returns a pseudo random id
  31904. */
  31905. static RandomId(): string;
  31906. /**
  31907. * Test if the given uri is a base64 string
  31908. * @param uri The uri to test
  31909. * @return True if the uri is a base64 string or false otherwise
  31910. */
  31911. static IsBase64(uri: string): boolean;
  31912. /**
  31913. * Decode the given base64 uri.
  31914. * @param uri The uri to decode
  31915. * @return The decoded base64 data.
  31916. */
  31917. static DecodeBase64(uri: string): ArrayBuffer;
  31918. /**
  31919. * Gets the absolute url.
  31920. * @param url the input url
  31921. * @return the absolute url
  31922. */
  31923. static GetAbsoluteUrl(url: string): string;
  31924. /**
  31925. * No log
  31926. */
  31927. static readonly NoneLogLevel: number;
  31928. /**
  31929. * Only message logs
  31930. */
  31931. static readonly MessageLogLevel: number;
  31932. /**
  31933. * Only warning logs
  31934. */
  31935. static readonly WarningLogLevel: number;
  31936. /**
  31937. * Only error logs
  31938. */
  31939. static readonly ErrorLogLevel: number;
  31940. /**
  31941. * All logs
  31942. */
  31943. static readonly AllLogLevel: number;
  31944. /**
  31945. * Gets a value indicating the number of loading errors
  31946. * @ignorenaming
  31947. */
  31948. static readonly errorsCount: number;
  31949. /**
  31950. * Callback called when a new log is added
  31951. */
  31952. static OnNewCacheEntry: (entry: string) => void;
  31953. /**
  31954. * Log a message to the console
  31955. * @param message defines the message to log
  31956. */
  31957. static Log(message: string): void;
  31958. /**
  31959. * Write a warning message to the console
  31960. * @param message defines the message to log
  31961. */
  31962. static Warn(message: string): void;
  31963. /**
  31964. * Write an error message to the console
  31965. * @param message defines the message to log
  31966. */
  31967. static Error(message: string): void;
  31968. /**
  31969. * Gets current log cache (list of logs)
  31970. */
  31971. static readonly LogCache: string;
  31972. /**
  31973. * Clears the log cache
  31974. */
  31975. static ClearLogCache(): void;
  31976. /**
  31977. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31978. */
  31979. static LogLevels: number;
  31980. /**
  31981. * Checks if the window object exists
  31982. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31983. */
  31984. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31985. /**
  31986. * No performance log
  31987. */
  31988. static readonly PerformanceNoneLogLevel: number;
  31989. /**
  31990. * Use user marks to log performance
  31991. */
  31992. static readonly PerformanceUserMarkLogLevel: number;
  31993. /**
  31994. * Log performance to the console
  31995. */
  31996. static readonly PerformanceConsoleLogLevel: number;
  31997. private static _performance;
  31998. /**
  31999. * Sets the current performance log level
  32000. */
  32001. static PerformanceLogLevel: number;
  32002. private static _StartPerformanceCounterDisabled;
  32003. private static _EndPerformanceCounterDisabled;
  32004. private static _StartUserMark;
  32005. private static _EndUserMark;
  32006. private static _StartPerformanceConsole;
  32007. private static _EndPerformanceConsole;
  32008. /**
  32009. * Starts a performance counter
  32010. */
  32011. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32012. /**
  32013. * Ends a specific performance coutner
  32014. */
  32015. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32016. /**
  32017. * Gets either window.performance.now() if supported or Date.now() else
  32018. */
  32019. static readonly Now: number;
  32020. /**
  32021. * This method will return the name of the class used to create the instance of the given object.
  32022. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32023. * @param object the object to get the class name from
  32024. * @param isType defines if the object is actually a type
  32025. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32026. */
  32027. static GetClassName(object: any, isType?: boolean): string;
  32028. /**
  32029. * Gets the first element of an array satisfying a given predicate
  32030. * @param array defines the array to browse
  32031. * @param predicate defines the predicate to use
  32032. * @returns null if not found or the element
  32033. */
  32034. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32035. /**
  32036. * This method will return the name of the full name of the class, including its owning module (if any).
  32037. * 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).
  32038. * @param object the object to get the class name from
  32039. * @param isType defines if the object is actually a type
  32040. * @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.
  32041. * @ignorenaming
  32042. */
  32043. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32044. /**
  32045. * Returns a promise that resolves after the given amount of time.
  32046. * @param delay Number of milliseconds to delay
  32047. * @returns Promise that resolves after the given amount of time
  32048. */
  32049. static DelayAsync(delay: number): Promise<void>;
  32050. }
  32051. /**
  32052. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32053. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32054. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32055. * @param name The name of the class, case should be preserved
  32056. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32057. */
  32058. export function className(name: string, module?: string): (target: Object) => void;
  32059. /**
  32060. * An implementation of a loop for asynchronous functions.
  32061. */
  32062. export class AsyncLoop {
  32063. /**
  32064. * Defines the number of iterations for the loop
  32065. */
  32066. iterations: number;
  32067. /**
  32068. * Defines the current index of the loop.
  32069. */
  32070. index: number;
  32071. private _done;
  32072. private _fn;
  32073. private _successCallback;
  32074. /**
  32075. * Constructor.
  32076. * @param iterations the number of iterations.
  32077. * @param func the function to run each iteration
  32078. * @param successCallback the callback that will be called upon succesful execution
  32079. * @param offset starting offset.
  32080. */
  32081. constructor(
  32082. /**
  32083. * Defines the number of iterations for the loop
  32084. */
  32085. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32086. /**
  32087. * Execute the next iteration. Must be called after the last iteration was finished.
  32088. */
  32089. executeNext(): void;
  32090. /**
  32091. * Break the loop and run the success callback.
  32092. */
  32093. breakLoop(): void;
  32094. /**
  32095. * Create and run an async loop.
  32096. * @param iterations the number of iterations.
  32097. * @param fn the function to run each iteration
  32098. * @param successCallback the callback that will be called upon succesful execution
  32099. * @param offset starting offset.
  32100. * @returns the created async loop object
  32101. */
  32102. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32103. /**
  32104. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32105. * @param iterations total number of iterations
  32106. * @param syncedIterations number of synchronous iterations in each async iteration.
  32107. * @param fn the function to call each iteration.
  32108. * @param callback a success call back that will be called when iterating stops.
  32109. * @param breakFunction a break condition (optional)
  32110. * @param timeout timeout settings for the setTimeout function. default - 0.
  32111. * @returns the created async loop object
  32112. */
  32113. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32114. }
  32115. }
  32116. declare module BABYLON {
  32117. /** @hidden */
  32118. export interface ICollisionCoordinator {
  32119. createCollider(): Collider;
  32120. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32121. init(scene: Scene): void;
  32122. }
  32123. /** @hidden */
  32124. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32125. private _scene;
  32126. private _scaledPosition;
  32127. private _scaledVelocity;
  32128. private _finalPosition;
  32129. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32130. createCollider(): Collider;
  32131. init(scene: Scene): void;
  32132. private _collideWithWorld;
  32133. }
  32134. }
  32135. declare module BABYLON {
  32136. /**
  32137. * Class used to manage all inputs for the scene.
  32138. */
  32139. export class InputManager {
  32140. /** The distance in pixel that you have to move to prevent some events */
  32141. static DragMovementThreshold: number;
  32142. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32143. static LongPressDelay: number;
  32144. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32145. static DoubleClickDelay: number;
  32146. /** If you need to check double click without raising a single click at first click, enable this flag */
  32147. static ExclusiveDoubleClickMode: boolean;
  32148. private _wheelEventName;
  32149. private _onPointerMove;
  32150. private _onPointerDown;
  32151. private _onPointerUp;
  32152. private _initClickEvent;
  32153. private _initActionManager;
  32154. private _delayedSimpleClick;
  32155. private _delayedSimpleClickTimeout;
  32156. private _previousDelayedSimpleClickTimeout;
  32157. private _meshPickProceed;
  32158. private _previousButtonPressed;
  32159. private _currentPickResult;
  32160. private _previousPickResult;
  32161. private _totalPointersPressed;
  32162. private _doubleClickOccured;
  32163. private _pointerOverMesh;
  32164. private _pickedDownMesh;
  32165. private _pickedUpMesh;
  32166. private _pointerX;
  32167. private _pointerY;
  32168. private _unTranslatedPointerX;
  32169. private _unTranslatedPointerY;
  32170. private _startingPointerPosition;
  32171. private _previousStartingPointerPosition;
  32172. private _startingPointerTime;
  32173. private _previousStartingPointerTime;
  32174. private _pointerCaptures;
  32175. private _onKeyDown;
  32176. private _onKeyUp;
  32177. private _onCanvasFocusObserver;
  32178. private _onCanvasBlurObserver;
  32179. private _scene;
  32180. /**
  32181. * Creates a new InputManager
  32182. * @param scene defines the hosting scene
  32183. */
  32184. constructor(scene: Scene);
  32185. /**
  32186. * Gets the mesh that is currently under the pointer
  32187. */
  32188. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32189. /**
  32190. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32191. */
  32192. readonly unTranslatedPointer: Vector2;
  32193. /**
  32194. * Gets or sets the current on-screen X position of the pointer
  32195. */
  32196. pointerX: number;
  32197. /**
  32198. * Gets or sets the current on-screen Y position of the pointer
  32199. */
  32200. pointerY: number;
  32201. private _updatePointerPosition;
  32202. private _processPointerMove;
  32203. private _setRayOnPointerInfo;
  32204. private _checkPrePointerObservable;
  32205. /**
  32206. * Use this method to simulate a pointer move on a mesh
  32207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32210. */
  32211. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32212. /**
  32213. * Use this method to simulate a pointer down on a mesh
  32214. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32215. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32216. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32217. */
  32218. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32219. private _processPointerDown;
  32220. /** @hidden */
  32221. _isPointerSwiping(): boolean;
  32222. /**
  32223. * Use this method to simulate a pointer up on a mesh
  32224. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32225. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32226. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32227. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32228. */
  32229. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32230. private _processPointerUp;
  32231. /**
  32232. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32233. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32234. * @returns true if the pointer was captured
  32235. */
  32236. isPointerCaptured(pointerId?: number): boolean;
  32237. /**
  32238. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32239. * @param attachUp defines if you want to attach events to pointerup
  32240. * @param attachDown defines if you want to attach events to pointerdown
  32241. * @param attachMove defines if you want to attach events to pointermove
  32242. */
  32243. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32244. /**
  32245. * Detaches all event handlers
  32246. */
  32247. detachControl(): void;
  32248. /**
  32249. * Force the value of meshUnderPointer
  32250. * @param mesh defines the mesh to use
  32251. */
  32252. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32253. /**
  32254. * Gets the mesh under the pointer
  32255. * @returns a Mesh or null if no mesh is under the pointer
  32256. */
  32257. getPointerOverMesh(): Nullable<AbstractMesh>;
  32258. }
  32259. }
  32260. declare module BABYLON {
  32261. /**
  32262. * Helper class used to generate session unique ID
  32263. */
  32264. export class UniqueIdGenerator {
  32265. private static _UniqueIdCounter;
  32266. /**
  32267. * Gets an unique (relatively to the current scene) Id
  32268. */
  32269. static readonly UniqueId: number;
  32270. }
  32271. }
  32272. declare module BABYLON {
  32273. /**
  32274. * This class defines the direct association between an animation and a target
  32275. */
  32276. export class TargetedAnimation {
  32277. /**
  32278. * Animation to perform
  32279. */
  32280. animation: Animation;
  32281. /**
  32282. * Target to animate
  32283. */
  32284. target: any;
  32285. /**
  32286. * Serialize the object
  32287. * @returns the JSON object representing the current entity
  32288. */
  32289. serialize(): any;
  32290. }
  32291. /**
  32292. * Use this class to create coordinated animations on multiple targets
  32293. */
  32294. export class AnimationGroup implements IDisposable {
  32295. /** The name of the animation group */
  32296. name: string;
  32297. private _scene;
  32298. private _targetedAnimations;
  32299. private _animatables;
  32300. private _from;
  32301. private _to;
  32302. private _isStarted;
  32303. private _isPaused;
  32304. private _speedRatio;
  32305. private _loopAnimation;
  32306. /**
  32307. * Gets or sets the unique id of the node
  32308. */
  32309. uniqueId: number;
  32310. /**
  32311. * This observable will notify when one animation have ended
  32312. */
  32313. onAnimationEndObservable: Observable<TargetedAnimation>;
  32314. /**
  32315. * Observer raised when one animation loops
  32316. */
  32317. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32318. /**
  32319. * This observable will notify when all animations have ended.
  32320. */
  32321. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32322. /**
  32323. * This observable will notify when all animations have paused.
  32324. */
  32325. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32326. /**
  32327. * This observable will notify when all animations are playing.
  32328. */
  32329. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32330. /**
  32331. * Gets the first frame
  32332. */
  32333. readonly from: number;
  32334. /**
  32335. * Gets the last frame
  32336. */
  32337. readonly to: number;
  32338. /**
  32339. * Define if the animations are started
  32340. */
  32341. readonly isStarted: boolean;
  32342. /**
  32343. * Gets a value indicating that the current group is playing
  32344. */
  32345. readonly isPlaying: boolean;
  32346. /**
  32347. * Gets or sets the speed ratio to use for all animations
  32348. */
  32349. /**
  32350. * Gets or sets the speed ratio to use for all animations
  32351. */
  32352. speedRatio: number;
  32353. /**
  32354. * Gets or sets if all animations should loop or not
  32355. */
  32356. loopAnimation: boolean;
  32357. /**
  32358. * Gets the targeted animations for this animation group
  32359. */
  32360. readonly targetedAnimations: Array<TargetedAnimation>;
  32361. /**
  32362. * returning the list of animatables controlled by this animation group.
  32363. */
  32364. readonly animatables: Array<Animatable>;
  32365. /**
  32366. * Instantiates a new Animation Group.
  32367. * This helps managing several animations at once.
  32368. * @see http://doc.babylonjs.com/how_to/group
  32369. * @param name Defines the name of the group
  32370. * @param scene Defines the scene the group belongs to
  32371. */
  32372. constructor(
  32373. /** The name of the animation group */
  32374. name: string, scene?: Nullable<Scene>);
  32375. /**
  32376. * Add an animation (with its target) in the group
  32377. * @param animation defines the animation we want to add
  32378. * @param target defines the target of the animation
  32379. * @returns the TargetedAnimation object
  32380. */
  32381. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32382. /**
  32383. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32384. * It can add constant keys at begin or end
  32385. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32386. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32387. * @returns the animation group
  32388. */
  32389. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32390. /**
  32391. * Start all animations on given targets
  32392. * @param loop defines if animations must loop
  32393. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32394. * @param from defines the from key (optional)
  32395. * @param to defines the to key (optional)
  32396. * @returns the current animation group
  32397. */
  32398. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32399. /**
  32400. * Pause all animations
  32401. * @returns the animation group
  32402. */
  32403. pause(): AnimationGroup;
  32404. /**
  32405. * Play all animations to initial state
  32406. * This function will start() the animations if they were not started or will restart() them if they were paused
  32407. * @param loop defines if animations must loop
  32408. * @returns the animation group
  32409. */
  32410. play(loop?: boolean): AnimationGroup;
  32411. /**
  32412. * Reset all animations to initial state
  32413. * @returns the animation group
  32414. */
  32415. reset(): AnimationGroup;
  32416. /**
  32417. * Restart animations from key 0
  32418. * @returns the animation group
  32419. */
  32420. restart(): AnimationGroup;
  32421. /**
  32422. * Stop all animations
  32423. * @returns the animation group
  32424. */
  32425. stop(): AnimationGroup;
  32426. /**
  32427. * Set animation weight for all animatables
  32428. * @param weight defines the weight to use
  32429. * @return the animationGroup
  32430. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32431. */
  32432. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32433. /**
  32434. * Synchronize and normalize all animatables with a source animatable
  32435. * @param root defines the root animatable to synchronize with
  32436. * @return the animationGroup
  32437. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32438. */
  32439. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32440. /**
  32441. * Goes to a specific frame in this animation group
  32442. * @param frame the frame number to go to
  32443. * @return the animationGroup
  32444. */
  32445. goToFrame(frame: number): AnimationGroup;
  32446. /**
  32447. * Dispose all associated resources
  32448. */
  32449. dispose(): void;
  32450. private _checkAnimationGroupEnded;
  32451. /**
  32452. * Clone the current animation group and returns a copy
  32453. * @param newName defines the name of the new group
  32454. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32455. * @returns the new aniamtion group
  32456. */
  32457. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32458. /**
  32459. * Serializes the animationGroup to an object
  32460. * @returns Serialized object
  32461. */
  32462. serialize(): any;
  32463. /**
  32464. * Returns a new AnimationGroup object parsed from the source provided.
  32465. * @param parsedAnimationGroup defines the source
  32466. * @param scene defines the scene that will receive the animationGroup
  32467. * @returns a new AnimationGroup
  32468. */
  32469. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32470. /**
  32471. * Returns the string "AnimationGroup"
  32472. * @returns "AnimationGroup"
  32473. */
  32474. getClassName(): string;
  32475. /**
  32476. * Creates a detailled string about the object
  32477. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32478. * @returns a string representing the object
  32479. */
  32480. toString(fullDetails?: boolean): string;
  32481. }
  32482. }
  32483. declare module BABYLON {
  32484. /**
  32485. * Define an interface for all classes that will hold resources
  32486. */
  32487. export interface IDisposable {
  32488. /**
  32489. * Releases all held resources
  32490. */
  32491. dispose(): void;
  32492. }
  32493. /** Interface defining initialization parameters for Scene class */
  32494. export interface SceneOptions {
  32495. /**
  32496. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32497. * It will improve performance when the number of geometries becomes important.
  32498. */
  32499. useGeometryUniqueIdsMap?: boolean;
  32500. /**
  32501. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32502. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32503. */
  32504. useMaterialMeshMap?: boolean;
  32505. /**
  32506. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32507. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32508. */
  32509. useClonedMeshhMap?: boolean;
  32510. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32511. virtual?: boolean;
  32512. }
  32513. /**
  32514. * Represents a scene to be rendered by the engine.
  32515. * @see http://doc.babylonjs.com/features/scene
  32516. */
  32517. export class Scene extends AbstractScene implements IAnimatable {
  32518. /** The fog is deactivated */
  32519. static readonly FOGMODE_NONE: number;
  32520. /** The fog density is following an exponential function */
  32521. static readonly FOGMODE_EXP: number;
  32522. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32523. static readonly FOGMODE_EXP2: number;
  32524. /** The fog density is following a linear function. */
  32525. static readonly FOGMODE_LINEAR: number;
  32526. /**
  32527. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32529. */
  32530. static MinDeltaTime: number;
  32531. /**
  32532. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32534. */
  32535. static MaxDeltaTime: number;
  32536. /**
  32537. * Factory used to create the default material.
  32538. * @param name The name of the material to create
  32539. * @param scene The scene to create the material for
  32540. * @returns The default material
  32541. */
  32542. static DefaultMaterialFactory(scene: Scene): Material;
  32543. /**
  32544. * Factory used to create the a collision coordinator.
  32545. * @returns The collision coordinator
  32546. */
  32547. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32548. /** @hidden */
  32549. _inputManager: InputManager;
  32550. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32551. cameraToUseForPointers: Nullable<Camera>;
  32552. /** @hidden */
  32553. readonly _isScene: boolean;
  32554. /**
  32555. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32556. */
  32557. autoClear: boolean;
  32558. /**
  32559. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32560. */
  32561. autoClearDepthAndStencil: boolean;
  32562. /**
  32563. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32564. */
  32565. clearColor: Color4;
  32566. /**
  32567. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32568. */
  32569. ambientColor: Color3;
  32570. /**
  32571. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32572. * It should only be one of the following (if not the default embedded one):
  32573. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32574. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32575. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32576. * The material properties need to be setup according to the type of texture in use.
  32577. */
  32578. environmentBRDFTexture: BaseTexture;
  32579. /** @hidden */
  32580. protected _environmentTexture: Nullable<BaseTexture>;
  32581. /**
  32582. * Texture used in all pbr material as the reflection texture.
  32583. * As in the majority of the scene they are the same (exception for multi room and so on),
  32584. * this is easier to reference from here than from all the materials.
  32585. */
  32586. /**
  32587. * Texture used in all pbr material as the reflection texture.
  32588. * As in the majority of the scene they are the same (exception for multi room and so on),
  32589. * this is easier to set here than in all the materials.
  32590. */
  32591. environmentTexture: Nullable<BaseTexture>;
  32592. /** @hidden */
  32593. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32594. /**
  32595. * Default image processing configuration used either in the rendering
  32596. * Forward main pass or through the imageProcessingPostProcess if present.
  32597. * As in the majority of the scene they are the same (exception for multi camera),
  32598. * this is easier to reference from here than from all the materials and post process.
  32599. *
  32600. * No setter as we it is a shared configuration, you can set the values instead.
  32601. */
  32602. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32603. private _forceWireframe;
  32604. /**
  32605. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32606. */
  32607. forceWireframe: boolean;
  32608. private _forcePointsCloud;
  32609. /**
  32610. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32611. */
  32612. forcePointsCloud: boolean;
  32613. /**
  32614. * Gets or sets the active clipplane 1
  32615. */
  32616. clipPlane: Nullable<Plane>;
  32617. /**
  32618. * Gets or sets the active clipplane 2
  32619. */
  32620. clipPlane2: Nullable<Plane>;
  32621. /**
  32622. * Gets or sets the active clipplane 3
  32623. */
  32624. clipPlane3: Nullable<Plane>;
  32625. /**
  32626. * Gets or sets the active clipplane 4
  32627. */
  32628. clipPlane4: Nullable<Plane>;
  32629. /**
  32630. * Gets or sets a boolean indicating if animations are enabled
  32631. */
  32632. animationsEnabled: boolean;
  32633. private _animationPropertiesOverride;
  32634. /**
  32635. * Gets or sets the animation properties override
  32636. */
  32637. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32638. /**
  32639. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32640. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32641. */
  32642. useConstantAnimationDeltaTime: boolean;
  32643. /**
  32644. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32645. * Please note that it requires to run a ray cast through the scene on every frame
  32646. */
  32647. constantlyUpdateMeshUnderPointer: boolean;
  32648. /**
  32649. * Defines the HTML cursor to use when hovering over interactive elements
  32650. */
  32651. hoverCursor: string;
  32652. /**
  32653. * Defines the HTML default cursor to use (empty by default)
  32654. */
  32655. defaultCursor: string;
  32656. /**
  32657. * This is used to call preventDefault() on pointer down
  32658. * in order to block unwanted artifacts like system double clicks
  32659. */
  32660. preventDefaultOnPointerDown: boolean;
  32661. /**
  32662. * This is used to call preventDefault() on pointer up
  32663. * in order to block unwanted artifacts like system double clicks
  32664. */
  32665. preventDefaultOnPointerUp: boolean;
  32666. /**
  32667. * Gets or sets user defined metadata
  32668. */
  32669. metadata: any;
  32670. /**
  32671. * For internal use only. Please do not use.
  32672. */
  32673. reservedDataStore: any;
  32674. /**
  32675. * Gets the name of the plugin used to load this scene (null by default)
  32676. */
  32677. loadingPluginName: string;
  32678. /**
  32679. * Use this array to add regular expressions used to disable offline support for specific urls
  32680. */
  32681. disableOfflineSupportExceptionRules: RegExp[];
  32682. /**
  32683. * An event triggered when the scene is disposed.
  32684. */
  32685. onDisposeObservable: Observable<Scene>;
  32686. private _onDisposeObserver;
  32687. /** Sets a function to be executed when this scene is disposed. */
  32688. onDispose: () => void;
  32689. /**
  32690. * An event triggered before rendering the scene (right after animations and physics)
  32691. */
  32692. onBeforeRenderObservable: Observable<Scene>;
  32693. private _onBeforeRenderObserver;
  32694. /** Sets a function to be executed before rendering this scene */
  32695. beforeRender: Nullable<() => void>;
  32696. /**
  32697. * An event triggered after rendering the scene
  32698. */
  32699. onAfterRenderObservable: Observable<Scene>;
  32700. /**
  32701. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32702. */
  32703. onAfterRenderCameraObservable: Observable<Camera>;
  32704. private _onAfterRenderObserver;
  32705. /** Sets a function to be executed after rendering this scene */
  32706. afterRender: Nullable<() => void>;
  32707. /**
  32708. * An event triggered before animating the scene
  32709. */
  32710. onBeforeAnimationsObservable: Observable<Scene>;
  32711. /**
  32712. * An event triggered after animations processing
  32713. */
  32714. onAfterAnimationsObservable: Observable<Scene>;
  32715. /**
  32716. * An event triggered before draw calls are ready to be sent
  32717. */
  32718. onBeforeDrawPhaseObservable: Observable<Scene>;
  32719. /**
  32720. * An event triggered after draw calls have been sent
  32721. */
  32722. onAfterDrawPhaseObservable: Observable<Scene>;
  32723. /**
  32724. * An event triggered when the scene is ready
  32725. */
  32726. onReadyObservable: Observable<Scene>;
  32727. /**
  32728. * An event triggered before rendering a camera
  32729. */
  32730. onBeforeCameraRenderObservable: Observable<Camera>;
  32731. private _onBeforeCameraRenderObserver;
  32732. /** Sets a function to be executed before rendering a camera*/
  32733. beforeCameraRender: () => void;
  32734. /**
  32735. * An event triggered after rendering a camera
  32736. */
  32737. onAfterCameraRenderObservable: Observable<Camera>;
  32738. private _onAfterCameraRenderObserver;
  32739. /** Sets a function to be executed after rendering a camera*/
  32740. afterCameraRender: () => void;
  32741. /**
  32742. * An event triggered when active meshes evaluation is about to start
  32743. */
  32744. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32745. /**
  32746. * An event triggered when active meshes evaluation is done
  32747. */
  32748. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32749. /**
  32750. * An event triggered when particles rendering is about to start
  32751. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32752. */
  32753. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32754. /**
  32755. * An event triggered when particles rendering is done
  32756. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32757. */
  32758. onAfterParticlesRenderingObservable: Observable<Scene>;
  32759. /**
  32760. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32761. */
  32762. onDataLoadedObservable: Observable<Scene>;
  32763. /**
  32764. * An event triggered when a camera is created
  32765. */
  32766. onNewCameraAddedObservable: Observable<Camera>;
  32767. /**
  32768. * An event triggered when a camera is removed
  32769. */
  32770. onCameraRemovedObservable: Observable<Camera>;
  32771. /**
  32772. * An event triggered when a light is created
  32773. */
  32774. onNewLightAddedObservable: Observable<Light>;
  32775. /**
  32776. * An event triggered when a light is removed
  32777. */
  32778. onLightRemovedObservable: Observable<Light>;
  32779. /**
  32780. * An event triggered when a geometry is created
  32781. */
  32782. onNewGeometryAddedObservable: Observable<Geometry>;
  32783. /**
  32784. * An event triggered when a geometry is removed
  32785. */
  32786. onGeometryRemovedObservable: Observable<Geometry>;
  32787. /**
  32788. * An event triggered when a transform node is created
  32789. */
  32790. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32791. /**
  32792. * An event triggered when a transform node is removed
  32793. */
  32794. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32795. /**
  32796. * An event triggered when a mesh is created
  32797. */
  32798. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32799. /**
  32800. * An event triggered when a mesh is removed
  32801. */
  32802. onMeshRemovedObservable: Observable<AbstractMesh>;
  32803. /**
  32804. * An event triggered when a skeleton is created
  32805. */
  32806. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32807. /**
  32808. * An event triggered when a skeleton is removed
  32809. */
  32810. onSkeletonRemovedObservable: Observable<Skeleton>;
  32811. /**
  32812. * An event triggered when a material is created
  32813. */
  32814. onNewMaterialAddedObservable: Observable<Material>;
  32815. /**
  32816. * An event triggered when a material is removed
  32817. */
  32818. onMaterialRemovedObservable: Observable<Material>;
  32819. /**
  32820. * An event triggered when a texture is created
  32821. */
  32822. onNewTextureAddedObservable: Observable<BaseTexture>;
  32823. /**
  32824. * An event triggered when a texture is removed
  32825. */
  32826. onTextureRemovedObservable: Observable<BaseTexture>;
  32827. /**
  32828. * An event triggered when render targets are about to be rendered
  32829. * Can happen multiple times per frame.
  32830. */
  32831. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32832. /**
  32833. * An event triggered when render targets were rendered.
  32834. * Can happen multiple times per frame.
  32835. */
  32836. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32837. /**
  32838. * An event triggered before calculating deterministic simulation step
  32839. */
  32840. onBeforeStepObservable: Observable<Scene>;
  32841. /**
  32842. * An event triggered after calculating deterministic simulation step
  32843. */
  32844. onAfterStepObservable: Observable<Scene>;
  32845. /**
  32846. * An event triggered when the activeCamera property is updated
  32847. */
  32848. onActiveCameraChanged: Observable<Scene>;
  32849. /**
  32850. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32851. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32852. * 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)
  32853. */
  32854. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32855. /**
  32856. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32857. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32858. * 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)
  32859. */
  32860. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32861. /**
  32862. * This Observable will when a mesh has been imported into the scene.
  32863. */
  32864. onMeshImportedObservable: Observable<AbstractMesh>;
  32865. /**
  32866. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32867. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32868. */
  32869. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32870. /** @hidden */
  32871. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32872. /**
  32873. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32874. */
  32875. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32876. /**
  32877. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32878. */
  32879. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32880. /**
  32881. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32882. */
  32883. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32884. /** Callback called when a pointer move is detected */
  32885. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32886. /** Callback called when a pointer down is detected */
  32887. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32888. /** Callback called when a pointer up is detected */
  32889. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32890. /** Callback called when a pointer pick is detected */
  32891. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32892. /**
  32893. * 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).
  32894. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32895. */
  32896. onPrePointerObservable: Observable<PointerInfoPre>;
  32897. /**
  32898. * Observable event triggered each time an input event is received from the rendering canvas
  32899. */
  32900. onPointerObservable: Observable<PointerInfo>;
  32901. /**
  32902. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32903. */
  32904. readonly unTranslatedPointer: Vector2;
  32905. /**
  32906. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32907. */
  32908. static DragMovementThreshold: number;
  32909. /**
  32910. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32911. */
  32912. static LongPressDelay: number;
  32913. /**
  32914. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32915. */
  32916. static DoubleClickDelay: number;
  32917. /** If you need to check double click without raising a single click at first click, enable this flag */
  32918. static ExclusiveDoubleClickMode: boolean;
  32919. /** @hidden */
  32920. _mirroredCameraPosition: Nullable<Vector3>;
  32921. /**
  32922. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32923. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32924. */
  32925. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32926. /**
  32927. * Observable event triggered each time an keyboard event is received from the hosting window
  32928. */
  32929. onKeyboardObservable: Observable<KeyboardInfo>;
  32930. private _useRightHandedSystem;
  32931. /**
  32932. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32933. */
  32934. useRightHandedSystem: boolean;
  32935. private _timeAccumulator;
  32936. private _currentStepId;
  32937. private _currentInternalStep;
  32938. /**
  32939. * Sets the step Id used by deterministic lock step
  32940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32941. * @param newStepId defines the step Id
  32942. */
  32943. setStepId(newStepId: number): void;
  32944. /**
  32945. * Gets the step Id used by deterministic lock step
  32946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32947. * @returns the step Id
  32948. */
  32949. getStepId(): number;
  32950. /**
  32951. * Gets the internal step used by deterministic lock step
  32952. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32953. * @returns the internal step
  32954. */
  32955. getInternalStep(): number;
  32956. private _fogEnabled;
  32957. /**
  32958. * Gets or sets a boolean indicating if fog is enabled on this scene
  32959. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32960. * (Default is true)
  32961. */
  32962. fogEnabled: boolean;
  32963. private _fogMode;
  32964. /**
  32965. * Gets or sets the fog mode to use
  32966. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32967. * | mode | value |
  32968. * | --- | --- |
  32969. * | FOGMODE_NONE | 0 |
  32970. * | FOGMODE_EXP | 1 |
  32971. * | FOGMODE_EXP2 | 2 |
  32972. * | FOGMODE_LINEAR | 3 |
  32973. */
  32974. fogMode: number;
  32975. /**
  32976. * Gets or sets the fog color to use
  32977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32978. * (Default is Color3(0.2, 0.2, 0.3))
  32979. */
  32980. fogColor: Color3;
  32981. /**
  32982. * Gets or sets the fog density to use
  32983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32984. * (Default is 0.1)
  32985. */
  32986. fogDensity: number;
  32987. /**
  32988. * Gets or sets the fog start distance to use
  32989. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32990. * (Default is 0)
  32991. */
  32992. fogStart: number;
  32993. /**
  32994. * Gets or sets the fog end distance to use
  32995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32996. * (Default is 1000)
  32997. */
  32998. fogEnd: number;
  32999. private _shadowsEnabled;
  33000. /**
  33001. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33002. */
  33003. shadowsEnabled: boolean;
  33004. private _lightsEnabled;
  33005. /**
  33006. * Gets or sets a boolean indicating if lights are enabled on this scene
  33007. */
  33008. lightsEnabled: boolean;
  33009. /** All of the active cameras added to this scene. */
  33010. activeCameras: Camera[];
  33011. /** @hidden */
  33012. _activeCamera: Nullable<Camera>;
  33013. /** Gets or sets the current active camera */
  33014. activeCamera: Nullable<Camera>;
  33015. private _defaultMaterial;
  33016. /** The default material used on meshes when no material is affected */
  33017. /** The default material used on meshes when no material is affected */
  33018. defaultMaterial: Material;
  33019. private _texturesEnabled;
  33020. /**
  33021. * Gets or sets a boolean indicating if textures are enabled on this scene
  33022. */
  33023. texturesEnabled: boolean;
  33024. /**
  33025. * Gets or sets a boolean indicating if particles are enabled on this scene
  33026. */
  33027. particlesEnabled: boolean;
  33028. /**
  33029. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33030. */
  33031. spritesEnabled: boolean;
  33032. private _skeletonsEnabled;
  33033. /**
  33034. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33035. */
  33036. skeletonsEnabled: boolean;
  33037. /**
  33038. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33039. */
  33040. lensFlaresEnabled: boolean;
  33041. /**
  33042. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33044. */
  33045. collisionsEnabled: boolean;
  33046. private _collisionCoordinator;
  33047. /** @hidden */
  33048. readonly collisionCoordinator: ICollisionCoordinator;
  33049. /**
  33050. * Defines the gravity applied to this scene (used only for collisions)
  33051. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33052. */
  33053. gravity: Vector3;
  33054. /**
  33055. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33056. */
  33057. postProcessesEnabled: boolean;
  33058. /**
  33059. * The list of postprocesses added to the scene
  33060. */
  33061. postProcesses: PostProcess[];
  33062. /**
  33063. * Gets the current postprocess manager
  33064. */
  33065. postProcessManager: PostProcessManager;
  33066. /**
  33067. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33068. */
  33069. renderTargetsEnabled: boolean;
  33070. /**
  33071. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33072. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33073. */
  33074. dumpNextRenderTargets: boolean;
  33075. /**
  33076. * The list of user defined render targets added to the scene
  33077. */
  33078. customRenderTargets: RenderTargetTexture[];
  33079. /**
  33080. * Defines if texture loading must be delayed
  33081. * If true, textures will only be loaded when they need to be rendered
  33082. */
  33083. useDelayedTextureLoading: boolean;
  33084. /**
  33085. * Gets the list of meshes imported to the scene through SceneLoader
  33086. */
  33087. importedMeshesFiles: String[];
  33088. /**
  33089. * Gets or sets a boolean indicating if probes are enabled on this scene
  33090. */
  33091. probesEnabled: boolean;
  33092. /**
  33093. * Gets or sets the current offline provider to use to store scene data
  33094. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33095. */
  33096. offlineProvider: IOfflineProvider;
  33097. /**
  33098. * Gets or sets the action manager associated with the scene
  33099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33100. */
  33101. actionManager: AbstractActionManager;
  33102. private _meshesForIntersections;
  33103. /**
  33104. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33105. */
  33106. proceduralTexturesEnabled: boolean;
  33107. private _engine;
  33108. private _totalVertices;
  33109. /** @hidden */
  33110. _activeIndices: PerfCounter;
  33111. /** @hidden */
  33112. _activeParticles: PerfCounter;
  33113. /** @hidden */
  33114. _activeBones: PerfCounter;
  33115. private _animationRatio;
  33116. /** @hidden */
  33117. _animationTimeLast: number;
  33118. /** @hidden */
  33119. _animationTime: number;
  33120. /**
  33121. * Gets or sets a general scale for animation speed
  33122. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33123. */
  33124. animationTimeScale: number;
  33125. /** @hidden */
  33126. _cachedMaterial: Nullable<Material>;
  33127. /** @hidden */
  33128. _cachedEffect: Nullable<Effect>;
  33129. /** @hidden */
  33130. _cachedVisibility: Nullable<number>;
  33131. private _renderId;
  33132. private _frameId;
  33133. private _executeWhenReadyTimeoutId;
  33134. private _intermediateRendering;
  33135. private _viewUpdateFlag;
  33136. private _projectionUpdateFlag;
  33137. /** @hidden */
  33138. _toBeDisposed: Nullable<IDisposable>[];
  33139. private _activeRequests;
  33140. /** @hidden */
  33141. _pendingData: any[];
  33142. private _isDisposed;
  33143. /**
  33144. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33145. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33146. */
  33147. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33148. private _activeMeshes;
  33149. private _processedMaterials;
  33150. private _renderTargets;
  33151. /** @hidden */
  33152. _activeParticleSystems: SmartArray<IParticleSystem>;
  33153. private _activeSkeletons;
  33154. private _softwareSkinnedMeshes;
  33155. private _renderingManager;
  33156. /** @hidden */
  33157. _activeAnimatables: Animatable[];
  33158. private _transformMatrix;
  33159. private _sceneUbo;
  33160. /** @hidden */
  33161. _viewMatrix: Matrix;
  33162. private _projectionMatrix;
  33163. /** @hidden */
  33164. _forcedViewPosition: Nullable<Vector3>;
  33165. /** @hidden */
  33166. _frustumPlanes: Plane[];
  33167. /**
  33168. * Gets the list of frustum planes (built from the active camera)
  33169. */
  33170. readonly frustumPlanes: Plane[];
  33171. /**
  33172. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33173. * This is useful if there are more lights that the maximum simulteanous authorized
  33174. */
  33175. requireLightSorting: boolean;
  33176. /** @hidden */
  33177. readonly useMaterialMeshMap: boolean;
  33178. /** @hidden */
  33179. readonly useClonedMeshhMap: boolean;
  33180. private _externalData;
  33181. private _uid;
  33182. /**
  33183. * @hidden
  33184. * Backing store of defined scene components.
  33185. */
  33186. _components: ISceneComponent[];
  33187. /**
  33188. * @hidden
  33189. * Backing store of defined scene components.
  33190. */
  33191. _serializableComponents: ISceneSerializableComponent[];
  33192. /**
  33193. * List of components to register on the next registration step.
  33194. */
  33195. private _transientComponents;
  33196. /**
  33197. * Registers the transient components if needed.
  33198. */
  33199. private _registerTransientComponents;
  33200. /**
  33201. * @hidden
  33202. * Add a component to the scene.
  33203. * Note that the ccomponent could be registered on th next frame if this is called after
  33204. * the register component stage.
  33205. * @param component Defines the component to add to the scene
  33206. */
  33207. _addComponent(component: ISceneComponent): void;
  33208. /**
  33209. * @hidden
  33210. * Gets a component from the scene.
  33211. * @param name defines the name of the component to retrieve
  33212. * @returns the component or null if not present
  33213. */
  33214. _getComponent(name: string): Nullable<ISceneComponent>;
  33215. /**
  33216. * @hidden
  33217. * Defines the actions happening before camera updates.
  33218. */
  33219. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33220. /**
  33221. * @hidden
  33222. * Defines the actions happening before clear the canvas.
  33223. */
  33224. _beforeClearStage: Stage<SimpleStageAction>;
  33225. /**
  33226. * @hidden
  33227. * Defines the actions when collecting render targets for the frame.
  33228. */
  33229. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33230. /**
  33231. * @hidden
  33232. * Defines the actions happening for one camera in the frame.
  33233. */
  33234. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33235. /**
  33236. * @hidden
  33237. * Defines the actions happening during the per mesh ready checks.
  33238. */
  33239. _isReadyForMeshStage: Stage<MeshStageAction>;
  33240. /**
  33241. * @hidden
  33242. * Defines the actions happening before evaluate active mesh checks.
  33243. */
  33244. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33245. /**
  33246. * @hidden
  33247. * Defines the actions happening during the evaluate sub mesh checks.
  33248. */
  33249. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33250. /**
  33251. * @hidden
  33252. * Defines the actions happening during the active mesh stage.
  33253. */
  33254. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33255. /**
  33256. * @hidden
  33257. * Defines the actions happening during the per camera render target step.
  33258. */
  33259. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33260. /**
  33261. * @hidden
  33262. * Defines the actions happening just before the active camera is drawing.
  33263. */
  33264. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33265. /**
  33266. * @hidden
  33267. * Defines the actions happening just before a render target is drawing.
  33268. */
  33269. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33270. /**
  33271. * @hidden
  33272. * Defines the actions happening just before a rendering group is drawing.
  33273. */
  33274. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33275. /**
  33276. * @hidden
  33277. * Defines the actions happening just before a mesh is drawing.
  33278. */
  33279. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33280. /**
  33281. * @hidden
  33282. * Defines the actions happening just after a mesh has been drawn.
  33283. */
  33284. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33285. /**
  33286. * @hidden
  33287. * Defines the actions happening just after a rendering group has been drawn.
  33288. */
  33289. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33290. /**
  33291. * @hidden
  33292. * Defines the actions happening just after the active camera has been drawn.
  33293. */
  33294. _afterCameraDrawStage: Stage<CameraStageAction>;
  33295. /**
  33296. * @hidden
  33297. * Defines the actions happening just after a render target has been drawn.
  33298. */
  33299. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33300. /**
  33301. * @hidden
  33302. * Defines the actions happening just after rendering all cameras and computing intersections.
  33303. */
  33304. _afterRenderStage: Stage<SimpleStageAction>;
  33305. /**
  33306. * @hidden
  33307. * Defines the actions happening when a pointer move event happens.
  33308. */
  33309. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33310. /**
  33311. * @hidden
  33312. * Defines the actions happening when a pointer down event happens.
  33313. */
  33314. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33315. /**
  33316. * @hidden
  33317. * Defines the actions happening when a pointer up event happens.
  33318. */
  33319. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33320. /**
  33321. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33322. */
  33323. private geometriesByUniqueId;
  33324. /**
  33325. * Creates a new Scene
  33326. * @param engine defines the engine to use to render this scene
  33327. * @param options defines the scene options
  33328. */
  33329. constructor(engine: Engine, options?: SceneOptions);
  33330. /**
  33331. * Gets a string idenfifying the name of the class
  33332. * @returns "Scene" string
  33333. */
  33334. getClassName(): string;
  33335. private _defaultMeshCandidates;
  33336. /**
  33337. * @hidden
  33338. */
  33339. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33340. private _defaultSubMeshCandidates;
  33341. /**
  33342. * @hidden
  33343. */
  33344. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33345. /**
  33346. * Sets the default candidate providers for the scene.
  33347. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33348. * and getCollidingSubMeshCandidates to their default function
  33349. */
  33350. setDefaultCandidateProviders(): void;
  33351. /**
  33352. * Gets the mesh that is currently under the pointer
  33353. */
  33354. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33355. /**
  33356. * Gets or sets the current on-screen X position of the pointer
  33357. */
  33358. pointerX: number;
  33359. /**
  33360. * Gets or sets the current on-screen Y position of the pointer
  33361. */
  33362. pointerY: number;
  33363. /**
  33364. * Gets the cached material (ie. the latest rendered one)
  33365. * @returns the cached material
  33366. */
  33367. getCachedMaterial(): Nullable<Material>;
  33368. /**
  33369. * Gets the cached effect (ie. the latest rendered one)
  33370. * @returns the cached effect
  33371. */
  33372. getCachedEffect(): Nullable<Effect>;
  33373. /**
  33374. * Gets the cached visibility state (ie. the latest rendered one)
  33375. * @returns the cached visibility state
  33376. */
  33377. getCachedVisibility(): Nullable<number>;
  33378. /**
  33379. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33380. * @param material defines the current material
  33381. * @param effect defines the current effect
  33382. * @param visibility defines the current visibility state
  33383. * @returns true if one parameter is not cached
  33384. */
  33385. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33386. /**
  33387. * Gets the engine associated with the scene
  33388. * @returns an Engine
  33389. */
  33390. getEngine(): Engine;
  33391. /**
  33392. * Gets the total number of vertices rendered per frame
  33393. * @returns the total number of vertices rendered per frame
  33394. */
  33395. getTotalVertices(): number;
  33396. /**
  33397. * Gets the performance counter for total vertices
  33398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33399. */
  33400. readonly totalVerticesPerfCounter: PerfCounter;
  33401. /**
  33402. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33403. * @returns the total number of active indices rendered per frame
  33404. */
  33405. getActiveIndices(): number;
  33406. /**
  33407. * Gets the performance counter for active indices
  33408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33409. */
  33410. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33411. /**
  33412. * Gets the total number of active particles rendered per frame
  33413. * @returns the total number of active particles rendered per frame
  33414. */
  33415. getActiveParticles(): number;
  33416. /**
  33417. * Gets the performance counter for active particles
  33418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33419. */
  33420. readonly activeParticlesPerfCounter: PerfCounter;
  33421. /**
  33422. * Gets the total number of active bones rendered per frame
  33423. * @returns the total number of active bones rendered per frame
  33424. */
  33425. getActiveBones(): number;
  33426. /**
  33427. * Gets the performance counter for active bones
  33428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33429. */
  33430. readonly activeBonesPerfCounter: PerfCounter;
  33431. /**
  33432. * Gets the array of active meshes
  33433. * @returns an array of AbstractMesh
  33434. */
  33435. getActiveMeshes(): SmartArray<AbstractMesh>;
  33436. /**
  33437. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33438. * @returns a number
  33439. */
  33440. getAnimationRatio(): number;
  33441. /**
  33442. * Gets an unique Id for the current render phase
  33443. * @returns a number
  33444. */
  33445. getRenderId(): number;
  33446. /**
  33447. * Gets an unique Id for the current frame
  33448. * @returns a number
  33449. */
  33450. getFrameId(): number;
  33451. /** Call this function if you want to manually increment the render Id*/
  33452. incrementRenderId(): void;
  33453. private _createUbo;
  33454. /**
  33455. * Use this method to simulate a pointer move on a mesh
  33456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33459. * @returns the current scene
  33460. */
  33461. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33462. /**
  33463. * Use this method to simulate a pointer down on a mesh
  33464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33467. * @returns the current scene
  33468. */
  33469. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33470. /**
  33471. * Use this method to simulate a pointer up on a mesh
  33472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33475. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33476. * @returns the current scene
  33477. */
  33478. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33479. /**
  33480. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33481. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33482. * @returns true if the pointer was captured
  33483. */
  33484. isPointerCaptured(pointerId?: number): boolean;
  33485. /**
  33486. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33487. * @param attachUp defines if you want to attach events to pointerup
  33488. * @param attachDown defines if you want to attach events to pointerdown
  33489. * @param attachMove defines if you want to attach events to pointermove
  33490. */
  33491. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33492. /** Detaches all event handlers*/
  33493. detachControl(): void;
  33494. /**
  33495. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33496. * Delay loaded resources are not taking in account
  33497. * @return true if all required resources are ready
  33498. */
  33499. isReady(): boolean;
  33500. /** Resets all cached information relative to material (including effect and visibility) */
  33501. resetCachedMaterial(): void;
  33502. /**
  33503. * Registers a function to be called before every frame render
  33504. * @param func defines the function to register
  33505. */
  33506. registerBeforeRender(func: () => void): void;
  33507. /**
  33508. * Unregisters a function called before every frame render
  33509. * @param func defines the function to unregister
  33510. */
  33511. unregisterBeforeRender(func: () => void): void;
  33512. /**
  33513. * Registers a function to be called after every frame render
  33514. * @param func defines the function to register
  33515. */
  33516. registerAfterRender(func: () => void): void;
  33517. /**
  33518. * Unregisters a function called after every frame render
  33519. * @param func defines the function to unregister
  33520. */
  33521. unregisterAfterRender(func: () => void): void;
  33522. private _executeOnceBeforeRender;
  33523. /**
  33524. * The provided function will run before render once and will be disposed afterwards.
  33525. * A timeout delay can be provided so that the function will be executed in N ms.
  33526. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33527. * @param func The function to be executed.
  33528. * @param timeout optional delay in ms
  33529. */
  33530. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33531. /** @hidden */
  33532. _addPendingData(data: any): void;
  33533. /** @hidden */
  33534. _removePendingData(data: any): void;
  33535. /**
  33536. * Returns the number of items waiting to be loaded
  33537. * @returns the number of items waiting to be loaded
  33538. */
  33539. getWaitingItemsCount(): number;
  33540. /**
  33541. * Returns a boolean indicating if the scene is still loading data
  33542. */
  33543. readonly isLoading: boolean;
  33544. /**
  33545. * Registers a function to be executed when the scene is ready
  33546. * @param {Function} func - the function to be executed
  33547. */
  33548. executeWhenReady(func: () => void): void;
  33549. /**
  33550. * Returns a promise that resolves when the scene is ready
  33551. * @returns A promise that resolves when the scene is ready
  33552. */
  33553. whenReadyAsync(): Promise<void>;
  33554. /** @hidden */
  33555. _checkIsReady(): void;
  33556. /**
  33557. * Gets all animatable attached to the scene
  33558. */
  33559. readonly animatables: Animatable[];
  33560. /**
  33561. * Resets the last animation time frame.
  33562. * Useful to override when animations start running when loading a scene for the first time.
  33563. */
  33564. resetLastAnimationTimeFrame(): void;
  33565. /**
  33566. * Gets the current view matrix
  33567. * @returns a Matrix
  33568. */
  33569. getViewMatrix(): Matrix;
  33570. /**
  33571. * Gets the current projection matrix
  33572. * @returns a Matrix
  33573. */
  33574. getProjectionMatrix(): Matrix;
  33575. /**
  33576. * Gets the current transform matrix
  33577. * @returns a Matrix made of View * Projection
  33578. */
  33579. getTransformMatrix(): Matrix;
  33580. /**
  33581. * Sets the current transform matrix
  33582. * @param viewL defines the View matrix to use
  33583. * @param projectionL defines the Projection matrix to use
  33584. * @param viewR defines the right View matrix to use (if provided)
  33585. * @param projectionR defines the right Projection matrix to use (if provided)
  33586. */
  33587. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33588. /**
  33589. * Gets the uniform buffer used to store scene data
  33590. * @returns a UniformBuffer
  33591. */
  33592. getSceneUniformBuffer(): UniformBuffer;
  33593. /**
  33594. * Gets an unique (relatively to the current scene) Id
  33595. * @returns an unique number for the scene
  33596. */
  33597. getUniqueId(): number;
  33598. /**
  33599. * Add a mesh to the list of scene's meshes
  33600. * @param newMesh defines the mesh to add
  33601. * @param recursive if all child meshes should also be added to the scene
  33602. */
  33603. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33604. /**
  33605. * Remove a mesh for the list of scene's meshes
  33606. * @param toRemove defines the mesh to remove
  33607. * @param recursive if all child meshes should also be removed from the scene
  33608. * @returns the index where the mesh was in the mesh list
  33609. */
  33610. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33611. /**
  33612. * Add a transform node to the list of scene's transform nodes
  33613. * @param newTransformNode defines the transform node to add
  33614. */
  33615. addTransformNode(newTransformNode: TransformNode): void;
  33616. /**
  33617. * Remove a transform node for the list of scene's transform nodes
  33618. * @param toRemove defines the transform node to remove
  33619. * @returns the index where the transform node was in the transform node list
  33620. */
  33621. removeTransformNode(toRemove: TransformNode): number;
  33622. /**
  33623. * Remove a skeleton for the list of scene's skeletons
  33624. * @param toRemove defines the skeleton to remove
  33625. * @returns the index where the skeleton was in the skeleton list
  33626. */
  33627. removeSkeleton(toRemove: Skeleton): number;
  33628. /**
  33629. * Remove a morph target for the list of scene's morph targets
  33630. * @param toRemove defines the morph target to remove
  33631. * @returns the index where the morph target was in the morph target list
  33632. */
  33633. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33634. /**
  33635. * Remove a light for the list of scene's lights
  33636. * @param toRemove defines the light to remove
  33637. * @returns the index where the light was in the light list
  33638. */
  33639. removeLight(toRemove: Light): number;
  33640. /**
  33641. * Remove a camera for the list of scene's cameras
  33642. * @param toRemove defines the camera to remove
  33643. * @returns the index where the camera was in the camera list
  33644. */
  33645. removeCamera(toRemove: Camera): number;
  33646. /**
  33647. * Remove a particle system for the list of scene's particle systems
  33648. * @param toRemove defines the particle system to remove
  33649. * @returns the index where the particle system was in the particle system list
  33650. */
  33651. removeParticleSystem(toRemove: IParticleSystem): number;
  33652. /**
  33653. * Remove a animation for the list of scene's animations
  33654. * @param toRemove defines the animation to remove
  33655. * @returns the index where the animation was in the animation list
  33656. */
  33657. removeAnimation(toRemove: Animation): number;
  33658. /**
  33659. * Will stop the animation of the given target
  33660. * @param target - the target
  33661. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33662. * @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)
  33663. */
  33664. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33665. /**
  33666. * Removes the given animation group from this scene.
  33667. * @param toRemove The animation group to remove
  33668. * @returns The index of the removed animation group
  33669. */
  33670. removeAnimationGroup(toRemove: AnimationGroup): number;
  33671. /**
  33672. * Removes the given multi-material from this scene.
  33673. * @param toRemove The multi-material to remove
  33674. * @returns The index of the removed multi-material
  33675. */
  33676. removeMultiMaterial(toRemove: MultiMaterial): number;
  33677. /**
  33678. * Removes the given material from this scene.
  33679. * @param toRemove The material to remove
  33680. * @returns The index of the removed material
  33681. */
  33682. removeMaterial(toRemove: Material): number;
  33683. /**
  33684. * Removes the given action manager from this scene.
  33685. * @param toRemove The action manager to remove
  33686. * @returns The index of the removed action manager
  33687. */
  33688. removeActionManager(toRemove: AbstractActionManager): number;
  33689. /**
  33690. * Removes the given texture from this scene.
  33691. * @param toRemove The texture to remove
  33692. * @returns The index of the removed texture
  33693. */
  33694. removeTexture(toRemove: BaseTexture): number;
  33695. /**
  33696. * Adds the given light to this scene
  33697. * @param newLight The light to add
  33698. */
  33699. addLight(newLight: Light): void;
  33700. /**
  33701. * Sorts the list list based on light priorities
  33702. */
  33703. sortLightsByPriority(): void;
  33704. /**
  33705. * Adds the given camera to this scene
  33706. * @param newCamera The camera to add
  33707. */
  33708. addCamera(newCamera: Camera): void;
  33709. /**
  33710. * Adds the given skeleton to this scene
  33711. * @param newSkeleton The skeleton to add
  33712. */
  33713. addSkeleton(newSkeleton: Skeleton): void;
  33714. /**
  33715. * Adds the given particle system to this scene
  33716. * @param newParticleSystem The particle system to add
  33717. */
  33718. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33719. /**
  33720. * Adds the given animation to this scene
  33721. * @param newAnimation The animation to add
  33722. */
  33723. addAnimation(newAnimation: Animation): void;
  33724. /**
  33725. * Adds the given animation group to this scene.
  33726. * @param newAnimationGroup The animation group to add
  33727. */
  33728. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33729. /**
  33730. * Adds the given multi-material to this scene
  33731. * @param newMultiMaterial The multi-material to add
  33732. */
  33733. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33734. /**
  33735. * Adds the given material to this scene
  33736. * @param newMaterial The material to add
  33737. */
  33738. addMaterial(newMaterial: Material): void;
  33739. /**
  33740. * Adds the given morph target to this scene
  33741. * @param newMorphTargetManager The morph target to add
  33742. */
  33743. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33744. /**
  33745. * Adds the given geometry to this scene
  33746. * @param newGeometry The geometry to add
  33747. */
  33748. addGeometry(newGeometry: Geometry): void;
  33749. /**
  33750. * Adds the given action manager to this scene
  33751. * @param newActionManager The action manager to add
  33752. */
  33753. addActionManager(newActionManager: AbstractActionManager): void;
  33754. /**
  33755. * Adds the given texture to this scene.
  33756. * @param newTexture The texture to add
  33757. */
  33758. addTexture(newTexture: BaseTexture): void;
  33759. /**
  33760. * Switch active camera
  33761. * @param newCamera defines the new active camera
  33762. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33763. */
  33764. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33765. /**
  33766. * sets the active camera of the scene using its ID
  33767. * @param id defines the camera's ID
  33768. * @return the new active camera or null if none found.
  33769. */
  33770. setActiveCameraByID(id: string): Nullable<Camera>;
  33771. /**
  33772. * sets the active camera of the scene using its name
  33773. * @param name defines the camera's name
  33774. * @returns the new active camera or null if none found.
  33775. */
  33776. setActiveCameraByName(name: string): Nullable<Camera>;
  33777. /**
  33778. * get an animation group using its name
  33779. * @param name defines the material's name
  33780. * @return the animation group or null if none found.
  33781. */
  33782. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33783. /**
  33784. * Get a material using its unique id
  33785. * @param uniqueId defines the material's unique id
  33786. * @return the material or null if none found.
  33787. */
  33788. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33789. /**
  33790. * get a material using its id
  33791. * @param id defines the material's ID
  33792. * @return the material or null if none found.
  33793. */
  33794. getMaterialByID(id: string): Nullable<Material>;
  33795. /**
  33796. * Gets a the last added material using a given id
  33797. * @param id defines the material's ID
  33798. * @return the last material with the given id or null if none found.
  33799. */
  33800. getLastMaterialByID(id: string): Nullable<Material>;
  33801. /**
  33802. * Gets a material using its name
  33803. * @param name defines the material's name
  33804. * @return the material or null if none found.
  33805. */
  33806. getMaterialByName(name: string): Nullable<Material>;
  33807. /**
  33808. * Gets a camera using its id
  33809. * @param id defines the id to look for
  33810. * @returns the camera or null if not found
  33811. */
  33812. getCameraByID(id: string): Nullable<Camera>;
  33813. /**
  33814. * Gets a camera using its unique id
  33815. * @param uniqueId defines the unique id to look for
  33816. * @returns the camera or null if not found
  33817. */
  33818. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33819. /**
  33820. * Gets a camera using its name
  33821. * @param name defines the camera's name
  33822. * @return the camera or null if none found.
  33823. */
  33824. getCameraByName(name: string): Nullable<Camera>;
  33825. /**
  33826. * Gets a bone using its id
  33827. * @param id defines the bone's id
  33828. * @return the bone or null if not found
  33829. */
  33830. getBoneByID(id: string): Nullable<Bone>;
  33831. /**
  33832. * Gets a bone using its id
  33833. * @param name defines the bone's name
  33834. * @return the bone or null if not found
  33835. */
  33836. getBoneByName(name: string): Nullable<Bone>;
  33837. /**
  33838. * Gets a light node using its name
  33839. * @param name defines the the light's name
  33840. * @return the light or null if none found.
  33841. */
  33842. getLightByName(name: string): Nullable<Light>;
  33843. /**
  33844. * Gets a light node using its id
  33845. * @param id defines the light's id
  33846. * @return the light or null if none found.
  33847. */
  33848. getLightByID(id: string): Nullable<Light>;
  33849. /**
  33850. * Gets a light node using its scene-generated unique ID
  33851. * @param uniqueId defines the light's unique id
  33852. * @return the light or null if none found.
  33853. */
  33854. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33855. /**
  33856. * Gets a particle system by id
  33857. * @param id defines the particle system id
  33858. * @return the corresponding system or null if none found
  33859. */
  33860. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33861. /**
  33862. * Gets a geometry using its ID
  33863. * @param id defines the geometry's id
  33864. * @return the geometry or null if none found.
  33865. */
  33866. getGeometryByID(id: string): Nullable<Geometry>;
  33867. private _getGeometryByUniqueID;
  33868. /**
  33869. * Add a new geometry to this scene
  33870. * @param geometry defines the geometry to be added to the scene.
  33871. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33872. * @return a boolean defining if the geometry was added or not
  33873. */
  33874. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33875. /**
  33876. * Removes an existing geometry
  33877. * @param geometry defines the geometry to be removed from the scene
  33878. * @return a boolean defining if the geometry was removed or not
  33879. */
  33880. removeGeometry(geometry: Geometry): boolean;
  33881. /**
  33882. * Gets the list of geometries attached to the scene
  33883. * @returns an array of Geometry
  33884. */
  33885. getGeometries(): Geometry[];
  33886. /**
  33887. * Gets the first added mesh found of a given ID
  33888. * @param id defines the id to search for
  33889. * @return the mesh found or null if not found at all
  33890. */
  33891. getMeshByID(id: string): Nullable<AbstractMesh>;
  33892. /**
  33893. * Gets a list of meshes using their id
  33894. * @param id defines the id to search for
  33895. * @returns a list of meshes
  33896. */
  33897. getMeshesByID(id: string): Array<AbstractMesh>;
  33898. /**
  33899. * Gets the first added transform node found of a given ID
  33900. * @param id defines the id to search for
  33901. * @return the found transform node or null if not found at all.
  33902. */
  33903. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33904. /**
  33905. * Gets a transform node with its auto-generated unique id
  33906. * @param uniqueId efines the unique id to search for
  33907. * @return the found transform node or null if not found at all.
  33908. */
  33909. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33910. /**
  33911. * Gets a list of transform nodes using their id
  33912. * @param id defines the id to search for
  33913. * @returns a list of transform nodes
  33914. */
  33915. getTransformNodesByID(id: string): Array<TransformNode>;
  33916. /**
  33917. * Gets a mesh with its auto-generated unique id
  33918. * @param uniqueId defines the unique id to search for
  33919. * @return the found mesh or null if not found at all.
  33920. */
  33921. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33922. /**
  33923. * Gets a the last added mesh using a given id
  33924. * @param id defines the id to search for
  33925. * @return the found mesh or null if not found at all.
  33926. */
  33927. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33928. /**
  33929. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33930. * @param id defines the id to search for
  33931. * @return the found node or null if not found at all
  33932. */
  33933. getLastEntryByID(id: string): Nullable<Node>;
  33934. /**
  33935. * Gets a node (Mesh, Camera, Light) using a given id
  33936. * @param id defines the id to search for
  33937. * @return the found node or null if not found at all
  33938. */
  33939. getNodeByID(id: string): Nullable<Node>;
  33940. /**
  33941. * Gets a node (Mesh, Camera, Light) using a given name
  33942. * @param name defines the name to search for
  33943. * @return the found node or null if not found at all.
  33944. */
  33945. getNodeByName(name: string): Nullable<Node>;
  33946. /**
  33947. * Gets a mesh using a given name
  33948. * @param name defines the name to search for
  33949. * @return the found mesh or null if not found at all.
  33950. */
  33951. getMeshByName(name: string): Nullable<AbstractMesh>;
  33952. /**
  33953. * Gets a transform node using a given name
  33954. * @param name defines the name to search for
  33955. * @return the found transform node or null if not found at all.
  33956. */
  33957. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33958. /**
  33959. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33960. * @param id defines the id to search for
  33961. * @return the found skeleton or null if not found at all.
  33962. */
  33963. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33964. /**
  33965. * Gets a skeleton using a given auto generated unique id
  33966. * @param uniqueId defines the unique id to search for
  33967. * @return the found skeleton or null if not found at all.
  33968. */
  33969. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33970. /**
  33971. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33972. * @param id defines the id to search for
  33973. * @return the found skeleton or null if not found at all.
  33974. */
  33975. getSkeletonById(id: string): Nullable<Skeleton>;
  33976. /**
  33977. * Gets a skeleton using a given name
  33978. * @param name defines the name to search for
  33979. * @return the found skeleton or null if not found at all.
  33980. */
  33981. getSkeletonByName(name: string): Nullable<Skeleton>;
  33982. /**
  33983. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33984. * @param id defines the id to search for
  33985. * @return the found morph target manager or null if not found at all.
  33986. */
  33987. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33988. /**
  33989. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33990. * @param id defines the id to search for
  33991. * @return the found morph target or null if not found at all.
  33992. */
  33993. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33994. /**
  33995. * Gets a boolean indicating if the given mesh is active
  33996. * @param mesh defines the mesh to look for
  33997. * @returns true if the mesh is in the active list
  33998. */
  33999. isActiveMesh(mesh: AbstractMesh): boolean;
  34000. /**
  34001. * Return a unique id as a string which can serve as an identifier for the scene
  34002. */
  34003. readonly uid: string;
  34004. /**
  34005. * Add an externaly attached data from its key.
  34006. * This method call will fail and return false, if such key already exists.
  34007. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34008. * @param key the unique key that identifies the data
  34009. * @param data the data object to associate to the key for this Engine instance
  34010. * @return true if no such key were already present and the data was added successfully, false otherwise
  34011. */
  34012. addExternalData<T>(key: string, data: T): boolean;
  34013. /**
  34014. * Get an externaly attached data from its key
  34015. * @param key the unique key that identifies the data
  34016. * @return the associated data, if present (can be null), or undefined if not present
  34017. */
  34018. getExternalData<T>(key: string): Nullable<T>;
  34019. /**
  34020. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34021. * @param key the unique key that identifies the data
  34022. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34023. * @return the associated data, can be null if the factory returned null.
  34024. */
  34025. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34026. /**
  34027. * Remove an externaly attached data from the Engine instance
  34028. * @param key the unique key that identifies the data
  34029. * @return true if the data was successfully removed, false if it doesn't exist
  34030. */
  34031. removeExternalData(key: string): boolean;
  34032. private _evaluateSubMesh;
  34033. /**
  34034. * Clear the processed materials smart array preventing retention point in material dispose.
  34035. */
  34036. freeProcessedMaterials(): void;
  34037. private _preventFreeActiveMeshesAndRenderingGroups;
  34038. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34039. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34040. * when disposing several meshes in a row or a hierarchy of meshes.
  34041. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34042. */
  34043. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34044. /**
  34045. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34046. */
  34047. freeActiveMeshes(): void;
  34048. /**
  34049. * Clear the info related to rendering groups preventing retention points during dispose.
  34050. */
  34051. freeRenderingGroups(): void;
  34052. /** @hidden */
  34053. _isInIntermediateRendering(): boolean;
  34054. /**
  34055. * Lambda returning the list of potentially active meshes.
  34056. */
  34057. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34058. /**
  34059. * Lambda returning the list of potentially active sub meshes.
  34060. */
  34061. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34062. /**
  34063. * Lambda returning the list of potentially intersecting sub meshes.
  34064. */
  34065. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34066. /**
  34067. * Lambda returning the list of potentially colliding sub meshes.
  34068. */
  34069. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34070. private _activeMeshesFrozen;
  34071. /**
  34072. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34073. * @returns the current scene
  34074. */
  34075. freezeActiveMeshes(): Scene;
  34076. /**
  34077. * Use this function to restart evaluating active meshes on every frame
  34078. * @returns the current scene
  34079. */
  34080. unfreezeActiveMeshes(): Scene;
  34081. private _evaluateActiveMeshes;
  34082. private _activeMesh;
  34083. /**
  34084. * Update the transform matrix to update from the current active camera
  34085. * @param force defines a boolean used to force the update even if cache is up to date
  34086. */
  34087. updateTransformMatrix(force?: boolean): void;
  34088. private _bindFrameBuffer;
  34089. /** @hidden */
  34090. _allowPostProcessClearColor: boolean;
  34091. /** @hidden */
  34092. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34093. private _processSubCameras;
  34094. private _checkIntersections;
  34095. /** @hidden */
  34096. _advancePhysicsEngineStep(step: number): void;
  34097. /**
  34098. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34099. */
  34100. getDeterministicFrameTime: () => number;
  34101. /** @hidden */
  34102. _animate(): void;
  34103. /** Execute all animations (for a frame) */
  34104. animate(): void;
  34105. /**
  34106. * Render the scene
  34107. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34108. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34109. */
  34110. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34111. /**
  34112. * Freeze all materials
  34113. * A frozen material will not be updatable but should be faster to render
  34114. */
  34115. freezeMaterials(): void;
  34116. /**
  34117. * Unfreeze all materials
  34118. * A frozen material will not be updatable but should be faster to render
  34119. */
  34120. unfreezeMaterials(): void;
  34121. /**
  34122. * Releases all held ressources
  34123. */
  34124. dispose(): void;
  34125. /**
  34126. * Gets if the scene is already disposed
  34127. */
  34128. readonly isDisposed: boolean;
  34129. /**
  34130. * Call this function to reduce memory footprint of the scene.
  34131. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34132. */
  34133. clearCachedVertexData(): void;
  34134. /**
  34135. * This function will remove the local cached buffer data from texture.
  34136. * It will save memory but will prevent the texture from being rebuilt
  34137. */
  34138. cleanCachedTextureBuffer(): void;
  34139. /**
  34140. * Get the world extend vectors with an optional filter
  34141. *
  34142. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34143. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34144. */
  34145. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34146. min: Vector3;
  34147. max: Vector3;
  34148. };
  34149. /**
  34150. * Creates a ray that can be used to pick in the scene
  34151. * @param x defines the x coordinate of the origin (on-screen)
  34152. * @param y defines the y coordinate of the origin (on-screen)
  34153. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34154. * @param camera defines the camera to use for the picking
  34155. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34156. * @returns a Ray
  34157. */
  34158. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34159. /**
  34160. * Creates a ray that can be used to pick in the scene
  34161. * @param x defines the x coordinate of the origin (on-screen)
  34162. * @param y defines the y coordinate of the origin (on-screen)
  34163. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34164. * @param result defines the ray where to store the picking ray
  34165. * @param camera defines the camera to use for the picking
  34166. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34167. * @returns the current scene
  34168. */
  34169. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34170. /**
  34171. * Creates a ray that can be used to pick in the scene
  34172. * @param x defines the x coordinate of the origin (on-screen)
  34173. * @param y defines the y coordinate of the origin (on-screen)
  34174. * @param camera defines the camera to use for the picking
  34175. * @returns a Ray
  34176. */
  34177. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34178. /**
  34179. * Creates a ray that can be used to pick in the scene
  34180. * @param x defines the x coordinate of the origin (on-screen)
  34181. * @param y defines the y coordinate of the origin (on-screen)
  34182. * @param result defines the ray where to store the picking ray
  34183. * @param camera defines the camera to use for the picking
  34184. * @returns the current scene
  34185. */
  34186. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34187. /** Launch a ray to try to pick a mesh in the scene
  34188. * @param x position on screen
  34189. * @param y position on screen
  34190. * @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
  34191. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34192. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34193. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34194. * @returns a PickingInfo
  34195. */
  34196. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34197. /** Use the given ray to pick a mesh in the scene
  34198. * @param ray The ray to use to pick meshes
  34199. * @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
  34200. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34201. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34202. * @returns a PickingInfo
  34203. */
  34204. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34205. /**
  34206. * Launch a ray to try to pick a mesh in the scene
  34207. * @param x X position on screen
  34208. * @param y Y position on screen
  34209. * @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
  34210. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34211. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34212. * @returns an array of PickingInfo
  34213. */
  34214. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34215. /**
  34216. * Launch a ray to try to pick a mesh in the scene
  34217. * @param ray Ray to use
  34218. * @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
  34219. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34220. * @returns an array of PickingInfo
  34221. */
  34222. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34223. /**
  34224. * Force the value of meshUnderPointer
  34225. * @param mesh defines the mesh to use
  34226. */
  34227. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34228. /**
  34229. * Gets the mesh under the pointer
  34230. * @returns a Mesh or null if no mesh is under the pointer
  34231. */
  34232. getPointerOverMesh(): Nullable<AbstractMesh>;
  34233. /** @hidden */
  34234. _rebuildGeometries(): void;
  34235. /** @hidden */
  34236. _rebuildTextures(): void;
  34237. private _getByTags;
  34238. /**
  34239. * Get a list of meshes by tags
  34240. * @param tagsQuery defines the tags query to use
  34241. * @param forEach defines a predicate used to filter results
  34242. * @returns an array of Mesh
  34243. */
  34244. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34245. /**
  34246. * Get a list of cameras by tags
  34247. * @param tagsQuery defines the tags query to use
  34248. * @param forEach defines a predicate used to filter results
  34249. * @returns an array of Camera
  34250. */
  34251. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34252. /**
  34253. * Get a list of lights by tags
  34254. * @param tagsQuery defines the tags query to use
  34255. * @param forEach defines a predicate used to filter results
  34256. * @returns an array of Light
  34257. */
  34258. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34259. /**
  34260. * Get a list of materials by tags
  34261. * @param tagsQuery defines the tags query to use
  34262. * @param forEach defines a predicate used to filter results
  34263. * @returns an array of Material
  34264. */
  34265. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34266. /**
  34267. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34268. * This allowed control for front to back rendering or reversly depending of the special needs.
  34269. *
  34270. * @param renderingGroupId The rendering group id corresponding to its index
  34271. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34272. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34273. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34274. */
  34275. 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;
  34276. /**
  34277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34278. *
  34279. * @param renderingGroupId The rendering group id corresponding to its index
  34280. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34281. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34282. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34283. */
  34284. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34285. /**
  34286. * Gets the current auto clear configuration for one rendering group of the rendering
  34287. * manager.
  34288. * @param index the rendering group index to get the information for
  34289. * @returns The auto clear setup for the requested rendering group
  34290. */
  34291. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34292. private _blockMaterialDirtyMechanism;
  34293. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34294. blockMaterialDirtyMechanism: boolean;
  34295. /**
  34296. * Will flag all materials as dirty to trigger new shader compilation
  34297. * @param flag defines the flag used to specify which material part must be marked as dirty
  34298. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34299. */
  34300. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34301. /** @hidden */
  34302. _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;
  34303. /** @hidden */
  34304. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34305. }
  34306. }
  34307. declare module BABYLON {
  34308. /**
  34309. * Set of assets to keep when moving a scene into an asset container.
  34310. */
  34311. export class KeepAssets extends AbstractScene {
  34312. }
  34313. /**
  34314. * Container with a set of assets that can be added or removed from a scene.
  34315. */
  34316. export class AssetContainer extends AbstractScene {
  34317. /**
  34318. * The scene the AssetContainer belongs to.
  34319. */
  34320. scene: Scene;
  34321. /**
  34322. * Instantiates an AssetContainer.
  34323. * @param scene The scene the AssetContainer belongs to.
  34324. */
  34325. constructor(scene: Scene);
  34326. /**
  34327. * Adds all the assets from the container to the scene.
  34328. */
  34329. addAllToScene(): void;
  34330. /**
  34331. * Removes all the assets in the container from the scene
  34332. */
  34333. removeAllFromScene(): void;
  34334. /**
  34335. * Disposes all the assets in the container
  34336. */
  34337. dispose(): void;
  34338. private _moveAssets;
  34339. /**
  34340. * Removes all the assets contained in the scene and adds them to the container.
  34341. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34342. */
  34343. moveAllFromScene(keepAssets?: KeepAssets): void;
  34344. /**
  34345. * 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.
  34346. * @returns the root mesh
  34347. */
  34348. createRootMesh(): Mesh;
  34349. }
  34350. }
  34351. declare module BABYLON {
  34352. /**
  34353. * Defines how the parser contract is defined.
  34354. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34355. */
  34356. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34357. /**
  34358. * Defines how the individual parser contract is defined.
  34359. * These parser can parse an individual asset
  34360. */
  34361. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34362. /**
  34363. * Base class of the scene acting as a container for the different elements composing a scene.
  34364. * This class is dynamically extended by the different components of the scene increasing
  34365. * flexibility and reducing coupling
  34366. */
  34367. export abstract class AbstractScene {
  34368. /**
  34369. * Stores the list of available parsers in the application.
  34370. */
  34371. private static _BabylonFileParsers;
  34372. /**
  34373. * Stores the list of available individual parsers in the application.
  34374. */
  34375. private static _IndividualBabylonFileParsers;
  34376. /**
  34377. * Adds a parser in the list of available ones
  34378. * @param name Defines the name of the parser
  34379. * @param parser Defines the parser to add
  34380. */
  34381. static AddParser(name: string, parser: BabylonFileParser): void;
  34382. /**
  34383. * Gets a general parser from the list of avaialble ones
  34384. * @param name Defines the name of the parser
  34385. * @returns the requested parser or null
  34386. */
  34387. static GetParser(name: string): Nullable<BabylonFileParser>;
  34388. /**
  34389. * Adds n individual parser in the list of available ones
  34390. * @param name Defines the name of the parser
  34391. * @param parser Defines the parser to add
  34392. */
  34393. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34394. /**
  34395. * Gets an individual parser from the list of avaialble ones
  34396. * @param name Defines the name of the parser
  34397. * @returns the requested parser or null
  34398. */
  34399. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34400. /**
  34401. * Parser json data and populate both a scene and its associated container object
  34402. * @param jsonData Defines the data to parse
  34403. * @param scene Defines the scene to parse the data for
  34404. * @param container Defines the container attached to the parsing sequence
  34405. * @param rootUrl Defines the root url of the data
  34406. */
  34407. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34408. /**
  34409. * Gets the list of root nodes (ie. nodes with no parent)
  34410. */
  34411. rootNodes: Node[];
  34412. /** All of the cameras added to this scene
  34413. * @see http://doc.babylonjs.com/babylon101/cameras
  34414. */
  34415. cameras: Camera[];
  34416. /**
  34417. * All of the lights added to this scene
  34418. * @see http://doc.babylonjs.com/babylon101/lights
  34419. */
  34420. lights: Light[];
  34421. /**
  34422. * All of the (abstract) meshes added to this scene
  34423. */
  34424. meshes: AbstractMesh[];
  34425. /**
  34426. * The list of skeletons added to the scene
  34427. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34428. */
  34429. skeletons: Skeleton[];
  34430. /**
  34431. * All of the particle systems added to this scene
  34432. * @see http://doc.babylonjs.com/babylon101/particles
  34433. */
  34434. particleSystems: IParticleSystem[];
  34435. /**
  34436. * Gets a list of Animations associated with the scene
  34437. */
  34438. animations: Animation[];
  34439. /**
  34440. * All of the animation groups added to this scene
  34441. * @see http://doc.babylonjs.com/how_to/group
  34442. */
  34443. animationGroups: AnimationGroup[];
  34444. /**
  34445. * All of the multi-materials added to this scene
  34446. * @see http://doc.babylonjs.com/how_to/multi_materials
  34447. */
  34448. multiMaterials: MultiMaterial[];
  34449. /**
  34450. * All of the materials added to this scene
  34451. * In the context of a Scene, it is not supposed to be modified manually.
  34452. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34453. * Note also that the order of the Material wihin the array is not significant and might change.
  34454. * @see http://doc.babylonjs.com/babylon101/materials
  34455. */
  34456. materials: Material[];
  34457. /**
  34458. * The list of morph target managers added to the scene
  34459. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34460. */
  34461. morphTargetManagers: MorphTargetManager[];
  34462. /**
  34463. * The list of geometries used in the scene.
  34464. */
  34465. geometries: Geometry[];
  34466. /**
  34467. * All of the tranform nodes added to this scene
  34468. * In the context of a Scene, it is not supposed to be modified manually.
  34469. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34470. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34471. * @see http://doc.babylonjs.com/how_to/transformnode
  34472. */
  34473. transformNodes: TransformNode[];
  34474. /**
  34475. * ActionManagers available on the scene.
  34476. */
  34477. actionManagers: AbstractActionManager[];
  34478. /**
  34479. * Textures to keep.
  34480. */
  34481. textures: BaseTexture[];
  34482. /**
  34483. * Environment texture for the scene
  34484. */
  34485. environmentTexture: Nullable<BaseTexture>;
  34486. }
  34487. }
  34488. declare module BABYLON {
  34489. /**
  34490. * Interface used to define options for Sound class
  34491. */
  34492. export interface ISoundOptions {
  34493. /**
  34494. * Does the sound autoplay once loaded.
  34495. */
  34496. autoplay?: boolean;
  34497. /**
  34498. * Does the sound loop after it finishes playing once.
  34499. */
  34500. loop?: boolean;
  34501. /**
  34502. * Sound's volume
  34503. */
  34504. volume?: number;
  34505. /**
  34506. * Is it a spatial sound?
  34507. */
  34508. spatialSound?: boolean;
  34509. /**
  34510. * Maximum distance to hear that sound
  34511. */
  34512. maxDistance?: number;
  34513. /**
  34514. * Uses user defined attenuation function
  34515. */
  34516. useCustomAttenuation?: boolean;
  34517. /**
  34518. * Define the roll off factor of spatial sounds.
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34520. */
  34521. rolloffFactor?: number;
  34522. /**
  34523. * Define the reference distance the sound should be heard perfectly.
  34524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34525. */
  34526. refDistance?: number;
  34527. /**
  34528. * Define the distance attenuation model the sound will follow.
  34529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34530. */
  34531. distanceModel?: string;
  34532. /**
  34533. * Defines the playback speed (1 by default)
  34534. */
  34535. playbackRate?: number;
  34536. /**
  34537. * Defines if the sound is from a streaming source
  34538. */
  34539. streaming?: boolean;
  34540. /**
  34541. * Defines an optional length (in seconds) inside the sound file
  34542. */
  34543. length?: number;
  34544. /**
  34545. * Defines an optional offset (in seconds) inside the sound file
  34546. */
  34547. offset?: number;
  34548. /**
  34549. * If true, URLs will not be required to state the audio file codec to use.
  34550. */
  34551. skipCodecCheck?: boolean;
  34552. }
  34553. /**
  34554. * Defines a sound that can be played in the application.
  34555. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34557. */
  34558. export class Sound {
  34559. /**
  34560. * The name of the sound in the scene.
  34561. */
  34562. name: string;
  34563. /**
  34564. * Does the sound autoplay once loaded.
  34565. */
  34566. autoplay: boolean;
  34567. /**
  34568. * Does the sound loop after it finishes playing once.
  34569. */
  34570. loop: boolean;
  34571. /**
  34572. * Does the sound use a custom attenuation curve to simulate the falloff
  34573. * happening when the source gets further away from the camera.
  34574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34575. */
  34576. useCustomAttenuation: boolean;
  34577. /**
  34578. * The sound track id this sound belongs to.
  34579. */
  34580. soundTrackId: number;
  34581. /**
  34582. * Is this sound currently played.
  34583. */
  34584. isPlaying: boolean;
  34585. /**
  34586. * Is this sound currently paused.
  34587. */
  34588. isPaused: boolean;
  34589. /**
  34590. * Does this sound enables spatial sound.
  34591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34592. */
  34593. spatialSound: boolean;
  34594. /**
  34595. * Define the reference distance the sound should be heard perfectly.
  34596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34597. */
  34598. refDistance: number;
  34599. /**
  34600. * Define the roll off factor of spatial sounds.
  34601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34602. */
  34603. rolloffFactor: number;
  34604. /**
  34605. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34607. */
  34608. maxDistance: number;
  34609. /**
  34610. * Define the distance attenuation model the sound will follow.
  34611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34612. */
  34613. distanceModel: string;
  34614. /**
  34615. * @hidden
  34616. * Back Compat
  34617. **/
  34618. onended: () => any;
  34619. /**
  34620. * Observable event when the current playing sound finishes.
  34621. */
  34622. onEndedObservable: Observable<Sound>;
  34623. private _panningModel;
  34624. private _playbackRate;
  34625. private _streaming;
  34626. private _startTime;
  34627. private _startOffset;
  34628. private _position;
  34629. /** @hidden */
  34630. _positionInEmitterSpace: boolean;
  34631. private _localDirection;
  34632. private _volume;
  34633. private _isReadyToPlay;
  34634. private _isDirectional;
  34635. private _readyToPlayCallback;
  34636. private _audioBuffer;
  34637. private _soundSource;
  34638. private _streamingSource;
  34639. private _soundPanner;
  34640. private _soundGain;
  34641. private _inputAudioNode;
  34642. private _outputAudioNode;
  34643. private _coneInnerAngle;
  34644. private _coneOuterAngle;
  34645. private _coneOuterGain;
  34646. private _scene;
  34647. private _connectedTransformNode;
  34648. private _customAttenuationFunction;
  34649. private _registerFunc;
  34650. private _isOutputConnected;
  34651. private _htmlAudioElement;
  34652. private _urlType;
  34653. private _length?;
  34654. private _offset?;
  34655. /** @hidden */
  34656. static _SceneComponentInitialization: (scene: Scene) => void;
  34657. /**
  34658. * Create a sound and attach it to a scene
  34659. * @param name Name of your sound
  34660. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34661. * @param scene defines the scene the sound belongs to
  34662. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34663. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34664. */
  34665. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34666. /**
  34667. * Release the sound and its associated resources
  34668. */
  34669. dispose(): void;
  34670. /**
  34671. * Gets if the sounds is ready to be played or not.
  34672. * @returns true if ready, otherwise false
  34673. */
  34674. isReady(): boolean;
  34675. private _soundLoaded;
  34676. /**
  34677. * Sets the data of the sound from an audiobuffer
  34678. * @param audioBuffer The audioBuffer containing the data
  34679. */
  34680. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34681. /**
  34682. * Updates the current sounds options such as maxdistance, loop...
  34683. * @param options A JSON object containing values named as the object properties
  34684. */
  34685. updateOptions(options: ISoundOptions): void;
  34686. private _createSpatialParameters;
  34687. private _updateSpatialParameters;
  34688. /**
  34689. * Switch the panning model to HRTF:
  34690. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34692. */
  34693. switchPanningModelToHRTF(): void;
  34694. /**
  34695. * Switch the panning model to Equal Power:
  34696. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34698. */
  34699. switchPanningModelToEqualPower(): void;
  34700. private _switchPanningModel;
  34701. /**
  34702. * Connect this sound to a sound track audio node like gain...
  34703. * @param soundTrackAudioNode the sound track audio node to connect to
  34704. */
  34705. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34706. /**
  34707. * Transform this sound into a directional source
  34708. * @param coneInnerAngle Size of the inner cone in degree
  34709. * @param coneOuterAngle Size of the outer cone in degree
  34710. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34711. */
  34712. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34713. /**
  34714. * Gets or sets the inner angle for the directional cone.
  34715. */
  34716. /**
  34717. * Gets or sets the inner angle for the directional cone.
  34718. */
  34719. directionalConeInnerAngle: number;
  34720. /**
  34721. * Gets or sets the outer angle for the directional cone.
  34722. */
  34723. /**
  34724. * Gets or sets the outer angle for the directional cone.
  34725. */
  34726. directionalConeOuterAngle: number;
  34727. /**
  34728. * Sets the position of the emitter if spatial sound is enabled
  34729. * @param newPosition Defines the new posisiton
  34730. */
  34731. setPosition(newPosition: Vector3): void;
  34732. /**
  34733. * Sets the local direction of the emitter if spatial sound is enabled
  34734. * @param newLocalDirection Defines the new local direction
  34735. */
  34736. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34737. private _updateDirection;
  34738. /** @hidden */
  34739. updateDistanceFromListener(): void;
  34740. /**
  34741. * Sets a new custom attenuation function for the sound.
  34742. * @param callback Defines the function used for the attenuation
  34743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34744. */
  34745. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34746. /**
  34747. * Play the sound
  34748. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34749. * @param offset (optional) Start the sound at a specific time in seconds
  34750. * @param length (optional) Sound duration (in seconds)
  34751. */
  34752. play(time?: number, offset?: number, length?: number): void;
  34753. private _onended;
  34754. /**
  34755. * Stop the sound
  34756. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34757. */
  34758. stop(time?: number): void;
  34759. /**
  34760. * Put the sound in pause
  34761. */
  34762. pause(): void;
  34763. /**
  34764. * Sets a dedicated volume for this sounds
  34765. * @param newVolume Define the new volume of the sound
  34766. * @param time Define time for gradual change to new volume
  34767. */
  34768. setVolume(newVolume: number, time?: number): void;
  34769. /**
  34770. * Set the sound play back rate
  34771. * @param newPlaybackRate Define the playback rate the sound should be played at
  34772. */
  34773. setPlaybackRate(newPlaybackRate: number): void;
  34774. /**
  34775. * Gets the volume of the sound.
  34776. * @returns the volume of the sound
  34777. */
  34778. getVolume(): number;
  34779. /**
  34780. * Attach the sound to a dedicated mesh
  34781. * @param transformNode The transform node to connect the sound with
  34782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34783. */
  34784. attachToMesh(transformNode: TransformNode): void;
  34785. /**
  34786. * Detach the sound from the previously attached mesh
  34787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34788. */
  34789. detachFromMesh(): void;
  34790. private _onRegisterAfterWorldMatrixUpdate;
  34791. /**
  34792. * Clone the current sound in the scene.
  34793. * @returns the new sound clone
  34794. */
  34795. clone(): Nullable<Sound>;
  34796. /**
  34797. * Gets the current underlying audio buffer containing the data
  34798. * @returns the audio buffer
  34799. */
  34800. getAudioBuffer(): Nullable<AudioBuffer>;
  34801. /**
  34802. * Serializes the Sound in a JSON representation
  34803. * @returns the JSON representation of the sound
  34804. */
  34805. serialize(): any;
  34806. /**
  34807. * Parse a JSON representation of a sound to innstantiate in a given scene
  34808. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34809. * @param scene Define the scene the new parsed sound should be created in
  34810. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34811. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34812. * @returns the newly parsed sound
  34813. */
  34814. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34815. }
  34816. }
  34817. declare module BABYLON {
  34818. /**
  34819. * This defines an action helpful to play a defined sound on a triggered action.
  34820. */
  34821. export class PlaySoundAction extends Action {
  34822. private _sound;
  34823. /**
  34824. * Instantiate the action
  34825. * @param triggerOptions defines the trigger options
  34826. * @param sound defines the sound to play
  34827. * @param condition defines the trigger related conditions
  34828. */
  34829. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34830. /** @hidden */
  34831. _prepare(): void;
  34832. /**
  34833. * Execute the action and play the sound.
  34834. */
  34835. execute(): void;
  34836. /**
  34837. * Serializes the actions and its related information.
  34838. * @param parent defines the object to serialize in
  34839. * @returns the serialized object
  34840. */
  34841. serialize(parent: any): any;
  34842. }
  34843. /**
  34844. * This defines an action helpful to stop a defined sound on a triggered action.
  34845. */
  34846. export class StopSoundAction extends Action {
  34847. private _sound;
  34848. /**
  34849. * Instantiate the action
  34850. * @param triggerOptions defines the trigger options
  34851. * @param sound defines the sound to stop
  34852. * @param condition defines the trigger related conditions
  34853. */
  34854. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34855. /** @hidden */
  34856. _prepare(): void;
  34857. /**
  34858. * Execute the action and stop the sound.
  34859. */
  34860. execute(): void;
  34861. /**
  34862. * Serializes the actions and its related information.
  34863. * @param parent defines the object to serialize in
  34864. * @returns the serialized object
  34865. */
  34866. serialize(parent: any): any;
  34867. }
  34868. }
  34869. declare module BABYLON {
  34870. /**
  34871. * This defines an action responsible to change the value of a property
  34872. * by interpolating between its current value and the newly set one once triggered.
  34873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34874. */
  34875. export class InterpolateValueAction extends Action {
  34876. /**
  34877. * Defines the path of the property where the value should be interpolated
  34878. */
  34879. propertyPath: string;
  34880. /**
  34881. * Defines the target value at the end of the interpolation.
  34882. */
  34883. value: any;
  34884. /**
  34885. * Defines the time it will take for the property to interpolate to the value.
  34886. */
  34887. duration: number;
  34888. /**
  34889. * Defines if the other scene animations should be stopped when the action has been triggered
  34890. */
  34891. stopOtherAnimations?: boolean;
  34892. /**
  34893. * Defines a callback raised once the interpolation animation has been done.
  34894. */
  34895. onInterpolationDone?: () => void;
  34896. /**
  34897. * Observable triggered once the interpolation animation has been done.
  34898. */
  34899. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34900. private _target;
  34901. private _effectiveTarget;
  34902. private _property;
  34903. /**
  34904. * Instantiate the action
  34905. * @param triggerOptions defines the trigger options
  34906. * @param target defines the object containing the value to interpolate
  34907. * @param propertyPath defines the path to the property in the target object
  34908. * @param value defines the target value at the end of the interpolation
  34909. * @param duration deines the time it will take for the property to interpolate to the value.
  34910. * @param condition defines the trigger related conditions
  34911. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34912. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34913. */
  34914. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34915. /** @hidden */
  34916. _prepare(): void;
  34917. /**
  34918. * Execute the action starts the value interpolation.
  34919. */
  34920. execute(): void;
  34921. /**
  34922. * Serializes the actions and its related information.
  34923. * @param parent defines the object to serialize in
  34924. * @returns the serialized object
  34925. */
  34926. serialize(parent: any): any;
  34927. }
  34928. }
  34929. declare module BABYLON {
  34930. /**
  34931. * Options allowed during the creation of a sound track.
  34932. */
  34933. export interface ISoundTrackOptions {
  34934. /**
  34935. * The volume the sound track should take during creation
  34936. */
  34937. volume?: number;
  34938. /**
  34939. * Define if the sound track is the main sound track of the scene
  34940. */
  34941. mainTrack?: boolean;
  34942. }
  34943. /**
  34944. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34945. * It will be also used in a future release to apply effects on a specific track.
  34946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34947. */
  34948. export class SoundTrack {
  34949. /**
  34950. * The unique identifier of the sound track in the scene.
  34951. */
  34952. id: number;
  34953. /**
  34954. * The list of sounds included in the sound track.
  34955. */
  34956. soundCollection: Array<Sound>;
  34957. private _outputAudioNode;
  34958. private _scene;
  34959. private _isMainTrack;
  34960. private _connectedAnalyser;
  34961. private _options;
  34962. private _isInitialized;
  34963. /**
  34964. * Creates a new sound track.
  34965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34966. * @param scene Define the scene the sound track belongs to
  34967. * @param options
  34968. */
  34969. constructor(scene: Scene, options?: ISoundTrackOptions);
  34970. private _initializeSoundTrackAudioGraph;
  34971. /**
  34972. * Release the sound track and its associated resources
  34973. */
  34974. dispose(): void;
  34975. /**
  34976. * Adds a sound to this sound track
  34977. * @param sound define the cound to add
  34978. * @ignoreNaming
  34979. */
  34980. AddSound(sound: Sound): void;
  34981. /**
  34982. * Removes a sound to this sound track
  34983. * @param sound define the cound to remove
  34984. * @ignoreNaming
  34985. */
  34986. RemoveSound(sound: Sound): void;
  34987. /**
  34988. * Set a global volume for the full sound track.
  34989. * @param newVolume Define the new volume of the sound track
  34990. */
  34991. setVolume(newVolume: number): void;
  34992. /**
  34993. * Switch the panning model to HRTF:
  34994. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34996. */
  34997. switchPanningModelToHRTF(): void;
  34998. /**
  34999. * Switch the panning model to Equal Power:
  35000. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35002. */
  35003. switchPanningModelToEqualPower(): void;
  35004. /**
  35005. * Connect the sound track to an audio analyser allowing some amazing
  35006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35008. * @param analyser The analyser to connect to the engine
  35009. */
  35010. connectToAnalyser(analyser: Analyser): void;
  35011. }
  35012. }
  35013. declare module BABYLON {
  35014. interface AbstractScene {
  35015. /**
  35016. * The list of sounds used in the scene.
  35017. */
  35018. sounds: Nullable<Array<Sound>>;
  35019. }
  35020. interface Scene {
  35021. /**
  35022. * @hidden
  35023. * Backing field
  35024. */
  35025. _mainSoundTrack: SoundTrack;
  35026. /**
  35027. * The main sound track played by the scene.
  35028. * It cotains your primary collection of sounds.
  35029. */
  35030. mainSoundTrack: SoundTrack;
  35031. /**
  35032. * The list of sound tracks added to the scene
  35033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35034. */
  35035. soundTracks: Nullable<Array<SoundTrack>>;
  35036. /**
  35037. * Gets a sound using a given name
  35038. * @param name defines the name to search for
  35039. * @return the found sound or null if not found at all.
  35040. */
  35041. getSoundByName(name: string): Nullable<Sound>;
  35042. /**
  35043. * Gets or sets if audio support is enabled
  35044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35045. */
  35046. audioEnabled: boolean;
  35047. /**
  35048. * Gets or sets if audio will be output to headphones
  35049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35050. */
  35051. headphone: boolean;
  35052. }
  35053. /**
  35054. * Defines the sound scene component responsible to manage any sounds
  35055. * in a given scene.
  35056. */
  35057. export class AudioSceneComponent implements ISceneSerializableComponent {
  35058. /**
  35059. * The component name helpfull to identify the component in the list of scene components.
  35060. */
  35061. readonly name: string;
  35062. /**
  35063. * The scene the component belongs to.
  35064. */
  35065. scene: Scene;
  35066. private _audioEnabled;
  35067. /**
  35068. * Gets whether audio is enabled or not.
  35069. * Please use related enable/disable method to switch state.
  35070. */
  35071. readonly audioEnabled: boolean;
  35072. private _headphone;
  35073. /**
  35074. * Gets whether audio is outputing to headphone or not.
  35075. * Please use the according Switch methods to change output.
  35076. */
  35077. readonly headphone: boolean;
  35078. /**
  35079. * Creates a new instance of the component for the given scene
  35080. * @param scene Defines the scene to register the component in
  35081. */
  35082. constructor(scene: Scene);
  35083. /**
  35084. * Registers the component in a given scene
  35085. */
  35086. register(): void;
  35087. /**
  35088. * Rebuilds the elements related to this component in case of
  35089. * context lost for instance.
  35090. */
  35091. rebuild(): void;
  35092. /**
  35093. * Serializes the component data to the specified json object
  35094. * @param serializationObject The object to serialize to
  35095. */
  35096. serialize(serializationObject: any): void;
  35097. /**
  35098. * Adds all the elements from the container to the scene
  35099. * @param container the container holding the elements
  35100. */
  35101. addFromContainer(container: AbstractScene): void;
  35102. /**
  35103. * Removes all the elements in the container from the scene
  35104. * @param container contains the elements to remove
  35105. * @param dispose if the removed element should be disposed (default: false)
  35106. */
  35107. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35108. /**
  35109. * Disposes the component and the associated ressources.
  35110. */
  35111. dispose(): void;
  35112. /**
  35113. * Disables audio in the associated scene.
  35114. */
  35115. disableAudio(): void;
  35116. /**
  35117. * Enables audio in the associated scene.
  35118. */
  35119. enableAudio(): void;
  35120. /**
  35121. * Switch audio to headphone output.
  35122. */
  35123. switchAudioModeForHeadphones(): void;
  35124. /**
  35125. * Switch audio to normal speakers.
  35126. */
  35127. switchAudioModeForNormalSpeakers(): void;
  35128. private _afterRender;
  35129. }
  35130. }
  35131. declare module BABYLON {
  35132. /**
  35133. * Wraps one or more Sound objects and selects one with random weight for playback.
  35134. */
  35135. export class WeightedSound {
  35136. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35137. loop: boolean;
  35138. private _coneInnerAngle;
  35139. private _coneOuterAngle;
  35140. private _volume;
  35141. /** A Sound is currently playing. */
  35142. isPlaying: boolean;
  35143. /** A Sound is currently paused. */
  35144. isPaused: boolean;
  35145. private _sounds;
  35146. private _weights;
  35147. private _currentIndex?;
  35148. /**
  35149. * Creates a new WeightedSound from the list of sounds given.
  35150. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35151. * @param sounds Array of Sounds that will be selected from.
  35152. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35153. */
  35154. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35155. /**
  35156. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35157. */
  35158. /**
  35159. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35160. */
  35161. directionalConeInnerAngle: number;
  35162. /**
  35163. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35164. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35165. */
  35166. /**
  35167. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35168. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35169. */
  35170. directionalConeOuterAngle: number;
  35171. /**
  35172. * Playback volume.
  35173. */
  35174. /**
  35175. * Playback volume.
  35176. */
  35177. volume: number;
  35178. private _onended;
  35179. /**
  35180. * Suspend playback
  35181. */
  35182. pause(): void;
  35183. /**
  35184. * Stop playback
  35185. */
  35186. stop(): void;
  35187. /**
  35188. * Start playback.
  35189. * @param startOffset Position the clip head at a specific time in seconds.
  35190. */
  35191. play(startOffset?: number): void;
  35192. }
  35193. }
  35194. declare module BABYLON {
  35195. /**
  35196. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35197. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35198. */
  35199. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35200. /**
  35201. * Gets the name of the behavior.
  35202. */
  35203. readonly name: string;
  35204. /**
  35205. * The easing function used by animations
  35206. */
  35207. static EasingFunction: BackEase;
  35208. /**
  35209. * The easing mode used by animations
  35210. */
  35211. static EasingMode: number;
  35212. /**
  35213. * The duration of the animation, in milliseconds
  35214. */
  35215. transitionDuration: number;
  35216. /**
  35217. * Length of the distance animated by the transition when lower radius is reached
  35218. */
  35219. lowerRadiusTransitionRange: number;
  35220. /**
  35221. * Length of the distance animated by the transition when upper radius is reached
  35222. */
  35223. upperRadiusTransitionRange: number;
  35224. private _autoTransitionRange;
  35225. /**
  35226. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35227. */
  35228. /**
  35229. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35230. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35231. */
  35232. autoTransitionRange: boolean;
  35233. private _attachedCamera;
  35234. private _onAfterCheckInputsObserver;
  35235. private _onMeshTargetChangedObserver;
  35236. /**
  35237. * Initializes the behavior.
  35238. */
  35239. init(): void;
  35240. /**
  35241. * Attaches the behavior to its arc rotate camera.
  35242. * @param camera Defines the camera to attach the behavior to
  35243. */
  35244. attach(camera: ArcRotateCamera): void;
  35245. /**
  35246. * Detaches the behavior from its current arc rotate camera.
  35247. */
  35248. detach(): void;
  35249. private _radiusIsAnimating;
  35250. private _radiusBounceTransition;
  35251. private _animatables;
  35252. private _cachedWheelPrecision;
  35253. /**
  35254. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35255. * @param radiusLimit The limit to check against.
  35256. * @return Bool to indicate if at limit.
  35257. */
  35258. private _isRadiusAtLimit;
  35259. /**
  35260. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35261. * @param radiusDelta The delta by which to animate to. Can be negative.
  35262. */
  35263. private _applyBoundRadiusAnimation;
  35264. /**
  35265. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35266. */
  35267. protected _clearAnimationLocks(): void;
  35268. /**
  35269. * Stops and removes all animations that have been applied to the camera
  35270. */
  35271. stopAllAnimations(): void;
  35272. }
  35273. }
  35274. declare module BABYLON {
  35275. /**
  35276. * 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.
  35277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35278. */
  35279. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35280. /**
  35281. * Gets the name of the behavior.
  35282. */
  35283. readonly name: string;
  35284. private _mode;
  35285. private _radiusScale;
  35286. private _positionScale;
  35287. private _defaultElevation;
  35288. private _elevationReturnTime;
  35289. private _elevationReturnWaitTime;
  35290. private _zoomStopsAnimation;
  35291. private _framingTime;
  35292. /**
  35293. * The easing function used by animations
  35294. */
  35295. static EasingFunction: ExponentialEase;
  35296. /**
  35297. * The easing mode used by animations
  35298. */
  35299. static EasingMode: number;
  35300. /**
  35301. * Sets the current mode used by the behavior
  35302. */
  35303. /**
  35304. * Gets current mode used by the behavior.
  35305. */
  35306. mode: number;
  35307. /**
  35308. * Sets the scale applied to the radius (1 by default)
  35309. */
  35310. /**
  35311. * Gets the scale applied to the radius
  35312. */
  35313. radiusScale: number;
  35314. /**
  35315. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35316. */
  35317. /**
  35318. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35319. */
  35320. positionScale: number;
  35321. /**
  35322. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35323. * behaviour is triggered, in radians.
  35324. */
  35325. /**
  35326. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35327. * behaviour is triggered, in radians.
  35328. */
  35329. defaultElevation: number;
  35330. /**
  35331. * Sets the time (in milliseconds) taken to return to the default beta position.
  35332. * Negative value indicates camera should not return to default.
  35333. */
  35334. /**
  35335. * Gets the time (in milliseconds) taken to return to the default beta position.
  35336. * Negative value indicates camera should not return to default.
  35337. */
  35338. elevationReturnTime: number;
  35339. /**
  35340. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35341. */
  35342. /**
  35343. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35344. */
  35345. elevationReturnWaitTime: number;
  35346. /**
  35347. * Sets the flag that indicates if user zooming should stop animation.
  35348. */
  35349. /**
  35350. * Gets the flag that indicates if user zooming should stop animation.
  35351. */
  35352. zoomStopsAnimation: boolean;
  35353. /**
  35354. * Sets the transition time when framing the mesh, in milliseconds
  35355. */
  35356. /**
  35357. * Gets the transition time when framing the mesh, in milliseconds
  35358. */
  35359. framingTime: number;
  35360. /**
  35361. * Define if the behavior should automatically change the configured
  35362. * camera limits and sensibilities.
  35363. */
  35364. autoCorrectCameraLimitsAndSensibility: boolean;
  35365. private _onPrePointerObservableObserver;
  35366. private _onAfterCheckInputsObserver;
  35367. private _onMeshTargetChangedObserver;
  35368. private _attachedCamera;
  35369. private _isPointerDown;
  35370. private _lastInteractionTime;
  35371. /**
  35372. * Initializes the behavior.
  35373. */
  35374. init(): void;
  35375. /**
  35376. * Attaches the behavior to its arc rotate camera.
  35377. * @param camera Defines the camera to attach the behavior to
  35378. */
  35379. attach(camera: ArcRotateCamera): void;
  35380. /**
  35381. * Detaches the behavior from its current arc rotate camera.
  35382. */
  35383. detach(): void;
  35384. private _animatables;
  35385. private _betaIsAnimating;
  35386. private _betaTransition;
  35387. private _radiusTransition;
  35388. private _vectorTransition;
  35389. /**
  35390. * Targets the given mesh and updates zoom level accordingly.
  35391. * @param mesh The mesh to target.
  35392. * @param radius Optional. If a cached radius position already exists, overrides default.
  35393. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35396. */
  35397. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35398. /**
  35399. * Targets the given mesh with its children and updates zoom level accordingly.
  35400. * @param mesh The mesh to target.
  35401. * @param radius Optional. If a cached radius position already exists, overrides default.
  35402. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35403. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35404. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35405. */
  35406. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35407. /**
  35408. * Targets the given meshes with their children and updates zoom level accordingly.
  35409. * @param meshes The mesh to target.
  35410. * @param radius Optional. If a cached radius position already exists, overrides default.
  35411. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35412. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35413. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35414. */
  35415. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35416. /**
  35417. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35418. * @param minimumWorld Determines the smaller position of the bounding box extend
  35419. * @param maximumWorld Determines the bigger position of the bounding box extend
  35420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35422. */
  35423. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35424. /**
  35425. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35426. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35427. * frustum width.
  35428. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35429. * to fully enclose the mesh in the viewing frustum.
  35430. */
  35431. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35432. /**
  35433. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35434. * is automatically returned to its default position (expected to be above ground plane).
  35435. */
  35436. private _maintainCameraAboveGround;
  35437. /**
  35438. * Returns the frustum slope based on the canvas ratio and camera FOV
  35439. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35440. */
  35441. private _getFrustumSlope;
  35442. /**
  35443. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35444. */
  35445. private _clearAnimationLocks;
  35446. /**
  35447. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35448. */
  35449. private _applyUserInteraction;
  35450. /**
  35451. * Stops and removes all animations that have been applied to the camera
  35452. */
  35453. stopAllAnimations(): void;
  35454. /**
  35455. * Gets a value indicating if the user is moving the camera
  35456. */
  35457. readonly isUserIsMoving: boolean;
  35458. /**
  35459. * The camera can move all the way towards the mesh.
  35460. */
  35461. static IgnoreBoundsSizeMode: number;
  35462. /**
  35463. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35464. */
  35465. static FitFrustumSidesMode: number;
  35466. }
  35467. }
  35468. declare module BABYLON {
  35469. /**
  35470. * Base class for Camera Pointer Inputs.
  35471. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35472. * for example usage.
  35473. */
  35474. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35475. /**
  35476. * Defines the camera the input is attached to.
  35477. */
  35478. abstract camera: Camera;
  35479. /**
  35480. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35481. */
  35482. protected _altKey: boolean;
  35483. protected _ctrlKey: boolean;
  35484. protected _metaKey: boolean;
  35485. protected _shiftKey: boolean;
  35486. /**
  35487. * Which mouse buttons were pressed at time of last mouse event.
  35488. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35489. */
  35490. protected _buttonsPressed: number;
  35491. /**
  35492. * Defines the buttons associated with the input to handle camera move.
  35493. */
  35494. buttons: number[];
  35495. /**
  35496. * Attach the input controls to a specific dom element to get the input from.
  35497. * @param element Defines the element the controls should be listened from
  35498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35499. */
  35500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35501. /**
  35502. * Detach the current controls from the specified dom element.
  35503. * @param element Defines the element to stop listening the inputs from
  35504. */
  35505. detachControl(element: Nullable<HTMLElement>): void;
  35506. /**
  35507. * Gets the class name of the current input.
  35508. * @returns the class name
  35509. */
  35510. getClassName(): string;
  35511. /**
  35512. * Get the friendly name associated with the input class.
  35513. * @returns the input friendly name
  35514. */
  35515. getSimpleName(): string;
  35516. /**
  35517. * Called on pointer POINTERDOUBLETAP event.
  35518. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35519. */
  35520. protected onDoubleTap(type: string): void;
  35521. /**
  35522. * Called on pointer POINTERMOVE event if only a single touch is active.
  35523. * Override this method to provide functionality.
  35524. */
  35525. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35526. /**
  35527. * Called on pointer POINTERMOVE event if multiple touches are active.
  35528. * Override this method to provide functionality.
  35529. */
  35530. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35531. /**
  35532. * Called on JS contextmenu event.
  35533. * Override this method to provide functionality.
  35534. */
  35535. protected onContextMenu(evt: PointerEvent): void;
  35536. /**
  35537. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35538. * press.
  35539. * Override this method to provide functionality.
  35540. */
  35541. protected onButtonDown(evt: PointerEvent): void;
  35542. /**
  35543. * Called each time a new POINTERUP event occurs. Ie, for each button
  35544. * release.
  35545. * Override this method to provide functionality.
  35546. */
  35547. protected onButtonUp(evt: PointerEvent): void;
  35548. /**
  35549. * Called when window becomes inactive.
  35550. * Override this method to provide functionality.
  35551. */
  35552. protected onLostFocus(): void;
  35553. private _pointerInput;
  35554. private _observer;
  35555. private _onLostFocus;
  35556. private pointA;
  35557. private pointB;
  35558. }
  35559. }
  35560. declare module BABYLON {
  35561. /**
  35562. * Manage the pointers inputs to control an arc rotate camera.
  35563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35564. */
  35565. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35566. /**
  35567. * Defines the camera the input is attached to.
  35568. */
  35569. camera: ArcRotateCamera;
  35570. /**
  35571. * Gets the class name of the current input.
  35572. * @returns the class name
  35573. */
  35574. getClassName(): string;
  35575. /**
  35576. * Defines the buttons associated with the input to handle camera move.
  35577. */
  35578. buttons: number[];
  35579. /**
  35580. * Defines the pointer angular sensibility along the X axis or how fast is
  35581. * the camera rotating.
  35582. */
  35583. angularSensibilityX: number;
  35584. /**
  35585. * Defines the pointer angular sensibility along the Y axis or how fast is
  35586. * the camera rotating.
  35587. */
  35588. angularSensibilityY: number;
  35589. /**
  35590. * Defines the pointer pinch precision or how fast is the camera zooming.
  35591. */
  35592. pinchPrecision: number;
  35593. /**
  35594. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35595. * from 0.
  35596. * It defines the percentage of current camera.radius to use as delta when
  35597. * pinch zoom is used.
  35598. */
  35599. pinchDeltaPercentage: number;
  35600. /**
  35601. * Defines the pointer panning sensibility or how fast is the camera moving.
  35602. */
  35603. panningSensibility: number;
  35604. /**
  35605. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35606. */
  35607. multiTouchPanning: boolean;
  35608. /**
  35609. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35610. * zoom (pinch) through multitouch.
  35611. */
  35612. multiTouchPanAndZoom: boolean;
  35613. /**
  35614. * Revers pinch action direction.
  35615. */
  35616. pinchInwards: boolean;
  35617. private _isPanClick;
  35618. private _twoFingerActivityCount;
  35619. private _isPinching;
  35620. /**
  35621. * Called on pointer POINTERMOVE event if only a single touch is active.
  35622. */
  35623. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35624. /**
  35625. * Called on pointer POINTERDOUBLETAP event.
  35626. */
  35627. protected onDoubleTap(type: string): void;
  35628. /**
  35629. * Called on pointer POINTERMOVE event if multiple touches are active.
  35630. */
  35631. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35632. /**
  35633. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35634. * press.
  35635. */
  35636. protected onButtonDown(evt: PointerEvent): void;
  35637. /**
  35638. * Called each time a new POINTERUP event occurs. Ie, for each button
  35639. * release.
  35640. */
  35641. protected onButtonUp(evt: PointerEvent): void;
  35642. /**
  35643. * Called when window becomes inactive.
  35644. */
  35645. protected onLostFocus(): void;
  35646. }
  35647. }
  35648. declare module BABYLON {
  35649. /**
  35650. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35652. */
  35653. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35654. /**
  35655. * Defines the camera the input is attached to.
  35656. */
  35657. camera: ArcRotateCamera;
  35658. /**
  35659. * Defines the list of key codes associated with the up action (increase alpha)
  35660. */
  35661. keysUp: number[];
  35662. /**
  35663. * Defines the list of key codes associated with the down action (decrease alpha)
  35664. */
  35665. keysDown: number[];
  35666. /**
  35667. * Defines the list of key codes associated with the left action (increase beta)
  35668. */
  35669. keysLeft: number[];
  35670. /**
  35671. * Defines the list of key codes associated with the right action (decrease beta)
  35672. */
  35673. keysRight: number[];
  35674. /**
  35675. * Defines the list of key codes associated with the reset action.
  35676. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35677. */
  35678. keysReset: number[];
  35679. /**
  35680. * Defines the panning sensibility of the inputs.
  35681. * (How fast is the camera paning)
  35682. */
  35683. panningSensibility: number;
  35684. /**
  35685. * Defines the zooming sensibility of the inputs.
  35686. * (How fast is the camera zooming)
  35687. */
  35688. zoomingSensibility: number;
  35689. /**
  35690. * Defines wether maintaining the alt key down switch the movement mode from
  35691. * orientation to zoom.
  35692. */
  35693. useAltToZoom: boolean;
  35694. /**
  35695. * Rotation speed of the camera
  35696. */
  35697. angularSpeed: number;
  35698. private _keys;
  35699. private _ctrlPressed;
  35700. private _altPressed;
  35701. private _onCanvasBlurObserver;
  35702. private _onKeyboardObserver;
  35703. private _engine;
  35704. private _scene;
  35705. /**
  35706. * Attach the input controls to a specific dom element to get the input from.
  35707. * @param element Defines the element the controls should be listened from
  35708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35709. */
  35710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35711. /**
  35712. * Detach the current controls from the specified dom element.
  35713. * @param element Defines the element to stop listening the inputs from
  35714. */
  35715. detachControl(element: Nullable<HTMLElement>): void;
  35716. /**
  35717. * Update the current camera state depending on the inputs that have been used this frame.
  35718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35719. */
  35720. checkInputs(): void;
  35721. /**
  35722. * Gets the class name of the current intput.
  35723. * @returns the class name
  35724. */
  35725. getClassName(): string;
  35726. /**
  35727. * Get the friendly name associated with the input class.
  35728. * @returns the input friendly name
  35729. */
  35730. getSimpleName(): string;
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * Manage the mouse wheel inputs to control an arc rotate camera.
  35736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35737. */
  35738. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35739. /**
  35740. * Defines the camera the input is attached to.
  35741. */
  35742. camera: ArcRotateCamera;
  35743. /**
  35744. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35745. */
  35746. wheelPrecision: number;
  35747. /**
  35748. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35749. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35750. */
  35751. wheelDeltaPercentage: number;
  35752. private _wheel;
  35753. private _observer;
  35754. private computeDeltaFromMouseWheelLegacyEvent;
  35755. /**
  35756. * Attach the input controls to a specific dom element to get the input from.
  35757. * @param element Defines the element the controls should be listened from
  35758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35759. */
  35760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35761. /**
  35762. * Detach the current controls from the specified dom element.
  35763. * @param element Defines the element to stop listening the inputs from
  35764. */
  35765. detachControl(element: Nullable<HTMLElement>): void;
  35766. /**
  35767. * Gets the class name of the current intput.
  35768. * @returns the class name
  35769. */
  35770. getClassName(): string;
  35771. /**
  35772. * Get the friendly name associated with the input class.
  35773. * @returns the input friendly name
  35774. */
  35775. getSimpleName(): string;
  35776. }
  35777. }
  35778. declare module BABYLON {
  35779. /**
  35780. * Default Inputs manager for the ArcRotateCamera.
  35781. * It groups all the default supported inputs for ease of use.
  35782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35783. */
  35784. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35785. /**
  35786. * Instantiates a new ArcRotateCameraInputsManager.
  35787. * @param camera Defines the camera the inputs belong to
  35788. */
  35789. constructor(camera: ArcRotateCamera);
  35790. /**
  35791. * Add mouse wheel input support to the input manager.
  35792. * @returns the current input manager
  35793. */
  35794. addMouseWheel(): ArcRotateCameraInputsManager;
  35795. /**
  35796. * Add pointers input support to the input manager.
  35797. * @returns the current input manager
  35798. */
  35799. addPointers(): ArcRotateCameraInputsManager;
  35800. /**
  35801. * Add keyboard input support to the input manager.
  35802. * @returns the current input manager
  35803. */
  35804. addKeyboard(): ArcRotateCameraInputsManager;
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /**
  35809. * This represents an orbital type of camera.
  35810. *
  35811. * 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.
  35812. * 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.
  35813. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35814. */
  35815. export class ArcRotateCamera extends TargetCamera {
  35816. /**
  35817. * Defines the rotation angle of the camera along the longitudinal axis.
  35818. */
  35819. alpha: number;
  35820. /**
  35821. * Defines the rotation angle of the camera along the latitudinal axis.
  35822. */
  35823. beta: number;
  35824. /**
  35825. * Defines the radius of the camera from it s target point.
  35826. */
  35827. radius: number;
  35828. protected _target: Vector3;
  35829. protected _targetHost: Nullable<AbstractMesh>;
  35830. /**
  35831. * Defines the target point of the camera.
  35832. * The camera looks towards it form the radius distance.
  35833. */
  35834. target: Vector3;
  35835. /**
  35836. * Define the current local position of the camera in the scene
  35837. */
  35838. position: Vector3;
  35839. protected _upVector: Vector3;
  35840. protected _upToYMatrix: Matrix;
  35841. protected _YToUpMatrix: Matrix;
  35842. /**
  35843. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35844. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35845. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35846. */
  35847. upVector: Vector3;
  35848. /**
  35849. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35850. */
  35851. setMatUp(): void;
  35852. /**
  35853. * Current inertia value on the longitudinal axis.
  35854. * The bigger this number the longer it will take for the camera to stop.
  35855. */
  35856. inertialAlphaOffset: number;
  35857. /**
  35858. * Current inertia value on the latitudinal axis.
  35859. * The bigger this number the longer it will take for the camera to stop.
  35860. */
  35861. inertialBetaOffset: number;
  35862. /**
  35863. * Current inertia value on the radius axis.
  35864. * The bigger this number the longer it will take for the camera to stop.
  35865. */
  35866. inertialRadiusOffset: number;
  35867. /**
  35868. * Minimum allowed angle on the longitudinal axis.
  35869. * This can help limiting how the Camera is able to move in the scene.
  35870. */
  35871. lowerAlphaLimit: Nullable<number>;
  35872. /**
  35873. * Maximum allowed angle on the longitudinal axis.
  35874. * This can help limiting how the Camera is able to move in the scene.
  35875. */
  35876. upperAlphaLimit: Nullable<number>;
  35877. /**
  35878. * Minimum allowed angle on the latitudinal axis.
  35879. * This can help limiting how the Camera is able to move in the scene.
  35880. */
  35881. lowerBetaLimit: number;
  35882. /**
  35883. * Maximum allowed angle on the latitudinal axis.
  35884. * This can help limiting how the Camera is able to move in the scene.
  35885. */
  35886. upperBetaLimit: number;
  35887. /**
  35888. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35889. * This can help limiting how the Camera is able to move in the scene.
  35890. */
  35891. lowerRadiusLimit: Nullable<number>;
  35892. /**
  35893. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35894. * This can help limiting how the Camera is able to move in the scene.
  35895. */
  35896. upperRadiusLimit: Nullable<number>;
  35897. /**
  35898. * Defines the current inertia value used during panning of the camera along the X axis.
  35899. */
  35900. inertialPanningX: number;
  35901. /**
  35902. * Defines the current inertia value used during panning of the camera along the Y axis.
  35903. */
  35904. inertialPanningY: number;
  35905. /**
  35906. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35907. * Basically if your fingers moves away from more than this distance you will be considered
  35908. * in pinch mode.
  35909. */
  35910. pinchToPanMaxDistance: number;
  35911. /**
  35912. * Defines the maximum distance the camera can pan.
  35913. * This could help keeping the cammera always in your scene.
  35914. */
  35915. panningDistanceLimit: Nullable<number>;
  35916. /**
  35917. * Defines the target of the camera before paning.
  35918. */
  35919. panningOriginTarget: Vector3;
  35920. /**
  35921. * Defines the value of the inertia used during panning.
  35922. * 0 would mean stop inertia and one would mean no decelleration at all.
  35923. */
  35924. panningInertia: number;
  35925. /**
  35926. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35927. */
  35928. angularSensibilityX: number;
  35929. /**
  35930. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35931. */
  35932. angularSensibilityY: number;
  35933. /**
  35934. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35935. */
  35936. pinchPrecision: number;
  35937. /**
  35938. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35939. * It will be used instead of pinchDeltaPrecision if different from 0.
  35940. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35941. */
  35942. pinchDeltaPercentage: number;
  35943. /**
  35944. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35945. */
  35946. panningSensibility: number;
  35947. /**
  35948. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35949. */
  35950. keysUp: number[];
  35951. /**
  35952. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35953. */
  35954. keysDown: number[];
  35955. /**
  35956. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35957. */
  35958. keysLeft: number[];
  35959. /**
  35960. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35961. */
  35962. keysRight: number[];
  35963. /**
  35964. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35965. */
  35966. wheelPrecision: number;
  35967. /**
  35968. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35969. * It will be used instead of pinchDeltaPrecision if different from 0.
  35970. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35971. */
  35972. wheelDeltaPercentage: number;
  35973. /**
  35974. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35975. */
  35976. zoomOnFactor: number;
  35977. /**
  35978. * Defines a screen offset for the camera position.
  35979. */
  35980. targetScreenOffset: Vector2;
  35981. /**
  35982. * Allows the camera to be completely reversed.
  35983. * If false the camera can not arrive upside down.
  35984. */
  35985. allowUpsideDown: boolean;
  35986. /**
  35987. * Define if double tap/click is used to restore the previously saved state of the camera.
  35988. */
  35989. useInputToRestoreState: boolean;
  35990. /** @hidden */
  35991. _viewMatrix: Matrix;
  35992. /** @hidden */
  35993. _useCtrlForPanning: boolean;
  35994. /** @hidden */
  35995. _panningMouseButton: number;
  35996. /**
  35997. * Defines the input associated to the camera.
  35998. */
  35999. inputs: ArcRotateCameraInputsManager;
  36000. /** @hidden */
  36001. _reset: () => void;
  36002. /**
  36003. * Defines the allowed panning axis.
  36004. */
  36005. panningAxis: Vector3;
  36006. protected _localDirection: Vector3;
  36007. protected _transformedDirection: Vector3;
  36008. private _bouncingBehavior;
  36009. /**
  36010. * Gets the bouncing behavior of the camera if it has been enabled.
  36011. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36012. */
  36013. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36014. /**
  36015. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36017. */
  36018. useBouncingBehavior: boolean;
  36019. private _framingBehavior;
  36020. /**
  36021. * Gets the framing behavior of the camera if it has been enabled.
  36022. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36023. */
  36024. readonly framingBehavior: Nullable<FramingBehavior>;
  36025. /**
  36026. * Defines if the framing behavior of the camera is enabled on the camera.
  36027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36028. */
  36029. useFramingBehavior: boolean;
  36030. private _autoRotationBehavior;
  36031. /**
  36032. * Gets the auto rotation behavior of the camera if it has been enabled.
  36033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36034. */
  36035. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36036. /**
  36037. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36039. */
  36040. useAutoRotationBehavior: boolean;
  36041. /**
  36042. * Observable triggered when the mesh target has been changed on the camera.
  36043. */
  36044. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36045. /**
  36046. * Event raised when the camera is colliding with a mesh.
  36047. */
  36048. onCollide: (collidedMesh: AbstractMesh) => void;
  36049. /**
  36050. * Defines whether the camera should check collision with the objects oh the scene.
  36051. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36052. */
  36053. checkCollisions: boolean;
  36054. /**
  36055. * Defines the collision radius of the camera.
  36056. * This simulates a sphere around the camera.
  36057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36058. */
  36059. collisionRadius: Vector3;
  36060. protected _collider: Collider;
  36061. protected _previousPosition: Vector3;
  36062. protected _collisionVelocity: Vector3;
  36063. protected _newPosition: Vector3;
  36064. protected _previousAlpha: number;
  36065. protected _previousBeta: number;
  36066. protected _previousRadius: number;
  36067. protected _collisionTriggered: boolean;
  36068. protected _targetBoundingCenter: Nullable<Vector3>;
  36069. private _computationVector;
  36070. /**
  36071. * Instantiates a new ArcRotateCamera in a given scene
  36072. * @param name Defines the name of the camera
  36073. * @param alpha Defines the camera rotation along the logitudinal axis
  36074. * @param beta Defines the camera rotation along the latitudinal axis
  36075. * @param radius Defines the camera distance from its target
  36076. * @param target Defines the camera target
  36077. * @param scene Defines the scene the camera belongs to
  36078. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36079. */
  36080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36081. /** @hidden */
  36082. _initCache(): void;
  36083. /** @hidden */
  36084. _updateCache(ignoreParentClass?: boolean): void;
  36085. protected _getTargetPosition(): Vector3;
  36086. private _storedAlpha;
  36087. private _storedBeta;
  36088. private _storedRadius;
  36089. private _storedTarget;
  36090. /**
  36091. * Stores the current state of the camera (alpha, beta, radius and target)
  36092. * @returns the camera itself
  36093. */
  36094. storeState(): Camera;
  36095. /**
  36096. * @hidden
  36097. * Restored camera state. You must call storeState() first
  36098. */
  36099. _restoreStateValues(): boolean;
  36100. /** @hidden */
  36101. _isSynchronizedViewMatrix(): boolean;
  36102. /**
  36103. * Attached controls to the current camera.
  36104. * @param element Defines the element the controls should be listened from
  36105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36106. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36107. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36108. */
  36109. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36110. /**
  36111. * Detach the current controls from the camera.
  36112. * The camera will stop reacting to inputs.
  36113. * @param element Defines the element to stop listening the inputs from
  36114. */
  36115. detachControl(element: HTMLElement): void;
  36116. /** @hidden */
  36117. _checkInputs(): void;
  36118. protected _checkLimits(): void;
  36119. /**
  36120. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36121. */
  36122. rebuildAnglesAndRadius(): void;
  36123. /**
  36124. * Use a position to define the current camera related information like aplha, beta and radius
  36125. * @param position Defines the position to set the camera at
  36126. */
  36127. setPosition(position: Vector3): void;
  36128. /**
  36129. * Defines the target the camera should look at.
  36130. * This will automatically adapt alpha beta and radius to fit within the new target.
  36131. * @param target Defines the new target as a Vector or a mesh
  36132. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36133. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36134. */
  36135. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36136. /** @hidden */
  36137. _getViewMatrix(): Matrix;
  36138. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36139. /**
  36140. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36141. * @param meshes Defines the mesh to zoom on
  36142. * @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)
  36143. */
  36144. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36145. /**
  36146. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36147. * The target will be changed but the radius
  36148. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36149. * @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)
  36150. */
  36151. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36152. min: Vector3;
  36153. max: Vector3;
  36154. distance: number;
  36155. }, doNotUpdateMaxZ?: boolean): void;
  36156. /**
  36157. * @override
  36158. * Override Camera.createRigCamera
  36159. */
  36160. createRigCamera(name: string, cameraIndex: number): Camera;
  36161. /**
  36162. * @hidden
  36163. * @override
  36164. * Override Camera._updateRigCameras
  36165. */
  36166. _updateRigCameras(): void;
  36167. /**
  36168. * Destroy the camera and release the current resources hold by it.
  36169. */
  36170. dispose(): void;
  36171. /**
  36172. * Gets the current object class name.
  36173. * @return the class name
  36174. */
  36175. getClassName(): string;
  36176. }
  36177. }
  36178. declare module BABYLON {
  36179. /**
  36180. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36181. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36182. */
  36183. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36184. /**
  36185. * Gets the name of the behavior.
  36186. */
  36187. readonly name: string;
  36188. private _zoomStopsAnimation;
  36189. private _idleRotationSpeed;
  36190. private _idleRotationWaitTime;
  36191. private _idleRotationSpinupTime;
  36192. /**
  36193. * Sets the flag that indicates if user zooming should stop animation.
  36194. */
  36195. /**
  36196. * Gets the flag that indicates if user zooming should stop animation.
  36197. */
  36198. zoomStopsAnimation: boolean;
  36199. /**
  36200. * Sets the default speed at which the camera rotates around the model.
  36201. */
  36202. /**
  36203. * Gets the default speed at which the camera rotates around the model.
  36204. */
  36205. idleRotationSpeed: number;
  36206. /**
  36207. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36208. */
  36209. /**
  36210. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36211. */
  36212. idleRotationWaitTime: number;
  36213. /**
  36214. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36215. */
  36216. /**
  36217. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36218. */
  36219. idleRotationSpinupTime: number;
  36220. /**
  36221. * Gets a value indicating if the camera is currently rotating because of this behavior
  36222. */
  36223. readonly rotationInProgress: boolean;
  36224. private _onPrePointerObservableObserver;
  36225. private _onAfterCheckInputsObserver;
  36226. private _attachedCamera;
  36227. private _isPointerDown;
  36228. private _lastFrameTime;
  36229. private _lastInteractionTime;
  36230. private _cameraRotationSpeed;
  36231. /**
  36232. * Initializes the behavior.
  36233. */
  36234. init(): void;
  36235. /**
  36236. * Attaches the behavior to its arc rotate camera.
  36237. * @param camera Defines the camera to attach the behavior to
  36238. */
  36239. attach(camera: ArcRotateCamera): void;
  36240. /**
  36241. * Detaches the behavior from its current arc rotate camera.
  36242. */
  36243. detach(): void;
  36244. /**
  36245. * Returns true if user is scrolling.
  36246. * @return true if user is scrolling.
  36247. */
  36248. private _userIsZooming;
  36249. private _lastFrameRadius;
  36250. private _shouldAnimationStopForInteraction;
  36251. /**
  36252. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36253. */
  36254. private _applyUserInteraction;
  36255. private _userIsMoving;
  36256. }
  36257. }
  36258. declare module BABYLON {
  36259. /**
  36260. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36261. */
  36262. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36263. private ui;
  36264. /**
  36265. * The name of the behavior
  36266. */
  36267. name: string;
  36268. /**
  36269. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36270. */
  36271. distanceAwayFromFace: number;
  36272. /**
  36273. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36274. */
  36275. distanceAwayFromBottomOfFace: number;
  36276. private _faceVectors;
  36277. private _target;
  36278. private _scene;
  36279. private _onRenderObserver;
  36280. private _tmpMatrix;
  36281. private _tmpVector;
  36282. /**
  36283. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36284. * @param ui The transform node that should be attched to the mesh
  36285. */
  36286. constructor(ui: TransformNode);
  36287. /**
  36288. * Initializes the behavior
  36289. */
  36290. init(): void;
  36291. private _closestFace;
  36292. private _zeroVector;
  36293. private _lookAtTmpMatrix;
  36294. private _lookAtToRef;
  36295. /**
  36296. * Attaches the AttachToBoxBehavior to the passed in mesh
  36297. * @param target The mesh that the specified node will be attached to
  36298. */
  36299. attach(target: Mesh): void;
  36300. /**
  36301. * Detaches the behavior from the mesh
  36302. */
  36303. detach(): void;
  36304. }
  36305. }
  36306. declare module BABYLON {
  36307. /**
  36308. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36309. */
  36310. export class FadeInOutBehavior implements Behavior<Mesh> {
  36311. /**
  36312. * Time in milliseconds to delay before fading in (Default: 0)
  36313. */
  36314. delay: number;
  36315. /**
  36316. * Time in milliseconds for the mesh to fade in (Default: 300)
  36317. */
  36318. fadeInTime: number;
  36319. private _millisecondsPerFrame;
  36320. private _hovered;
  36321. private _hoverValue;
  36322. private _ownerNode;
  36323. /**
  36324. * Instatiates the FadeInOutBehavior
  36325. */
  36326. constructor();
  36327. /**
  36328. * The name of the behavior
  36329. */
  36330. readonly name: string;
  36331. /**
  36332. * Initializes the behavior
  36333. */
  36334. init(): void;
  36335. /**
  36336. * Attaches the fade behavior on the passed in mesh
  36337. * @param ownerNode The mesh that will be faded in/out once attached
  36338. */
  36339. attach(ownerNode: Mesh): void;
  36340. /**
  36341. * Detaches the behavior from the mesh
  36342. */
  36343. detach(): void;
  36344. /**
  36345. * Triggers the mesh to begin fading in or out
  36346. * @param value if the object should fade in or out (true to fade in)
  36347. */
  36348. fadeIn(value: boolean): void;
  36349. private _update;
  36350. private _setAllVisibility;
  36351. }
  36352. }
  36353. declare module BABYLON {
  36354. /**
  36355. * Class containing a set of static utilities functions for managing Pivots
  36356. * @hidden
  36357. */
  36358. export class PivotTools {
  36359. private static _PivotCached;
  36360. private static _OldPivotPoint;
  36361. private static _PivotTranslation;
  36362. private static _PivotTmpVector;
  36363. /** @hidden */
  36364. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36365. /** @hidden */
  36366. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36367. }
  36368. }
  36369. declare module BABYLON {
  36370. /**
  36371. * Class containing static functions to help procedurally build meshes
  36372. */
  36373. export class PlaneBuilder {
  36374. /**
  36375. * Creates a plane mesh
  36376. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36377. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36378. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36380. * * 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
  36381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36382. * @param name defines the name of the mesh
  36383. * @param options defines the options used to create the mesh
  36384. * @param scene defines the hosting scene
  36385. * @returns the plane mesh
  36386. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36387. */
  36388. static CreatePlane(name: string, options: {
  36389. size?: number;
  36390. width?: number;
  36391. height?: number;
  36392. sideOrientation?: number;
  36393. frontUVs?: Vector4;
  36394. backUVs?: Vector4;
  36395. updatable?: boolean;
  36396. sourcePlane?: Plane;
  36397. }, scene?: Nullable<Scene>): Mesh;
  36398. }
  36399. }
  36400. declare module BABYLON {
  36401. /**
  36402. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36403. */
  36404. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36405. private static _AnyMouseID;
  36406. /**
  36407. * Abstract mesh the behavior is set on
  36408. */
  36409. attachedNode: AbstractMesh;
  36410. private _dragPlane;
  36411. private _scene;
  36412. private _pointerObserver;
  36413. private _beforeRenderObserver;
  36414. private static _planeScene;
  36415. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36416. /**
  36417. * 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)
  36418. */
  36419. maxDragAngle: number;
  36420. /**
  36421. * @hidden
  36422. */
  36423. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36424. /**
  36425. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36426. */
  36427. currentDraggingPointerID: number;
  36428. /**
  36429. * The last position where the pointer hit the drag plane in world space
  36430. */
  36431. lastDragPosition: Vector3;
  36432. /**
  36433. * If the behavior is currently in a dragging state
  36434. */
  36435. dragging: boolean;
  36436. /**
  36437. * 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)
  36438. */
  36439. dragDeltaRatio: number;
  36440. /**
  36441. * If the drag plane orientation should be updated during the dragging (Default: true)
  36442. */
  36443. updateDragPlane: boolean;
  36444. private _debugMode;
  36445. private _moving;
  36446. /**
  36447. * Fires each time the attached mesh is dragged with the pointer
  36448. * * delta between last drag position and current drag position in world space
  36449. * * dragDistance along the drag axis
  36450. * * dragPlaneNormal normal of the current drag plane used during the drag
  36451. * * dragPlanePoint in world space where the drag intersects the drag plane
  36452. */
  36453. onDragObservable: Observable<{
  36454. delta: Vector3;
  36455. dragPlanePoint: Vector3;
  36456. dragPlaneNormal: Vector3;
  36457. dragDistance: number;
  36458. pointerId: number;
  36459. }>;
  36460. /**
  36461. * Fires each time a drag begins (eg. mouse down on mesh)
  36462. */
  36463. onDragStartObservable: Observable<{
  36464. dragPlanePoint: Vector3;
  36465. pointerId: number;
  36466. }>;
  36467. /**
  36468. * Fires each time a drag ends (eg. mouse release after drag)
  36469. */
  36470. onDragEndObservable: Observable<{
  36471. dragPlanePoint: Vector3;
  36472. pointerId: number;
  36473. }>;
  36474. /**
  36475. * If the attached mesh should be moved when dragged
  36476. */
  36477. moveAttached: boolean;
  36478. /**
  36479. * If the drag behavior will react to drag events (Default: true)
  36480. */
  36481. enabled: boolean;
  36482. /**
  36483. * If pointer events should start and release the drag (Default: true)
  36484. */
  36485. startAndReleaseDragOnPointerEvents: boolean;
  36486. /**
  36487. * If camera controls should be detached during the drag
  36488. */
  36489. detachCameraControls: boolean;
  36490. /**
  36491. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36492. */
  36493. useObjectOrienationForDragging: boolean;
  36494. private _options;
  36495. /**
  36496. * Creates a pointer drag behavior that can be attached to a mesh
  36497. * @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)
  36498. */
  36499. constructor(options?: {
  36500. dragAxis?: Vector3;
  36501. dragPlaneNormal?: Vector3;
  36502. });
  36503. /**
  36504. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36505. */
  36506. validateDrag: (targetPosition: Vector3) => boolean;
  36507. /**
  36508. * The name of the behavior
  36509. */
  36510. readonly name: string;
  36511. /**
  36512. * Initializes the behavior
  36513. */
  36514. init(): void;
  36515. private _tmpVector;
  36516. private _alternatePickedPoint;
  36517. private _worldDragAxis;
  36518. private _targetPosition;
  36519. private _attachedElement;
  36520. /**
  36521. * Attaches the drag behavior the passed in mesh
  36522. * @param ownerNode The mesh that will be dragged around once attached
  36523. */
  36524. attach(ownerNode: AbstractMesh): void;
  36525. /**
  36526. * Force relase the drag action by code.
  36527. */
  36528. releaseDrag(): void;
  36529. private _startDragRay;
  36530. private _lastPointerRay;
  36531. /**
  36532. * Simulates the start of a pointer drag event on the behavior
  36533. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36534. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36535. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36536. */
  36537. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36538. private _startDrag;
  36539. private _dragDelta;
  36540. private _moveDrag;
  36541. private _pickWithRayOnDragPlane;
  36542. private _pointA;
  36543. private _pointB;
  36544. private _pointC;
  36545. private _lineA;
  36546. private _lineB;
  36547. private _localAxis;
  36548. private _lookAt;
  36549. private _updateDragPlanePosition;
  36550. /**
  36551. * Detaches the behavior from the mesh
  36552. */
  36553. detach(): void;
  36554. }
  36555. }
  36556. declare module BABYLON {
  36557. /**
  36558. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36559. */
  36560. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36561. private _dragBehaviorA;
  36562. private _dragBehaviorB;
  36563. private _startDistance;
  36564. private _initialScale;
  36565. private _targetScale;
  36566. private _ownerNode;
  36567. private _sceneRenderObserver;
  36568. /**
  36569. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36570. */
  36571. constructor();
  36572. /**
  36573. * The name of the behavior
  36574. */
  36575. readonly name: string;
  36576. /**
  36577. * Initializes the behavior
  36578. */
  36579. init(): void;
  36580. private _getCurrentDistance;
  36581. /**
  36582. * Attaches the scale behavior the passed in mesh
  36583. * @param ownerNode The mesh that will be scaled around once attached
  36584. */
  36585. attach(ownerNode: Mesh): void;
  36586. /**
  36587. * Detaches the behavior from the mesh
  36588. */
  36589. detach(): void;
  36590. }
  36591. }
  36592. declare module BABYLON {
  36593. /**
  36594. * 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
  36595. */
  36596. export class SixDofDragBehavior implements Behavior<Mesh> {
  36597. private static _virtualScene;
  36598. private _ownerNode;
  36599. private _sceneRenderObserver;
  36600. private _scene;
  36601. private _targetPosition;
  36602. private _virtualOriginMesh;
  36603. private _virtualDragMesh;
  36604. private _pointerObserver;
  36605. private _moving;
  36606. private _startingOrientation;
  36607. /**
  36608. * 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)
  36609. */
  36610. private zDragFactor;
  36611. /**
  36612. * If the object should rotate to face the drag origin
  36613. */
  36614. rotateDraggedObject: boolean;
  36615. /**
  36616. * If the behavior is currently in a dragging state
  36617. */
  36618. dragging: boolean;
  36619. /**
  36620. * 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)
  36621. */
  36622. dragDeltaRatio: number;
  36623. /**
  36624. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36625. */
  36626. currentDraggingPointerID: number;
  36627. /**
  36628. * If camera controls should be detached during the drag
  36629. */
  36630. detachCameraControls: boolean;
  36631. /**
  36632. * Fires each time a drag starts
  36633. */
  36634. onDragStartObservable: Observable<{}>;
  36635. /**
  36636. * Fires each time a drag ends (eg. mouse release after drag)
  36637. */
  36638. onDragEndObservable: Observable<{}>;
  36639. /**
  36640. * 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
  36641. */
  36642. constructor();
  36643. /**
  36644. * The name of the behavior
  36645. */
  36646. readonly name: string;
  36647. /**
  36648. * Initializes the behavior
  36649. */
  36650. init(): void;
  36651. /**
  36652. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36653. */
  36654. private readonly _pointerCamera;
  36655. /**
  36656. * Attaches the scale behavior the passed in mesh
  36657. * @param ownerNode The mesh that will be scaled around once attached
  36658. */
  36659. attach(ownerNode: Mesh): void;
  36660. /**
  36661. * Detaches the behavior from the mesh
  36662. */
  36663. detach(): void;
  36664. }
  36665. }
  36666. declare module BABYLON {
  36667. /**
  36668. * Class used to apply inverse kinematics to bones
  36669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36670. */
  36671. export class BoneIKController {
  36672. private static _tmpVecs;
  36673. private static _tmpQuat;
  36674. private static _tmpMats;
  36675. /**
  36676. * Gets or sets the target mesh
  36677. */
  36678. targetMesh: AbstractMesh;
  36679. /** Gets or sets the mesh used as pole */
  36680. poleTargetMesh: AbstractMesh;
  36681. /**
  36682. * Gets or sets the bone used as pole
  36683. */
  36684. poleTargetBone: Nullable<Bone>;
  36685. /**
  36686. * Gets or sets the target position
  36687. */
  36688. targetPosition: Vector3;
  36689. /**
  36690. * Gets or sets the pole target position
  36691. */
  36692. poleTargetPosition: Vector3;
  36693. /**
  36694. * Gets or sets the pole target local offset
  36695. */
  36696. poleTargetLocalOffset: Vector3;
  36697. /**
  36698. * Gets or sets the pole angle
  36699. */
  36700. poleAngle: number;
  36701. /**
  36702. * Gets or sets the mesh associated with the controller
  36703. */
  36704. mesh: AbstractMesh;
  36705. /**
  36706. * 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)
  36707. */
  36708. slerpAmount: number;
  36709. private _bone1Quat;
  36710. private _bone1Mat;
  36711. private _bone2Ang;
  36712. private _bone1;
  36713. private _bone2;
  36714. private _bone1Length;
  36715. private _bone2Length;
  36716. private _maxAngle;
  36717. private _maxReach;
  36718. private _rightHandedSystem;
  36719. private _bendAxis;
  36720. private _slerping;
  36721. private _adjustRoll;
  36722. /**
  36723. * Gets or sets maximum allowed angle
  36724. */
  36725. maxAngle: number;
  36726. /**
  36727. * Creates a new BoneIKController
  36728. * @param mesh defines the mesh to control
  36729. * @param bone defines the bone to control
  36730. * @param options defines options to set up the controller
  36731. */
  36732. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36733. targetMesh?: AbstractMesh;
  36734. poleTargetMesh?: AbstractMesh;
  36735. poleTargetBone?: Bone;
  36736. poleTargetLocalOffset?: Vector3;
  36737. poleAngle?: number;
  36738. bendAxis?: Vector3;
  36739. maxAngle?: number;
  36740. slerpAmount?: number;
  36741. });
  36742. private _setMaxAngle;
  36743. /**
  36744. * Force the controller to update the bones
  36745. */
  36746. update(): void;
  36747. }
  36748. }
  36749. declare module BABYLON {
  36750. /**
  36751. * Class used to make a bone look toward a point in space
  36752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36753. */
  36754. export class BoneLookController {
  36755. private static _tmpVecs;
  36756. private static _tmpQuat;
  36757. private static _tmpMats;
  36758. /**
  36759. * The target Vector3 that the bone will look at
  36760. */
  36761. target: Vector3;
  36762. /**
  36763. * The mesh that the bone is attached to
  36764. */
  36765. mesh: AbstractMesh;
  36766. /**
  36767. * The bone that will be looking to the target
  36768. */
  36769. bone: Bone;
  36770. /**
  36771. * The up axis of the coordinate system that is used when the bone is rotated
  36772. */
  36773. upAxis: Vector3;
  36774. /**
  36775. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36776. */
  36777. upAxisSpace: Space;
  36778. /**
  36779. * Used to make an adjustment to the yaw of the bone
  36780. */
  36781. adjustYaw: number;
  36782. /**
  36783. * Used to make an adjustment to the pitch of the bone
  36784. */
  36785. adjustPitch: number;
  36786. /**
  36787. * Used to make an adjustment to the roll of the bone
  36788. */
  36789. adjustRoll: number;
  36790. /**
  36791. * 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)
  36792. */
  36793. slerpAmount: number;
  36794. private _minYaw;
  36795. private _maxYaw;
  36796. private _minPitch;
  36797. private _maxPitch;
  36798. private _minYawSin;
  36799. private _minYawCos;
  36800. private _maxYawSin;
  36801. private _maxYawCos;
  36802. private _midYawConstraint;
  36803. private _minPitchTan;
  36804. private _maxPitchTan;
  36805. private _boneQuat;
  36806. private _slerping;
  36807. private _transformYawPitch;
  36808. private _transformYawPitchInv;
  36809. private _firstFrameSkipped;
  36810. private _yawRange;
  36811. private _fowardAxis;
  36812. /**
  36813. * Gets or sets the minimum yaw angle that the bone can look to
  36814. */
  36815. minYaw: number;
  36816. /**
  36817. * Gets or sets the maximum yaw angle that the bone can look to
  36818. */
  36819. maxYaw: number;
  36820. /**
  36821. * Gets or sets the minimum pitch angle that the bone can look to
  36822. */
  36823. minPitch: number;
  36824. /**
  36825. * Gets or sets the maximum pitch angle that the bone can look to
  36826. */
  36827. maxPitch: number;
  36828. /**
  36829. * Create a BoneLookController
  36830. * @param mesh the mesh that the bone belongs to
  36831. * @param bone the bone that will be looking to the target
  36832. * @param target the target Vector3 to look at
  36833. * @param options optional settings:
  36834. * * maxYaw: the maximum angle the bone will yaw to
  36835. * * minYaw: the minimum angle the bone will yaw to
  36836. * * maxPitch: the maximum angle the bone will pitch to
  36837. * * minPitch: the minimum angle the bone will yaw to
  36838. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36839. * * upAxis: the up axis of the coordinate system
  36840. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36841. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36842. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36843. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36844. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36845. * * adjustRoll: used to make an adjustment to the roll of the bone
  36846. **/
  36847. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36848. maxYaw?: number;
  36849. minYaw?: number;
  36850. maxPitch?: number;
  36851. minPitch?: number;
  36852. slerpAmount?: number;
  36853. upAxis?: Vector3;
  36854. upAxisSpace?: Space;
  36855. yawAxis?: Vector3;
  36856. pitchAxis?: Vector3;
  36857. adjustYaw?: number;
  36858. adjustPitch?: number;
  36859. adjustRoll?: number;
  36860. });
  36861. /**
  36862. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36863. */
  36864. update(): void;
  36865. private _getAngleDiff;
  36866. private _getAngleBetween;
  36867. private _isAngleBetween;
  36868. }
  36869. }
  36870. declare module BABYLON {
  36871. /**
  36872. * Manage the gamepad inputs to control an arc rotate camera.
  36873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36874. */
  36875. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36876. /**
  36877. * Defines the camera the input is attached to.
  36878. */
  36879. camera: ArcRotateCamera;
  36880. /**
  36881. * Defines the gamepad the input is gathering event from.
  36882. */
  36883. gamepad: Nullable<Gamepad>;
  36884. /**
  36885. * Defines the gamepad rotation sensiblity.
  36886. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36887. */
  36888. gamepadRotationSensibility: number;
  36889. /**
  36890. * Defines the gamepad move sensiblity.
  36891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36892. */
  36893. gamepadMoveSensibility: number;
  36894. private _onGamepadConnectedObserver;
  36895. private _onGamepadDisconnectedObserver;
  36896. /**
  36897. * Attach the input controls to a specific dom element to get the input from.
  36898. * @param element Defines the element the controls should be listened from
  36899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36900. */
  36901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36902. /**
  36903. * Detach the current controls from the specified dom element.
  36904. * @param element Defines the element to stop listening the inputs from
  36905. */
  36906. detachControl(element: Nullable<HTMLElement>): void;
  36907. /**
  36908. * Update the current camera state depending on the inputs that have been used this frame.
  36909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36910. */
  36911. checkInputs(): void;
  36912. /**
  36913. * Gets the class name of the current intput.
  36914. * @returns the class name
  36915. */
  36916. getClassName(): string;
  36917. /**
  36918. * Get the friendly name associated with the input class.
  36919. * @returns the input friendly name
  36920. */
  36921. getSimpleName(): string;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. interface ArcRotateCameraInputsManager {
  36926. /**
  36927. * Add orientation input support to the input manager.
  36928. * @returns the current input manager
  36929. */
  36930. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36931. }
  36932. /**
  36933. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36935. */
  36936. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36937. /**
  36938. * Defines the camera the input is attached to.
  36939. */
  36940. camera: ArcRotateCamera;
  36941. /**
  36942. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36943. */
  36944. alphaCorrection: number;
  36945. /**
  36946. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36947. */
  36948. gammaCorrection: number;
  36949. private _alpha;
  36950. private _gamma;
  36951. private _dirty;
  36952. private _deviceOrientationHandler;
  36953. /**
  36954. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36955. */
  36956. constructor();
  36957. /**
  36958. * Attach the input controls to a specific dom element to get the input from.
  36959. * @param element Defines the element the controls should be listened from
  36960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36961. */
  36962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36963. /** @hidden */
  36964. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36965. /**
  36966. * Update the current camera state depending on the inputs that have been used this frame.
  36967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36968. */
  36969. checkInputs(): void;
  36970. /**
  36971. * Detach the current controls from the specified dom element.
  36972. * @param element Defines the element to stop listening the inputs from
  36973. */
  36974. detachControl(element: Nullable<HTMLElement>): void;
  36975. /**
  36976. * Gets the class name of the current intput.
  36977. * @returns the class name
  36978. */
  36979. getClassName(): string;
  36980. /**
  36981. * Get the friendly name associated with the input class.
  36982. * @returns the input friendly name
  36983. */
  36984. getSimpleName(): string;
  36985. }
  36986. }
  36987. declare module BABYLON {
  36988. /**
  36989. * Listen to mouse events to control the camera.
  36990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36991. */
  36992. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36993. /**
  36994. * Defines the camera the input is attached to.
  36995. */
  36996. camera: FlyCamera;
  36997. /**
  36998. * Defines if touch is enabled. (Default is true.)
  36999. */
  37000. touchEnabled: boolean;
  37001. /**
  37002. * Defines the buttons associated with the input to handle camera rotation.
  37003. */
  37004. buttons: number[];
  37005. /**
  37006. * Assign buttons for Yaw control.
  37007. */
  37008. buttonsYaw: number[];
  37009. /**
  37010. * Assign buttons for Pitch control.
  37011. */
  37012. buttonsPitch: number[];
  37013. /**
  37014. * Assign buttons for Roll control.
  37015. */
  37016. buttonsRoll: number[];
  37017. /**
  37018. * Detect if any button is being pressed while mouse is moved.
  37019. * -1 = Mouse locked.
  37020. * 0 = Left button.
  37021. * 1 = Middle Button.
  37022. * 2 = Right Button.
  37023. */
  37024. activeButton: number;
  37025. /**
  37026. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37027. * Higher values reduce its sensitivity.
  37028. */
  37029. angularSensibility: number;
  37030. private _mousemoveCallback;
  37031. private _observer;
  37032. private _rollObserver;
  37033. private previousPosition;
  37034. private noPreventDefault;
  37035. private element;
  37036. /**
  37037. * Listen to mouse events to control the camera.
  37038. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37040. */
  37041. constructor(touchEnabled?: boolean);
  37042. /**
  37043. * Attach the mouse control to the HTML DOM element.
  37044. * @param element Defines the element that listens to the input events.
  37045. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37046. */
  37047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37048. /**
  37049. * Detach the current controls from the specified dom element.
  37050. * @param element Defines the element to stop listening the inputs from
  37051. */
  37052. detachControl(element: Nullable<HTMLElement>): void;
  37053. /**
  37054. * Gets the class name of the current input.
  37055. * @returns the class name.
  37056. */
  37057. getClassName(): string;
  37058. /**
  37059. * Get the friendly name associated with the input class.
  37060. * @returns the input's friendly name.
  37061. */
  37062. getSimpleName(): string;
  37063. private _pointerInput;
  37064. private _onMouseMove;
  37065. /**
  37066. * Rotate camera by mouse offset.
  37067. */
  37068. private rotateCamera;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * Default Inputs manager for the FlyCamera.
  37074. * It groups all the default supported inputs for ease of use.
  37075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37076. */
  37077. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37078. /**
  37079. * Instantiates a new FlyCameraInputsManager.
  37080. * @param camera Defines the camera the inputs belong to.
  37081. */
  37082. constructor(camera: FlyCamera);
  37083. /**
  37084. * Add keyboard input support to the input manager.
  37085. * @returns the new FlyCameraKeyboardMoveInput().
  37086. */
  37087. addKeyboard(): FlyCameraInputsManager;
  37088. /**
  37089. * Add mouse input support to the input manager.
  37090. * @param touchEnabled Enable touch screen support.
  37091. * @returns the new FlyCameraMouseInput().
  37092. */
  37093. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. /**
  37098. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37099. * such as in a 3D Space Shooter or a Flight Simulator.
  37100. */
  37101. export class FlyCamera extends TargetCamera {
  37102. /**
  37103. * Define the collision ellipsoid of the camera.
  37104. * This is helpful for simulating a camera body, like a player's body.
  37105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37106. */
  37107. ellipsoid: Vector3;
  37108. /**
  37109. * Define an offset for the position of the ellipsoid around the camera.
  37110. * This can be helpful if the camera is attached away from the player's body center,
  37111. * such as at its head.
  37112. */
  37113. ellipsoidOffset: Vector3;
  37114. /**
  37115. * Enable or disable collisions of the camera with the rest of the scene objects.
  37116. */
  37117. checkCollisions: boolean;
  37118. /**
  37119. * Enable or disable gravity on the camera.
  37120. */
  37121. applyGravity: boolean;
  37122. /**
  37123. * Define the current direction the camera is moving to.
  37124. */
  37125. cameraDirection: Vector3;
  37126. /**
  37127. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37128. * This overrides and empties cameraRotation.
  37129. */
  37130. rotationQuaternion: Quaternion;
  37131. /**
  37132. * Track Roll to maintain the wanted Rolling when looking around.
  37133. */
  37134. _trackRoll: number;
  37135. /**
  37136. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37137. */
  37138. rollCorrect: number;
  37139. /**
  37140. * Mimic a banked turn, Rolling the camera when Yawing.
  37141. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37142. */
  37143. bankedTurn: boolean;
  37144. /**
  37145. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37146. */
  37147. bankedTurnLimit: number;
  37148. /**
  37149. * Value of 0 disables the banked Roll.
  37150. * Value of 1 is equal to the Yaw angle in radians.
  37151. */
  37152. bankedTurnMultiplier: number;
  37153. /**
  37154. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37155. */
  37156. inputs: FlyCameraInputsManager;
  37157. /**
  37158. * Gets the input sensibility for mouse input.
  37159. * Higher values reduce sensitivity.
  37160. */
  37161. /**
  37162. * Sets the input sensibility for a mouse input.
  37163. * Higher values reduce sensitivity.
  37164. */
  37165. angularSensibility: number;
  37166. /**
  37167. * Get the keys for camera movement forward.
  37168. */
  37169. /**
  37170. * Set the keys for camera movement forward.
  37171. */
  37172. keysForward: number[];
  37173. /**
  37174. * Get the keys for camera movement backward.
  37175. */
  37176. keysBackward: number[];
  37177. /**
  37178. * Get the keys for camera movement up.
  37179. */
  37180. /**
  37181. * Set the keys for camera movement up.
  37182. */
  37183. keysUp: number[];
  37184. /**
  37185. * Get the keys for camera movement down.
  37186. */
  37187. /**
  37188. * Set the keys for camera movement down.
  37189. */
  37190. keysDown: number[];
  37191. /**
  37192. * Get the keys for camera movement left.
  37193. */
  37194. /**
  37195. * Set the keys for camera movement left.
  37196. */
  37197. keysLeft: number[];
  37198. /**
  37199. * Set the keys for camera movement right.
  37200. */
  37201. /**
  37202. * Set the keys for camera movement right.
  37203. */
  37204. keysRight: number[];
  37205. /**
  37206. * Event raised when the camera collides with a mesh in the scene.
  37207. */
  37208. onCollide: (collidedMesh: AbstractMesh) => void;
  37209. private _collider;
  37210. private _needMoveForGravity;
  37211. private _oldPosition;
  37212. private _diffPosition;
  37213. private _newPosition;
  37214. /** @hidden */
  37215. _localDirection: Vector3;
  37216. /** @hidden */
  37217. _transformedDirection: Vector3;
  37218. /**
  37219. * Instantiates a FlyCamera.
  37220. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37221. * such as in a 3D Space Shooter or a Flight Simulator.
  37222. * @param name Define the name of the camera in the scene.
  37223. * @param position Define the starting position of the camera in the scene.
  37224. * @param scene Define the scene the camera belongs to.
  37225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37226. */
  37227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37228. /**
  37229. * Attach a control to the HTML DOM element.
  37230. * @param element Defines the element that listens to the input events.
  37231. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37232. */
  37233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37234. /**
  37235. * Detach a control from the HTML DOM element.
  37236. * The camera will stop reacting to that input.
  37237. * @param element Defines the element that listens to the input events.
  37238. */
  37239. detachControl(element: HTMLElement): void;
  37240. private _collisionMask;
  37241. /**
  37242. * Get the mask that the camera ignores in collision events.
  37243. */
  37244. /**
  37245. * Set the mask that the camera ignores in collision events.
  37246. */
  37247. collisionMask: number;
  37248. /** @hidden */
  37249. _collideWithWorld(displacement: Vector3): void;
  37250. /** @hidden */
  37251. private _onCollisionPositionChange;
  37252. /** @hidden */
  37253. _checkInputs(): void;
  37254. /** @hidden */
  37255. _decideIfNeedsToMove(): boolean;
  37256. /** @hidden */
  37257. _updatePosition(): void;
  37258. /**
  37259. * Restore the Roll to its target value at the rate specified.
  37260. * @param rate - Higher means slower restoring.
  37261. * @hidden
  37262. */
  37263. restoreRoll(rate: number): void;
  37264. /**
  37265. * Destroy the camera and release the current resources held by it.
  37266. */
  37267. dispose(): void;
  37268. /**
  37269. * Get the current object class name.
  37270. * @returns the class name.
  37271. */
  37272. getClassName(): string;
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. /**
  37277. * Listen to keyboard events to control the camera.
  37278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37279. */
  37280. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37281. /**
  37282. * Defines the camera the input is attached to.
  37283. */
  37284. camera: FlyCamera;
  37285. /**
  37286. * The list of keyboard keys used to control the forward move of the camera.
  37287. */
  37288. keysForward: number[];
  37289. /**
  37290. * The list of keyboard keys used to control the backward move of the camera.
  37291. */
  37292. keysBackward: number[];
  37293. /**
  37294. * The list of keyboard keys used to control the forward move of the camera.
  37295. */
  37296. keysUp: number[];
  37297. /**
  37298. * The list of keyboard keys used to control the backward move of the camera.
  37299. */
  37300. keysDown: number[];
  37301. /**
  37302. * The list of keyboard keys used to control the right strafe move of the camera.
  37303. */
  37304. keysRight: number[];
  37305. /**
  37306. * The list of keyboard keys used to control the left strafe move of the camera.
  37307. */
  37308. keysLeft: number[];
  37309. private _keys;
  37310. private _onCanvasBlurObserver;
  37311. private _onKeyboardObserver;
  37312. private _engine;
  37313. private _scene;
  37314. /**
  37315. * Attach the input controls to a specific dom element to get the input from.
  37316. * @param element Defines the element the controls should be listened from
  37317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37318. */
  37319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37320. /**
  37321. * Detach the current controls from the specified dom element.
  37322. * @param element Defines the element to stop listening the inputs from
  37323. */
  37324. detachControl(element: Nullable<HTMLElement>): void;
  37325. /**
  37326. * Gets the class name of the current intput.
  37327. * @returns the class name
  37328. */
  37329. getClassName(): string;
  37330. /** @hidden */
  37331. _onLostFocus(e: FocusEvent): void;
  37332. /**
  37333. * Get the friendly name associated with the input class.
  37334. * @returns the input friendly name
  37335. */
  37336. getSimpleName(): string;
  37337. /**
  37338. * Update the current camera state depending on the inputs that have been used this frame.
  37339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37340. */
  37341. checkInputs(): void;
  37342. }
  37343. }
  37344. declare module BABYLON {
  37345. /**
  37346. * Manage the mouse wheel inputs to control a follow camera.
  37347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37348. */
  37349. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37350. /**
  37351. * Defines the camera the input is attached to.
  37352. */
  37353. camera: FollowCamera;
  37354. /**
  37355. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37356. */
  37357. axisControlRadius: boolean;
  37358. /**
  37359. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37360. */
  37361. axisControlHeight: boolean;
  37362. /**
  37363. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37364. */
  37365. axisControlRotation: boolean;
  37366. /**
  37367. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37368. * relation to mouseWheel events.
  37369. */
  37370. wheelPrecision: number;
  37371. /**
  37372. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37373. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37374. */
  37375. wheelDeltaPercentage: number;
  37376. private _wheel;
  37377. private _observer;
  37378. /**
  37379. * Attach the input controls to a specific dom element to get the input from.
  37380. * @param element Defines the element the controls should be listened from
  37381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37382. */
  37383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37384. /**
  37385. * Detach the current controls from the specified dom element.
  37386. * @param element Defines the element to stop listening the inputs from
  37387. */
  37388. detachControl(element: Nullable<HTMLElement>): void;
  37389. /**
  37390. * Gets the class name of the current intput.
  37391. * @returns the class name
  37392. */
  37393. getClassName(): string;
  37394. /**
  37395. * Get the friendly name associated with the input class.
  37396. * @returns the input friendly name
  37397. */
  37398. getSimpleName(): string;
  37399. }
  37400. }
  37401. declare module BABYLON {
  37402. /**
  37403. * Manage the pointers inputs to control an follow camera.
  37404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37405. */
  37406. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37407. /**
  37408. * Defines the camera the input is attached to.
  37409. */
  37410. camera: FollowCamera;
  37411. /**
  37412. * Gets the class name of the current input.
  37413. * @returns the class name
  37414. */
  37415. getClassName(): string;
  37416. /**
  37417. * Defines the pointer angular sensibility along the X axis or how fast is
  37418. * the camera rotating.
  37419. * A negative number will reverse the axis direction.
  37420. */
  37421. angularSensibilityX: number;
  37422. /**
  37423. * Defines the pointer angular sensibility along the Y axis or how fast is
  37424. * the camera rotating.
  37425. * A negative number will reverse the axis direction.
  37426. */
  37427. angularSensibilityY: number;
  37428. /**
  37429. * Defines the pointer pinch precision or how fast is the camera zooming.
  37430. * A negative number will reverse the axis direction.
  37431. */
  37432. pinchPrecision: number;
  37433. /**
  37434. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37435. * from 0.
  37436. * It defines the percentage of current camera.radius to use as delta when
  37437. * pinch zoom is used.
  37438. */
  37439. pinchDeltaPercentage: number;
  37440. /**
  37441. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37442. */
  37443. axisXControlRadius: boolean;
  37444. /**
  37445. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37446. */
  37447. axisXControlHeight: boolean;
  37448. /**
  37449. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37450. */
  37451. axisXControlRotation: boolean;
  37452. /**
  37453. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37454. */
  37455. axisYControlRadius: boolean;
  37456. /**
  37457. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37458. */
  37459. axisYControlHeight: boolean;
  37460. /**
  37461. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37462. */
  37463. axisYControlRotation: boolean;
  37464. /**
  37465. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37466. */
  37467. axisPinchControlRadius: boolean;
  37468. /**
  37469. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37470. */
  37471. axisPinchControlHeight: boolean;
  37472. /**
  37473. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37474. */
  37475. axisPinchControlRotation: boolean;
  37476. /**
  37477. * Log error messages if basic misconfiguration has occurred.
  37478. */
  37479. warningEnable: boolean;
  37480. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37481. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37482. private _warningCounter;
  37483. private _warning;
  37484. }
  37485. }
  37486. declare module BABYLON {
  37487. /**
  37488. * Default Inputs manager for the FollowCamera.
  37489. * It groups all the default supported inputs for ease of use.
  37490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37491. */
  37492. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37493. /**
  37494. * Instantiates a new FollowCameraInputsManager.
  37495. * @param camera Defines the camera the inputs belong to
  37496. */
  37497. constructor(camera: FollowCamera);
  37498. /**
  37499. * Add keyboard input support to the input manager.
  37500. * @returns the current input manager
  37501. */
  37502. addKeyboard(): FollowCameraInputsManager;
  37503. /**
  37504. * Add mouse wheel input support to the input manager.
  37505. * @returns the current input manager
  37506. */
  37507. addMouseWheel(): FollowCameraInputsManager;
  37508. /**
  37509. * Add pointers input support to the input manager.
  37510. * @returns the current input manager
  37511. */
  37512. addPointers(): FollowCameraInputsManager;
  37513. /**
  37514. * Add orientation input support to the input manager.
  37515. * @returns the current input manager
  37516. */
  37517. addVRDeviceOrientation(): FollowCameraInputsManager;
  37518. }
  37519. }
  37520. declare module BABYLON {
  37521. /**
  37522. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37523. * an arc rotate version arcFollowCamera are available.
  37524. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37525. */
  37526. export class FollowCamera extends TargetCamera {
  37527. /**
  37528. * Distance the follow camera should follow an object at
  37529. */
  37530. radius: number;
  37531. /**
  37532. * Minimum allowed distance of the camera to the axis of rotation
  37533. * (The camera can not get closer).
  37534. * This can help limiting how the Camera is able to move in the scene.
  37535. */
  37536. lowerRadiusLimit: Nullable<number>;
  37537. /**
  37538. * Maximum allowed distance of the camera to the axis of rotation
  37539. * (The camera can not get further).
  37540. * This can help limiting how the Camera is able to move in the scene.
  37541. */
  37542. upperRadiusLimit: Nullable<number>;
  37543. /**
  37544. * Define a rotation offset between the camera and the object it follows
  37545. */
  37546. rotationOffset: number;
  37547. /**
  37548. * Minimum allowed angle to camera position relative to target object.
  37549. * This can help limiting how the Camera is able to move in the scene.
  37550. */
  37551. lowerRotationOffsetLimit: Nullable<number>;
  37552. /**
  37553. * Maximum allowed angle to camera position relative to target object.
  37554. * This can help limiting how the Camera is able to move in the scene.
  37555. */
  37556. upperRotationOffsetLimit: Nullable<number>;
  37557. /**
  37558. * Define a height offset between the camera and the object it follows.
  37559. * It can help following an object from the top (like a car chaing a plane)
  37560. */
  37561. heightOffset: number;
  37562. /**
  37563. * Minimum allowed height of camera position relative to target object.
  37564. * This can help limiting how the Camera is able to move in the scene.
  37565. */
  37566. lowerHeightOffsetLimit: Nullable<number>;
  37567. /**
  37568. * Maximum allowed height of camera position relative to target object.
  37569. * This can help limiting how the Camera is able to move in the scene.
  37570. */
  37571. upperHeightOffsetLimit: Nullable<number>;
  37572. /**
  37573. * Define how fast the camera can accelerate to follow it s target.
  37574. */
  37575. cameraAcceleration: number;
  37576. /**
  37577. * Define the speed limit of the camera following an object.
  37578. */
  37579. maxCameraSpeed: number;
  37580. /**
  37581. * Define the target of the camera.
  37582. */
  37583. lockedTarget: Nullable<AbstractMesh>;
  37584. /**
  37585. * Defines the input associated with the camera.
  37586. */
  37587. inputs: FollowCameraInputsManager;
  37588. /**
  37589. * Instantiates the follow camera.
  37590. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37591. * @param name Define the name of the camera in the scene
  37592. * @param position Define the position of the camera
  37593. * @param scene Define the scene the camera belong to
  37594. * @param lockedTarget Define the target of the camera
  37595. */
  37596. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37597. private _follow;
  37598. /**
  37599. * Attached controls to the current camera.
  37600. * @param element Defines the element the controls should be listened from
  37601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37602. */
  37603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37604. /**
  37605. * Detach the current controls from the camera.
  37606. * The camera will stop reacting to inputs.
  37607. * @param element Defines the element to stop listening the inputs from
  37608. */
  37609. detachControl(element: HTMLElement): void;
  37610. /** @hidden */
  37611. _checkInputs(): void;
  37612. private _checkLimits;
  37613. /**
  37614. * Gets the camera class name.
  37615. * @returns the class name
  37616. */
  37617. getClassName(): string;
  37618. }
  37619. /**
  37620. * Arc Rotate version of the follow camera.
  37621. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37622. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37623. */
  37624. export class ArcFollowCamera extends TargetCamera {
  37625. /** The longitudinal angle of the camera */
  37626. alpha: number;
  37627. /** The latitudinal angle of the camera */
  37628. beta: number;
  37629. /** The radius of the camera from its target */
  37630. radius: number;
  37631. /** Define the camera target (the messh it should follow) */
  37632. target: Nullable<AbstractMesh>;
  37633. private _cartesianCoordinates;
  37634. /**
  37635. * Instantiates a new ArcFollowCamera
  37636. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37637. * @param name Define the name of the camera
  37638. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37639. * @param beta Define the rotation angle of the camera around the elevation axis
  37640. * @param radius Define the radius of the camera from its target point
  37641. * @param target Define the target of the camera
  37642. * @param scene Define the scene the camera belongs to
  37643. */
  37644. constructor(name: string,
  37645. /** The longitudinal angle of the camera */
  37646. alpha: number,
  37647. /** The latitudinal angle of the camera */
  37648. beta: number,
  37649. /** The radius of the camera from its target */
  37650. radius: number,
  37651. /** Define the camera target (the messh it should follow) */
  37652. target: Nullable<AbstractMesh>, scene: Scene);
  37653. private _follow;
  37654. /** @hidden */
  37655. _checkInputs(): void;
  37656. /**
  37657. * Returns the class name of the object.
  37658. * It is mostly used internally for serialization purposes.
  37659. */
  37660. getClassName(): string;
  37661. }
  37662. }
  37663. declare module BABYLON {
  37664. /**
  37665. * Manage the keyboard inputs to control the movement of a follow camera.
  37666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37667. */
  37668. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37669. /**
  37670. * Defines the camera the input is attached to.
  37671. */
  37672. camera: FollowCamera;
  37673. /**
  37674. * Defines the list of key codes associated with the up action (increase heightOffset)
  37675. */
  37676. keysHeightOffsetIncr: number[];
  37677. /**
  37678. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37679. */
  37680. keysHeightOffsetDecr: number[];
  37681. /**
  37682. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37683. */
  37684. keysHeightOffsetModifierAlt: boolean;
  37685. /**
  37686. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37687. */
  37688. keysHeightOffsetModifierCtrl: boolean;
  37689. /**
  37690. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37691. */
  37692. keysHeightOffsetModifierShift: boolean;
  37693. /**
  37694. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37695. */
  37696. keysRotationOffsetIncr: number[];
  37697. /**
  37698. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37699. */
  37700. keysRotationOffsetDecr: number[];
  37701. /**
  37702. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37703. */
  37704. keysRotationOffsetModifierAlt: boolean;
  37705. /**
  37706. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37707. */
  37708. keysRotationOffsetModifierCtrl: boolean;
  37709. /**
  37710. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37711. */
  37712. keysRotationOffsetModifierShift: boolean;
  37713. /**
  37714. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37715. */
  37716. keysRadiusIncr: number[];
  37717. /**
  37718. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37719. */
  37720. keysRadiusDecr: number[];
  37721. /**
  37722. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37723. */
  37724. keysRadiusModifierAlt: boolean;
  37725. /**
  37726. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37727. */
  37728. keysRadiusModifierCtrl: boolean;
  37729. /**
  37730. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37731. */
  37732. keysRadiusModifierShift: boolean;
  37733. /**
  37734. * Defines the rate of change of heightOffset.
  37735. */
  37736. heightSensibility: number;
  37737. /**
  37738. * Defines the rate of change of rotationOffset.
  37739. */
  37740. rotationSensibility: number;
  37741. /**
  37742. * Defines the rate of change of radius.
  37743. */
  37744. radiusSensibility: number;
  37745. private _keys;
  37746. private _ctrlPressed;
  37747. private _altPressed;
  37748. private _shiftPressed;
  37749. private _onCanvasBlurObserver;
  37750. private _onKeyboardObserver;
  37751. private _engine;
  37752. private _scene;
  37753. /**
  37754. * Attach the input controls to a specific dom element to get the input from.
  37755. * @param element Defines the element the controls should be listened from
  37756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37757. */
  37758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37759. /**
  37760. * Detach the current controls from the specified dom element.
  37761. * @param element Defines the element to stop listening the inputs from
  37762. */
  37763. detachControl(element: Nullable<HTMLElement>): void;
  37764. /**
  37765. * Update the current camera state depending on the inputs that have been used this frame.
  37766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37767. */
  37768. checkInputs(): void;
  37769. /**
  37770. * Gets the class name of the current input.
  37771. * @returns the class name
  37772. */
  37773. getClassName(): string;
  37774. /**
  37775. * Get the friendly name associated with the input class.
  37776. * @returns the input friendly name
  37777. */
  37778. getSimpleName(): string;
  37779. /**
  37780. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37781. * allow modification of the heightOffset value.
  37782. */
  37783. private _modifierHeightOffset;
  37784. /**
  37785. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37786. * allow modification of the rotationOffset value.
  37787. */
  37788. private _modifierRotationOffset;
  37789. /**
  37790. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37791. * allow modification of the radius value.
  37792. */
  37793. private _modifierRadius;
  37794. }
  37795. }
  37796. declare module BABYLON {
  37797. interface FreeCameraInputsManager {
  37798. /**
  37799. * @hidden
  37800. */
  37801. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37802. /**
  37803. * Add orientation input support to the input manager.
  37804. * @returns the current input manager
  37805. */
  37806. addDeviceOrientation(): FreeCameraInputsManager;
  37807. }
  37808. /**
  37809. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37810. * Screen rotation is taken into account.
  37811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37812. */
  37813. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37814. private _camera;
  37815. private _screenOrientationAngle;
  37816. private _constantTranform;
  37817. private _screenQuaternion;
  37818. private _alpha;
  37819. private _beta;
  37820. private _gamma;
  37821. /**
  37822. * Can be used to detect if a device orientation sensor is availible on a device
  37823. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37824. * @returns a promise that will resolve on orientation change
  37825. */
  37826. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37827. /**
  37828. * @hidden
  37829. */
  37830. _onDeviceOrientationChangedObservable: Observable<void>;
  37831. /**
  37832. * Instantiates a new input
  37833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37834. */
  37835. constructor();
  37836. /**
  37837. * Define the camera controlled by the input.
  37838. */
  37839. camera: FreeCamera;
  37840. /**
  37841. * Attach the input controls to a specific dom element to get the input from.
  37842. * @param element Defines the element the controls should be listened from
  37843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37844. */
  37845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37846. private _orientationChanged;
  37847. private _deviceOrientation;
  37848. /**
  37849. * Detach the current controls from the specified dom element.
  37850. * @param element Defines the element to stop listening the inputs from
  37851. */
  37852. detachControl(element: Nullable<HTMLElement>): void;
  37853. /**
  37854. * Update the current camera state depending on the inputs that have been used this frame.
  37855. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37856. */
  37857. checkInputs(): void;
  37858. /**
  37859. * Gets the class name of the current intput.
  37860. * @returns the class name
  37861. */
  37862. getClassName(): string;
  37863. /**
  37864. * Get the friendly name associated with the input class.
  37865. * @returns the input friendly name
  37866. */
  37867. getSimpleName(): string;
  37868. }
  37869. }
  37870. declare module BABYLON {
  37871. /**
  37872. * Manage the gamepad inputs to control a free camera.
  37873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37874. */
  37875. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37876. /**
  37877. * Define the camera the input is attached to.
  37878. */
  37879. camera: FreeCamera;
  37880. /**
  37881. * Define the Gamepad controlling the input
  37882. */
  37883. gamepad: Nullable<Gamepad>;
  37884. /**
  37885. * Defines the gamepad rotation sensiblity.
  37886. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37887. */
  37888. gamepadAngularSensibility: number;
  37889. /**
  37890. * Defines the gamepad move sensiblity.
  37891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37892. */
  37893. gamepadMoveSensibility: number;
  37894. private _onGamepadConnectedObserver;
  37895. private _onGamepadDisconnectedObserver;
  37896. private _cameraTransform;
  37897. private _deltaTransform;
  37898. private _vector3;
  37899. private _vector2;
  37900. /**
  37901. * Attach the input controls to a specific dom element to get the input from.
  37902. * @param element Defines the element the controls should be listened from
  37903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37904. */
  37905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37906. /**
  37907. * Detach the current controls from the specified dom element.
  37908. * @param element Defines the element to stop listening the inputs from
  37909. */
  37910. detachControl(element: Nullable<HTMLElement>): void;
  37911. /**
  37912. * Update the current camera state depending on the inputs that have been used this frame.
  37913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37914. */
  37915. checkInputs(): void;
  37916. /**
  37917. * Gets the class name of the current intput.
  37918. * @returns the class name
  37919. */
  37920. getClassName(): string;
  37921. /**
  37922. * Get the friendly name associated with the input class.
  37923. * @returns the input friendly name
  37924. */
  37925. getSimpleName(): string;
  37926. }
  37927. }
  37928. declare module BABYLON {
  37929. /**
  37930. * Defines the potential axis of a Joystick
  37931. */
  37932. export enum JoystickAxis {
  37933. /** X axis */
  37934. X = 0,
  37935. /** Y axis */
  37936. Y = 1,
  37937. /** Z axis */
  37938. Z = 2
  37939. }
  37940. /**
  37941. * Class used to define virtual joystick (used in touch mode)
  37942. */
  37943. export class VirtualJoystick {
  37944. /**
  37945. * Gets or sets a boolean indicating that left and right values must be inverted
  37946. */
  37947. reverseLeftRight: boolean;
  37948. /**
  37949. * Gets or sets a boolean indicating that up and down values must be inverted
  37950. */
  37951. reverseUpDown: boolean;
  37952. /**
  37953. * Gets the offset value for the position (ie. the change of the position value)
  37954. */
  37955. deltaPosition: Vector3;
  37956. /**
  37957. * Gets a boolean indicating if the virtual joystick was pressed
  37958. */
  37959. pressed: boolean;
  37960. /**
  37961. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37962. */
  37963. static Canvas: Nullable<HTMLCanvasElement>;
  37964. private static _globalJoystickIndex;
  37965. private static vjCanvasContext;
  37966. private static vjCanvasWidth;
  37967. private static vjCanvasHeight;
  37968. private static halfWidth;
  37969. private _action;
  37970. private _axisTargetedByLeftAndRight;
  37971. private _axisTargetedByUpAndDown;
  37972. private _joystickSensibility;
  37973. private _inversedSensibility;
  37974. private _joystickPointerID;
  37975. private _joystickColor;
  37976. private _joystickPointerPos;
  37977. private _joystickPreviousPointerPos;
  37978. private _joystickPointerStartPos;
  37979. private _deltaJoystickVector;
  37980. private _leftJoystick;
  37981. private _touches;
  37982. private _onPointerDownHandlerRef;
  37983. private _onPointerMoveHandlerRef;
  37984. private _onPointerUpHandlerRef;
  37985. private _onResize;
  37986. /**
  37987. * Creates a new virtual joystick
  37988. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37989. */
  37990. constructor(leftJoystick?: boolean);
  37991. /**
  37992. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37993. * @param newJoystickSensibility defines the new sensibility
  37994. */
  37995. setJoystickSensibility(newJoystickSensibility: number): void;
  37996. private _onPointerDown;
  37997. private _onPointerMove;
  37998. private _onPointerUp;
  37999. /**
  38000. * Change the color of the virtual joystick
  38001. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38002. */
  38003. setJoystickColor(newColor: string): void;
  38004. /**
  38005. * Defines a callback to call when the joystick is touched
  38006. * @param action defines the callback
  38007. */
  38008. setActionOnTouch(action: () => any): void;
  38009. /**
  38010. * Defines which axis you'd like to control for left & right
  38011. * @param axis defines the axis to use
  38012. */
  38013. setAxisForLeftRight(axis: JoystickAxis): void;
  38014. /**
  38015. * Defines which axis you'd like to control for up & down
  38016. * @param axis defines the axis to use
  38017. */
  38018. setAxisForUpDown(axis: JoystickAxis): void;
  38019. private _drawVirtualJoystick;
  38020. /**
  38021. * Release internal HTML canvas
  38022. */
  38023. releaseCanvas(): void;
  38024. }
  38025. }
  38026. declare module BABYLON {
  38027. interface FreeCameraInputsManager {
  38028. /**
  38029. * Add virtual joystick input support to the input manager.
  38030. * @returns the current input manager
  38031. */
  38032. addVirtualJoystick(): FreeCameraInputsManager;
  38033. }
  38034. /**
  38035. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38037. */
  38038. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38039. /**
  38040. * Defines the camera the input is attached to.
  38041. */
  38042. camera: FreeCamera;
  38043. private _leftjoystick;
  38044. private _rightjoystick;
  38045. /**
  38046. * Gets the left stick of the virtual joystick.
  38047. * @returns The virtual Joystick
  38048. */
  38049. getLeftJoystick(): VirtualJoystick;
  38050. /**
  38051. * Gets the right stick of the virtual joystick.
  38052. * @returns The virtual Joystick
  38053. */
  38054. getRightJoystick(): VirtualJoystick;
  38055. /**
  38056. * Update the current camera state depending on the inputs that have been used this frame.
  38057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38058. */
  38059. checkInputs(): void;
  38060. /**
  38061. * Attach the input controls to a specific dom element to get the input from.
  38062. * @param element Defines the element the controls should be listened from
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. */
  38065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38066. /**
  38067. * Detach the current controls from the specified dom element.
  38068. * @param element Defines the element to stop listening the inputs from
  38069. */
  38070. detachControl(element: Nullable<HTMLElement>): void;
  38071. /**
  38072. * Gets the class name of the current intput.
  38073. * @returns the class name
  38074. */
  38075. getClassName(): string;
  38076. /**
  38077. * Get the friendly name associated with the input class.
  38078. * @returns the input friendly name
  38079. */
  38080. getSimpleName(): string;
  38081. }
  38082. }
  38083. declare module BABYLON {
  38084. /**
  38085. * This represents a FPS type of camera controlled by touch.
  38086. * This is like a universal camera minus the Gamepad controls.
  38087. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38088. */
  38089. export class TouchCamera extends FreeCamera {
  38090. /**
  38091. * Defines the touch sensibility for rotation.
  38092. * The higher the faster.
  38093. */
  38094. touchAngularSensibility: number;
  38095. /**
  38096. * Defines the touch sensibility for move.
  38097. * The higher the faster.
  38098. */
  38099. touchMoveSensibility: number;
  38100. /**
  38101. * Instantiates a new touch camera.
  38102. * This represents a FPS type of camera controlled by touch.
  38103. * This is like a universal camera minus the Gamepad controls.
  38104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38105. * @param name Define the name of the camera in the scene
  38106. * @param position Define the start position of the camera in the scene
  38107. * @param scene Define the scene the camera belongs to
  38108. */
  38109. constructor(name: string, position: Vector3, scene: Scene);
  38110. /**
  38111. * Gets the current object class name.
  38112. * @return the class name
  38113. */
  38114. getClassName(): string;
  38115. /** @hidden */
  38116. _setupInputs(): void;
  38117. }
  38118. }
  38119. declare module BABYLON {
  38120. /**
  38121. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38122. * being tilted forward or back and left or right.
  38123. */
  38124. export class DeviceOrientationCamera extends FreeCamera {
  38125. private _initialQuaternion;
  38126. private _quaternionCache;
  38127. private _tmpDragQuaternion;
  38128. /**
  38129. * Creates a new device orientation camera
  38130. * @param name The name of the camera
  38131. * @param position The start position camera
  38132. * @param scene The scene the camera belongs to
  38133. */
  38134. constructor(name: string, position: Vector3, scene: Scene);
  38135. /**
  38136. * @hidden
  38137. * Disabled pointer input on first orientation sensor update (Default: true)
  38138. */
  38139. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38140. private _dragFactor;
  38141. /**
  38142. * Enabled turning on the y axis when the orientation sensor is active
  38143. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38144. */
  38145. enableHorizontalDragging(dragFactor?: number): void;
  38146. /**
  38147. * Gets the current instance class name ("DeviceOrientationCamera").
  38148. * This helps avoiding instanceof at run time.
  38149. * @returns the class name
  38150. */
  38151. getClassName(): string;
  38152. /**
  38153. * @hidden
  38154. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38155. */
  38156. _checkInputs(): void;
  38157. /**
  38158. * Reset the camera to its default orientation on the specified axis only.
  38159. * @param axis The axis to reset
  38160. */
  38161. resetToCurrentRotation(axis?: Axis): void;
  38162. }
  38163. }
  38164. declare module BABYLON {
  38165. /**
  38166. * Defines supported buttons for XBox360 compatible gamepads
  38167. */
  38168. export enum Xbox360Button {
  38169. /** A */
  38170. A = 0,
  38171. /** B */
  38172. B = 1,
  38173. /** X */
  38174. X = 2,
  38175. /** Y */
  38176. Y = 3,
  38177. /** Start */
  38178. Start = 4,
  38179. /** Back */
  38180. Back = 5,
  38181. /** Left button */
  38182. LB = 6,
  38183. /** Right button */
  38184. RB = 7,
  38185. /** Left stick */
  38186. LeftStick = 8,
  38187. /** Right stick */
  38188. RightStick = 9
  38189. }
  38190. /** Defines values for XBox360 DPad */
  38191. export enum Xbox360Dpad {
  38192. /** Up */
  38193. Up = 0,
  38194. /** Down */
  38195. Down = 1,
  38196. /** Left */
  38197. Left = 2,
  38198. /** Right */
  38199. Right = 3
  38200. }
  38201. /**
  38202. * Defines a XBox360 gamepad
  38203. */
  38204. export class Xbox360Pad extends Gamepad {
  38205. private _leftTrigger;
  38206. private _rightTrigger;
  38207. private _onlefttriggerchanged;
  38208. private _onrighttriggerchanged;
  38209. private _onbuttondown;
  38210. private _onbuttonup;
  38211. private _ondpaddown;
  38212. private _ondpadup;
  38213. /** Observable raised when a button is pressed */
  38214. onButtonDownObservable: Observable<Xbox360Button>;
  38215. /** Observable raised when a button is released */
  38216. onButtonUpObservable: Observable<Xbox360Button>;
  38217. /** Observable raised when a pad is pressed */
  38218. onPadDownObservable: Observable<Xbox360Dpad>;
  38219. /** Observable raised when a pad is released */
  38220. onPadUpObservable: Observable<Xbox360Dpad>;
  38221. private _buttonA;
  38222. private _buttonB;
  38223. private _buttonX;
  38224. private _buttonY;
  38225. private _buttonBack;
  38226. private _buttonStart;
  38227. private _buttonLB;
  38228. private _buttonRB;
  38229. private _buttonLeftStick;
  38230. private _buttonRightStick;
  38231. private _dPadUp;
  38232. private _dPadDown;
  38233. private _dPadLeft;
  38234. private _dPadRight;
  38235. private _isXboxOnePad;
  38236. /**
  38237. * Creates a new XBox360 gamepad object
  38238. * @param id defines the id of this gamepad
  38239. * @param index defines its index
  38240. * @param gamepad defines the internal HTML gamepad object
  38241. * @param xboxOne defines if it is a XBox One gamepad
  38242. */
  38243. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38244. /**
  38245. * Defines the callback to call when left trigger is pressed
  38246. * @param callback defines the callback to use
  38247. */
  38248. onlefttriggerchanged(callback: (value: number) => void): void;
  38249. /**
  38250. * Defines the callback to call when right trigger is pressed
  38251. * @param callback defines the callback to use
  38252. */
  38253. onrighttriggerchanged(callback: (value: number) => void): void;
  38254. /**
  38255. * Gets the left trigger value
  38256. */
  38257. /**
  38258. * Sets the left trigger value
  38259. */
  38260. leftTrigger: number;
  38261. /**
  38262. * Gets the right trigger value
  38263. */
  38264. /**
  38265. * Sets the right trigger value
  38266. */
  38267. rightTrigger: number;
  38268. /**
  38269. * Defines the callback to call when a button is pressed
  38270. * @param callback defines the callback to use
  38271. */
  38272. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38273. /**
  38274. * Defines the callback to call when a button is released
  38275. * @param callback defines the callback to use
  38276. */
  38277. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38278. /**
  38279. * Defines the callback to call when a pad is pressed
  38280. * @param callback defines the callback to use
  38281. */
  38282. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38283. /**
  38284. * Defines the callback to call when a pad is released
  38285. * @param callback defines the callback to use
  38286. */
  38287. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38288. private _setButtonValue;
  38289. private _setDPadValue;
  38290. /**
  38291. * Gets the value of the `A` button
  38292. */
  38293. /**
  38294. * Sets the value of the `A` button
  38295. */
  38296. buttonA: number;
  38297. /**
  38298. * Gets the value of the `B` button
  38299. */
  38300. /**
  38301. * Sets the value of the `B` button
  38302. */
  38303. buttonB: number;
  38304. /**
  38305. * Gets the value of the `X` button
  38306. */
  38307. /**
  38308. * Sets the value of the `X` button
  38309. */
  38310. buttonX: number;
  38311. /**
  38312. * Gets the value of the `Y` button
  38313. */
  38314. /**
  38315. * Sets the value of the `Y` button
  38316. */
  38317. buttonY: number;
  38318. /**
  38319. * Gets the value of the `Start` button
  38320. */
  38321. /**
  38322. * Sets the value of the `Start` button
  38323. */
  38324. buttonStart: number;
  38325. /**
  38326. * Gets the value of the `Back` button
  38327. */
  38328. /**
  38329. * Sets the value of the `Back` button
  38330. */
  38331. buttonBack: number;
  38332. /**
  38333. * Gets the value of the `Left` button
  38334. */
  38335. /**
  38336. * Sets the value of the `Left` button
  38337. */
  38338. buttonLB: number;
  38339. /**
  38340. * Gets the value of the `Right` button
  38341. */
  38342. /**
  38343. * Sets the value of the `Right` button
  38344. */
  38345. buttonRB: number;
  38346. /**
  38347. * Gets the value of the Left joystick
  38348. */
  38349. /**
  38350. * Sets the value of the Left joystick
  38351. */
  38352. buttonLeftStick: number;
  38353. /**
  38354. * Gets the value of the Right joystick
  38355. */
  38356. /**
  38357. * Sets the value of the Right joystick
  38358. */
  38359. buttonRightStick: number;
  38360. /**
  38361. * Gets the value of D-pad up
  38362. */
  38363. /**
  38364. * Sets the value of D-pad up
  38365. */
  38366. dPadUp: number;
  38367. /**
  38368. * Gets the value of D-pad down
  38369. */
  38370. /**
  38371. * Sets the value of D-pad down
  38372. */
  38373. dPadDown: number;
  38374. /**
  38375. * Gets the value of D-pad left
  38376. */
  38377. /**
  38378. * Sets the value of D-pad left
  38379. */
  38380. dPadLeft: number;
  38381. /**
  38382. * Gets the value of D-pad right
  38383. */
  38384. /**
  38385. * Sets the value of D-pad right
  38386. */
  38387. dPadRight: number;
  38388. /**
  38389. * Force the gamepad to synchronize with device values
  38390. */
  38391. update(): void;
  38392. /**
  38393. * Disposes the gamepad
  38394. */
  38395. dispose(): void;
  38396. }
  38397. }
  38398. declare module BABYLON {
  38399. /**
  38400. * Manager for handling gamepads
  38401. */
  38402. export class GamepadManager {
  38403. private _scene?;
  38404. private _babylonGamepads;
  38405. private _oneGamepadConnected;
  38406. /** @hidden */
  38407. _isMonitoring: boolean;
  38408. private _gamepadEventSupported;
  38409. private _gamepadSupport;
  38410. /**
  38411. * observable to be triggered when the gamepad controller has been connected
  38412. */
  38413. onGamepadConnectedObservable: Observable<Gamepad>;
  38414. /**
  38415. * observable to be triggered when the gamepad controller has been disconnected
  38416. */
  38417. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38418. private _onGamepadConnectedEvent;
  38419. private _onGamepadDisconnectedEvent;
  38420. /**
  38421. * Initializes the gamepad manager
  38422. * @param _scene BabylonJS scene
  38423. */
  38424. constructor(_scene?: Scene | undefined);
  38425. /**
  38426. * The gamepads in the game pad manager
  38427. */
  38428. readonly gamepads: Gamepad[];
  38429. /**
  38430. * Get the gamepad controllers based on type
  38431. * @param type The type of gamepad controller
  38432. * @returns Nullable gamepad
  38433. */
  38434. getGamepadByType(type?: number): Nullable<Gamepad>;
  38435. /**
  38436. * Disposes the gamepad manager
  38437. */
  38438. dispose(): void;
  38439. private _addNewGamepad;
  38440. private _startMonitoringGamepads;
  38441. private _stopMonitoringGamepads;
  38442. /** @hidden */
  38443. _checkGamepadsStatus(): void;
  38444. private _updateGamepadObjects;
  38445. }
  38446. }
  38447. declare module BABYLON {
  38448. interface Scene {
  38449. /** @hidden */
  38450. _gamepadManager: Nullable<GamepadManager>;
  38451. /**
  38452. * Gets the gamepad manager associated with the scene
  38453. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38454. */
  38455. gamepadManager: GamepadManager;
  38456. }
  38457. /**
  38458. * Interface representing a free camera inputs manager
  38459. */
  38460. interface FreeCameraInputsManager {
  38461. /**
  38462. * Adds gamepad input support to the FreeCameraInputsManager.
  38463. * @returns the FreeCameraInputsManager
  38464. */
  38465. addGamepad(): FreeCameraInputsManager;
  38466. }
  38467. /**
  38468. * Interface representing an arc rotate camera inputs manager
  38469. */
  38470. interface ArcRotateCameraInputsManager {
  38471. /**
  38472. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38473. * @returns the camera inputs manager
  38474. */
  38475. addGamepad(): ArcRotateCameraInputsManager;
  38476. }
  38477. /**
  38478. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38479. */
  38480. export class GamepadSystemSceneComponent implements ISceneComponent {
  38481. /**
  38482. * The component name helpfull to identify the component in the list of scene components.
  38483. */
  38484. readonly name: string;
  38485. /**
  38486. * The scene the component belongs to.
  38487. */
  38488. scene: Scene;
  38489. /**
  38490. * Creates a new instance of the component for the given scene
  38491. * @param scene Defines the scene to register the component in
  38492. */
  38493. constructor(scene: Scene);
  38494. /**
  38495. * Registers the component in a given scene
  38496. */
  38497. register(): void;
  38498. /**
  38499. * Rebuilds the elements related to this component in case of
  38500. * context lost for instance.
  38501. */
  38502. rebuild(): void;
  38503. /**
  38504. * Disposes the component and the associated ressources
  38505. */
  38506. dispose(): void;
  38507. private _beforeCameraUpdate;
  38508. }
  38509. }
  38510. declare module BABYLON {
  38511. /**
  38512. * 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,
  38513. * which still works and will still be found in many Playgrounds.
  38514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38515. */
  38516. export class UniversalCamera extends TouchCamera {
  38517. /**
  38518. * Defines the gamepad rotation sensiblity.
  38519. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38520. */
  38521. gamepadAngularSensibility: number;
  38522. /**
  38523. * Defines the gamepad move sensiblity.
  38524. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38525. */
  38526. gamepadMoveSensibility: number;
  38527. /**
  38528. * 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,
  38529. * which still works and will still be found in many Playgrounds.
  38530. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38531. * @param name Define the name of the camera in the scene
  38532. * @param position Define the start position of the camera in the scene
  38533. * @param scene Define the scene the camera belongs to
  38534. */
  38535. constructor(name: string, position: Vector3, scene: Scene);
  38536. /**
  38537. * Gets the current object class name.
  38538. * @return the class name
  38539. */
  38540. getClassName(): string;
  38541. }
  38542. }
  38543. declare module BABYLON {
  38544. /**
  38545. * This represents a FPS type of camera. This is only here for back compat purpose.
  38546. * Please use the UniversalCamera instead as both are identical.
  38547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38548. */
  38549. export class GamepadCamera extends UniversalCamera {
  38550. /**
  38551. * Instantiates a new Gamepad Camera
  38552. * This represents a FPS type of camera. This is only here for back compat purpose.
  38553. * Please use the UniversalCamera instead as both are identical.
  38554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38555. * @param name Define the name of the camera in the scene
  38556. * @param position Define the start position of the camera in the scene
  38557. * @param scene Define the scene the camera belongs to
  38558. */
  38559. constructor(name: string, position: Vector3, scene: Scene);
  38560. /**
  38561. * Gets the current object class name.
  38562. * @return the class name
  38563. */
  38564. getClassName(): string;
  38565. }
  38566. }
  38567. declare module BABYLON {
  38568. /** @hidden */
  38569. export var passPixelShader: {
  38570. name: string;
  38571. shader: string;
  38572. };
  38573. }
  38574. declare module BABYLON {
  38575. /** @hidden */
  38576. export var passCubePixelShader: {
  38577. name: string;
  38578. shader: string;
  38579. };
  38580. }
  38581. declare module BABYLON {
  38582. /**
  38583. * PassPostProcess which produces an output the same as it's input
  38584. */
  38585. export class PassPostProcess extends PostProcess {
  38586. /**
  38587. * Creates the PassPostProcess
  38588. * @param name The name of the effect.
  38589. * @param options The required width/height ratio to downsize to before computing the render pass.
  38590. * @param camera The camera to apply the render pass to.
  38591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38592. * @param engine The engine which the post process will be applied. (default: current engine)
  38593. * @param reusable If the post process can be reused on the same frame. (default: false)
  38594. * @param textureType The type of texture to be used when performing the post processing.
  38595. * @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)
  38596. */
  38597. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38598. }
  38599. /**
  38600. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38601. */
  38602. export class PassCubePostProcess extends PostProcess {
  38603. private _face;
  38604. /**
  38605. * Gets or sets the cube face to display.
  38606. * * 0 is +X
  38607. * * 1 is -X
  38608. * * 2 is +Y
  38609. * * 3 is -Y
  38610. * * 4 is +Z
  38611. * * 5 is -Z
  38612. */
  38613. face: number;
  38614. /**
  38615. * Creates the PassCubePostProcess
  38616. * @param name The name of the effect.
  38617. * @param options The required width/height ratio to downsize to before computing the render pass.
  38618. * @param camera The camera to apply the render pass to.
  38619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38620. * @param engine The engine which the post process will be applied. (default: current engine)
  38621. * @param reusable If the post process can be reused on the same frame. (default: false)
  38622. * @param textureType The type of texture to be used when performing the post processing.
  38623. * @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)
  38624. */
  38625. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38626. }
  38627. }
  38628. declare module BABYLON {
  38629. /** @hidden */
  38630. export var anaglyphPixelShader: {
  38631. name: string;
  38632. shader: string;
  38633. };
  38634. }
  38635. declare module BABYLON {
  38636. /**
  38637. * Postprocess used to generate anaglyphic rendering
  38638. */
  38639. export class AnaglyphPostProcess extends PostProcess {
  38640. private _passedProcess;
  38641. /**
  38642. * Creates a new AnaglyphPostProcess
  38643. * @param name defines postprocess name
  38644. * @param options defines creation options or target ratio scale
  38645. * @param rigCameras defines cameras using this postprocess
  38646. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38647. * @param engine defines hosting engine
  38648. * @param reusable defines if the postprocess will be reused multiple times per frame
  38649. */
  38650. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38651. }
  38652. }
  38653. declare module BABYLON {
  38654. /**
  38655. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38656. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38657. */
  38658. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38659. /**
  38660. * Creates a new AnaglyphArcRotateCamera
  38661. * @param name defines camera name
  38662. * @param alpha defines alpha angle (in radians)
  38663. * @param beta defines beta angle (in radians)
  38664. * @param radius defines radius
  38665. * @param target defines camera target
  38666. * @param interaxialDistance defines distance between each color axis
  38667. * @param scene defines the hosting scene
  38668. */
  38669. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38670. /**
  38671. * Gets camera class name
  38672. * @returns AnaglyphArcRotateCamera
  38673. */
  38674. getClassName(): string;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38680. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38681. */
  38682. export class AnaglyphFreeCamera extends FreeCamera {
  38683. /**
  38684. * Creates a new AnaglyphFreeCamera
  38685. * @param name defines camera name
  38686. * @param position defines initial position
  38687. * @param interaxialDistance defines distance between each color axis
  38688. * @param scene defines the hosting scene
  38689. */
  38690. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38691. /**
  38692. * Gets camera class name
  38693. * @returns AnaglyphFreeCamera
  38694. */
  38695. getClassName(): string;
  38696. }
  38697. }
  38698. declare module BABYLON {
  38699. /**
  38700. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38701. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38702. */
  38703. export class AnaglyphGamepadCamera extends GamepadCamera {
  38704. /**
  38705. * Creates a new AnaglyphGamepadCamera
  38706. * @param name defines camera name
  38707. * @param position defines initial position
  38708. * @param interaxialDistance defines distance between each color axis
  38709. * @param scene defines the hosting scene
  38710. */
  38711. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38712. /**
  38713. * Gets camera class name
  38714. * @returns AnaglyphGamepadCamera
  38715. */
  38716. getClassName(): string;
  38717. }
  38718. }
  38719. declare module BABYLON {
  38720. /**
  38721. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38722. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38723. */
  38724. export class AnaglyphUniversalCamera extends UniversalCamera {
  38725. /**
  38726. * Creates a new AnaglyphUniversalCamera
  38727. * @param name defines camera name
  38728. * @param position defines initial position
  38729. * @param interaxialDistance defines distance between each color axis
  38730. * @param scene defines the hosting scene
  38731. */
  38732. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38733. /**
  38734. * Gets camera class name
  38735. * @returns AnaglyphUniversalCamera
  38736. */
  38737. getClassName(): string;
  38738. }
  38739. }
  38740. declare module BABYLON {
  38741. /** @hidden */
  38742. export var stereoscopicInterlacePixelShader: {
  38743. name: string;
  38744. shader: string;
  38745. };
  38746. }
  38747. declare module BABYLON {
  38748. /**
  38749. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38750. */
  38751. export class StereoscopicInterlacePostProcess extends PostProcess {
  38752. private _stepSize;
  38753. private _passedProcess;
  38754. /**
  38755. * Initializes a StereoscopicInterlacePostProcess
  38756. * @param name The name of the effect.
  38757. * @param rigCameras The rig cameras to be appled to the post process
  38758. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38760. * @param engine The engine which the post process will be applied. (default: current engine)
  38761. * @param reusable If the post process can be reused on the same frame. (default: false)
  38762. */
  38763. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /**
  38768. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38769. * @see http://doc.babylonjs.com/features/cameras
  38770. */
  38771. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38772. /**
  38773. * Creates a new StereoscopicArcRotateCamera
  38774. * @param name defines camera name
  38775. * @param alpha defines alpha angle (in radians)
  38776. * @param beta defines beta angle (in radians)
  38777. * @param radius defines radius
  38778. * @param target defines camera target
  38779. * @param interaxialDistance defines distance between each color axis
  38780. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38781. * @param scene defines the hosting scene
  38782. */
  38783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38784. /**
  38785. * Gets camera class name
  38786. * @returns StereoscopicArcRotateCamera
  38787. */
  38788. getClassName(): string;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38794. * @see http://doc.babylonjs.com/features/cameras
  38795. */
  38796. export class StereoscopicFreeCamera extends FreeCamera {
  38797. /**
  38798. * Creates a new StereoscopicFreeCamera
  38799. * @param name defines camera name
  38800. * @param position defines initial position
  38801. * @param interaxialDistance defines distance between each color axis
  38802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38803. * @param scene defines the hosting scene
  38804. */
  38805. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38806. /**
  38807. * Gets camera class name
  38808. * @returns StereoscopicFreeCamera
  38809. */
  38810. getClassName(): string;
  38811. }
  38812. }
  38813. declare module BABYLON {
  38814. /**
  38815. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38816. * @see http://doc.babylonjs.com/features/cameras
  38817. */
  38818. export class StereoscopicGamepadCamera extends GamepadCamera {
  38819. /**
  38820. * Creates a new StereoscopicGamepadCamera
  38821. * @param name defines camera name
  38822. * @param position defines initial position
  38823. * @param interaxialDistance defines distance between each color axis
  38824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38825. * @param scene defines the hosting scene
  38826. */
  38827. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38828. /**
  38829. * Gets camera class name
  38830. * @returns StereoscopicGamepadCamera
  38831. */
  38832. getClassName(): string;
  38833. }
  38834. }
  38835. declare module BABYLON {
  38836. /**
  38837. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38838. * @see http://doc.babylonjs.com/features/cameras
  38839. */
  38840. export class StereoscopicUniversalCamera extends UniversalCamera {
  38841. /**
  38842. * Creates a new StereoscopicUniversalCamera
  38843. * @param name defines camera name
  38844. * @param position defines initial position
  38845. * @param interaxialDistance defines distance between each color axis
  38846. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38847. * @param scene defines the hosting scene
  38848. */
  38849. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38850. /**
  38851. * Gets camera class name
  38852. * @returns StereoscopicUniversalCamera
  38853. */
  38854. getClassName(): string;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. /**
  38859. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38860. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38861. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38862. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38863. */
  38864. export class VirtualJoysticksCamera extends FreeCamera {
  38865. /**
  38866. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38867. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38868. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38869. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38870. * @param name Define the name of the camera in the scene
  38871. * @param position Define the start position of the camera in the scene
  38872. * @param scene Define the scene the camera belongs to
  38873. */
  38874. constructor(name: string, position: Vector3, scene: Scene);
  38875. /**
  38876. * Gets the current object class name.
  38877. * @return the class name
  38878. */
  38879. getClassName(): string;
  38880. }
  38881. }
  38882. declare module BABYLON {
  38883. /**
  38884. * This represents all the required metrics to create a VR camera.
  38885. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38886. */
  38887. export class VRCameraMetrics {
  38888. /**
  38889. * Define the horizontal resolution off the screen.
  38890. */
  38891. hResolution: number;
  38892. /**
  38893. * Define the vertical resolution off the screen.
  38894. */
  38895. vResolution: number;
  38896. /**
  38897. * Define the horizontal screen size.
  38898. */
  38899. hScreenSize: number;
  38900. /**
  38901. * Define the vertical screen size.
  38902. */
  38903. vScreenSize: number;
  38904. /**
  38905. * Define the vertical screen center position.
  38906. */
  38907. vScreenCenter: number;
  38908. /**
  38909. * Define the distance of the eyes to the screen.
  38910. */
  38911. eyeToScreenDistance: number;
  38912. /**
  38913. * Define the distance between both lenses
  38914. */
  38915. lensSeparationDistance: number;
  38916. /**
  38917. * Define the distance between both viewer's eyes.
  38918. */
  38919. interpupillaryDistance: number;
  38920. /**
  38921. * Define the distortion factor of the VR postprocess.
  38922. * Please, touch with care.
  38923. */
  38924. distortionK: number[];
  38925. /**
  38926. * Define the chromatic aberration correction factors for the VR post process.
  38927. */
  38928. chromaAbCorrection: number[];
  38929. /**
  38930. * Define the scale factor of the post process.
  38931. * The smaller the better but the slower.
  38932. */
  38933. postProcessScaleFactor: number;
  38934. /**
  38935. * Define an offset for the lens center.
  38936. */
  38937. lensCenterOffset: number;
  38938. /**
  38939. * Define if the current vr camera should compensate the distortion of the lense or not.
  38940. */
  38941. compensateDistortion: boolean;
  38942. /**
  38943. * Defines if multiview should be enabled when rendering (Default: false)
  38944. */
  38945. multiviewEnabled: boolean;
  38946. /**
  38947. * Gets the rendering aspect ratio based on the provided resolutions.
  38948. */
  38949. readonly aspectRatio: number;
  38950. /**
  38951. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38952. */
  38953. readonly aspectRatioFov: number;
  38954. /**
  38955. * @hidden
  38956. */
  38957. readonly leftHMatrix: Matrix;
  38958. /**
  38959. * @hidden
  38960. */
  38961. readonly rightHMatrix: Matrix;
  38962. /**
  38963. * @hidden
  38964. */
  38965. readonly leftPreViewMatrix: Matrix;
  38966. /**
  38967. * @hidden
  38968. */
  38969. readonly rightPreViewMatrix: Matrix;
  38970. /**
  38971. * Get the default VRMetrics based on the most generic setup.
  38972. * @returns the default vr metrics
  38973. */
  38974. static GetDefault(): VRCameraMetrics;
  38975. }
  38976. }
  38977. declare module BABYLON {
  38978. /** @hidden */
  38979. export var vrDistortionCorrectionPixelShader: {
  38980. name: string;
  38981. shader: string;
  38982. };
  38983. }
  38984. declare module BABYLON {
  38985. /**
  38986. * VRDistortionCorrectionPostProcess used for mobile VR
  38987. */
  38988. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38989. private _isRightEye;
  38990. private _distortionFactors;
  38991. private _postProcessScaleFactor;
  38992. private _lensCenterOffset;
  38993. private _scaleIn;
  38994. private _scaleFactor;
  38995. private _lensCenter;
  38996. /**
  38997. * Initializes the VRDistortionCorrectionPostProcess
  38998. * @param name The name of the effect.
  38999. * @param camera The camera to apply the render pass to.
  39000. * @param isRightEye If this is for the right eye distortion
  39001. * @param vrMetrics All the required metrics for the VR camera
  39002. */
  39003. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39004. }
  39005. }
  39006. declare module BABYLON {
  39007. /**
  39008. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39009. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39010. */
  39011. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39012. /**
  39013. * Creates a new VRDeviceOrientationArcRotateCamera
  39014. * @param name defines camera name
  39015. * @param alpha defines the camera rotation along the logitudinal axis
  39016. * @param beta defines the camera rotation along the latitudinal axis
  39017. * @param radius defines the camera distance from its target
  39018. * @param target defines the camera target
  39019. * @param scene defines the scene the camera belongs to
  39020. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39021. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39022. */
  39023. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39024. /**
  39025. * Gets camera class name
  39026. * @returns VRDeviceOrientationArcRotateCamera
  39027. */
  39028. getClassName(): string;
  39029. }
  39030. }
  39031. declare module BABYLON {
  39032. /**
  39033. * Camera used to simulate VR rendering (based on FreeCamera)
  39034. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39035. */
  39036. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39037. /**
  39038. * Creates a new VRDeviceOrientationFreeCamera
  39039. * @param name defines camera name
  39040. * @param position defines the start position of the camera
  39041. * @param scene defines the scene the camera belongs to
  39042. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39043. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39044. */
  39045. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39046. /**
  39047. * Gets camera class name
  39048. * @returns VRDeviceOrientationFreeCamera
  39049. */
  39050. getClassName(): string;
  39051. }
  39052. }
  39053. declare module BABYLON {
  39054. /**
  39055. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39056. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39057. */
  39058. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39059. /**
  39060. * Creates a new VRDeviceOrientationGamepadCamera
  39061. * @param name defines camera name
  39062. * @param position defines the start position of the camera
  39063. * @param scene defines the scene the camera belongs to
  39064. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39065. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39066. */
  39067. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39068. /**
  39069. * Gets camera class name
  39070. * @returns VRDeviceOrientationGamepadCamera
  39071. */
  39072. getClassName(): string;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /**
  39077. * Base class of materials working in push mode in babylon JS
  39078. * @hidden
  39079. */
  39080. export class PushMaterial extends Material {
  39081. protected _activeEffect: Effect;
  39082. protected _normalMatrix: Matrix;
  39083. /**
  39084. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39085. * This means that the material can keep using a previous shader while a new one is being compiled.
  39086. * This is mostly used when shader parallel compilation is supported (true by default)
  39087. */
  39088. allowShaderHotSwapping: boolean;
  39089. constructor(name: string, scene: Scene);
  39090. getEffect(): Effect;
  39091. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39092. /**
  39093. * Binds the given world matrix to the active effect
  39094. *
  39095. * @param world the matrix to bind
  39096. */
  39097. bindOnlyWorldMatrix(world: Matrix): void;
  39098. /**
  39099. * Binds the given normal matrix to the active effect
  39100. *
  39101. * @param normalMatrix the matrix to bind
  39102. */
  39103. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39104. bind(world: Matrix, mesh?: Mesh): void;
  39105. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39106. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39107. }
  39108. }
  39109. declare module BABYLON {
  39110. /**
  39111. * This groups all the flags used to control the materials channel.
  39112. */
  39113. export class MaterialFlags {
  39114. private static _DiffuseTextureEnabled;
  39115. /**
  39116. * Are diffuse textures enabled in the application.
  39117. */
  39118. static DiffuseTextureEnabled: boolean;
  39119. private static _AmbientTextureEnabled;
  39120. /**
  39121. * Are ambient textures enabled in the application.
  39122. */
  39123. static AmbientTextureEnabled: boolean;
  39124. private static _OpacityTextureEnabled;
  39125. /**
  39126. * Are opacity textures enabled in the application.
  39127. */
  39128. static OpacityTextureEnabled: boolean;
  39129. private static _ReflectionTextureEnabled;
  39130. /**
  39131. * Are reflection textures enabled in the application.
  39132. */
  39133. static ReflectionTextureEnabled: boolean;
  39134. private static _EmissiveTextureEnabled;
  39135. /**
  39136. * Are emissive textures enabled in the application.
  39137. */
  39138. static EmissiveTextureEnabled: boolean;
  39139. private static _SpecularTextureEnabled;
  39140. /**
  39141. * Are specular textures enabled in the application.
  39142. */
  39143. static SpecularTextureEnabled: boolean;
  39144. private static _BumpTextureEnabled;
  39145. /**
  39146. * Are bump textures enabled in the application.
  39147. */
  39148. static BumpTextureEnabled: boolean;
  39149. private static _LightmapTextureEnabled;
  39150. /**
  39151. * Are lightmap textures enabled in the application.
  39152. */
  39153. static LightmapTextureEnabled: boolean;
  39154. private static _RefractionTextureEnabled;
  39155. /**
  39156. * Are refraction textures enabled in the application.
  39157. */
  39158. static RefractionTextureEnabled: boolean;
  39159. private static _ColorGradingTextureEnabled;
  39160. /**
  39161. * Are color grading textures enabled in the application.
  39162. */
  39163. static ColorGradingTextureEnabled: boolean;
  39164. private static _FresnelEnabled;
  39165. /**
  39166. * Are fresnels enabled in the application.
  39167. */
  39168. static FresnelEnabled: boolean;
  39169. private static _ClearCoatTextureEnabled;
  39170. /**
  39171. * Are clear coat textures enabled in the application.
  39172. */
  39173. static ClearCoatTextureEnabled: boolean;
  39174. private static _ClearCoatBumpTextureEnabled;
  39175. /**
  39176. * Are clear coat bump textures enabled in the application.
  39177. */
  39178. static ClearCoatBumpTextureEnabled: boolean;
  39179. private static _ClearCoatTintTextureEnabled;
  39180. /**
  39181. * Are clear coat tint textures enabled in the application.
  39182. */
  39183. static ClearCoatTintTextureEnabled: boolean;
  39184. private static _SheenTextureEnabled;
  39185. /**
  39186. * Are sheen textures enabled in the application.
  39187. */
  39188. static SheenTextureEnabled: boolean;
  39189. private static _AnisotropicTextureEnabled;
  39190. /**
  39191. * Are anisotropic textures enabled in the application.
  39192. */
  39193. static AnisotropicTextureEnabled: boolean;
  39194. private static _ThicknessTextureEnabled;
  39195. /**
  39196. * Are thickness textures enabled in the application.
  39197. */
  39198. static ThicknessTextureEnabled: boolean;
  39199. }
  39200. }
  39201. declare module BABYLON {
  39202. /** @hidden */
  39203. export var defaultFragmentDeclaration: {
  39204. name: string;
  39205. shader: string;
  39206. };
  39207. }
  39208. declare module BABYLON {
  39209. /** @hidden */
  39210. export var defaultUboDeclaration: {
  39211. name: string;
  39212. shader: string;
  39213. };
  39214. }
  39215. declare module BABYLON {
  39216. /** @hidden */
  39217. export var lightFragmentDeclaration: {
  39218. name: string;
  39219. shader: string;
  39220. };
  39221. }
  39222. declare module BABYLON {
  39223. /** @hidden */
  39224. export var lightUboDeclaration: {
  39225. name: string;
  39226. shader: string;
  39227. };
  39228. }
  39229. declare module BABYLON {
  39230. /** @hidden */
  39231. export var lightsFragmentFunctions: {
  39232. name: string;
  39233. shader: string;
  39234. };
  39235. }
  39236. declare module BABYLON {
  39237. /** @hidden */
  39238. export var shadowsFragmentFunctions: {
  39239. name: string;
  39240. shader: string;
  39241. };
  39242. }
  39243. declare module BABYLON {
  39244. /** @hidden */
  39245. export var fresnelFunction: {
  39246. name: string;
  39247. shader: string;
  39248. };
  39249. }
  39250. declare module BABYLON {
  39251. /** @hidden */
  39252. export var reflectionFunction: {
  39253. name: string;
  39254. shader: string;
  39255. };
  39256. }
  39257. declare module BABYLON {
  39258. /** @hidden */
  39259. export var bumpFragmentFunctions: {
  39260. name: string;
  39261. shader: string;
  39262. };
  39263. }
  39264. declare module BABYLON {
  39265. /** @hidden */
  39266. export var logDepthDeclaration: {
  39267. name: string;
  39268. shader: string;
  39269. };
  39270. }
  39271. declare module BABYLON {
  39272. /** @hidden */
  39273. export var bumpFragment: {
  39274. name: string;
  39275. shader: string;
  39276. };
  39277. }
  39278. declare module BABYLON {
  39279. /** @hidden */
  39280. export var depthPrePass: {
  39281. name: string;
  39282. shader: string;
  39283. };
  39284. }
  39285. declare module BABYLON {
  39286. /** @hidden */
  39287. export var lightFragment: {
  39288. name: string;
  39289. shader: string;
  39290. };
  39291. }
  39292. declare module BABYLON {
  39293. /** @hidden */
  39294. export var logDepthFragment: {
  39295. name: string;
  39296. shader: string;
  39297. };
  39298. }
  39299. declare module BABYLON {
  39300. /** @hidden */
  39301. export var defaultPixelShader: {
  39302. name: string;
  39303. shader: string;
  39304. };
  39305. }
  39306. declare module BABYLON {
  39307. /** @hidden */
  39308. export var defaultVertexDeclaration: {
  39309. name: string;
  39310. shader: string;
  39311. };
  39312. }
  39313. declare module BABYLON {
  39314. /** @hidden */
  39315. export var bumpVertexDeclaration: {
  39316. name: string;
  39317. shader: string;
  39318. };
  39319. }
  39320. declare module BABYLON {
  39321. /** @hidden */
  39322. export var bumpVertex: {
  39323. name: string;
  39324. shader: string;
  39325. };
  39326. }
  39327. declare module BABYLON {
  39328. /** @hidden */
  39329. export var fogVertex: {
  39330. name: string;
  39331. shader: string;
  39332. };
  39333. }
  39334. declare module BABYLON {
  39335. /** @hidden */
  39336. export var shadowsVertex: {
  39337. name: string;
  39338. shader: string;
  39339. };
  39340. }
  39341. declare module BABYLON {
  39342. /** @hidden */
  39343. export var pointCloudVertex: {
  39344. name: string;
  39345. shader: string;
  39346. };
  39347. }
  39348. declare module BABYLON {
  39349. /** @hidden */
  39350. export var logDepthVertex: {
  39351. name: string;
  39352. shader: string;
  39353. };
  39354. }
  39355. declare module BABYLON {
  39356. /** @hidden */
  39357. export var defaultVertexShader: {
  39358. name: string;
  39359. shader: string;
  39360. };
  39361. }
  39362. declare module BABYLON {
  39363. /** @hidden */
  39364. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39365. MAINUV1: boolean;
  39366. MAINUV2: boolean;
  39367. DIFFUSE: boolean;
  39368. DIFFUSEDIRECTUV: number;
  39369. AMBIENT: boolean;
  39370. AMBIENTDIRECTUV: number;
  39371. OPACITY: boolean;
  39372. OPACITYDIRECTUV: number;
  39373. OPACITYRGB: boolean;
  39374. REFLECTION: boolean;
  39375. EMISSIVE: boolean;
  39376. EMISSIVEDIRECTUV: number;
  39377. SPECULAR: boolean;
  39378. SPECULARDIRECTUV: number;
  39379. BUMP: boolean;
  39380. BUMPDIRECTUV: number;
  39381. PARALLAX: boolean;
  39382. PARALLAXOCCLUSION: boolean;
  39383. SPECULAROVERALPHA: boolean;
  39384. CLIPPLANE: boolean;
  39385. CLIPPLANE2: boolean;
  39386. CLIPPLANE3: boolean;
  39387. CLIPPLANE4: boolean;
  39388. ALPHATEST: boolean;
  39389. DEPTHPREPASS: boolean;
  39390. ALPHAFROMDIFFUSE: boolean;
  39391. POINTSIZE: boolean;
  39392. FOG: boolean;
  39393. SPECULARTERM: boolean;
  39394. DIFFUSEFRESNEL: boolean;
  39395. OPACITYFRESNEL: boolean;
  39396. REFLECTIONFRESNEL: boolean;
  39397. REFRACTIONFRESNEL: boolean;
  39398. EMISSIVEFRESNEL: boolean;
  39399. FRESNEL: boolean;
  39400. NORMAL: boolean;
  39401. UV1: boolean;
  39402. UV2: boolean;
  39403. VERTEXCOLOR: boolean;
  39404. VERTEXALPHA: boolean;
  39405. NUM_BONE_INFLUENCERS: number;
  39406. BonesPerMesh: number;
  39407. BONETEXTURE: boolean;
  39408. INSTANCES: boolean;
  39409. GLOSSINESS: boolean;
  39410. ROUGHNESS: boolean;
  39411. EMISSIVEASILLUMINATION: boolean;
  39412. LINKEMISSIVEWITHDIFFUSE: boolean;
  39413. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39414. LIGHTMAP: boolean;
  39415. LIGHTMAPDIRECTUV: number;
  39416. OBJECTSPACE_NORMALMAP: boolean;
  39417. USELIGHTMAPASSHADOWMAP: boolean;
  39418. REFLECTIONMAP_3D: boolean;
  39419. REFLECTIONMAP_SPHERICAL: boolean;
  39420. REFLECTIONMAP_PLANAR: boolean;
  39421. REFLECTIONMAP_CUBIC: boolean;
  39422. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39423. REFLECTIONMAP_PROJECTION: boolean;
  39424. REFLECTIONMAP_SKYBOX: boolean;
  39425. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39426. REFLECTIONMAP_EXPLICIT: boolean;
  39427. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39428. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39429. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39430. INVERTCUBICMAP: boolean;
  39431. LOGARITHMICDEPTH: boolean;
  39432. REFRACTION: boolean;
  39433. REFRACTIONMAP_3D: boolean;
  39434. REFLECTIONOVERALPHA: boolean;
  39435. TWOSIDEDLIGHTING: boolean;
  39436. SHADOWFLOAT: boolean;
  39437. MORPHTARGETS: boolean;
  39438. MORPHTARGETS_NORMAL: boolean;
  39439. MORPHTARGETS_TANGENT: boolean;
  39440. MORPHTARGETS_UV: boolean;
  39441. NUM_MORPH_INFLUENCERS: number;
  39442. NONUNIFORMSCALING: boolean;
  39443. PREMULTIPLYALPHA: boolean;
  39444. IMAGEPROCESSING: boolean;
  39445. VIGNETTE: boolean;
  39446. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39447. VIGNETTEBLENDMODEOPAQUE: boolean;
  39448. TONEMAPPING: boolean;
  39449. TONEMAPPING_ACES: boolean;
  39450. CONTRAST: boolean;
  39451. COLORCURVES: boolean;
  39452. COLORGRADING: boolean;
  39453. COLORGRADING3D: boolean;
  39454. SAMPLER3DGREENDEPTH: boolean;
  39455. SAMPLER3DBGRMAP: boolean;
  39456. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39457. MULTIVIEW: boolean;
  39458. /**
  39459. * If the reflection texture on this material is in linear color space
  39460. * @hidden
  39461. */
  39462. IS_REFLECTION_LINEAR: boolean;
  39463. /**
  39464. * If the refraction texture on this material is in linear color space
  39465. * @hidden
  39466. */
  39467. IS_REFRACTION_LINEAR: boolean;
  39468. EXPOSURE: boolean;
  39469. constructor();
  39470. setReflectionMode(modeToEnable: string): void;
  39471. }
  39472. /**
  39473. * This is the default material used in Babylon. It is the best trade off between quality
  39474. * and performances.
  39475. * @see http://doc.babylonjs.com/babylon101/materials
  39476. */
  39477. export class StandardMaterial extends PushMaterial {
  39478. private _diffuseTexture;
  39479. /**
  39480. * The basic texture of the material as viewed under a light.
  39481. */
  39482. diffuseTexture: Nullable<BaseTexture>;
  39483. private _ambientTexture;
  39484. /**
  39485. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39486. */
  39487. ambientTexture: Nullable<BaseTexture>;
  39488. private _opacityTexture;
  39489. /**
  39490. * Define the transparency of the material from a texture.
  39491. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39492. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39493. */
  39494. opacityTexture: Nullable<BaseTexture>;
  39495. private _reflectionTexture;
  39496. /**
  39497. * Define the texture used to display the reflection.
  39498. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39499. */
  39500. reflectionTexture: Nullable<BaseTexture>;
  39501. private _emissiveTexture;
  39502. /**
  39503. * Define texture of the material as if self lit.
  39504. * This will be mixed in the final result even in the absence of light.
  39505. */
  39506. emissiveTexture: Nullable<BaseTexture>;
  39507. private _specularTexture;
  39508. /**
  39509. * Define how the color and intensity of the highlight given by the light in the material.
  39510. */
  39511. specularTexture: Nullable<BaseTexture>;
  39512. private _bumpTexture;
  39513. /**
  39514. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39515. * 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.
  39516. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39517. */
  39518. bumpTexture: Nullable<BaseTexture>;
  39519. private _lightmapTexture;
  39520. /**
  39521. * Complex lighting can be computationally expensive to compute at runtime.
  39522. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39523. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39524. */
  39525. lightmapTexture: Nullable<BaseTexture>;
  39526. private _refractionTexture;
  39527. /**
  39528. * Define the texture used to display the refraction.
  39529. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39530. */
  39531. refractionTexture: Nullable<BaseTexture>;
  39532. /**
  39533. * The color of the material lit by the environmental background lighting.
  39534. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39535. */
  39536. ambientColor: Color3;
  39537. /**
  39538. * The basic color of the material as viewed under a light.
  39539. */
  39540. diffuseColor: Color3;
  39541. /**
  39542. * Define how the color and intensity of the highlight given by the light in the material.
  39543. */
  39544. specularColor: Color3;
  39545. /**
  39546. * Define the color of the material as if self lit.
  39547. * This will be mixed in the final result even in the absence of light.
  39548. */
  39549. emissiveColor: Color3;
  39550. /**
  39551. * Defines how sharp are the highlights in the material.
  39552. * The bigger the value the sharper giving a more glossy feeling to the result.
  39553. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39554. */
  39555. specularPower: number;
  39556. private _useAlphaFromDiffuseTexture;
  39557. /**
  39558. * Does the transparency come from the diffuse texture alpha channel.
  39559. */
  39560. useAlphaFromDiffuseTexture: boolean;
  39561. private _useEmissiveAsIllumination;
  39562. /**
  39563. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39564. */
  39565. useEmissiveAsIllumination: boolean;
  39566. private _linkEmissiveWithDiffuse;
  39567. /**
  39568. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39569. * the emissive level when the final color is close to one.
  39570. */
  39571. linkEmissiveWithDiffuse: boolean;
  39572. private _useSpecularOverAlpha;
  39573. /**
  39574. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39575. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39576. */
  39577. useSpecularOverAlpha: boolean;
  39578. private _useReflectionOverAlpha;
  39579. /**
  39580. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39581. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39582. */
  39583. useReflectionOverAlpha: boolean;
  39584. private _disableLighting;
  39585. /**
  39586. * Does lights from the scene impacts this material.
  39587. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39588. */
  39589. disableLighting: boolean;
  39590. private _useObjectSpaceNormalMap;
  39591. /**
  39592. * Allows using an object space normal map (instead of tangent space).
  39593. */
  39594. useObjectSpaceNormalMap: boolean;
  39595. private _useParallax;
  39596. /**
  39597. * Is parallax enabled or not.
  39598. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39599. */
  39600. useParallax: boolean;
  39601. private _useParallaxOcclusion;
  39602. /**
  39603. * Is parallax occlusion enabled or not.
  39604. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39605. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39606. */
  39607. useParallaxOcclusion: boolean;
  39608. /**
  39609. * 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.
  39610. */
  39611. parallaxScaleBias: number;
  39612. private _roughness;
  39613. /**
  39614. * Helps to define how blurry the reflections should appears in the material.
  39615. */
  39616. roughness: number;
  39617. /**
  39618. * In case of refraction, define the value of the index of refraction.
  39619. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39620. */
  39621. indexOfRefraction: number;
  39622. /**
  39623. * Invert the refraction texture alongside the y axis.
  39624. * It can be useful with procedural textures or probe for instance.
  39625. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39626. */
  39627. invertRefractionY: boolean;
  39628. /**
  39629. * Defines the alpha limits in alpha test mode.
  39630. */
  39631. alphaCutOff: number;
  39632. private _useLightmapAsShadowmap;
  39633. /**
  39634. * In case of light mapping, define whether the map contains light or shadow informations.
  39635. */
  39636. useLightmapAsShadowmap: boolean;
  39637. private _diffuseFresnelParameters;
  39638. /**
  39639. * Define the diffuse fresnel parameters of the material.
  39640. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39641. */
  39642. diffuseFresnelParameters: FresnelParameters;
  39643. private _opacityFresnelParameters;
  39644. /**
  39645. * Define the opacity fresnel parameters of the material.
  39646. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39647. */
  39648. opacityFresnelParameters: FresnelParameters;
  39649. private _reflectionFresnelParameters;
  39650. /**
  39651. * Define the reflection fresnel parameters of the material.
  39652. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39653. */
  39654. reflectionFresnelParameters: FresnelParameters;
  39655. private _refractionFresnelParameters;
  39656. /**
  39657. * Define the refraction fresnel parameters of the material.
  39658. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39659. */
  39660. refractionFresnelParameters: FresnelParameters;
  39661. private _emissiveFresnelParameters;
  39662. /**
  39663. * Define the emissive fresnel parameters of the material.
  39664. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39665. */
  39666. emissiveFresnelParameters: FresnelParameters;
  39667. private _useReflectionFresnelFromSpecular;
  39668. /**
  39669. * If true automatically deducts the fresnels values from the material specularity.
  39670. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39671. */
  39672. useReflectionFresnelFromSpecular: boolean;
  39673. private _useGlossinessFromSpecularMapAlpha;
  39674. /**
  39675. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39676. */
  39677. useGlossinessFromSpecularMapAlpha: boolean;
  39678. private _maxSimultaneousLights;
  39679. /**
  39680. * Defines the maximum number of lights that can be used in the material
  39681. */
  39682. maxSimultaneousLights: number;
  39683. private _invertNormalMapX;
  39684. /**
  39685. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39686. */
  39687. invertNormalMapX: boolean;
  39688. private _invertNormalMapY;
  39689. /**
  39690. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39691. */
  39692. invertNormalMapY: boolean;
  39693. private _twoSidedLighting;
  39694. /**
  39695. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39696. */
  39697. twoSidedLighting: boolean;
  39698. /**
  39699. * Default configuration related to image processing available in the standard Material.
  39700. */
  39701. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39702. /**
  39703. * Gets the image processing configuration used either in this material.
  39704. */
  39705. /**
  39706. * Sets the Default image processing configuration used either in the this material.
  39707. *
  39708. * If sets to null, the scene one is in use.
  39709. */
  39710. imageProcessingConfiguration: ImageProcessingConfiguration;
  39711. /**
  39712. * Keep track of the image processing observer to allow dispose and replace.
  39713. */
  39714. private _imageProcessingObserver;
  39715. /**
  39716. * Attaches a new image processing configuration to the Standard Material.
  39717. * @param configuration
  39718. */
  39719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39720. /**
  39721. * Gets wether the color curves effect is enabled.
  39722. */
  39723. /**
  39724. * Sets wether the color curves effect is enabled.
  39725. */
  39726. cameraColorCurvesEnabled: boolean;
  39727. /**
  39728. * Gets wether the color grading effect is enabled.
  39729. */
  39730. /**
  39731. * Gets wether the color grading effect is enabled.
  39732. */
  39733. cameraColorGradingEnabled: boolean;
  39734. /**
  39735. * Gets wether tonemapping is enabled or not.
  39736. */
  39737. /**
  39738. * Sets wether tonemapping is enabled or not
  39739. */
  39740. cameraToneMappingEnabled: boolean;
  39741. /**
  39742. * The camera exposure used on this material.
  39743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39744. * This corresponds to a photographic exposure.
  39745. */
  39746. /**
  39747. * The camera exposure used on this material.
  39748. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39749. * This corresponds to a photographic exposure.
  39750. */
  39751. cameraExposure: number;
  39752. /**
  39753. * Gets The camera contrast used on this material.
  39754. */
  39755. /**
  39756. * Sets The camera contrast used on this material.
  39757. */
  39758. cameraContrast: number;
  39759. /**
  39760. * Gets the Color Grading 2D Lookup Texture.
  39761. */
  39762. /**
  39763. * Sets the Color Grading 2D Lookup Texture.
  39764. */
  39765. cameraColorGradingTexture: Nullable<BaseTexture>;
  39766. /**
  39767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39769. * 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;
  39770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39771. */
  39772. /**
  39773. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39774. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39775. * 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;
  39776. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39777. */
  39778. cameraColorCurves: Nullable<ColorCurves>;
  39779. /**
  39780. * Custom callback helping to override the default shader used in the material.
  39781. */
  39782. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39783. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39784. protected _worldViewProjectionMatrix: Matrix;
  39785. protected _globalAmbientColor: Color3;
  39786. protected _useLogarithmicDepth: boolean;
  39787. /**
  39788. * Instantiates a new standard material.
  39789. * This is the default material used in Babylon. It is the best trade off between quality
  39790. * and performances.
  39791. * @see http://doc.babylonjs.com/babylon101/materials
  39792. * @param name Define the name of the material in the scene
  39793. * @param scene Define the scene the material belong to
  39794. */
  39795. constructor(name: string, scene: Scene);
  39796. /**
  39797. * Gets a boolean indicating that current material needs to register RTT
  39798. */
  39799. readonly hasRenderTargetTextures: boolean;
  39800. /**
  39801. * Gets the current class name of the material e.g. "StandardMaterial"
  39802. * Mainly use in serialization.
  39803. * @returns the class name
  39804. */
  39805. getClassName(): string;
  39806. /**
  39807. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39808. * You can try switching to logarithmic depth.
  39809. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39810. */
  39811. useLogarithmicDepth: boolean;
  39812. /**
  39813. * Specifies if the material will require alpha blending
  39814. * @returns a boolean specifying if alpha blending is needed
  39815. */
  39816. needAlphaBlending(): boolean;
  39817. /**
  39818. * Specifies if this material should be rendered in alpha test mode
  39819. * @returns a boolean specifying if an alpha test is needed.
  39820. */
  39821. needAlphaTesting(): boolean;
  39822. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39823. /**
  39824. * Get the texture used for alpha test purpose.
  39825. * @returns the diffuse texture in case of the standard material.
  39826. */
  39827. getAlphaTestTexture(): Nullable<BaseTexture>;
  39828. /**
  39829. * Get if the submesh is ready to be used and all its information available.
  39830. * Child classes can use it to update shaders
  39831. * @param mesh defines the mesh to check
  39832. * @param subMesh defines which submesh to check
  39833. * @param useInstances specifies that instances should be used
  39834. * @returns a boolean indicating that the submesh is ready or not
  39835. */
  39836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39837. /**
  39838. * Builds the material UBO layouts.
  39839. * Used internally during the effect preparation.
  39840. */
  39841. buildUniformLayout(): void;
  39842. /**
  39843. * Unbinds the material from the mesh
  39844. */
  39845. unbind(): void;
  39846. /**
  39847. * Binds the submesh to this material by preparing the effect and shader to draw
  39848. * @param world defines the world transformation matrix
  39849. * @param mesh defines the mesh containing the submesh
  39850. * @param subMesh defines the submesh to bind the material to
  39851. */
  39852. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39853. /**
  39854. * Get the list of animatables in the material.
  39855. * @returns the list of animatables object used in the material
  39856. */
  39857. getAnimatables(): IAnimatable[];
  39858. /**
  39859. * Gets the active textures from the material
  39860. * @returns an array of textures
  39861. */
  39862. getActiveTextures(): BaseTexture[];
  39863. /**
  39864. * Specifies if the material uses a texture
  39865. * @param texture defines the texture to check against the material
  39866. * @returns a boolean specifying if the material uses the texture
  39867. */
  39868. hasTexture(texture: BaseTexture): boolean;
  39869. /**
  39870. * Disposes the material
  39871. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39872. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39873. */
  39874. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39875. /**
  39876. * Makes a duplicate of the material, and gives it a new name
  39877. * @param name defines the new name for the duplicated material
  39878. * @returns the cloned material
  39879. */
  39880. clone(name: string): StandardMaterial;
  39881. /**
  39882. * Serializes this material in a JSON representation
  39883. * @returns the serialized material object
  39884. */
  39885. serialize(): any;
  39886. /**
  39887. * Creates a standard material from parsed material data
  39888. * @param source defines the JSON representation of the material
  39889. * @param scene defines the hosting scene
  39890. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39891. * @returns a new standard material
  39892. */
  39893. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39894. /**
  39895. * Are diffuse textures enabled in the application.
  39896. */
  39897. static DiffuseTextureEnabled: boolean;
  39898. /**
  39899. * Are ambient textures enabled in the application.
  39900. */
  39901. static AmbientTextureEnabled: boolean;
  39902. /**
  39903. * Are opacity textures enabled in the application.
  39904. */
  39905. static OpacityTextureEnabled: boolean;
  39906. /**
  39907. * Are reflection textures enabled in the application.
  39908. */
  39909. static ReflectionTextureEnabled: boolean;
  39910. /**
  39911. * Are emissive textures enabled in the application.
  39912. */
  39913. static EmissiveTextureEnabled: boolean;
  39914. /**
  39915. * Are specular textures enabled in the application.
  39916. */
  39917. static SpecularTextureEnabled: boolean;
  39918. /**
  39919. * Are bump textures enabled in the application.
  39920. */
  39921. static BumpTextureEnabled: boolean;
  39922. /**
  39923. * Are lightmap textures enabled in the application.
  39924. */
  39925. static LightmapTextureEnabled: boolean;
  39926. /**
  39927. * Are refraction textures enabled in the application.
  39928. */
  39929. static RefractionTextureEnabled: boolean;
  39930. /**
  39931. * Are color grading textures enabled in the application.
  39932. */
  39933. static ColorGradingTextureEnabled: boolean;
  39934. /**
  39935. * Are fresnels enabled in the application.
  39936. */
  39937. static FresnelEnabled: boolean;
  39938. }
  39939. }
  39940. declare module BABYLON {
  39941. /**
  39942. * A class extending Texture allowing drawing on a texture
  39943. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39944. */
  39945. export class DynamicTexture extends Texture {
  39946. private _generateMipMaps;
  39947. private _canvas;
  39948. private _context;
  39949. private _engine;
  39950. /**
  39951. * Creates a DynamicTexture
  39952. * @param name defines the name of the texture
  39953. * @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
  39954. * @param scene defines the scene where you want the texture
  39955. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39956. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39957. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39958. */
  39959. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39960. /**
  39961. * Get the current class name of the texture useful for serialization or dynamic coding.
  39962. * @returns "DynamicTexture"
  39963. */
  39964. getClassName(): string;
  39965. /**
  39966. * Gets the current state of canRescale
  39967. */
  39968. readonly canRescale: boolean;
  39969. private _recreate;
  39970. /**
  39971. * Scales the texture
  39972. * @param ratio the scale factor to apply to both width and height
  39973. */
  39974. scale(ratio: number): void;
  39975. /**
  39976. * Resizes the texture
  39977. * @param width the new width
  39978. * @param height the new height
  39979. */
  39980. scaleTo(width: number, height: number): void;
  39981. /**
  39982. * Gets the context of the canvas used by the texture
  39983. * @returns the canvas context of the dynamic texture
  39984. */
  39985. getContext(): CanvasRenderingContext2D;
  39986. /**
  39987. * Clears the texture
  39988. */
  39989. clear(): void;
  39990. /**
  39991. * Updates the texture
  39992. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39993. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39994. */
  39995. update(invertY?: boolean, premulAlpha?: boolean): void;
  39996. /**
  39997. * Draws text onto the texture
  39998. * @param text defines the text to be drawn
  39999. * @param x defines the placement of the text from the left
  40000. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40001. * @param font defines the font to be used with font-style, font-size, font-name
  40002. * @param color defines the color used for the text
  40003. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40004. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40005. * @param update defines whether texture is immediately update (default is true)
  40006. */
  40007. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40008. /**
  40009. * Clones the texture
  40010. * @returns the clone of the texture.
  40011. */
  40012. clone(): DynamicTexture;
  40013. /**
  40014. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40015. * @returns a serialized dynamic texture object
  40016. */
  40017. serialize(): any;
  40018. /** @hidden */
  40019. _rebuild(): void;
  40020. }
  40021. }
  40022. declare module BABYLON {
  40023. /** @hidden */
  40024. export var imageProcessingPixelShader: {
  40025. name: string;
  40026. shader: string;
  40027. };
  40028. }
  40029. declare module BABYLON {
  40030. /**
  40031. * ImageProcessingPostProcess
  40032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40033. */
  40034. export class ImageProcessingPostProcess extends PostProcess {
  40035. /**
  40036. * Default configuration related to image processing available in the PBR Material.
  40037. */
  40038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40039. /**
  40040. * Gets the image processing configuration used either in this material.
  40041. */
  40042. /**
  40043. * Sets the Default image processing configuration used either in the this material.
  40044. *
  40045. * If sets to null, the scene one is in use.
  40046. */
  40047. imageProcessingConfiguration: ImageProcessingConfiguration;
  40048. /**
  40049. * Keep track of the image processing observer to allow dispose and replace.
  40050. */
  40051. private _imageProcessingObserver;
  40052. /**
  40053. * Attaches a new image processing configuration to the PBR Material.
  40054. * @param configuration
  40055. */
  40056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40057. /**
  40058. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40059. */
  40060. /**
  40061. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40062. */
  40063. colorCurves: Nullable<ColorCurves>;
  40064. /**
  40065. * Gets wether the color curves effect is enabled.
  40066. */
  40067. /**
  40068. * Sets wether the color curves effect is enabled.
  40069. */
  40070. colorCurvesEnabled: boolean;
  40071. /**
  40072. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40073. */
  40074. /**
  40075. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40076. */
  40077. colorGradingTexture: Nullable<BaseTexture>;
  40078. /**
  40079. * Gets wether the color grading effect is enabled.
  40080. */
  40081. /**
  40082. * Gets wether the color grading effect is enabled.
  40083. */
  40084. colorGradingEnabled: boolean;
  40085. /**
  40086. * Gets exposure used in the effect.
  40087. */
  40088. /**
  40089. * Sets exposure used in the effect.
  40090. */
  40091. exposure: number;
  40092. /**
  40093. * Gets wether tonemapping is enabled or not.
  40094. */
  40095. /**
  40096. * Sets wether tonemapping is enabled or not
  40097. */
  40098. toneMappingEnabled: boolean;
  40099. /**
  40100. * Gets the type of tone mapping effect.
  40101. */
  40102. /**
  40103. * Sets the type of tone mapping effect.
  40104. */
  40105. toneMappingType: number;
  40106. /**
  40107. * Gets contrast used in the effect.
  40108. */
  40109. /**
  40110. * Sets contrast used in the effect.
  40111. */
  40112. contrast: number;
  40113. /**
  40114. * Gets Vignette stretch size.
  40115. */
  40116. /**
  40117. * Sets Vignette stretch size.
  40118. */
  40119. vignetteStretch: number;
  40120. /**
  40121. * Gets Vignette centre X Offset.
  40122. */
  40123. /**
  40124. * Sets Vignette centre X Offset.
  40125. */
  40126. vignetteCentreX: number;
  40127. /**
  40128. * Gets Vignette centre Y Offset.
  40129. */
  40130. /**
  40131. * Sets Vignette centre Y Offset.
  40132. */
  40133. vignetteCentreY: number;
  40134. /**
  40135. * Gets Vignette weight or intensity of the vignette effect.
  40136. */
  40137. /**
  40138. * Sets Vignette weight or intensity of the vignette effect.
  40139. */
  40140. vignetteWeight: number;
  40141. /**
  40142. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40143. * if vignetteEnabled is set to true.
  40144. */
  40145. /**
  40146. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40147. * if vignetteEnabled is set to true.
  40148. */
  40149. vignetteColor: Color4;
  40150. /**
  40151. * Gets Camera field of view used by the Vignette effect.
  40152. */
  40153. /**
  40154. * Sets Camera field of view used by the Vignette effect.
  40155. */
  40156. vignetteCameraFov: number;
  40157. /**
  40158. * Gets the vignette blend mode allowing different kind of effect.
  40159. */
  40160. /**
  40161. * Sets the vignette blend mode allowing different kind of effect.
  40162. */
  40163. vignetteBlendMode: number;
  40164. /**
  40165. * Gets wether the vignette effect is enabled.
  40166. */
  40167. /**
  40168. * Sets wether the vignette effect is enabled.
  40169. */
  40170. vignetteEnabled: boolean;
  40171. private _fromLinearSpace;
  40172. /**
  40173. * Gets wether the input of the processing is in Gamma or Linear Space.
  40174. */
  40175. /**
  40176. * Sets wether the input of the processing is in Gamma or Linear Space.
  40177. */
  40178. fromLinearSpace: boolean;
  40179. /**
  40180. * Defines cache preventing GC.
  40181. */
  40182. private _defines;
  40183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40184. /**
  40185. * "ImageProcessingPostProcess"
  40186. * @returns "ImageProcessingPostProcess"
  40187. */
  40188. getClassName(): string;
  40189. protected _updateParameters(): void;
  40190. dispose(camera?: Camera): void;
  40191. }
  40192. }
  40193. declare module BABYLON {
  40194. /**
  40195. * Class containing static functions to help procedurally build meshes
  40196. */
  40197. export class GroundBuilder {
  40198. /**
  40199. * Creates a ground mesh
  40200. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40201. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40203. * @param name defines the name of the mesh
  40204. * @param options defines the options used to create the mesh
  40205. * @param scene defines the hosting scene
  40206. * @returns the ground mesh
  40207. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40208. */
  40209. static CreateGround(name: string, options: {
  40210. width?: number;
  40211. height?: number;
  40212. subdivisions?: number;
  40213. subdivisionsX?: number;
  40214. subdivisionsY?: number;
  40215. updatable?: boolean;
  40216. }, scene: any): Mesh;
  40217. /**
  40218. * Creates a tiled ground mesh
  40219. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40220. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40221. * * 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
  40222. * * 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
  40223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40224. * @param name defines the name of the mesh
  40225. * @param options defines the options used to create the mesh
  40226. * @param scene defines the hosting scene
  40227. * @returns the tiled ground mesh
  40228. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40229. */
  40230. static CreateTiledGround(name: string, options: {
  40231. xmin: number;
  40232. zmin: number;
  40233. xmax: number;
  40234. zmax: number;
  40235. subdivisions?: {
  40236. w: number;
  40237. h: number;
  40238. };
  40239. precision?: {
  40240. w: number;
  40241. h: number;
  40242. };
  40243. updatable?: boolean;
  40244. }, scene?: Nullable<Scene>): Mesh;
  40245. /**
  40246. * Creates a ground mesh from a height map
  40247. * * The parameter `url` sets the URL of the height map image resource.
  40248. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40249. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40250. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40251. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40252. * * 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.
  40253. * * 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).
  40254. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40256. * @param name defines the name of the mesh
  40257. * @param url defines the url to the height map
  40258. * @param options defines the options used to create the mesh
  40259. * @param scene defines the hosting scene
  40260. * @returns the ground mesh
  40261. * @see https://doc.babylonjs.com/babylon101/height_map
  40262. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40263. */
  40264. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40265. width?: number;
  40266. height?: number;
  40267. subdivisions?: number;
  40268. minHeight?: number;
  40269. maxHeight?: number;
  40270. colorFilter?: Color3;
  40271. alphaFilter?: number;
  40272. updatable?: boolean;
  40273. onReady?: (mesh: GroundMesh) => void;
  40274. }, scene?: Nullable<Scene>): GroundMesh;
  40275. }
  40276. }
  40277. declare module BABYLON {
  40278. /**
  40279. * Class containing static functions to help procedurally build meshes
  40280. */
  40281. export class TorusBuilder {
  40282. /**
  40283. * Creates a torus mesh
  40284. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40285. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40286. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40288. * * 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
  40289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40290. * @param name defines the name of the mesh
  40291. * @param options defines the options used to create the mesh
  40292. * @param scene defines the hosting scene
  40293. * @returns the torus mesh
  40294. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40295. */
  40296. static CreateTorus(name: string, options: {
  40297. diameter?: number;
  40298. thickness?: number;
  40299. tessellation?: number;
  40300. updatable?: boolean;
  40301. sideOrientation?: number;
  40302. frontUVs?: Vector4;
  40303. backUVs?: Vector4;
  40304. }, scene: any): Mesh;
  40305. }
  40306. }
  40307. declare module BABYLON {
  40308. /**
  40309. * Class containing static functions to help procedurally build meshes
  40310. */
  40311. export class CylinderBuilder {
  40312. /**
  40313. * Creates a cylinder or a cone mesh
  40314. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40315. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40316. * * 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.
  40317. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40318. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40319. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40320. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40321. * * 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).
  40322. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40323. * * 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).
  40324. * * 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
  40325. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40326. * * 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
  40327. * * 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.
  40328. * * If `enclose` is false, a ring surface is one element.
  40329. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40330. * * 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
  40331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40332. * * 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
  40333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40334. * @param name defines the name of the mesh
  40335. * @param options defines the options used to create the mesh
  40336. * @param scene defines the hosting scene
  40337. * @returns the cylinder mesh
  40338. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40339. */
  40340. static CreateCylinder(name: string, options: {
  40341. height?: number;
  40342. diameterTop?: number;
  40343. diameterBottom?: number;
  40344. diameter?: number;
  40345. tessellation?: number;
  40346. subdivisions?: number;
  40347. arc?: number;
  40348. faceColors?: Color4[];
  40349. faceUV?: Vector4[];
  40350. updatable?: boolean;
  40351. hasRings?: boolean;
  40352. enclose?: boolean;
  40353. cap?: number;
  40354. sideOrientation?: number;
  40355. frontUVs?: Vector4;
  40356. backUVs?: Vector4;
  40357. }, scene: any): Mesh;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * Options to modify the vr teleportation behavior.
  40363. */
  40364. export interface VRTeleportationOptions {
  40365. /**
  40366. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40367. */
  40368. floorMeshName?: string;
  40369. /**
  40370. * A list of meshes to be used as the teleportation floor. (default: empty)
  40371. */
  40372. floorMeshes?: Mesh[];
  40373. }
  40374. /**
  40375. * Options to modify the vr experience helper's behavior.
  40376. */
  40377. export interface VRExperienceHelperOptions extends WebVROptions {
  40378. /**
  40379. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40380. */
  40381. createDeviceOrientationCamera?: boolean;
  40382. /**
  40383. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40384. */
  40385. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40386. /**
  40387. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40388. */
  40389. laserToggle?: boolean;
  40390. /**
  40391. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40392. */
  40393. floorMeshes?: Mesh[];
  40394. /**
  40395. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40396. */
  40397. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40398. }
  40399. /**
  40400. * Event containing information after VR has been entered
  40401. */
  40402. export class OnAfterEnteringVRObservableEvent {
  40403. /**
  40404. * If entering vr was successful
  40405. */
  40406. success: boolean;
  40407. }
  40408. /**
  40409. * Helps to quickly add VR support to an existing scene.
  40410. * See http://doc.babylonjs.com/how_to/webvr_helper
  40411. */
  40412. export class VRExperienceHelper {
  40413. /** Options to modify the vr experience helper's behavior. */
  40414. webVROptions: VRExperienceHelperOptions;
  40415. private _scene;
  40416. private _position;
  40417. private _btnVR;
  40418. private _btnVRDisplayed;
  40419. private _webVRsupported;
  40420. private _webVRready;
  40421. private _webVRrequesting;
  40422. private _webVRpresenting;
  40423. private _hasEnteredVR;
  40424. private _fullscreenVRpresenting;
  40425. private _canvas;
  40426. private _webVRCamera;
  40427. private _vrDeviceOrientationCamera;
  40428. private _deviceOrientationCamera;
  40429. private _existingCamera;
  40430. private _onKeyDown;
  40431. private _onVrDisplayPresentChange;
  40432. private _onVRDisplayChanged;
  40433. private _onVRRequestPresentStart;
  40434. private _onVRRequestPresentComplete;
  40435. /**
  40436. * Observable raised right before entering VR.
  40437. */
  40438. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40439. /**
  40440. * Observable raised when entering VR has completed.
  40441. */
  40442. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40443. /**
  40444. * Observable raised when exiting VR.
  40445. */
  40446. onExitingVRObservable: Observable<VRExperienceHelper>;
  40447. /**
  40448. * Observable raised when controller mesh is loaded.
  40449. */
  40450. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40451. /** Return this.onEnteringVRObservable
  40452. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40453. */
  40454. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40455. /** Return this.onExitingVRObservable
  40456. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40457. */
  40458. readonly onExitingVR: Observable<VRExperienceHelper>;
  40459. /** Return this.onControllerMeshLoadedObservable
  40460. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40461. */
  40462. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40463. private _rayLength;
  40464. private _useCustomVRButton;
  40465. private _teleportationRequested;
  40466. private _teleportActive;
  40467. private _floorMeshName;
  40468. private _floorMeshesCollection;
  40469. private _rotationAllowed;
  40470. private _teleportBackwardsVector;
  40471. private _teleportationTarget;
  40472. private _isDefaultTeleportationTarget;
  40473. private _postProcessMove;
  40474. private _teleportationFillColor;
  40475. private _teleportationBorderColor;
  40476. private _rotationAngle;
  40477. private _haloCenter;
  40478. private _cameraGazer;
  40479. private _padSensibilityUp;
  40480. private _padSensibilityDown;
  40481. private _leftController;
  40482. private _rightController;
  40483. /**
  40484. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40485. */
  40486. onNewMeshSelected: Observable<AbstractMesh>;
  40487. /**
  40488. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40489. */
  40490. onNewMeshPicked: Observable<PickingInfo>;
  40491. private _circleEase;
  40492. /**
  40493. * Observable raised before camera teleportation
  40494. */
  40495. onBeforeCameraTeleport: Observable<Vector3>;
  40496. /**
  40497. * Observable raised after camera teleportation
  40498. */
  40499. onAfterCameraTeleport: Observable<Vector3>;
  40500. /**
  40501. * Observable raised when current selected mesh gets unselected
  40502. */
  40503. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40504. private _raySelectionPredicate;
  40505. /**
  40506. * To be optionaly changed by user to define custom ray selection
  40507. */
  40508. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40509. /**
  40510. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40511. */
  40512. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40513. /**
  40514. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40515. */
  40516. teleportationEnabled: boolean;
  40517. private _defaultHeight;
  40518. private _teleportationInitialized;
  40519. private _interactionsEnabled;
  40520. private _interactionsRequested;
  40521. private _displayGaze;
  40522. private _displayLaserPointer;
  40523. /**
  40524. * The mesh used to display where the user is going to teleport.
  40525. */
  40526. /**
  40527. * Sets the mesh to be used to display where the user is going to teleport.
  40528. */
  40529. teleportationTarget: Mesh;
  40530. /**
  40531. * 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
  40532. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40533. * See http://doc.babylonjs.com/resources/baking_transformations
  40534. */
  40535. gazeTrackerMesh: Mesh;
  40536. /**
  40537. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40538. */
  40539. updateGazeTrackerScale: boolean;
  40540. /**
  40541. * If the gaze trackers color should be updated when selecting meshes
  40542. */
  40543. updateGazeTrackerColor: boolean;
  40544. /**
  40545. * The gaze tracking mesh corresponding to the left controller
  40546. */
  40547. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40548. /**
  40549. * The gaze tracking mesh corresponding to the right controller
  40550. */
  40551. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40552. /**
  40553. * If the ray of the gaze should be displayed.
  40554. */
  40555. /**
  40556. * Sets if the ray of the gaze should be displayed.
  40557. */
  40558. displayGaze: boolean;
  40559. /**
  40560. * If the ray of the LaserPointer should be displayed.
  40561. */
  40562. /**
  40563. * Sets if the ray of the LaserPointer should be displayed.
  40564. */
  40565. displayLaserPointer: boolean;
  40566. /**
  40567. * The deviceOrientationCamera used as the camera when not in VR.
  40568. */
  40569. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40570. /**
  40571. * Based on the current WebVR support, returns the current VR camera used.
  40572. */
  40573. readonly currentVRCamera: Nullable<Camera>;
  40574. /**
  40575. * The webVRCamera which is used when in VR.
  40576. */
  40577. readonly webVRCamera: WebVRFreeCamera;
  40578. /**
  40579. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40580. */
  40581. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40582. private readonly _teleportationRequestInitiated;
  40583. /**
  40584. * Defines wether or not Pointer lock should be requested when switching to
  40585. * full screen.
  40586. */
  40587. requestPointerLockOnFullScreen: boolean;
  40588. /**
  40589. * Instantiates a VRExperienceHelper.
  40590. * Helps to quickly add VR support to an existing scene.
  40591. * @param scene The scene the VRExperienceHelper belongs to.
  40592. * @param webVROptions Options to modify the vr experience helper's behavior.
  40593. */
  40594. constructor(scene: Scene,
  40595. /** Options to modify the vr experience helper's behavior. */
  40596. webVROptions?: VRExperienceHelperOptions);
  40597. private _onDefaultMeshLoaded;
  40598. private _onResize;
  40599. private _onFullscreenChange;
  40600. /**
  40601. * Gets a value indicating if we are currently in VR mode.
  40602. */
  40603. readonly isInVRMode: boolean;
  40604. private onVrDisplayPresentChange;
  40605. private onVRDisplayChanged;
  40606. private moveButtonToBottomRight;
  40607. private displayVRButton;
  40608. private updateButtonVisibility;
  40609. private _cachedAngularSensibility;
  40610. /**
  40611. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40612. * Otherwise, will use the fullscreen API.
  40613. */
  40614. enterVR(): void;
  40615. /**
  40616. * Attempt to exit VR, or fullscreen.
  40617. */
  40618. exitVR(): void;
  40619. /**
  40620. * The position of the vr experience helper.
  40621. */
  40622. /**
  40623. * Sets the position of the vr experience helper.
  40624. */
  40625. position: Vector3;
  40626. /**
  40627. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40628. */
  40629. enableInteractions(): void;
  40630. private readonly _noControllerIsActive;
  40631. private beforeRender;
  40632. private _isTeleportationFloor;
  40633. /**
  40634. * Adds a floor mesh to be used for teleportation.
  40635. * @param floorMesh the mesh to be used for teleportation.
  40636. */
  40637. addFloorMesh(floorMesh: Mesh): void;
  40638. /**
  40639. * Removes a floor mesh from being used for teleportation.
  40640. * @param floorMesh the mesh to be removed.
  40641. */
  40642. removeFloorMesh(floorMesh: Mesh): void;
  40643. /**
  40644. * Enables interactions and teleportation using the VR controllers and gaze.
  40645. * @param vrTeleportationOptions options to modify teleportation behavior.
  40646. */
  40647. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40648. private _onNewGamepadConnected;
  40649. private _tryEnableInteractionOnController;
  40650. private _onNewGamepadDisconnected;
  40651. private _enableInteractionOnController;
  40652. private _checkTeleportWithRay;
  40653. private _checkRotate;
  40654. private _checkTeleportBackwards;
  40655. private _enableTeleportationOnController;
  40656. private _createTeleportationCircles;
  40657. private _displayTeleportationTarget;
  40658. private _hideTeleportationTarget;
  40659. private _rotateCamera;
  40660. private _moveTeleportationSelectorTo;
  40661. private _workingVector;
  40662. private _workingQuaternion;
  40663. private _workingMatrix;
  40664. /**
  40665. * Teleports the users feet to the desired location
  40666. * @param location The location where the user's feet should be placed
  40667. */
  40668. teleportCamera(location: Vector3): void;
  40669. private _convertNormalToDirectionOfRay;
  40670. private _castRayAndSelectObject;
  40671. private _notifySelectedMeshUnselected;
  40672. /**
  40673. * Sets the color of the laser ray from the vr controllers.
  40674. * @param color new color for the ray.
  40675. */
  40676. changeLaserColor(color: Color3): void;
  40677. /**
  40678. * Sets the color of the ray from the vr headsets gaze.
  40679. * @param color new color for the ray.
  40680. */
  40681. changeGazeColor(color: Color3): void;
  40682. /**
  40683. * Exits VR and disposes of the vr experience helper
  40684. */
  40685. dispose(): void;
  40686. /**
  40687. * Gets the name of the VRExperienceHelper class
  40688. * @returns "VRExperienceHelper"
  40689. */
  40690. getClassName(): string;
  40691. }
  40692. }
  40693. declare module BABYLON {
  40694. /**
  40695. * Manages an XRSession to work with Babylon's engine
  40696. * @see https://doc.babylonjs.com/how_to/webxr
  40697. */
  40698. export class WebXRSessionManager implements IDisposable {
  40699. private scene;
  40700. /**
  40701. * Fires every time a new xrFrame arrives which can be used to update the camera
  40702. */
  40703. onXRFrameObservable: Observable<any>;
  40704. /**
  40705. * Fires when the xr session is ended either by the device or manually done
  40706. */
  40707. onXRSessionEnded: Observable<any>;
  40708. /**
  40709. * Underlying xr session
  40710. */
  40711. session: XRSession;
  40712. /**
  40713. * Type of reference space used when creating the session
  40714. */
  40715. referenceSpace: XRReferenceSpace;
  40716. /** @hidden */
  40717. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40718. /**
  40719. * Current XR frame
  40720. */
  40721. currentFrame: Nullable<XRFrame>;
  40722. private _xrNavigator;
  40723. private baseLayer;
  40724. /**
  40725. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40726. * @param scene The scene which the session should be created for
  40727. */
  40728. constructor(scene: Scene);
  40729. /**
  40730. * Initializes the manager
  40731. * After initialization enterXR can be called to start an XR session
  40732. * @returns Promise which resolves after it is initialized
  40733. */
  40734. initializeAsync(): Promise<void>;
  40735. /**
  40736. * Initializes an xr session
  40737. * @param xrSessionMode mode to initialize
  40738. * @returns a promise which will resolve once the session has been initialized
  40739. */
  40740. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40741. /**
  40742. * Sets the reference space on the xr session
  40743. * @param referenceSpace space to set
  40744. * @returns a promise that will resolve once the reference space has been set
  40745. */
  40746. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40747. /**
  40748. * Updates the render state of the session
  40749. * @param state state to set
  40750. * @returns a promise that resolves once the render state has been updated
  40751. */
  40752. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40753. /**
  40754. * Starts rendering to the xr layer
  40755. * @returns a promise that will resolve once rendering has started
  40756. */
  40757. startRenderingToXRAsync(): Promise<void>;
  40758. /**
  40759. * Stops the xrSession and restores the renderloop
  40760. * @returns Promise which resolves after it exits XR
  40761. */
  40762. exitXRAsync(): Promise<unknown>;
  40763. /**
  40764. * Checks if a session would be supported for the creation options specified
  40765. * @param sessionMode session mode to check if supported eg. immersive-vr
  40766. * @returns true if supported
  40767. */
  40768. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40769. /**
  40770. * @hidden
  40771. * Converts the render layer of xrSession to a render target
  40772. * @param session session to create render target for
  40773. * @param scene scene the new render target should be created for
  40774. */
  40775. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40776. /**
  40777. * Disposes of the session manager
  40778. */
  40779. dispose(): void;
  40780. }
  40781. }
  40782. declare module BABYLON {
  40783. /**
  40784. * WebXR Camera which holds the views for the xrSession
  40785. * @see https://doc.babylonjs.com/how_to/webxr
  40786. */
  40787. export class WebXRCamera extends FreeCamera {
  40788. private static _TmpMatrix;
  40789. /**
  40790. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40791. * @param name the name of the camera
  40792. * @param scene the scene to add the camera to
  40793. */
  40794. constructor(name: string, scene: Scene);
  40795. private _updateNumberOfRigCameras;
  40796. /** @hidden */
  40797. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40798. /**
  40799. * Updates the cameras position from the current pose information of the XR session
  40800. * @param xrSessionManager the session containing pose information
  40801. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40802. */
  40803. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40804. }
  40805. }
  40806. declare module BABYLON {
  40807. /**
  40808. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40809. */
  40810. export class WebXRManagedOutputCanvas implements IDisposable {
  40811. private helper;
  40812. private _canvas;
  40813. /**
  40814. * xrpresent context of the canvas which can be used to display/mirror xr content
  40815. */
  40816. canvasContext: WebGLRenderingContext;
  40817. /**
  40818. * xr layer for the canvas
  40819. */
  40820. xrLayer: Nullable<XRWebGLLayer>;
  40821. /**
  40822. * Initializes the xr layer for the session
  40823. * @param xrSession xr session
  40824. * @returns a promise that will resolve once the XR Layer has been created
  40825. */
  40826. initializeXRLayerAsync(xrSession: any): any;
  40827. /**
  40828. * Initializes the canvas to be added/removed upon entering/exiting xr
  40829. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40830. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40831. */
  40832. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40833. /**
  40834. * Disposes of the object
  40835. */
  40836. dispose(): void;
  40837. private _setManagedOutputCanvas;
  40838. private _addCanvas;
  40839. private _removeCanvas;
  40840. }
  40841. }
  40842. declare module BABYLON {
  40843. /**
  40844. * States of the webXR experience
  40845. */
  40846. export enum WebXRState {
  40847. /**
  40848. * Transitioning to being in XR mode
  40849. */
  40850. ENTERING_XR = 0,
  40851. /**
  40852. * Transitioning to non XR mode
  40853. */
  40854. EXITING_XR = 1,
  40855. /**
  40856. * In XR mode and presenting
  40857. */
  40858. IN_XR = 2,
  40859. /**
  40860. * Not entered XR mode
  40861. */
  40862. NOT_IN_XR = 3
  40863. }
  40864. /**
  40865. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40866. * @see https://doc.babylonjs.com/how_to/webxr
  40867. */
  40868. export class WebXRExperienceHelper implements IDisposable {
  40869. private scene;
  40870. /**
  40871. * 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
  40872. */
  40873. container: AbstractMesh;
  40874. /**
  40875. * Camera used to render xr content
  40876. */
  40877. camera: WebXRCamera;
  40878. /**
  40879. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40880. */
  40881. state: WebXRState;
  40882. private _setState;
  40883. private static _TmpVector;
  40884. /**
  40885. * Fires when the state of the experience helper has changed
  40886. */
  40887. onStateChangedObservable: Observable<WebXRState>;
  40888. /** Session manager used to keep track of xr session */
  40889. sessionManager: WebXRSessionManager;
  40890. private _nonVRCamera;
  40891. private _originalSceneAutoClear;
  40892. private _supported;
  40893. /**
  40894. * Creates the experience helper
  40895. * @param scene the scene to attach the experience helper to
  40896. * @returns a promise for the experience helper
  40897. */
  40898. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40899. /**
  40900. * Creates a WebXRExperienceHelper
  40901. * @param scene The scene the helper should be created in
  40902. */
  40903. private constructor();
  40904. /**
  40905. * Exits XR mode and returns the scene to its original state
  40906. * @returns promise that resolves after xr mode has exited
  40907. */
  40908. exitXRAsync(): Promise<unknown>;
  40909. /**
  40910. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40911. * @param sessionCreationOptions options for the XR session
  40912. * @param referenceSpaceType frame of reference of the XR session
  40913. * @param outputCanvas the output canvas that will be used to enter XR mode
  40914. * @returns promise that resolves after xr mode has entered
  40915. */
  40916. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40917. /**
  40918. * Updates the global position of the camera by moving the camera's container
  40919. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40920. * @param position The desired global position of the camera
  40921. */
  40922. setPositionOfCameraUsingContainer(position: Vector3): void;
  40923. /**
  40924. * Rotates the xr camera by rotating the camera's container around the camera's position
  40925. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40926. * @param rotation the desired quaternion rotation to apply to the camera
  40927. */
  40928. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40929. /**
  40930. * Disposes of the experience helper
  40931. */
  40932. dispose(): void;
  40933. }
  40934. }
  40935. declare module BABYLON {
  40936. /**
  40937. * Button which can be used to enter a different mode of XR
  40938. */
  40939. export class WebXREnterExitUIButton {
  40940. /** button element */
  40941. element: HTMLElement;
  40942. /** XR initialization options for the button */
  40943. sessionMode: XRSessionMode;
  40944. /** Reference space type */
  40945. referenceSpaceType: XRReferenceSpaceType;
  40946. /**
  40947. * Creates a WebXREnterExitUIButton
  40948. * @param element button element
  40949. * @param sessionMode XR initialization session mode
  40950. * @param referenceSpaceType the type of reference space to be used
  40951. */
  40952. constructor(
  40953. /** button element */
  40954. element: HTMLElement,
  40955. /** XR initialization options for the button */
  40956. sessionMode: XRSessionMode,
  40957. /** Reference space type */
  40958. referenceSpaceType: XRReferenceSpaceType);
  40959. /**
  40960. * Overwritable function which can be used to update the button's visuals when the state changes
  40961. * @param activeButton the current active button in the UI
  40962. */
  40963. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40964. }
  40965. /**
  40966. * Options to create the webXR UI
  40967. */
  40968. export class WebXREnterExitUIOptions {
  40969. /**
  40970. * Context to enter xr with
  40971. */
  40972. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40973. /**
  40974. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40975. */
  40976. customButtons?: Array<WebXREnterExitUIButton>;
  40977. }
  40978. /**
  40979. * UI to allow the user to enter/exit XR mode
  40980. */
  40981. export class WebXREnterExitUI implements IDisposable {
  40982. private scene;
  40983. private _overlay;
  40984. private _buttons;
  40985. private _activeButton;
  40986. /**
  40987. * Fired every time the active button is changed.
  40988. *
  40989. * When xr is entered via a button that launches xr that button will be the callback parameter
  40990. *
  40991. * When exiting xr the callback parameter will be null)
  40992. */
  40993. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40994. /**
  40995. * Creates UI to allow the user to enter/exit XR mode
  40996. * @param scene the scene to add the ui to
  40997. * @param helper the xr experience helper to enter/exit xr with
  40998. * @param options options to configure the UI
  40999. * @returns the created ui
  41000. */
  41001. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41002. private constructor();
  41003. private _updateButtons;
  41004. /**
  41005. * Disposes of the object
  41006. */
  41007. dispose(): void;
  41008. }
  41009. }
  41010. declare module BABYLON {
  41011. /**
  41012. * Represents an XR input
  41013. */
  41014. export class WebXRController {
  41015. private scene;
  41016. /** The underlying input source for the controller */
  41017. inputSource: XRInputSource;
  41018. private parentContainer;
  41019. /**
  41020. * 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
  41021. */
  41022. grip?: AbstractMesh;
  41023. /**
  41024. * Pointer which can be used to select objects or attach a visible laser to
  41025. */
  41026. pointer: AbstractMesh;
  41027. /**
  41028. * Event that fires when the controller is removed/disposed
  41029. */
  41030. onDisposeObservable: Observable<{}>;
  41031. private _tmpMatrix;
  41032. private _tmpQuaternion;
  41033. private _tmpVector;
  41034. /**
  41035. * Creates the controller
  41036. * @see https://doc.babylonjs.com/how_to/webxr
  41037. * @param scene the scene which the controller should be associated to
  41038. * @param inputSource the underlying input source for the controller
  41039. * @param parentContainer parent that the controller meshes should be children of
  41040. */
  41041. constructor(scene: Scene,
  41042. /** The underlying input source for the controller */
  41043. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41044. /**
  41045. * Updates the controller pose based on the given XRFrame
  41046. * @param xrFrame xr frame to update the pose with
  41047. * @param referenceSpace reference space to use
  41048. */
  41049. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41050. /**
  41051. * Gets a world space ray coming from the controller
  41052. * @param result the resulting ray
  41053. */
  41054. getWorldPointerRayToRef(result: Ray): void;
  41055. /**
  41056. * Disposes of the object
  41057. */
  41058. dispose(): void;
  41059. }
  41060. }
  41061. declare module BABYLON {
  41062. /**
  41063. * XR input used to track XR inputs such as controllers/rays
  41064. */
  41065. export class WebXRInput implements IDisposable {
  41066. /**
  41067. * Base experience the input listens to
  41068. */
  41069. baseExperience: WebXRExperienceHelper;
  41070. /**
  41071. * XR controllers being tracked
  41072. */
  41073. controllers: Array<WebXRController>;
  41074. private _frameObserver;
  41075. private _stateObserver;
  41076. /**
  41077. * Event when a controller has been connected/added
  41078. */
  41079. onControllerAddedObservable: Observable<WebXRController>;
  41080. /**
  41081. * Event when a controller has been removed/disconnected
  41082. */
  41083. onControllerRemovedObservable: Observable<WebXRController>;
  41084. /**
  41085. * Initializes the WebXRInput
  41086. * @param baseExperience experience helper which the input should be created for
  41087. */
  41088. constructor(
  41089. /**
  41090. * Base experience the input listens to
  41091. */
  41092. baseExperience: WebXRExperienceHelper);
  41093. private _onInputSourcesChange;
  41094. private _addAndRemoveControllers;
  41095. /**
  41096. * Disposes of the object
  41097. */
  41098. dispose(): void;
  41099. }
  41100. }
  41101. declare module BABYLON {
  41102. /**
  41103. * Enables teleportation
  41104. */
  41105. export class WebXRControllerTeleportation {
  41106. private _teleportationFillColor;
  41107. private _teleportationBorderColor;
  41108. private _tmpRay;
  41109. private _tmpVector;
  41110. /**
  41111. * Creates a WebXRControllerTeleportation
  41112. * @param input input manager to add teleportation to
  41113. * @param floorMeshes floormeshes which can be teleported to
  41114. */
  41115. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41116. }
  41117. }
  41118. declare module BABYLON {
  41119. /**
  41120. * Handles pointer input automatically for the pointer of XR controllers
  41121. */
  41122. export class WebXRControllerPointerSelection {
  41123. private static _idCounter;
  41124. private _tmpRay;
  41125. /**
  41126. * Creates a WebXRControllerPointerSelection
  41127. * @param input input manager to setup pointer selection
  41128. */
  41129. constructor(input: WebXRInput);
  41130. private _convertNormalToDirectionOfRay;
  41131. private _updatePointerDistance;
  41132. }
  41133. }
  41134. declare module BABYLON {
  41135. /**
  41136. * Class used to represent data loading progression
  41137. */
  41138. export class SceneLoaderProgressEvent {
  41139. /** defines if data length to load can be evaluated */
  41140. readonly lengthComputable: boolean;
  41141. /** defines the loaded data length */
  41142. readonly loaded: number;
  41143. /** defines the data length to load */
  41144. readonly total: number;
  41145. /**
  41146. * Create a new progress event
  41147. * @param lengthComputable defines if data length to load can be evaluated
  41148. * @param loaded defines the loaded data length
  41149. * @param total defines the data length to load
  41150. */
  41151. constructor(
  41152. /** defines if data length to load can be evaluated */
  41153. lengthComputable: boolean,
  41154. /** defines the loaded data length */
  41155. loaded: number,
  41156. /** defines the data length to load */
  41157. total: number);
  41158. /**
  41159. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41160. * @param event defines the source event
  41161. * @returns a new SceneLoaderProgressEvent
  41162. */
  41163. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41164. }
  41165. /**
  41166. * Interface used by SceneLoader plugins to define supported file extensions
  41167. */
  41168. export interface ISceneLoaderPluginExtensions {
  41169. /**
  41170. * Defines the list of supported extensions
  41171. */
  41172. [extension: string]: {
  41173. isBinary: boolean;
  41174. };
  41175. }
  41176. /**
  41177. * Interface used by SceneLoader plugin factory
  41178. */
  41179. export interface ISceneLoaderPluginFactory {
  41180. /**
  41181. * Defines the name of the factory
  41182. */
  41183. name: string;
  41184. /**
  41185. * Function called to create a new plugin
  41186. * @return the new plugin
  41187. */
  41188. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41189. /**
  41190. * Boolean indicating if the plugin can direct load specific data
  41191. */
  41192. canDirectLoad?: (data: string) => boolean;
  41193. }
  41194. /**
  41195. * Interface used to define a SceneLoader plugin
  41196. */
  41197. export interface ISceneLoaderPlugin {
  41198. /**
  41199. * The friendly name of this plugin.
  41200. */
  41201. name: string;
  41202. /**
  41203. * The file extensions supported by this plugin.
  41204. */
  41205. extensions: string | ISceneLoaderPluginExtensions;
  41206. /**
  41207. * Import meshes into a scene.
  41208. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41209. * @param scene The scene to import into
  41210. * @param data The data to import
  41211. * @param rootUrl The root url for scene and resources
  41212. * @param meshes The meshes array to import into
  41213. * @param particleSystems The particle systems array to import into
  41214. * @param skeletons The skeletons array to import into
  41215. * @param onError The callback when import fails
  41216. * @returns True if successful or false otherwise
  41217. */
  41218. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41219. /**
  41220. * Load into a scene.
  41221. * @param scene The scene to load into
  41222. * @param data The data to import
  41223. * @param rootUrl The root url for scene and resources
  41224. * @param onError The callback when import fails
  41225. * @returns true if successful or false otherwise
  41226. */
  41227. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41228. /**
  41229. * The callback that returns true if the data can be directly loaded.
  41230. */
  41231. canDirectLoad?: (data: string) => boolean;
  41232. /**
  41233. * The callback that allows custom handling of the root url based on the response url.
  41234. */
  41235. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41236. /**
  41237. * Load into an asset container.
  41238. * @param scene The scene to load into
  41239. * @param data The data to import
  41240. * @param rootUrl The root url for scene and resources
  41241. * @param onError The callback when import fails
  41242. * @returns The loaded asset container
  41243. */
  41244. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41245. }
  41246. /**
  41247. * Interface used to define an async SceneLoader plugin
  41248. */
  41249. export interface ISceneLoaderPluginAsync {
  41250. /**
  41251. * The friendly name of this plugin.
  41252. */
  41253. name: string;
  41254. /**
  41255. * The file extensions supported by this plugin.
  41256. */
  41257. extensions: string | ISceneLoaderPluginExtensions;
  41258. /**
  41259. * Import meshes into a scene.
  41260. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41261. * @param scene The scene to import into
  41262. * @param data The data to import
  41263. * @param rootUrl The root url for scene and resources
  41264. * @param onProgress The callback when the load progresses
  41265. * @param fileName Defines the name of the file to load
  41266. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41267. */
  41268. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41269. meshes: AbstractMesh[];
  41270. particleSystems: IParticleSystem[];
  41271. skeletons: Skeleton[];
  41272. animationGroups: AnimationGroup[];
  41273. }>;
  41274. /**
  41275. * Load into a scene.
  41276. * @param scene The scene to load into
  41277. * @param data The data to import
  41278. * @param rootUrl The root url for scene and resources
  41279. * @param onProgress The callback when the load progresses
  41280. * @param fileName Defines the name of the file to load
  41281. * @returns Nothing
  41282. */
  41283. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41284. /**
  41285. * The callback that returns true if the data can be directly loaded.
  41286. */
  41287. canDirectLoad?: (data: string) => boolean;
  41288. /**
  41289. * The callback that allows custom handling of the root url based on the response url.
  41290. */
  41291. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41292. /**
  41293. * Load into an asset container.
  41294. * @param scene The scene to load into
  41295. * @param data The data to import
  41296. * @param rootUrl The root url for scene and resources
  41297. * @param onProgress The callback when the load progresses
  41298. * @param fileName Defines the name of the file to load
  41299. * @returns The loaded asset container
  41300. */
  41301. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41302. }
  41303. /**
  41304. * Class used to load scene from various file formats using registered plugins
  41305. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41306. */
  41307. export class SceneLoader {
  41308. /**
  41309. * No logging while loading
  41310. */
  41311. static readonly NO_LOGGING: number;
  41312. /**
  41313. * Minimal logging while loading
  41314. */
  41315. static readonly MINIMAL_LOGGING: number;
  41316. /**
  41317. * Summary logging while loading
  41318. */
  41319. static readonly SUMMARY_LOGGING: number;
  41320. /**
  41321. * Detailled logging while loading
  41322. */
  41323. static readonly DETAILED_LOGGING: number;
  41324. /**
  41325. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41326. */
  41327. static ForceFullSceneLoadingForIncremental: boolean;
  41328. /**
  41329. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41330. */
  41331. static ShowLoadingScreen: boolean;
  41332. /**
  41333. * Defines the current logging level (while loading the scene)
  41334. * @ignorenaming
  41335. */
  41336. static loggingLevel: number;
  41337. /**
  41338. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41339. */
  41340. static CleanBoneMatrixWeights: boolean;
  41341. /**
  41342. * Event raised when a plugin is used to load a scene
  41343. */
  41344. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41345. private static _registeredPlugins;
  41346. private static _getDefaultPlugin;
  41347. private static _getPluginForExtension;
  41348. private static _getPluginForDirectLoad;
  41349. private static _getPluginForFilename;
  41350. private static _getDirectLoad;
  41351. private static _loadData;
  41352. private static _getFileInfo;
  41353. /**
  41354. * Gets a plugin that can load the given extension
  41355. * @param extension defines the extension to load
  41356. * @returns a plugin or null if none works
  41357. */
  41358. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41359. /**
  41360. * Gets a boolean indicating that the given extension can be loaded
  41361. * @param extension defines the extension to load
  41362. * @returns true if the extension is supported
  41363. */
  41364. static IsPluginForExtensionAvailable(extension: string): boolean;
  41365. /**
  41366. * Adds a new plugin to the list of registered plugins
  41367. * @param plugin defines the plugin to add
  41368. */
  41369. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41370. /**
  41371. * Import meshes into a scene
  41372. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41373. * @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)
  41374. * @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)
  41375. * @param scene the instance of BABYLON.Scene to append to
  41376. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41377. * @param onProgress a callback with a progress event for each file being loaded
  41378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41379. * @param pluginExtension the extension used to determine the plugin
  41380. * @returns The loaded plugin
  41381. */
  41382. 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>;
  41383. /**
  41384. * Import meshes into a scene
  41385. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41386. * @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)
  41387. * @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)
  41388. * @param scene the instance of BABYLON.Scene to append to
  41389. * @param onProgress a callback with a progress event for each file being loaded
  41390. * @param pluginExtension the extension used to determine the plugin
  41391. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41392. */
  41393. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41394. meshes: AbstractMesh[];
  41395. particleSystems: IParticleSystem[];
  41396. skeletons: Skeleton[];
  41397. animationGroups: AnimationGroup[];
  41398. }>;
  41399. /**
  41400. * Load a scene
  41401. * @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)
  41402. * @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)
  41403. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41404. * @param onSuccess a callback with the scene when import succeeds
  41405. * @param onProgress a callback with a progress event for each file being loaded
  41406. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41407. * @param pluginExtension the extension used to determine the plugin
  41408. * @returns The loaded plugin
  41409. */
  41410. 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>;
  41411. /**
  41412. * Load a scene
  41413. * @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)
  41414. * @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)
  41415. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41416. * @param onProgress a callback with a progress event for each file being loaded
  41417. * @param pluginExtension the extension used to determine the plugin
  41418. * @returns The loaded scene
  41419. */
  41420. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41421. /**
  41422. * Append a scene
  41423. * @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)
  41424. * @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)
  41425. * @param scene is the instance of BABYLON.Scene to append to
  41426. * @param onSuccess a callback with the scene when import succeeds
  41427. * @param onProgress a callback with a progress event for each file being loaded
  41428. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41429. * @param pluginExtension the extension used to determine the plugin
  41430. * @returns The loaded plugin
  41431. */
  41432. 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>;
  41433. /**
  41434. * Append a scene
  41435. * @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)
  41436. * @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)
  41437. * @param scene is the instance of BABYLON.Scene to append to
  41438. * @param onProgress a callback with a progress event for each file being loaded
  41439. * @param pluginExtension the extension used to determine the plugin
  41440. * @returns The given scene
  41441. */
  41442. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41443. /**
  41444. * Load a scene into an asset container
  41445. * @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)
  41446. * @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)
  41447. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41448. * @param onSuccess a callback with the scene when import succeeds
  41449. * @param onProgress a callback with a progress event for each file being loaded
  41450. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41451. * @param pluginExtension the extension used to determine the plugin
  41452. * @returns The loaded plugin
  41453. */
  41454. 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>;
  41455. /**
  41456. * Load a scene into an asset container
  41457. * @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)
  41458. * @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)
  41459. * @param scene is the instance of Scene to append to
  41460. * @param onProgress a callback with a progress event for each file being loaded
  41461. * @param pluginExtension the extension used to determine the plugin
  41462. * @returns The loaded asset container
  41463. */
  41464. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41465. }
  41466. }
  41467. declare module BABYLON {
  41468. /**
  41469. * Generic Controller
  41470. */
  41471. export class GenericController extends WebVRController {
  41472. /**
  41473. * Base Url for the controller model.
  41474. */
  41475. static readonly MODEL_BASE_URL: string;
  41476. /**
  41477. * File name for the controller model.
  41478. */
  41479. static readonly MODEL_FILENAME: string;
  41480. /**
  41481. * Creates a new GenericController from a gamepad
  41482. * @param vrGamepad the gamepad that the controller should be created from
  41483. */
  41484. constructor(vrGamepad: any);
  41485. /**
  41486. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41487. * @param scene scene in which to add meshes
  41488. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41489. */
  41490. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41491. /**
  41492. * Called once for each button that changed state since the last frame
  41493. * @param buttonIdx Which button index changed
  41494. * @param state New state of the button
  41495. * @param changes Which properties on the state changed since last frame
  41496. */
  41497. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41498. }
  41499. }
  41500. declare module BABYLON {
  41501. /**
  41502. * Defines the WindowsMotionController object that the state of the windows motion controller
  41503. */
  41504. export class WindowsMotionController extends WebVRController {
  41505. /**
  41506. * The base url used to load the left and right controller models
  41507. */
  41508. static MODEL_BASE_URL: string;
  41509. /**
  41510. * The name of the left controller model file
  41511. */
  41512. static MODEL_LEFT_FILENAME: string;
  41513. /**
  41514. * The name of the right controller model file
  41515. */
  41516. static MODEL_RIGHT_FILENAME: string;
  41517. /**
  41518. * The controller name prefix for this controller type
  41519. */
  41520. static readonly GAMEPAD_ID_PREFIX: string;
  41521. /**
  41522. * The controller id pattern for this controller type
  41523. */
  41524. private static readonly GAMEPAD_ID_PATTERN;
  41525. private _loadedMeshInfo;
  41526. private readonly _mapping;
  41527. /**
  41528. * Fired when the trackpad on this controller is clicked
  41529. */
  41530. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41531. /**
  41532. * Fired when the trackpad on this controller is modified
  41533. */
  41534. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41535. /**
  41536. * The current x and y values of this controller's trackpad
  41537. */
  41538. trackpad: StickValues;
  41539. /**
  41540. * Creates a new WindowsMotionController from a gamepad
  41541. * @param vrGamepad the gamepad that the controller should be created from
  41542. */
  41543. constructor(vrGamepad: any);
  41544. /**
  41545. * Fired when the trigger on this controller is modified
  41546. */
  41547. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41548. /**
  41549. * Fired when the menu button on this controller is modified
  41550. */
  41551. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41552. /**
  41553. * Fired when the grip button on this controller is modified
  41554. */
  41555. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41556. /**
  41557. * Fired when the thumbstick button on this controller is modified
  41558. */
  41559. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41560. /**
  41561. * Fired when the touchpad button on this controller is modified
  41562. */
  41563. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41564. /**
  41565. * Fired when the touchpad values on this controller are modified
  41566. */
  41567. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41568. private _updateTrackpad;
  41569. /**
  41570. * Called once per frame by the engine.
  41571. */
  41572. update(): void;
  41573. /**
  41574. * Called once for each button that changed state since the last frame
  41575. * @param buttonIdx Which button index changed
  41576. * @param state New state of the button
  41577. * @param changes Which properties on the state changed since last frame
  41578. */
  41579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41580. /**
  41581. * Moves the buttons on the controller mesh based on their current state
  41582. * @param buttonName the name of the button to move
  41583. * @param buttonValue the value of the button which determines the buttons new position
  41584. */
  41585. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41586. /**
  41587. * Moves the axis on the controller mesh based on its current state
  41588. * @param axis the index of the axis
  41589. * @param axisValue the value of the axis which determines the meshes new position
  41590. * @hidden
  41591. */
  41592. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41593. /**
  41594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41595. * @param scene scene in which to add meshes
  41596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41597. */
  41598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41599. /**
  41600. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41601. * can be transformed by button presses and axes values, based on this._mapping.
  41602. *
  41603. * @param scene scene in which the meshes exist
  41604. * @param meshes list of meshes that make up the controller model to process
  41605. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41606. */
  41607. private processModel;
  41608. private createMeshInfo;
  41609. /**
  41610. * Gets the ray of the controller in the direction the controller is pointing
  41611. * @param length the length the resulting ray should be
  41612. * @returns a ray in the direction the controller is pointing
  41613. */
  41614. getForwardRay(length?: number): Ray;
  41615. /**
  41616. * Disposes of the controller
  41617. */
  41618. dispose(): void;
  41619. }
  41620. }
  41621. declare module BABYLON {
  41622. /**
  41623. * Oculus Touch Controller
  41624. */
  41625. export class OculusTouchController extends WebVRController {
  41626. /**
  41627. * Base Url for the controller model.
  41628. */
  41629. static MODEL_BASE_URL: string;
  41630. /**
  41631. * File name for the left controller model.
  41632. */
  41633. static MODEL_LEFT_FILENAME: string;
  41634. /**
  41635. * File name for the right controller model.
  41636. */
  41637. static MODEL_RIGHT_FILENAME: string;
  41638. /**
  41639. * Base Url for the Quest controller model.
  41640. */
  41641. static QUEST_MODEL_BASE_URL: string;
  41642. /**
  41643. * @hidden
  41644. * If the controllers are running on a device that needs the updated Quest controller models
  41645. */
  41646. static _IsQuest: boolean;
  41647. /**
  41648. * Fired when the secondary trigger on this controller is modified
  41649. */
  41650. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41651. /**
  41652. * Fired when the thumb rest on this controller is modified
  41653. */
  41654. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41655. /**
  41656. * Creates a new OculusTouchController from a gamepad
  41657. * @param vrGamepad the gamepad that the controller should be created from
  41658. */
  41659. constructor(vrGamepad: any);
  41660. /**
  41661. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41662. * @param scene scene in which to add meshes
  41663. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41664. */
  41665. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41666. /**
  41667. * Fired when the A button on this controller is modified
  41668. */
  41669. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41670. /**
  41671. * Fired when the B button on this controller is modified
  41672. */
  41673. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41674. /**
  41675. * Fired when the X button on this controller is modified
  41676. */
  41677. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41678. /**
  41679. * Fired when the Y button on this controller is modified
  41680. */
  41681. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41682. /**
  41683. * Called once for each button that changed state since the last frame
  41684. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41685. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41686. * 2) secondary trigger (same)
  41687. * 3) A (right) X (left), touch, pressed = value
  41688. * 4) B / Y
  41689. * 5) thumb rest
  41690. * @param buttonIdx Which button index changed
  41691. * @param state New state of the button
  41692. * @param changes Which properties on the state changed since last frame
  41693. */
  41694. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. /**
  41699. * Vive Controller
  41700. */
  41701. export class ViveController extends WebVRController {
  41702. /**
  41703. * Base Url for the controller model.
  41704. */
  41705. static MODEL_BASE_URL: string;
  41706. /**
  41707. * File name for the controller model.
  41708. */
  41709. static MODEL_FILENAME: string;
  41710. /**
  41711. * Creates a new ViveController from a gamepad
  41712. * @param vrGamepad the gamepad that the controller should be created from
  41713. */
  41714. constructor(vrGamepad: any);
  41715. /**
  41716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41717. * @param scene scene in which to add meshes
  41718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41719. */
  41720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41721. /**
  41722. * Fired when the left button on this controller is modified
  41723. */
  41724. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41725. /**
  41726. * Fired when the right button on this controller is modified
  41727. */
  41728. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41729. /**
  41730. * Fired when the menu button on this controller is modified
  41731. */
  41732. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41733. /**
  41734. * Called once for each button that changed state since the last frame
  41735. * Vive mapping:
  41736. * 0: touchpad
  41737. * 1: trigger
  41738. * 2: left AND right buttons
  41739. * 3: menu button
  41740. * @param buttonIdx Which button index changed
  41741. * @param state New state of the button
  41742. * @param changes Which properties on the state changed since last frame
  41743. */
  41744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41745. }
  41746. }
  41747. declare module BABYLON {
  41748. /**
  41749. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41750. */
  41751. export class WebXRControllerModelLoader {
  41752. /**
  41753. * Creates the WebXRControllerModelLoader
  41754. * @param input xr input that creates the controllers
  41755. */
  41756. constructor(input: WebXRInput);
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /**
  41761. * Contains an array of blocks representing the octree
  41762. */
  41763. export interface IOctreeContainer<T> {
  41764. /**
  41765. * Blocks within the octree
  41766. */
  41767. blocks: Array<OctreeBlock<T>>;
  41768. }
  41769. /**
  41770. * Class used to store a cell in an octree
  41771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41772. */
  41773. export class OctreeBlock<T> {
  41774. /**
  41775. * Gets the content of the current block
  41776. */
  41777. entries: T[];
  41778. /**
  41779. * Gets the list of block children
  41780. */
  41781. blocks: Array<OctreeBlock<T>>;
  41782. private _depth;
  41783. private _maxDepth;
  41784. private _capacity;
  41785. private _minPoint;
  41786. private _maxPoint;
  41787. private _boundingVectors;
  41788. private _creationFunc;
  41789. /**
  41790. * Creates a new block
  41791. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41792. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41793. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41794. * @param depth defines the current depth of this block in the octree
  41795. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41796. * @param creationFunc defines a callback to call when an element is added to the block
  41797. */
  41798. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41799. /**
  41800. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41801. */
  41802. readonly capacity: number;
  41803. /**
  41804. * Gets the minimum vector (in world space) of the block's bounding box
  41805. */
  41806. readonly minPoint: Vector3;
  41807. /**
  41808. * Gets the maximum vector (in world space) of the block's bounding box
  41809. */
  41810. readonly maxPoint: Vector3;
  41811. /**
  41812. * Add a new element to this block
  41813. * @param entry defines the element to add
  41814. */
  41815. addEntry(entry: T): void;
  41816. /**
  41817. * Remove an element from this block
  41818. * @param entry defines the element to remove
  41819. */
  41820. removeEntry(entry: T): void;
  41821. /**
  41822. * Add an array of elements to this block
  41823. * @param entries defines the array of elements to add
  41824. */
  41825. addEntries(entries: T[]): void;
  41826. /**
  41827. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41828. * @param frustumPlanes defines the frustum planes to test
  41829. * @param selection defines the array to store current content if selection is positive
  41830. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41831. */
  41832. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41833. /**
  41834. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41835. * @param sphereCenter defines the bounding sphere center
  41836. * @param sphereRadius defines the bounding sphere radius
  41837. * @param selection defines the array to store current content if selection is positive
  41838. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41839. */
  41840. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41841. /**
  41842. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41843. * @param ray defines the ray to test with
  41844. * @param selection defines the array to store current content if selection is positive
  41845. */
  41846. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41847. /**
  41848. * Subdivide the content into child blocks (this block will then be empty)
  41849. */
  41850. createInnerBlocks(): void;
  41851. /**
  41852. * @hidden
  41853. */
  41854. 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;
  41855. }
  41856. }
  41857. declare module BABYLON {
  41858. /**
  41859. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41860. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41861. */
  41862. export class Octree<T> {
  41863. /** 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.) */
  41864. maxDepth: number;
  41865. /**
  41866. * Blocks within the octree containing objects
  41867. */
  41868. blocks: Array<OctreeBlock<T>>;
  41869. /**
  41870. * Content stored in the octree
  41871. */
  41872. dynamicContent: T[];
  41873. private _maxBlockCapacity;
  41874. private _selectionContent;
  41875. private _creationFunc;
  41876. /**
  41877. * Creates a octree
  41878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41879. * @param creationFunc function to be used to instatiate the octree
  41880. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41881. * @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.)
  41882. */
  41883. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41884. /** 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.) */
  41885. maxDepth?: number);
  41886. /**
  41887. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41888. * @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);
  41889. * @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);
  41890. * @param entries meshes to be added to the octree blocks
  41891. */
  41892. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41893. /**
  41894. * Adds a mesh to the octree
  41895. * @param entry Mesh to add to the octree
  41896. */
  41897. addMesh(entry: T): void;
  41898. /**
  41899. * Remove an element from the octree
  41900. * @param entry defines the element to remove
  41901. */
  41902. removeMesh(entry: T): void;
  41903. /**
  41904. * Selects an array of meshes within the frustum
  41905. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41906. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41907. * @returns array of meshes within the frustum
  41908. */
  41909. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41910. /**
  41911. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41912. * @param sphereCenter defines the bounding sphere center
  41913. * @param sphereRadius defines the bounding sphere radius
  41914. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41915. * @returns an array of objects that intersect the sphere
  41916. */
  41917. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41918. /**
  41919. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41920. * @param ray defines the ray to test with
  41921. * @returns array of intersected objects
  41922. */
  41923. intersectsRay(ray: Ray): SmartArray<T>;
  41924. /**
  41925. * Adds a mesh into the octree block if it intersects the block
  41926. */
  41927. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41928. /**
  41929. * Adds a submesh into the octree block if it intersects the block
  41930. */
  41931. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41932. }
  41933. }
  41934. declare module BABYLON {
  41935. interface Scene {
  41936. /**
  41937. * @hidden
  41938. * Backing Filed
  41939. */
  41940. _selectionOctree: Octree<AbstractMesh>;
  41941. /**
  41942. * Gets the octree used to boost mesh selection (picking)
  41943. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41944. */
  41945. selectionOctree: Octree<AbstractMesh>;
  41946. /**
  41947. * Creates or updates the octree used to boost selection (picking)
  41948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41949. * @param maxCapacity defines the maximum capacity per leaf
  41950. * @param maxDepth defines the maximum depth of the octree
  41951. * @returns an octree of AbstractMesh
  41952. */
  41953. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41954. }
  41955. interface AbstractMesh {
  41956. /**
  41957. * @hidden
  41958. * Backing Field
  41959. */
  41960. _submeshesOctree: Octree<SubMesh>;
  41961. /**
  41962. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41963. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41964. * @param maxCapacity defines the maximum size of each block (64 by default)
  41965. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41966. * @returns the new octree
  41967. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41969. */
  41970. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41971. }
  41972. /**
  41973. * Defines the octree scene component responsible to manage any octrees
  41974. * in a given scene.
  41975. */
  41976. export class OctreeSceneComponent {
  41977. /**
  41978. * The component name help to identify the component in the list of scene components.
  41979. */
  41980. readonly name: string;
  41981. /**
  41982. * The scene the component belongs to.
  41983. */
  41984. scene: Scene;
  41985. /**
  41986. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41987. */
  41988. readonly checksIsEnabled: boolean;
  41989. /**
  41990. * Creates a new instance of the component for the given scene
  41991. * @param scene Defines the scene to register the component in
  41992. */
  41993. constructor(scene: Scene);
  41994. /**
  41995. * Registers the component in a given scene
  41996. */
  41997. register(): void;
  41998. /**
  41999. * Return the list of active meshes
  42000. * @returns the list of active meshes
  42001. */
  42002. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42003. /**
  42004. * Return the list of active sub meshes
  42005. * @param mesh The mesh to get the candidates sub meshes from
  42006. * @returns the list of active sub meshes
  42007. */
  42008. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42009. private _tempRay;
  42010. /**
  42011. * Return the list of sub meshes intersecting with a given local ray
  42012. * @param mesh defines the mesh to find the submesh for
  42013. * @param localRay defines the ray in local space
  42014. * @returns the list of intersecting sub meshes
  42015. */
  42016. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42017. /**
  42018. * Return the list of sub meshes colliding with a collider
  42019. * @param mesh defines the mesh to find the submesh for
  42020. * @param collider defines the collider to evaluate the collision against
  42021. * @returns the list of colliding sub meshes
  42022. */
  42023. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42024. /**
  42025. * Rebuilds the elements related to this component in case of
  42026. * context lost for instance.
  42027. */
  42028. rebuild(): void;
  42029. /**
  42030. * Disposes the component and the associated ressources.
  42031. */
  42032. dispose(): void;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /**
  42037. * Renders a layer on top of an existing scene
  42038. */
  42039. export class UtilityLayerRenderer implements IDisposable {
  42040. /** the original scene that will be rendered on top of */
  42041. originalScene: Scene;
  42042. private _pointerCaptures;
  42043. private _lastPointerEvents;
  42044. private static _DefaultUtilityLayer;
  42045. private static _DefaultKeepDepthUtilityLayer;
  42046. private _sharedGizmoLight;
  42047. private _renderCamera;
  42048. /**
  42049. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42050. * @returns the camera that is used when rendering the utility layer
  42051. */
  42052. getRenderCamera(): Nullable<Camera>;
  42053. /**
  42054. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42055. * @param cam the camera that should be used when rendering the utility layer
  42056. */
  42057. setRenderCamera(cam: Nullable<Camera>): void;
  42058. /**
  42059. * @hidden
  42060. * Light which used by gizmos to get light shading
  42061. */
  42062. _getSharedGizmoLight(): HemisphericLight;
  42063. /**
  42064. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42065. */
  42066. pickUtilitySceneFirst: boolean;
  42067. /**
  42068. * 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)
  42069. */
  42070. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42071. /**
  42072. * 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)
  42073. */
  42074. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42075. /**
  42076. * The scene that is rendered on top of the original scene
  42077. */
  42078. utilityLayerScene: Scene;
  42079. /**
  42080. * If the utility layer should automatically be rendered on top of existing scene
  42081. */
  42082. shouldRender: boolean;
  42083. /**
  42084. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42085. */
  42086. onlyCheckPointerDownEvents: boolean;
  42087. /**
  42088. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42089. */
  42090. processAllEvents: boolean;
  42091. /**
  42092. * Observable raised when the pointer move from the utility layer scene to the main scene
  42093. */
  42094. onPointerOutObservable: Observable<number>;
  42095. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42096. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42097. private _afterRenderObserver;
  42098. private _sceneDisposeObserver;
  42099. private _originalPointerObserver;
  42100. /**
  42101. * Instantiates a UtilityLayerRenderer
  42102. * @param originalScene the original scene that will be rendered on top of
  42103. * @param handleEvents boolean indicating if the utility layer should handle events
  42104. */
  42105. constructor(
  42106. /** the original scene that will be rendered on top of */
  42107. originalScene: Scene, handleEvents?: boolean);
  42108. private _notifyObservers;
  42109. /**
  42110. * Renders the utility layers scene on top of the original scene
  42111. */
  42112. render(): void;
  42113. /**
  42114. * Disposes of the renderer
  42115. */
  42116. dispose(): void;
  42117. private _updateCamera;
  42118. }
  42119. }
  42120. declare module BABYLON {
  42121. /**
  42122. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42123. */
  42124. export class Gizmo implements IDisposable {
  42125. /** The utility layer the gizmo will be added to */
  42126. gizmoLayer: UtilityLayerRenderer;
  42127. /**
  42128. * The root mesh of the gizmo
  42129. */
  42130. _rootMesh: Mesh;
  42131. private _attachedMesh;
  42132. /**
  42133. * Ratio for the scale of the gizmo (Default: 1)
  42134. */
  42135. scaleRatio: number;
  42136. /**
  42137. * If a custom mesh has been set (Default: false)
  42138. */
  42139. protected _customMeshSet: boolean;
  42140. /**
  42141. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42142. * * When set, interactions will be enabled
  42143. */
  42144. attachedMesh: Nullable<AbstractMesh>;
  42145. /**
  42146. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42147. * @param mesh The mesh to replace the default mesh of the gizmo
  42148. */
  42149. setCustomMesh(mesh: Mesh): void;
  42150. /**
  42151. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42152. */
  42153. updateGizmoRotationToMatchAttachedMesh: boolean;
  42154. /**
  42155. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42156. */
  42157. updateGizmoPositionToMatchAttachedMesh: boolean;
  42158. /**
  42159. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42160. */
  42161. updateScale: boolean;
  42162. protected _interactionsEnabled: boolean;
  42163. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42164. private _beforeRenderObserver;
  42165. private _tempVector;
  42166. /**
  42167. * Creates a gizmo
  42168. * @param gizmoLayer The utility layer the gizmo will be added to
  42169. */
  42170. constructor(
  42171. /** The utility layer the gizmo will be added to */
  42172. gizmoLayer?: UtilityLayerRenderer);
  42173. /**
  42174. * Updates the gizmo to match the attached mesh's position/rotation
  42175. */
  42176. protected _update(): void;
  42177. /**
  42178. * Disposes of the gizmo
  42179. */
  42180. dispose(): void;
  42181. }
  42182. }
  42183. declare module BABYLON {
  42184. /**
  42185. * Single plane drag gizmo
  42186. */
  42187. export class PlaneDragGizmo extends Gizmo {
  42188. /**
  42189. * Drag behavior responsible for the gizmos dragging interactions
  42190. */
  42191. dragBehavior: PointerDragBehavior;
  42192. private _pointerObserver;
  42193. /**
  42194. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42195. */
  42196. snapDistance: number;
  42197. /**
  42198. * Event that fires each time the gizmo snaps to a new location.
  42199. * * snapDistance is the the change in distance
  42200. */
  42201. onSnapObservable: Observable<{
  42202. snapDistance: number;
  42203. }>;
  42204. private _plane;
  42205. private _coloredMaterial;
  42206. private _hoverMaterial;
  42207. private _isEnabled;
  42208. private _parent;
  42209. /** @hidden */
  42210. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42211. /** @hidden */
  42212. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42213. /**
  42214. * Creates a PlaneDragGizmo
  42215. * @param gizmoLayer The utility layer the gizmo will be added to
  42216. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42217. * @param color The color of the gizmo
  42218. */
  42219. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42220. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42221. /**
  42222. * If the gizmo is enabled
  42223. */
  42224. isEnabled: boolean;
  42225. /**
  42226. * Disposes of the gizmo
  42227. */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * Gizmo that enables dragging a mesh along 3 axis
  42234. */
  42235. export class PositionGizmo extends Gizmo {
  42236. /**
  42237. * Internal gizmo used for interactions on the x axis
  42238. */
  42239. xGizmo: AxisDragGizmo;
  42240. /**
  42241. * Internal gizmo used for interactions on the y axis
  42242. */
  42243. yGizmo: AxisDragGizmo;
  42244. /**
  42245. * Internal gizmo used for interactions on the z axis
  42246. */
  42247. zGizmo: AxisDragGizmo;
  42248. /**
  42249. * Internal gizmo used for interactions on the yz plane
  42250. */
  42251. xPlaneGizmo: PlaneDragGizmo;
  42252. /**
  42253. * Internal gizmo used for interactions on the xz plane
  42254. */
  42255. yPlaneGizmo: PlaneDragGizmo;
  42256. /**
  42257. * Internal gizmo used for interactions on the xy plane
  42258. */
  42259. zPlaneGizmo: PlaneDragGizmo;
  42260. /**
  42261. * private variables
  42262. */
  42263. private _meshAttached;
  42264. private _updateGizmoRotationToMatchAttachedMesh;
  42265. private _snapDistance;
  42266. private _scaleRatio;
  42267. /** Fires an event when any of it's sub gizmos are dragged */
  42268. onDragStartObservable: Observable<unknown>;
  42269. /** Fires an event when any of it's sub gizmos are released from dragging */
  42270. onDragEndObservable: Observable<unknown>;
  42271. /**
  42272. * If set to true, planar drag is enabled
  42273. */
  42274. private _planarGizmoEnabled;
  42275. attachedMesh: Nullable<AbstractMesh>;
  42276. /**
  42277. * Creates a PositionGizmo
  42278. * @param gizmoLayer The utility layer the gizmo will be added to
  42279. */
  42280. constructor(gizmoLayer?: UtilityLayerRenderer);
  42281. /**
  42282. * If the planar drag gizmo is enabled
  42283. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42284. */
  42285. planarGizmoEnabled: boolean;
  42286. updateGizmoRotationToMatchAttachedMesh: boolean;
  42287. /**
  42288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42289. */
  42290. snapDistance: number;
  42291. /**
  42292. * Ratio for the scale of the gizmo (Default: 1)
  42293. */
  42294. scaleRatio: number;
  42295. /**
  42296. * Disposes of the gizmo
  42297. */
  42298. dispose(): void;
  42299. /**
  42300. * CustomMeshes are not supported by this gizmo
  42301. * @param mesh The mesh to replace the default mesh of the gizmo
  42302. */
  42303. setCustomMesh(mesh: Mesh): void;
  42304. }
  42305. }
  42306. declare module BABYLON {
  42307. /**
  42308. * Single axis drag gizmo
  42309. */
  42310. export class AxisDragGizmo extends Gizmo {
  42311. /**
  42312. * Drag behavior responsible for the gizmos dragging interactions
  42313. */
  42314. dragBehavior: PointerDragBehavior;
  42315. private _pointerObserver;
  42316. /**
  42317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42318. */
  42319. snapDistance: number;
  42320. /**
  42321. * Event that fires each time the gizmo snaps to a new location.
  42322. * * snapDistance is the the change in distance
  42323. */
  42324. onSnapObservable: Observable<{
  42325. snapDistance: number;
  42326. }>;
  42327. private _isEnabled;
  42328. private _parent;
  42329. private _arrow;
  42330. private _coloredMaterial;
  42331. private _hoverMaterial;
  42332. /** @hidden */
  42333. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42334. /** @hidden */
  42335. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42336. /**
  42337. * Creates an AxisDragGizmo
  42338. * @param gizmoLayer The utility layer the gizmo will be added to
  42339. * @param dragAxis The axis which the gizmo will be able to drag on
  42340. * @param color The color of the gizmo
  42341. */
  42342. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42344. /**
  42345. * If the gizmo is enabled
  42346. */
  42347. isEnabled: boolean;
  42348. /**
  42349. * Disposes of the gizmo
  42350. */
  42351. dispose(): void;
  42352. }
  42353. }
  42354. declare module BABYLON.Debug {
  42355. /**
  42356. * The Axes viewer will show 3 axes in a specific point in space
  42357. */
  42358. export class AxesViewer {
  42359. private _xAxis;
  42360. private _yAxis;
  42361. private _zAxis;
  42362. private _scaleLinesFactor;
  42363. private _instanced;
  42364. /**
  42365. * Gets the hosting scene
  42366. */
  42367. scene: Scene;
  42368. /**
  42369. * Gets or sets a number used to scale line length
  42370. */
  42371. scaleLines: number;
  42372. /** Gets the node hierarchy used to render x-axis */
  42373. readonly xAxis: TransformNode;
  42374. /** Gets the node hierarchy used to render y-axis */
  42375. readonly yAxis: TransformNode;
  42376. /** Gets the node hierarchy used to render z-axis */
  42377. readonly zAxis: TransformNode;
  42378. /**
  42379. * Creates a new AxesViewer
  42380. * @param scene defines the hosting scene
  42381. * @param scaleLines defines a number used to scale line length (1 by default)
  42382. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42383. * @param xAxis defines the node hierarchy used to render the x-axis
  42384. * @param yAxis defines the node hierarchy used to render the y-axis
  42385. * @param zAxis defines the node hierarchy used to render the z-axis
  42386. */
  42387. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42388. /**
  42389. * Force the viewer to update
  42390. * @param position defines the position of the viewer
  42391. * @param xaxis defines the x axis of the viewer
  42392. * @param yaxis defines the y axis of the viewer
  42393. * @param zaxis defines the z axis of the viewer
  42394. */
  42395. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42396. /**
  42397. * Creates an instance of this axes viewer.
  42398. * @returns a new axes viewer with instanced meshes
  42399. */
  42400. createInstance(): AxesViewer;
  42401. /** Releases resources */
  42402. dispose(): void;
  42403. private static _SetRenderingGroupId;
  42404. }
  42405. }
  42406. declare module BABYLON.Debug {
  42407. /**
  42408. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42409. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42410. */
  42411. export class BoneAxesViewer extends AxesViewer {
  42412. /**
  42413. * Gets or sets the target mesh where to display the axes viewer
  42414. */
  42415. mesh: Nullable<Mesh>;
  42416. /**
  42417. * Gets or sets the target bone where to display the axes viewer
  42418. */
  42419. bone: Nullable<Bone>;
  42420. /** Gets current position */
  42421. pos: Vector3;
  42422. /** Gets direction of X axis */
  42423. xaxis: Vector3;
  42424. /** Gets direction of Y axis */
  42425. yaxis: Vector3;
  42426. /** Gets direction of Z axis */
  42427. zaxis: Vector3;
  42428. /**
  42429. * Creates a new BoneAxesViewer
  42430. * @param scene defines the hosting scene
  42431. * @param bone defines the target bone
  42432. * @param mesh defines the target mesh
  42433. * @param scaleLines defines a scaling factor for line length (1 by default)
  42434. */
  42435. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42436. /**
  42437. * Force the viewer to update
  42438. */
  42439. update(): void;
  42440. /** Releases resources */
  42441. dispose(): void;
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Interface used to define scene explorer extensibility option
  42447. */
  42448. export interface IExplorerExtensibilityOption {
  42449. /**
  42450. * Define the option label
  42451. */
  42452. label: string;
  42453. /**
  42454. * Defines the action to execute on click
  42455. */
  42456. action: (entity: any) => void;
  42457. }
  42458. /**
  42459. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42460. */
  42461. export interface IExplorerExtensibilityGroup {
  42462. /**
  42463. * Defines a predicate to test if a given type mut be extended
  42464. */
  42465. predicate: (entity: any) => boolean;
  42466. /**
  42467. * Gets the list of options added to a type
  42468. */
  42469. entries: IExplorerExtensibilityOption[];
  42470. }
  42471. /**
  42472. * Interface used to define the options to use to create the Inspector
  42473. */
  42474. export interface IInspectorOptions {
  42475. /**
  42476. * Display in overlay mode (default: false)
  42477. */
  42478. overlay?: boolean;
  42479. /**
  42480. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42481. */
  42482. globalRoot?: HTMLElement;
  42483. /**
  42484. * Display the Scene explorer
  42485. */
  42486. showExplorer?: boolean;
  42487. /**
  42488. * Display the property inspector
  42489. */
  42490. showInspector?: boolean;
  42491. /**
  42492. * Display in embed mode (both panes on the right)
  42493. */
  42494. embedMode?: boolean;
  42495. /**
  42496. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42497. */
  42498. handleResize?: boolean;
  42499. /**
  42500. * Allow the panes to popup (default: true)
  42501. */
  42502. enablePopup?: boolean;
  42503. /**
  42504. * Allow the panes to be closed by users (default: true)
  42505. */
  42506. enableClose?: boolean;
  42507. /**
  42508. * Optional list of extensibility entries
  42509. */
  42510. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42511. /**
  42512. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42513. */
  42514. inspectorURL?: string;
  42515. }
  42516. interface Scene {
  42517. /**
  42518. * @hidden
  42519. * Backing field
  42520. */
  42521. _debugLayer: DebugLayer;
  42522. /**
  42523. * Gets the debug layer (aka Inspector) associated with the scene
  42524. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42525. */
  42526. debugLayer: DebugLayer;
  42527. }
  42528. /**
  42529. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42530. * what is happening in your scene
  42531. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42532. */
  42533. export class DebugLayer {
  42534. /**
  42535. * Define the url to get the inspector script from.
  42536. * By default it uses the babylonjs CDN.
  42537. * @ignoreNaming
  42538. */
  42539. static InspectorURL: string;
  42540. private _scene;
  42541. private BJSINSPECTOR;
  42542. private _onPropertyChangedObservable?;
  42543. /**
  42544. * Observable triggered when a property is changed through the inspector.
  42545. */
  42546. readonly onPropertyChangedObservable: any;
  42547. /**
  42548. * Instantiates a new debug layer.
  42549. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42550. * what is happening in your scene
  42551. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42552. * @param scene Defines the scene to inspect
  42553. */
  42554. constructor(scene: Scene);
  42555. /** Creates the inspector window. */
  42556. private _createInspector;
  42557. /**
  42558. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42559. * @param entity defines the entity to select
  42560. * @param lineContainerTitle defines the specific block to highlight
  42561. */
  42562. select(entity: any, lineContainerTitle?: string): void;
  42563. /** Get the inspector from bundle or global */
  42564. private _getGlobalInspector;
  42565. /**
  42566. * Get if the inspector is visible or not.
  42567. * @returns true if visible otherwise, false
  42568. */
  42569. isVisible(): boolean;
  42570. /**
  42571. * Hide the inspector and close its window.
  42572. */
  42573. hide(): void;
  42574. /**
  42575. * Launch the debugLayer.
  42576. * @param config Define the configuration of the inspector
  42577. * @return a promise fulfilled when the debug layer is visible
  42578. */
  42579. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42580. }
  42581. }
  42582. declare module BABYLON {
  42583. /**
  42584. * Class containing static functions to help procedurally build meshes
  42585. */
  42586. export class BoxBuilder {
  42587. /**
  42588. * Creates a box mesh
  42589. * * The parameter `size` sets the size (float) of each box side (default 1)
  42590. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42591. * * 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)
  42592. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42594. * * 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
  42595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42596. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42597. * @param name defines the name of the mesh
  42598. * @param options defines the options used to create the mesh
  42599. * @param scene defines the hosting scene
  42600. * @returns the box mesh
  42601. */
  42602. static CreateBox(name: string, options: {
  42603. size?: number;
  42604. width?: number;
  42605. height?: number;
  42606. depth?: number;
  42607. faceUV?: Vector4[];
  42608. faceColors?: Color4[];
  42609. sideOrientation?: number;
  42610. frontUVs?: Vector4;
  42611. backUVs?: Vector4;
  42612. wrap?: boolean;
  42613. topBaseAt?: number;
  42614. bottomBaseAt?: number;
  42615. updatable?: boolean;
  42616. }, scene?: Nullable<Scene>): Mesh;
  42617. }
  42618. }
  42619. declare module BABYLON {
  42620. /**
  42621. * Class containing static functions to help procedurally build meshes
  42622. */
  42623. export class SphereBuilder {
  42624. /**
  42625. * Creates a sphere mesh
  42626. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42627. * * 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`)
  42628. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42629. * * 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
  42630. * * 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)
  42631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42632. * * 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
  42633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42634. * @param name defines the name of the mesh
  42635. * @param options defines the options used to create the mesh
  42636. * @param scene defines the hosting scene
  42637. * @returns the sphere mesh
  42638. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42639. */
  42640. static CreateSphere(name: string, options: {
  42641. segments?: number;
  42642. diameter?: number;
  42643. diameterX?: number;
  42644. diameterY?: number;
  42645. diameterZ?: number;
  42646. arc?: number;
  42647. slice?: number;
  42648. sideOrientation?: number;
  42649. frontUVs?: Vector4;
  42650. backUVs?: Vector4;
  42651. updatable?: boolean;
  42652. }, scene: any): Mesh;
  42653. }
  42654. }
  42655. declare module BABYLON.Debug {
  42656. /**
  42657. * Used to show the physics impostor around the specific mesh
  42658. */
  42659. export class PhysicsViewer {
  42660. /** @hidden */
  42661. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42662. /** @hidden */
  42663. protected _meshes: Array<Nullable<AbstractMesh>>;
  42664. /** @hidden */
  42665. protected _scene: Nullable<Scene>;
  42666. /** @hidden */
  42667. protected _numMeshes: number;
  42668. /** @hidden */
  42669. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42670. private _renderFunction;
  42671. private _utilityLayer;
  42672. private _debugBoxMesh;
  42673. private _debugSphereMesh;
  42674. private _debugCylinderMesh;
  42675. private _debugMaterial;
  42676. private _debugMeshMeshes;
  42677. /**
  42678. * Creates a new PhysicsViewer
  42679. * @param scene defines the hosting scene
  42680. */
  42681. constructor(scene: Scene);
  42682. /** @hidden */
  42683. protected _updateDebugMeshes(): void;
  42684. /**
  42685. * Renders a specified physic impostor
  42686. * @param impostor defines the impostor to render
  42687. * @param targetMesh defines the mesh represented by the impostor
  42688. * @returns the new debug mesh used to render the impostor
  42689. */
  42690. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42691. /**
  42692. * Hides a specified physic impostor
  42693. * @param impostor defines the impostor to hide
  42694. */
  42695. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42696. private _getDebugMaterial;
  42697. private _getDebugBoxMesh;
  42698. private _getDebugSphereMesh;
  42699. private _getDebugCylinderMesh;
  42700. private _getDebugMeshMesh;
  42701. private _getDebugMesh;
  42702. /** Releases all resources */
  42703. dispose(): void;
  42704. }
  42705. }
  42706. declare module BABYLON {
  42707. /**
  42708. * Class containing static functions to help procedurally build meshes
  42709. */
  42710. export class LinesBuilder {
  42711. /**
  42712. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42713. * * 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
  42714. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42715. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42716. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42717. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42718. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42719. * * 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
  42720. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42723. * @param name defines the name of the new line system
  42724. * @param options defines the options used to create the line system
  42725. * @param scene defines the hosting scene
  42726. * @returns a new line system mesh
  42727. */
  42728. static CreateLineSystem(name: string, options: {
  42729. lines: Vector3[][];
  42730. updatable?: boolean;
  42731. instance?: Nullable<LinesMesh>;
  42732. colors?: Nullable<Color4[][]>;
  42733. useVertexAlpha?: boolean;
  42734. }, scene: Nullable<Scene>): LinesMesh;
  42735. /**
  42736. * Creates a line mesh
  42737. * 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
  42738. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42739. * * The parameter `points` is an array successive Vector3
  42740. * * 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
  42741. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42742. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42743. * * When updating an instance, remember that only point positions can change, not the number of points
  42744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42746. * @param name defines the name of the new line system
  42747. * @param options defines the options used to create the line system
  42748. * @param scene defines the hosting scene
  42749. * @returns a new line mesh
  42750. */
  42751. static CreateLines(name: string, options: {
  42752. points: Vector3[];
  42753. updatable?: boolean;
  42754. instance?: Nullable<LinesMesh>;
  42755. colors?: Color4[];
  42756. useVertexAlpha?: boolean;
  42757. }, scene?: Nullable<Scene>): LinesMesh;
  42758. /**
  42759. * Creates a dashed line mesh
  42760. * * 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
  42761. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42762. * * The parameter `points` is an array successive Vector3
  42763. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42764. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42765. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42766. * * 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
  42767. * * When updating an instance, remember that only point positions can change, not the number of points
  42768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42769. * @param name defines the name of the mesh
  42770. * @param options defines the options used to create the mesh
  42771. * @param scene defines the hosting scene
  42772. * @returns the dashed line mesh
  42773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42774. */
  42775. static CreateDashedLines(name: string, options: {
  42776. points: Vector3[];
  42777. dashSize?: number;
  42778. gapSize?: number;
  42779. dashNb?: number;
  42780. updatable?: boolean;
  42781. instance?: LinesMesh;
  42782. }, scene?: Nullable<Scene>): LinesMesh;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42788. * in order to better appreciate the issue one might have.
  42789. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42790. */
  42791. export class RayHelper {
  42792. /**
  42793. * Defines the ray we are currently tryin to visualize.
  42794. */
  42795. ray: Nullable<Ray>;
  42796. private _renderPoints;
  42797. private _renderLine;
  42798. private _renderFunction;
  42799. private _scene;
  42800. private _updateToMeshFunction;
  42801. private _attachedToMesh;
  42802. private _meshSpaceDirection;
  42803. private _meshSpaceOrigin;
  42804. /**
  42805. * Helper function to create a colored helper in a scene in one line.
  42806. * @param ray Defines the ray we are currently tryin to visualize
  42807. * @param scene Defines the scene the ray is used in
  42808. * @param color Defines the color we want to see the ray in
  42809. * @returns The newly created ray helper.
  42810. */
  42811. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42812. /**
  42813. * Instantiate a new ray helper.
  42814. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42815. * in order to better appreciate the issue one might have.
  42816. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42817. * @param ray Defines the ray we are currently tryin to visualize
  42818. */
  42819. constructor(ray: Ray);
  42820. /**
  42821. * Shows the ray we are willing to debug.
  42822. * @param scene Defines the scene the ray needs to be rendered in
  42823. * @param color Defines the color the ray needs to be rendered in
  42824. */
  42825. show(scene: Scene, color?: Color3): void;
  42826. /**
  42827. * Hides the ray we are debugging.
  42828. */
  42829. hide(): void;
  42830. private _render;
  42831. /**
  42832. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42833. * @param mesh Defines the mesh we want the helper attached to
  42834. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42835. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42836. * @param length Defines the length of the ray
  42837. */
  42838. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42839. /**
  42840. * Detach the ray helper from the mesh it has previously been attached to.
  42841. */
  42842. detachFromMesh(): void;
  42843. private _updateToMesh;
  42844. /**
  42845. * Dispose the helper and release its associated resources.
  42846. */
  42847. dispose(): void;
  42848. }
  42849. }
  42850. declare module BABYLON.Debug {
  42851. /**
  42852. * Class used to render a debug view of a given skeleton
  42853. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42854. */
  42855. export class SkeletonViewer {
  42856. /** defines the skeleton to render */
  42857. skeleton: Skeleton;
  42858. /** defines the mesh attached to the skeleton */
  42859. mesh: AbstractMesh;
  42860. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42861. autoUpdateBonesMatrices: boolean;
  42862. /** defines the rendering group id to use with the viewer */
  42863. renderingGroupId: number;
  42864. /** Gets or sets the color used to render the skeleton */
  42865. color: Color3;
  42866. private _scene;
  42867. private _debugLines;
  42868. private _debugMesh;
  42869. private _isEnabled;
  42870. private _renderFunction;
  42871. private _utilityLayer;
  42872. /**
  42873. * Returns the mesh used to render the bones
  42874. */
  42875. readonly debugMesh: Nullable<LinesMesh>;
  42876. /**
  42877. * Creates a new SkeletonViewer
  42878. * @param skeleton defines the skeleton to render
  42879. * @param mesh defines the mesh attached to the skeleton
  42880. * @param scene defines the hosting scene
  42881. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42882. * @param renderingGroupId defines the rendering group id to use with the viewer
  42883. */
  42884. constructor(
  42885. /** defines the skeleton to render */
  42886. skeleton: Skeleton,
  42887. /** defines the mesh attached to the skeleton */
  42888. mesh: AbstractMesh, scene: Scene,
  42889. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42890. autoUpdateBonesMatrices?: boolean,
  42891. /** defines the rendering group id to use with the viewer */
  42892. renderingGroupId?: number);
  42893. /** Gets or sets a boolean indicating if the viewer is enabled */
  42894. isEnabled: boolean;
  42895. private _getBonePosition;
  42896. private _getLinesForBonesWithLength;
  42897. private _getLinesForBonesNoLength;
  42898. /** Update the viewer to sync with current skeleton state */
  42899. update(): void;
  42900. /** Release associated resources */
  42901. dispose(): void;
  42902. }
  42903. }
  42904. declare module BABYLON {
  42905. /**
  42906. * Options to create the null engine
  42907. */
  42908. export class NullEngineOptions {
  42909. /**
  42910. * Render width (Default: 512)
  42911. */
  42912. renderWidth: number;
  42913. /**
  42914. * Render height (Default: 256)
  42915. */
  42916. renderHeight: number;
  42917. /**
  42918. * Texture size (Default: 512)
  42919. */
  42920. textureSize: number;
  42921. /**
  42922. * If delta time between frames should be constant
  42923. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42924. */
  42925. deterministicLockstep: boolean;
  42926. /**
  42927. * Maximum about of steps between frames (Default: 4)
  42928. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42929. */
  42930. lockstepMaxSteps: number;
  42931. }
  42932. /**
  42933. * The null engine class provides support for headless version of babylon.js.
  42934. * This can be used in server side scenario or for testing purposes
  42935. */
  42936. export class NullEngine extends Engine {
  42937. private _options;
  42938. /**
  42939. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42940. */
  42941. isDeterministicLockStep(): boolean;
  42942. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42943. getLockstepMaxSteps(): number;
  42944. /**
  42945. * Sets hardware scaling, used to save performance if needed
  42946. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42947. */
  42948. getHardwareScalingLevel(): number;
  42949. constructor(options?: NullEngineOptions);
  42950. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42951. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42952. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42953. getRenderWidth(useScreen?: boolean): number;
  42954. getRenderHeight(useScreen?: boolean): number;
  42955. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42956. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42957. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42958. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42959. bindSamplers(effect: Effect): void;
  42960. enableEffect(effect: Effect): void;
  42961. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42962. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42963. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42964. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42965. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42966. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42967. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42968. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42969. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42970. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42971. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42972. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42973. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42974. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42975. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42976. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42977. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42978. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42979. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42980. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42981. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42982. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42983. bindBuffers(vertexBuffers: {
  42984. [key: string]: VertexBuffer;
  42985. }, indexBuffer: DataBuffer, effect: Effect): void;
  42986. wipeCaches(bruteForce?: boolean): void;
  42987. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42988. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42989. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42990. /** @hidden */
  42991. _createTexture(): WebGLTexture;
  42992. /** @hidden */
  42993. _releaseTexture(texture: InternalTexture): void;
  42994. 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;
  42995. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42996. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42997. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42998. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42999. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43000. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43001. areAllEffectsReady(): boolean;
  43002. /**
  43003. * @hidden
  43004. * Get the current error code of the webGL context
  43005. * @returns the error code
  43006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43007. */
  43008. getError(): number;
  43009. /** @hidden */
  43010. _getUnpackAlignement(): number;
  43011. /** @hidden */
  43012. _unpackFlipY(value: boolean): void;
  43013. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43014. /**
  43015. * Updates a dynamic vertex buffer.
  43016. * @param vertexBuffer the vertex buffer to update
  43017. * @param data the data used to update the vertex buffer
  43018. * @param byteOffset the byte offset of the data (optional)
  43019. * @param byteLength the byte length of the data (optional)
  43020. */
  43021. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43022. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43023. /** @hidden */
  43024. _bindTexture(channel: number, texture: InternalTexture): void;
  43025. /** @hidden */
  43026. _releaseBuffer(buffer: DataBuffer): boolean;
  43027. releaseEffects(): void;
  43028. displayLoadingUI(): void;
  43029. hideLoadingUI(): void;
  43030. /** @hidden */
  43031. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43032. /** @hidden */
  43033. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43034. /** @hidden */
  43035. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43036. /** @hidden */
  43037. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43038. }
  43039. }
  43040. declare module BABYLON {
  43041. /** @hidden */
  43042. export class _OcclusionDataStorage {
  43043. /** @hidden */
  43044. occlusionInternalRetryCounter: number;
  43045. /** @hidden */
  43046. isOcclusionQueryInProgress: boolean;
  43047. /** @hidden */
  43048. isOccluded: boolean;
  43049. /** @hidden */
  43050. occlusionRetryCount: number;
  43051. /** @hidden */
  43052. occlusionType: number;
  43053. /** @hidden */
  43054. occlusionQueryAlgorithmType: number;
  43055. }
  43056. interface Engine {
  43057. /**
  43058. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43059. * @return the new query
  43060. */
  43061. createQuery(): WebGLQuery;
  43062. /**
  43063. * Delete and release a webGL query
  43064. * @param query defines the query to delete
  43065. * @return the current engine
  43066. */
  43067. deleteQuery(query: WebGLQuery): Engine;
  43068. /**
  43069. * Check if a given query has resolved and got its value
  43070. * @param query defines the query to check
  43071. * @returns true if the query got its value
  43072. */
  43073. isQueryResultAvailable(query: WebGLQuery): boolean;
  43074. /**
  43075. * Gets the value of a given query
  43076. * @param query defines the query to check
  43077. * @returns the value of the query
  43078. */
  43079. getQueryResult(query: WebGLQuery): number;
  43080. /**
  43081. * Initiates an occlusion query
  43082. * @param algorithmType defines the algorithm to use
  43083. * @param query defines the query to use
  43084. * @returns the current engine
  43085. * @see http://doc.babylonjs.com/features/occlusionquery
  43086. */
  43087. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43088. /**
  43089. * Ends an occlusion query
  43090. * @see http://doc.babylonjs.com/features/occlusionquery
  43091. * @param algorithmType defines the algorithm to use
  43092. * @returns the current engine
  43093. */
  43094. endOcclusionQuery(algorithmType: number): Engine;
  43095. /**
  43096. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43097. * Please note that only one query can be issued at a time
  43098. * @returns a time token used to track the time span
  43099. */
  43100. startTimeQuery(): Nullable<_TimeToken>;
  43101. /**
  43102. * Ends a time query
  43103. * @param token defines the token used to measure the time span
  43104. * @returns the time spent (in ns)
  43105. */
  43106. endTimeQuery(token: _TimeToken): int;
  43107. /** @hidden */
  43108. _currentNonTimestampToken: Nullable<_TimeToken>;
  43109. /** @hidden */
  43110. _createTimeQuery(): WebGLQuery;
  43111. /** @hidden */
  43112. _deleteTimeQuery(query: WebGLQuery): void;
  43113. /** @hidden */
  43114. _getGlAlgorithmType(algorithmType: number): number;
  43115. /** @hidden */
  43116. _getTimeQueryResult(query: WebGLQuery): any;
  43117. /** @hidden */
  43118. _getTimeQueryAvailability(query: WebGLQuery): any;
  43119. }
  43120. interface AbstractMesh {
  43121. /**
  43122. * Backing filed
  43123. * @hidden
  43124. */
  43125. __occlusionDataStorage: _OcclusionDataStorage;
  43126. /**
  43127. * Access property
  43128. * @hidden
  43129. */
  43130. _occlusionDataStorage: _OcclusionDataStorage;
  43131. /**
  43132. * 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.
  43133. * The default value is -1 which means don't break the query and wait till the result
  43134. * @see http://doc.babylonjs.com/features/occlusionquery
  43135. */
  43136. occlusionRetryCount: number;
  43137. /**
  43138. * 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:
  43139. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43140. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43141. * * 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.
  43142. * @see http://doc.babylonjs.com/features/occlusionquery
  43143. */
  43144. occlusionType: number;
  43145. /**
  43146. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43147. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43148. * * 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.
  43149. * @see http://doc.babylonjs.com/features/occlusionquery
  43150. */
  43151. occlusionQueryAlgorithmType: number;
  43152. /**
  43153. * 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
  43154. * @see http://doc.babylonjs.com/features/occlusionquery
  43155. */
  43156. isOccluded: boolean;
  43157. /**
  43158. * Flag to check the progress status of the query
  43159. * @see http://doc.babylonjs.com/features/occlusionquery
  43160. */
  43161. isOcclusionQueryInProgress: boolean;
  43162. }
  43163. }
  43164. declare module BABYLON {
  43165. /** @hidden */
  43166. export var _forceTransformFeedbackToBundle: boolean;
  43167. interface Engine {
  43168. /**
  43169. * Creates a webGL transform feedback object
  43170. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43171. * @returns the webGL transform feedback object
  43172. */
  43173. createTransformFeedback(): WebGLTransformFeedback;
  43174. /**
  43175. * Delete a webGL transform feedback object
  43176. * @param value defines the webGL transform feedback object to delete
  43177. */
  43178. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43179. /**
  43180. * Bind a webGL transform feedback object to the webgl context
  43181. * @param value defines the webGL transform feedback object to bind
  43182. */
  43183. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43184. /**
  43185. * Begins a transform feedback operation
  43186. * @param usePoints defines if points or triangles must be used
  43187. */
  43188. beginTransformFeedback(usePoints: boolean): void;
  43189. /**
  43190. * Ends a transform feedback operation
  43191. */
  43192. endTransformFeedback(): void;
  43193. /**
  43194. * Specify the varyings to use with transform feedback
  43195. * @param program defines the associated webGL program
  43196. * @param value defines the list of strings representing the varying names
  43197. */
  43198. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43199. /**
  43200. * Bind a webGL buffer for a transform feedback operation
  43201. * @param value defines the webGL buffer to bind
  43202. */
  43203. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43204. }
  43205. }
  43206. declare module BABYLON {
  43207. /**
  43208. * Creation options of the multi render target texture.
  43209. */
  43210. export interface IMultiRenderTargetOptions {
  43211. /**
  43212. * Define if the texture needs to create mip maps after render.
  43213. */
  43214. generateMipMaps?: boolean;
  43215. /**
  43216. * Define the types of all the draw buffers we want to create
  43217. */
  43218. types?: number[];
  43219. /**
  43220. * Define the sampling modes of all the draw buffers we want to create
  43221. */
  43222. samplingModes?: number[];
  43223. /**
  43224. * Define if a depth buffer is required
  43225. */
  43226. generateDepthBuffer?: boolean;
  43227. /**
  43228. * Define if a stencil buffer is required
  43229. */
  43230. generateStencilBuffer?: boolean;
  43231. /**
  43232. * Define if a depth texture is required instead of a depth buffer
  43233. */
  43234. generateDepthTexture?: boolean;
  43235. /**
  43236. * Define the number of desired draw buffers
  43237. */
  43238. textureCount?: number;
  43239. /**
  43240. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43241. */
  43242. doNotChangeAspectRatio?: boolean;
  43243. /**
  43244. * Define the default type of the buffers we are creating
  43245. */
  43246. defaultType?: number;
  43247. }
  43248. /**
  43249. * A multi render target, like a render target provides the ability to render to a texture.
  43250. * Unlike the render target, it can render to several draw buffers in one draw.
  43251. * This is specially interesting in deferred rendering or for any effects requiring more than
  43252. * just one color from a single pass.
  43253. */
  43254. export class MultiRenderTarget extends RenderTargetTexture {
  43255. private _internalTextures;
  43256. private _textures;
  43257. private _multiRenderTargetOptions;
  43258. /**
  43259. * Get if draw buffers are currently supported by the used hardware and browser.
  43260. */
  43261. readonly isSupported: boolean;
  43262. /**
  43263. * Get the list of textures generated by the multi render target.
  43264. */
  43265. readonly textures: Texture[];
  43266. /**
  43267. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43268. */
  43269. readonly depthTexture: Texture;
  43270. /**
  43271. * Set the wrapping mode on U of all the textures we are rendering to.
  43272. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43273. */
  43274. wrapU: number;
  43275. /**
  43276. * Set the wrapping mode on V of all the textures we are rendering to.
  43277. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43278. */
  43279. wrapV: number;
  43280. /**
  43281. * Instantiate a new multi render target texture.
  43282. * A multi render target, like a render target provides the ability to render to a texture.
  43283. * Unlike the render target, it can render to several draw buffers in one draw.
  43284. * This is specially interesting in deferred rendering or for any effects requiring more than
  43285. * just one color from a single pass.
  43286. * @param name Define the name of the texture
  43287. * @param size Define the size of the buffers to render to
  43288. * @param count Define the number of target we are rendering into
  43289. * @param scene Define the scene the texture belongs to
  43290. * @param options Define the options used to create the multi render target
  43291. */
  43292. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43293. /** @hidden */
  43294. _rebuild(): void;
  43295. private _createInternalTextures;
  43296. private _createTextures;
  43297. /**
  43298. * Define the number of samples used if MSAA is enabled.
  43299. */
  43300. samples: number;
  43301. /**
  43302. * Resize all the textures in the multi render target.
  43303. * Be carrefull as it will recreate all the data in the new texture.
  43304. * @param size Define the new size
  43305. */
  43306. resize(size: any): void;
  43307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43308. /**
  43309. * Dispose the render targets and their associated resources
  43310. */
  43311. dispose(): void;
  43312. /**
  43313. * Release all the underlying texture used as draw buffers.
  43314. */
  43315. releaseInternalTextures(): void;
  43316. }
  43317. }
  43318. declare module BABYLON {
  43319. interface Engine {
  43320. /**
  43321. * Unbind a list of render target textures from the webGL context
  43322. * This is used only when drawBuffer extension or webGL2 are active
  43323. * @param textures defines the render target textures to unbind
  43324. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43325. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43326. */
  43327. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43328. /**
  43329. * Create a multi render target texture
  43330. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43331. * @param size defines the size of the texture
  43332. * @param options defines the creation options
  43333. * @returns the cube texture as an InternalTexture
  43334. */
  43335. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43336. /**
  43337. * Update the sample count for a given multiple render target texture
  43338. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43339. * @param textures defines the textures to update
  43340. * @param samples defines the sample count to set
  43341. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43342. */
  43343. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43344. }
  43345. }
  43346. declare module BABYLON {
  43347. /**
  43348. * Gather the list of clipboard event types as constants.
  43349. */
  43350. export class ClipboardEventTypes {
  43351. /**
  43352. * The clipboard event is fired when a copy command is active (pressed).
  43353. */
  43354. static readonly COPY: number;
  43355. /**
  43356. * The clipboard event is fired when a cut command is active (pressed).
  43357. */
  43358. static readonly CUT: number;
  43359. /**
  43360. * The clipboard event is fired when a paste command is active (pressed).
  43361. */
  43362. static readonly PASTE: number;
  43363. }
  43364. /**
  43365. * This class is used to store clipboard related info for the onClipboardObservable event.
  43366. */
  43367. export class ClipboardInfo {
  43368. /**
  43369. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43370. */
  43371. type: number;
  43372. /**
  43373. * Defines the related dom event
  43374. */
  43375. event: ClipboardEvent;
  43376. /**
  43377. *Creates an instance of ClipboardInfo.
  43378. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43379. * @param event Defines the related dom event
  43380. */
  43381. constructor(
  43382. /**
  43383. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43384. */
  43385. type: number,
  43386. /**
  43387. * Defines the related dom event
  43388. */
  43389. event: ClipboardEvent);
  43390. /**
  43391. * Get the clipboard event's type from the keycode.
  43392. * @param keyCode Defines the keyCode for the current keyboard event.
  43393. * @return {number}
  43394. */
  43395. static GetTypeFromCharacter(keyCode: number): number;
  43396. }
  43397. }
  43398. declare module BABYLON {
  43399. /**
  43400. * Google Daydream controller
  43401. */
  43402. export class DaydreamController extends WebVRController {
  43403. /**
  43404. * Base Url for the controller model.
  43405. */
  43406. static MODEL_BASE_URL: string;
  43407. /**
  43408. * File name for the controller model.
  43409. */
  43410. static MODEL_FILENAME: string;
  43411. /**
  43412. * Gamepad Id prefix used to identify Daydream Controller.
  43413. */
  43414. static readonly GAMEPAD_ID_PREFIX: string;
  43415. /**
  43416. * Creates a new DaydreamController from a gamepad
  43417. * @param vrGamepad the gamepad that the controller should be created from
  43418. */
  43419. constructor(vrGamepad: any);
  43420. /**
  43421. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43422. * @param scene scene in which to add meshes
  43423. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43424. */
  43425. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43426. /**
  43427. * Called once for each button that changed state since the last frame
  43428. * @param buttonIdx Which button index changed
  43429. * @param state New state of the button
  43430. * @param changes Which properties on the state changed since last frame
  43431. */
  43432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43433. }
  43434. }
  43435. declare module BABYLON {
  43436. /**
  43437. * Gear VR Controller
  43438. */
  43439. export class GearVRController extends WebVRController {
  43440. /**
  43441. * Base Url for the controller model.
  43442. */
  43443. static MODEL_BASE_URL: string;
  43444. /**
  43445. * File name for the controller model.
  43446. */
  43447. static MODEL_FILENAME: string;
  43448. /**
  43449. * Gamepad Id prefix used to identify this controller.
  43450. */
  43451. static readonly GAMEPAD_ID_PREFIX: string;
  43452. private readonly _buttonIndexToObservableNameMap;
  43453. /**
  43454. * Creates a new GearVRController from a gamepad
  43455. * @param vrGamepad the gamepad that the controller should be created from
  43456. */
  43457. constructor(vrGamepad: any);
  43458. /**
  43459. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43460. * @param scene scene in which to add meshes
  43461. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43462. */
  43463. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43464. /**
  43465. * Called once for each button that changed state since the last frame
  43466. * @param buttonIdx Which button index changed
  43467. * @param state New state of the button
  43468. * @param changes Which properties on the state changed since last frame
  43469. */
  43470. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43471. }
  43472. }
  43473. declare module BABYLON {
  43474. /**
  43475. * Class containing static functions to help procedurally build meshes
  43476. */
  43477. export class PolyhedronBuilder {
  43478. /**
  43479. * Creates a polyhedron mesh
  43480. * * 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
  43481. * * The parameter `size` (positive float, default 1) sets the polygon size
  43482. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43483. * * 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`
  43484. * * 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
  43485. * * 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)`)
  43486. * * 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
  43487. * * 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
  43488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43489. * * 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
  43490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43491. * @param name defines the name of the mesh
  43492. * @param options defines the options used to create the mesh
  43493. * @param scene defines the hosting scene
  43494. * @returns the polyhedron mesh
  43495. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43496. */
  43497. static CreatePolyhedron(name: string, options: {
  43498. type?: number;
  43499. size?: number;
  43500. sizeX?: number;
  43501. sizeY?: number;
  43502. sizeZ?: number;
  43503. custom?: any;
  43504. faceUV?: Vector4[];
  43505. faceColors?: Color4[];
  43506. flat?: boolean;
  43507. updatable?: boolean;
  43508. sideOrientation?: number;
  43509. frontUVs?: Vector4;
  43510. backUVs?: Vector4;
  43511. }, scene?: Nullable<Scene>): Mesh;
  43512. }
  43513. }
  43514. declare module BABYLON {
  43515. /**
  43516. * Gizmo that enables scaling a mesh along 3 axis
  43517. */
  43518. export class ScaleGizmo extends Gizmo {
  43519. /**
  43520. * Internal gizmo used for interactions on the x axis
  43521. */
  43522. xGizmo: AxisScaleGizmo;
  43523. /**
  43524. * Internal gizmo used for interactions on the y axis
  43525. */
  43526. yGizmo: AxisScaleGizmo;
  43527. /**
  43528. * Internal gizmo used for interactions on the z axis
  43529. */
  43530. zGizmo: AxisScaleGizmo;
  43531. /**
  43532. * Internal gizmo used to scale all axis equally
  43533. */
  43534. uniformScaleGizmo: AxisScaleGizmo;
  43535. private _meshAttached;
  43536. private _updateGizmoRotationToMatchAttachedMesh;
  43537. private _snapDistance;
  43538. private _scaleRatio;
  43539. private _uniformScalingMesh;
  43540. private _octahedron;
  43541. /** Fires an event when any of it's sub gizmos are dragged */
  43542. onDragStartObservable: Observable<unknown>;
  43543. /** Fires an event when any of it's sub gizmos are released from dragging */
  43544. onDragEndObservable: Observable<unknown>;
  43545. attachedMesh: Nullable<AbstractMesh>;
  43546. /**
  43547. * Creates a ScaleGizmo
  43548. * @param gizmoLayer The utility layer the gizmo will be added to
  43549. */
  43550. constructor(gizmoLayer?: UtilityLayerRenderer);
  43551. updateGizmoRotationToMatchAttachedMesh: boolean;
  43552. /**
  43553. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43554. */
  43555. snapDistance: number;
  43556. /**
  43557. * Ratio for the scale of the gizmo (Default: 1)
  43558. */
  43559. scaleRatio: number;
  43560. /**
  43561. * Disposes of the gizmo
  43562. */
  43563. dispose(): void;
  43564. }
  43565. }
  43566. declare module BABYLON {
  43567. /**
  43568. * Single axis scale gizmo
  43569. */
  43570. export class AxisScaleGizmo extends Gizmo {
  43571. /**
  43572. * Drag behavior responsible for the gizmos dragging interactions
  43573. */
  43574. dragBehavior: PointerDragBehavior;
  43575. private _pointerObserver;
  43576. /**
  43577. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43578. */
  43579. snapDistance: number;
  43580. /**
  43581. * Event that fires each time the gizmo snaps to a new location.
  43582. * * snapDistance is the the change in distance
  43583. */
  43584. onSnapObservable: Observable<{
  43585. snapDistance: number;
  43586. }>;
  43587. /**
  43588. * If the scaling operation should be done on all axis (default: false)
  43589. */
  43590. uniformScaling: boolean;
  43591. private _isEnabled;
  43592. private _parent;
  43593. private _arrow;
  43594. private _coloredMaterial;
  43595. private _hoverMaterial;
  43596. /**
  43597. * Creates an AxisScaleGizmo
  43598. * @param gizmoLayer The utility layer the gizmo will be added to
  43599. * @param dragAxis The axis which the gizmo will be able to scale on
  43600. * @param color The color of the gizmo
  43601. */
  43602. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43603. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43604. /**
  43605. * If the gizmo is enabled
  43606. */
  43607. isEnabled: boolean;
  43608. /**
  43609. * Disposes of the gizmo
  43610. */
  43611. dispose(): void;
  43612. /**
  43613. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43614. * @param mesh The mesh to replace the default mesh of the gizmo
  43615. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43616. */
  43617. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43618. }
  43619. }
  43620. declare module BABYLON {
  43621. /**
  43622. * Bounding box gizmo
  43623. */
  43624. export class BoundingBoxGizmo extends Gizmo {
  43625. private _lineBoundingBox;
  43626. private _rotateSpheresParent;
  43627. private _scaleBoxesParent;
  43628. private _boundingDimensions;
  43629. private _renderObserver;
  43630. private _pointerObserver;
  43631. private _scaleDragSpeed;
  43632. private _tmpQuaternion;
  43633. private _tmpVector;
  43634. private _tmpRotationMatrix;
  43635. /**
  43636. * 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)
  43637. */
  43638. ignoreChildren: boolean;
  43639. /**
  43640. * 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)
  43641. */
  43642. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43643. /**
  43644. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43645. */
  43646. rotationSphereSize: number;
  43647. /**
  43648. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43649. */
  43650. scaleBoxSize: number;
  43651. /**
  43652. * 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)
  43653. */
  43654. fixedDragMeshScreenSize: boolean;
  43655. /**
  43656. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43657. */
  43658. fixedDragMeshScreenSizeDistanceFactor: number;
  43659. /**
  43660. * Fired when a rotation sphere or scale box is dragged
  43661. */
  43662. onDragStartObservable: Observable<{}>;
  43663. /**
  43664. * Fired when a scale box is dragged
  43665. */
  43666. onScaleBoxDragObservable: Observable<{}>;
  43667. /**
  43668. * Fired when a scale box drag is ended
  43669. */
  43670. onScaleBoxDragEndObservable: Observable<{}>;
  43671. /**
  43672. * Fired when a rotation sphere is dragged
  43673. */
  43674. onRotationSphereDragObservable: Observable<{}>;
  43675. /**
  43676. * Fired when a rotation sphere drag is ended
  43677. */
  43678. onRotationSphereDragEndObservable: Observable<{}>;
  43679. /**
  43680. * 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)
  43681. */
  43682. scalePivot: Nullable<Vector3>;
  43683. /**
  43684. * Mesh used as a pivot to rotate the attached mesh
  43685. */
  43686. private _anchorMesh;
  43687. private _existingMeshScale;
  43688. private _dragMesh;
  43689. private pointerDragBehavior;
  43690. private coloredMaterial;
  43691. private hoverColoredMaterial;
  43692. /**
  43693. * Sets the color of the bounding box gizmo
  43694. * @param color the color to set
  43695. */
  43696. setColor(color: Color3): void;
  43697. /**
  43698. * Creates an BoundingBoxGizmo
  43699. * @param gizmoLayer The utility layer the gizmo will be added to
  43700. * @param color The color of the gizmo
  43701. */
  43702. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43704. private _selectNode;
  43705. /**
  43706. * Updates the bounding box information for the Gizmo
  43707. */
  43708. updateBoundingBox(): void;
  43709. private _updateRotationSpheres;
  43710. private _updateScaleBoxes;
  43711. /**
  43712. * Enables rotation on the specified axis and disables rotation on the others
  43713. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43714. */
  43715. setEnabledRotationAxis(axis: string): void;
  43716. /**
  43717. * Enables/disables scaling
  43718. * @param enable if scaling should be enabled
  43719. */
  43720. setEnabledScaling(enable: boolean): void;
  43721. private _updateDummy;
  43722. /**
  43723. * Enables a pointer drag behavior on the bounding box of the gizmo
  43724. */
  43725. enableDragBehavior(): void;
  43726. /**
  43727. * Disposes of the gizmo
  43728. */
  43729. dispose(): void;
  43730. /**
  43731. * 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)
  43732. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43733. * @returns the bounding box mesh with the passed in mesh as a child
  43734. */
  43735. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43736. /**
  43737. * CustomMeshes are not supported by this gizmo
  43738. * @param mesh The mesh to replace the default mesh of the gizmo
  43739. */
  43740. setCustomMesh(mesh: Mesh): void;
  43741. }
  43742. }
  43743. declare module BABYLON {
  43744. /**
  43745. * Single plane rotation gizmo
  43746. */
  43747. export class PlaneRotationGizmo extends Gizmo {
  43748. /**
  43749. * Drag behavior responsible for the gizmos dragging interactions
  43750. */
  43751. dragBehavior: PointerDragBehavior;
  43752. private _pointerObserver;
  43753. /**
  43754. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43755. */
  43756. snapDistance: number;
  43757. /**
  43758. * Event that fires each time the gizmo snaps to a new location.
  43759. * * snapDistance is the the change in distance
  43760. */
  43761. onSnapObservable: Observable<{
  43762. snapDistance: number;
  43763. }>;
  43764. private _isEnabled;
  43765. private _parent;
  43766. /**
  43767. * Creates a PlaneRotationGizmo
  43768. * @param gizmoLayer The utility layer the gizmo will be added to
  43769. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43770. * @param color The color of the gizmo
  43771. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43772. */
  43773. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43774. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43775. /**
  43776. * If the gizmo is enabled
  43777. */
  43778. isEnabled: boolean;
  43779. /**
  43780. * Disposes of the gizmo
  43781. */
  43782. dispose(): void;
  43783. }
  43784. }
  43785. declare module BABYLON {
  43786. /**
  43787. * Gizmo that enables rotating a mesh along 3 axis
  43788. */
  43789. export class RotationGizmo extends Gizmo {
  43790. /**
  43791. * Internal gizmo used for interactions on the x axis
  43792. */
  43793. xGizmo: PlaneRotationGizmo;
  43794. /**
  43795. * Internal gizmo used for interactions on the y axis
  43796. */
  43797. yGizmo: PlaneRotationGizmo;
  43798. /**
  43799. * Internal gizmo used for interactions on the z axis
  43800. */
  43801. zGizmo: PlaneRotationGizmo;
  43802. /** Fires an event when any of it's sub gizmos are dragged */
  43803. onDragStartObservable: Observable<unknown>;
  43804. /** Fires an event when any of it's sub gizmos are released from dragging */
  43805. onDragEndObservable: Observable<unknown>;
  43806. private _meshAttached;
  43807. attachedMesh: Nullable<AbstractMesh>;
  43808. /**
  43809. * Creates a RotationGizmo
  43810. * @param gizmoLayer The utility layer the gizmo will be added to
  43811. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43812. */
  43813. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43814. updateGizmoRotationToMatchAttachedMesh: boolean;
  43815. /**
  43816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43817. */
  43818. snapDistance: number;
  43819. /**
  43820. * Ratio for the scale of the gizmo (Default: 1)
  43821. */
  43822. scaleRatio: number;
  43823. /**
  43824. * Disposes of the gizmo
  43825. */
  43826. dispose(): void;
  43827. /**
  43828. * CustomMeshes are not supported by this gizmo
  43829. * @param mesh The mesh to replace the default mesh of the gizmo
  43830. */
  43831. setCustomMesh(mesh: Mesh): void;
  43832. }
  43833. }
  43834. declare module BABYLON {
  43835. /**
  43836. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43837. */
  43838. export class GizmoManager implements IDisposable {
  43839. private scene;
  43840. /**
  43841. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43842. */
  43843. gizmos: {
  43844. positionGizmo: Nullable<PositionGizmo>;
  43845. rotationGizmo: Nullable<RotationGizmo>;
  43846. scaleGizmo: Nullable<ScaleGizmo>;
  43847. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43848. };
  43849. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43850. clearGizmoOnEmptyPointerEvent: boolean;
  43851. /** Fires an event when the manager is attached to a mesh */
  43852. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43853. private _gizmosEnabled;
  43854. private _pointerObserver;
  43855. private _attachedMesh;
  43856. private _boundingBoxColor;
  43857. private _defaultUtilityLayer;
  43858. private _defaultKeepDepthUtilityLayer;
  43859. /**
  43860. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43861. */
  43862. boundingBoxDragBehavior: SixDofDragBehavior;
  43863. /**
  43864. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43865. */
  43866. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43867. /**
  43868. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43869. */
  43870. usePointerToAttachGizmos: boolean;
  43871. /**
  43872. * Utility layer that the bounding box gizmo belongs to
  43873. */
  43874. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43875. /**
  43876. * Utility layer that all gizmos besides bounding box belong to
  43877. */
  43878. readonly utilityLayer: UtilityLayerRenderer;
  43879. /**
  43880. * Instatiates a gizmo manager
  43881. * @param scene the scene to overlay the gizmos on top of
  43882. */
  43883. constructor(scene: Scene);
  43884. /**
  43885. * Attaches a set of gizmos to the specified mesh
  43886. * @param mesh The mesh the gizmo's should be attached to
  43887. */
  43888. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43889. /**
  43890. * If the position gizmo is enabled
  43891. */
  43892. positionGizmoEnabled: boolean;
  43893. /**
  43894. * If the rotation gizmo is enabled
  43895. */
  43896. rotationGizmoEnabled: boolean;
  43897. /**
  43898. * If the scale gizmo is enabled
  43899. */
  43900. scaleGizmoEnabled: boolean;
  43901. /**
  43902. * If the boundingBox gizmo is enabled
  43903. */
  43904. boundingBoxGizmoEnabled: boolean;
  43905. /**
  43906. * Disposes of the gizmo manager
  43907. */
  43908. dispose(): void;
  43909. }
  43910. }
  43911. declare module BABYLON {
  43912. /**
  43913. * A directional light is defined by a direction (what a surprise!).
  43914. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43915. * 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.
  43916. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43917. */
  43918. export class DirectionalLight extends ShadowLight {
  43919. private _shadowFrustumSize;
  43920. /**
  43921. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43922. */
  43923. /**
  43924. * Specifies a fix frustum size for the shadow generation.
  43925. */
  43926. shadowFrustumSize: number;
  43927. private _shadowOrthoScale;
  43928. /**
  43929. * Gets the shadow projection scale against the optimal computed one.
  43930. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43931. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43932. */
  43933. /**
  43934. * Sets the shadow projection scale against the optimal computed one.
  43935. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43936. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43937. */
  43938. shadowOrthoScale: number;
  43939. /**
  43940. * Automatically compute the projection matrix to best fit (including all the casters)
  43941. * on each frame.
  43942. */
  43943. autoUpdateExtends: boolean;
  43944. private _orthoLeft;
  43945. private _orthoRight;
  43946. private _orthoTop;
  43947. private _orthoBottom;
  43948. /**
  43949. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43950. * The directional light is emitted from everywhere in the given direction.
  43951. * It can cast shadows.
  43952. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43953. * @param name The friendly name of the light
  43954. * @param direction The direction of the light
  43955. * @param scene The scene the light belongs to
  43956. */
  43957. constructor(name: string, direction: Vector3, scene: Scene);
  43958. /**
  43959. * Returns the string "DirectionalLight".
  43960. * @return The class name
  43961. */
  43962. getClassName(): string;
  43963. /**
  43964. * Returns the integer 1.
  43965. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43966. */
  43967. getTypeID(): number;
  43968. /**
  43969. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43970. * Returns the DirectionalLight Shadow projection matrix.
  43971. */
  43972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43973. /**
  43974. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43975. * Returns the DirectionalLight Shadow projection matrix.
  43976. */
  43977. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43978. /**
  43979. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43980. * Returns the DirectionalLight Shadow projection matrix.
  43981. */
  43982. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43983. protected _buildUniformLayout(): void;
  43984. /**
  43985. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43986. * @param effect The effect to update
  43987. * @param lightIndex The index of the light in the effect to update
  43988. * @returns The directional light
  43989. */
  43990. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43991. /**
  43992. * Gets the minZ used for shadow according to both the scene and the light.
  43993. *
  43994. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43995. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43996. * @param activeCamera The camera we are returning the min for
  43997. * @returns the depth min z
  43998. */
  43999. getDepthMinZ(activeCamera: Camera): number;
  44000. /**
  44001. * Gets the maxZ used for shadow according to both the scene and the light.
  44002. *
  44003. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44004. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44005. * @param activeCamera The camera we are returning the max for
  44006. * @returns the depth max z
  44007. */
  44008. getDepthMaxZ(activeCamera: Camera): number;
  44009. /**
  44010. * Prepares the list of defines specific to the light type.
  44011. * @param defines the list of defines
  44012. * @param lightIndex defines the index of the light for the effect
  44013. */
  44014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44015. }
  44016. }
  44017. declare module BABYLON {
  44018. /**
  44019. * Class containing static functions to help procedurally build meshes
  44020. */
  44021. export class HemisphereBuilder {
  44022. /**
  44023. * Creates a hemisphere mesh
  44024. * @param name defines the name of the mesh
  44025. * @param options defines the options used to create the mesh
  44026. * @param scene defines the hosting scene
  44027. * @returns the hemisphere mesh
  44028. */
  44029. static CreateHemisphere(name: string, options: {
  44030. segments?: number;
  44031. diameter?: number;
  44032. sideOrientation?: number;
  44033. }, scene: any): Mesh;
  44034. }
  44035. }
  44036. declare module BABYLON {
  44037. /**
  44038. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44039. * These values define a cone of light starting from the position, emitting toward the direction.
  44040. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44041. * and the exponent defines the speed of the decay of the light with distance (reach).
  44042. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44043. */
  44044. export class SpotLight extends ShadowLight {
  44045. private _angle;
  44046. private _innerAngle;
  44047. private _cosHalfAngle;
  44048. private _lightAngleScale;
  44049. private _lightAngleOffset;
  44050. /**
  44051. * Gets the cone angle of the spot light in Radians.
  44052. */
  44053. /**
  44054. * Sets the cone angle of the spot light in Radians.
  44055. */
  44056. angle: number;
  44057. /**
  44058. * Only used in gltf falloff mode, this defines the angle where
  44059. * the directional falloff will start before cutting at angle which could be seen
  44060. * as outer angle.
  44061. */
  44062. /**
  44063. * Only used in gltf falloff mode, this defines the angle where
  44064. * the directional falloff will start before cutting at angle which could be seen
  44065. * as outer angle.
  44066. */
  44067. innerAngle: number;
  44068. private _shadowAngleScale;
  44069. /**
  44070. * Allows scaling the angle of the light for shadow generation only.
  44071. */
  44072. /**
  44073. * Allows scaling the angle of the light for shadow generation only.
  44074. */
  44075. shadowAngleScale: number;
  44076. /**
  44077. * The light decay speed with the distance from the emission spot.
  44078. */
  44079. exponent: number;
  44080. private _projectionTextureMatrix;
  44081. /**
  44082. * Allows reading the projecton texture
  44083. */
  44084. readonly projectionTextureMatrix: Matrix;
  44085. protected _projectionTextureLightNear: number;
  44086. /**
  44087. * Gets the near clip of the Spotlight for texture projection.
  44088. */
  44089. /**
  44090. * Sets the near clip of the Spotlight for texture projection.
  44091. */
  44092. projectionTextureLightNear: number;
  44093. protected _projectionTextureLightFar: number;
  44094. /**
  44095. * Gets the far clip of the Spotlight for texture projection.
  44096. */
  44097. /**
  44098. * Sets the far clip of the Spotlight for texture projection.
  44099. */
  44100. projectionTextureLightFar: number;
  44101. protected _projectionTextureUpDirection: Vector3;
  44102. /**
  44103. * Gets the Up vector of the Spotlight for texture projection.
  44104. */
  44105. /**
  44106. * Sets the Up vector of the Spotlight for texture projection.
  44107. */
  44108. projectionTextureUpDirection: Vector3;
  44109. private _projectionTexture;
  44110. /**
  44111. * Gets the projection texture of the light.
  44112. */
  44113. /**
  44114. * Sets the projection texture of the light.
  44115. */
  44116. projectionTexture: Nullable<BaseTexture>;
  44117. private _projectionTextureViewLightDirty;
  44118. private _projectionTextureProjectionLightDirty;
  44119. private _projectionTextureDirty;
  44120. private _projectionTextureViewTargetVector;
  44121. private _projectionTextureViewLightMatrix;
  44122. private _projectionTextureProjectionLightMatrix;
  44123. private _projectionTextureScalingMatrix;
  44124. /**
  44125. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44126. * It can cast shadows.
  44127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44128. * @param name The light friendly name
  44129. * @param position The position of the spot light in the scene
  44130. * @param direction The direction of the light in the scene
  44131. * @param angle The cone angle of the light in Radians
  44132. * @param exponent The light decay speed with the distance from the emission spot
  44133. * @param scene The scene the lights belongs to
  44134. */
  44135. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44136. /**
  44137. * Returns the string "SpotLight".
  44138. * @returns the class name
  44139. */
  44140. getClassName(): string;
  44141. /**
  44142. * Returns the integer 2.
  44143. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44144. */
  44145. getTypeID(): number;
  44146. /**
  44147. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44148. */
  44149. protected _setDirection(value: Vector3): void;
  44150. /**
  44151. * Overrides the position setter to recompute the projection texture view light Matrix.
  44152. */
  44153. protected _setPosition(value: Vector3): void;
  44154. /**
  44155. * 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.
  44156. * Returns the SpotLight.
  44157. */
  44158. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44159. protected _computeProjectionTextureViewLightMatrix(): void;
  44160. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44161. /**
  44162. * Main function for light texture projection matrix computing.
  44163. */
  44164. protected _computeProjectionTextureMatrix(): void;
  44165. protected _buildUniformLayout(): void;
  44166. private _computeAngleValues;
  44167. /**
  44168. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44169. * @param effect The effect to update
  44170. * @param lightIndex The index of the light in the effect to update
  44171. * @returns The spot light
  44172. */
  44173. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44174. /**
  44175. * Disposes the light and the associated resources.
  44176. */
  44177. dispose(): void;
  44178. /**
  44179. * Prepares the list of defines specific to the light type.
  44180. * @param defines the list of defines
  44181. * @param lightIndex defines the index of the light for the effect
  44182. */
  44183. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44184. }
  44185. }
  44186. declare module BABYLON {
  44187. /**
  44188. * Gizmo that enables viewing a light
  44189. */
  44190. export class LightGizmo extends Gizmo {
  44191. private _lightMesh;
  44192. private _material;
  44193. private cachedPosition;
  44194. private cachedForward;
  44195. /**
  44196. * Creates a LightGizmo
  44197. * @param gizmoLayer The utility layer the gizmo will be added to
  44198. */
  44199. constructor(gizmoLayer?: UtilityLayerRenderer);
  44200. private _light;
  44201. /**
  44202. * The light that the gizmo is attached to
  44203. */
  44204. light: Nullable<Light>;
  44205. /**
  44206. * @hidden
  44207. * Updates the gizmo to match the attached mesh's position/rotation
  44208. */
  44209. protected _update(): void;
  44210. private static _Scale;
  44211. /**
  44212. * Creates the lines for a light mesh
  44213. */
  44214. private static _createLightLines;
  44215. /**
  44216. * Disposes of the light gizmo
  44217. */
  44218. dispose(): void;
  44219. private static _CreateHemisphericLightMesh;
  44220. private static _CreatePointLightMesh;
  44221. private static _CreateSpotLightMesh;
  44222. private static _CreateDirectionalLightMesh;
  44223. }
  44224. }
  44225. declare module BABYLON {
  44226. /** @hidden */
  44227. export var backgroundFragmentDeclaration: {
  44228. name: string;
  44229. shader: string;
  44230. };
  44231. }
  44232. declare module BABYLON {
  44233. /** @hidden */
  44234. export var backgroundUboDeclaration: {
  44235. name: string;
  44236. shader: string;
  44237. };
  44238. }
  44239. declare module BABYLON {
  44240. /** @hidden */
  44241. export var backgroundPixelShader: {
  44242. name: string;
  44243. shader: string;
  44244. };
  44245. }
  44246. declare module BABYLON {
  44247. /** @hidden */
  44248. export var backgroundVertexDeclaration: {
  44249. name: string;
  44250. shader: string;
  44251. };
  44252. }
  44253. declare module BABYLON {
  44254. /** @hidden */
  44255. export var backgroundVertexShader: {
  44256. name: string;
  44257. shader: string;
  44258. };
  44259. }
  44260. declare module BABYLON {
  44261. /**
  44262. * Background material used to create an efficient environement around your scene.
  44263. */
  44264. export class BackgroundMaterial extends PushMaterial {
  44265. /**
  44266. * Standard reflectance value at parallel view angle.
  44267. */
  44268. static StandardReflectance0: number;
  44269. /**
  44270. * Standard reflectance value at grazing angle.
  44271. */
  44272. static StandardReflectance90: number;
  44273. protected _primaryColor: Color3;
  44274. /**
  44275. * Key light Color (multiply against the environement texture)
  44276. */
  44277. primaryColor: Color3;
  44278. protected __perceptualColor: Nullable<Color3>;
  44279. /**
  44280. * Experimental Internal Use Only.
  44281. *
  44282. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44283. * This acts as a helper to set the primary color to a more "human friendly" value.
  44284. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44285. * output color as close as possible from the chosen value.
  44286. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44287. * part of lighting setup.)
  44288. */
  44289. _perceptualColor: Nullable<Color3>;
  44290. protected _primaryColorShadowLevel: float;
  44291. /**
  44292. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44293. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44294. */
  44295. primaryColorShadowLevel: float;
  44296. protected _primaryColorHighlightLevel: float;
  44297. /**
  44298. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44299. * The primary color is used at the level chosen to define what the white area would look.
  44300. */
  44301. primaryColorHighlightLevel: float;
  44302. protected _reflectionTexture: Nullable<BaseTexture>;
  44303. /**
  44304. * Reflection Texture used in the material.
  44305. * Should be author in a specific way for the best result (refer to the documentation).
  44306. */
  44307. reflectionTexture: Nullable<BaseTexture>;
  44308. protected _reflectionBlur: float;
  44309. /**
  44310. * Reflection Texture level of blur.
  44311. *
  44312. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44313. * texture twice.
  44314. */
  44315. reflectionBlur: float;
  44316. protected _diffuseTexture: Nullable<BaseTexture>;
  44317. /**
  44318. * Diffuse Texture used in the material.
  44319. * Should be author in a specific way for the best result (refer to the documentation).
  44320. */
  44321. diffuseTexture: Nullable<BaseTexture>;
  44322. protected _shadowLights: Nullable<IShadowLight[]>;
  44323. /**
  44324. * Specify the list of lights casting shadow on the material.
  44325. * All scene shadow lights will be included if null.
  44326. */
  44327. shadowLights: Nullable<IShadowLight[]>;
  44328. protected _shadowLevel: float;
  44329. /**
  44330. * Helps adjusting the shadow to a softer level if required.
  44331. * 0 means black shadows and 1 means no shadows.
  44332. */
  44333. shadowLevel: float;
  44334. protected _sceneCenter: Vector3;
  44335. /**
  44336. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44337. * It is usually zero but might be interesting to modify according to your setup.
  44338. */
  44339. sceneCenter: Vector3;
  44340. protected _opacityFresnel: boolean;
  44341. /**
  44342. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44343. * This helps ensuring a nice transition when the camera goes under the ground.
  44344. */
  44345. opacityFresnel: boolean;
  44346. protected _reflectionFresnel: boolean;
  44347. /**
  44348. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44349. * This helps adding a mirror texture on the ground.
  44350. */
  44351. reflectionFresnel: boolean;
  44352. protected _reflectionFalloffDistance: number;
  44353. /**
  44354. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44355. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44356. */
  44357. reflectionFalloffDistance: number;
  44358. protected _reflectionAmount: number;
  44359. /**
  44360. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44361. */
  44362. reflectionAmount: number;
  44363. protected _reflectionReflectance0: number;
  44364. /**
  44365. * This specifies the weight of the reflection at grazing angle.
  44366. */
  44367. reflectionReflectance0: number;
  44368. protected _reflectionReflectance90: number;
  44369. /**
  44370. * This specifies the weight of the reflection at a perpendicular point of view.
  44371. */
  44372. reflectionReflectance90: number;
  44373. /**
  44374. * Sets the reflection reflectance fresnel values according to the default standard
  44375. * empirically know to work well :-)
  44376. */
  44377. reflectionStandardFresnelWeight: number;
  44378. protected _useRGBColor: boolean;
  44379. /**
  44380. * Helps to directly use the maps channels instead of their level.
  44381. */
  44382. useRGBColor: boolean;
  44383. protected _enableNoise: boolean;
  44384. /**
  44385. * This helps reducing the banding effect that could occur on the background.
  44386. */
  44387. enableNoise: boolean;
  44388. /**
  44389. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44390. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44391. * Recommended to be keep at 1.0 except for special cases.
  44392. */
  44393. fovMultiplier: number;
  44394. private _fovMultiplier;
  44395. /**
  44396. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44397. */
  44398. useEquirectangularFOV: boolean;
  44399. private _maxSimultaneousLights;
  44400. /**
  44401. * Number of Simultaneous lights allowed on the material.
  44402. */
  44403. maxSimultaneousLights: int;
  44404. /**
  44405. * Default configuration related to image processing available in the Background Material.
  44406. */
  44407. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44408. /**
  44409. * Keep track of the image processing observer to allow dispose and replace.
  44410. */
  44411. private _imageProcessingObserver;
  44412. /**
  44413. * Attaches a new image processing configuration to the PBR Material.
  44414. * @param configuration (if null the scene configuration will be use)
  44415. */
  44416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44417. /**
  44418. * Gets the image processing configuration used either in this material.
  44419. */
  44420. /**
  44421. * Sets the Default image processing configuration used either in the this material.
  44422. *
  44423. * If sets to null, the scene one is in use.
  44424. */
  44425. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44426. /**
  44427. * Gets wether the color curves effect is enabled.
  44428. */
  44429. /**
  44430. * Sets wether the color curves effect is enabled.
  44431. */
  44432. cameraColorCurvesEnabled: boolean;
  44433. /**
  44434. * Gets wether the color grading effect is enabled.
  44435. */
  44436. /**
  44437. * Gets wether the color grading effect is enabled.
  44438. */
  44439. cameraColorGradingEnabled: boolean;
  44440. /**
  44441. * Gets wether tonemapping is enabled or not.
  44442. */
  44443. /**
  44444. * Sets wether tonemapping is enabled or not
  44445. */
  44446. cameraToneMappingEnabled: boolean;
  44447. /**
  44448. * The camera exposure used on this material.
  44449. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44450. * This corresponds to a photographic exposure.
  44451. */
  44452. /**
  44453. * The camera exposure used on this material.
  44454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44455. * This corresponds to a photographic exposure.
  44456. */
  44457. cameraExposure: float;
  44458. /**
  44459. * Gets The camera contrast used on this material.
  44460. */
  44461. /**
  44462. * Sets The camera contrast used on this material.
  44463. */
  44464. cameraContrast: float;
  44465. /**
  44466. * Gets the Color Grading 2D Lookup Texture.
  44467. */
  44468. /**
  44469. * Sets the Color Grading 2D Lookup Texture.
  44470. */
  44471. cameraColorGradingTexture: Nullable<BaseTexture>;
  44472. /**
  44473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44475. * 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;
  44476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44477. */
  44478. /**
  44479. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44480. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44481. * 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;
  44482. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44483. */
  44484. cameraColorCurves: Nullable<ColorCurves>;
  44485. /**
  44486. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44487. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44488. */
  44489. switchToBGR: boolean;
  44490. private _renderTargets;
  44491. private _reflectionControls;
  44492. private _white;
  44493. private _primaryShadowColor;
  44494. private _primaryHighlightColor;
  44495. /**
  44496. * Instantiates a Background Material in the given scene
  44497. * @param name The friendly name of the material
  44498. * @param scene The scene to add the material to
  44499. */
  44500. constructor(name: string, scene: Scene);
  44501. /**
  44502. * Gets a boolean indicating that current material needs to register RTT
  44503. */
  44504. readonly hasRenderTargetTextures: boolean;
  44505. /**
  44506. * The entire material has been created in order to prevent overdraw.
  44507. * @returns false
  44508. */
  44509. needAlphaTesting(): boolean;
  44510. /**
  44511. * The entire material has been created in order to prevent overdraw.
  44512. * @returns true if blending is enable
  44513. */
  44514. needAlphaBlending(): boolean;
  44515. /**
  44516. * Checks wether the material is ready to be rendered for a given mesh.
  44517. * @param mesh The mesh to render
  44518. * @param subMesh The submesh to check against
  44519. * @param useInstances Specify wether or not the material is used with instances
  44520. * @returns true if all the dependencies are ready (Textures, Effects...)
  44521. */
  44522. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44523. /**
  44524. * Compute the primary color according to the chosen perceptual color.
  44525. */
  44526. private _computePrimaryColorFromPerceptualColor;
  44527. /**
  44528. * Compute the highlights and shadow colors according to their chosen levels.
  44529. */
  44530. private _computePrimaryColors;
  44531. /**
  44532. * Build the uniform buffer used in the material.
  44533. */
  44534. buildUniformLayout(): void;
  44535. /**
  44536. * Unbind the material.
  44537. */
  44538. unbind(): void;
  44539. /**
  44540. * Bind only the world matrix to the material.
  44541. * @param world The world matrix to bind.
  44542. */
  44543. bindOnlyWorldMatrix(world: Matrix): void;
  44544. /**
  44545. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44546. * @param world The world matrix to bind.
  44547. * @param subMesh The submesh to bind for.
  44548. */
  44549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44550. /**
  44551. * Dispose the material.
  44552. * @param forceDisposeEffect Force disposal of the associated effect.
  44553. * @param forceDisposeTextures Force disposal of the associated textures.
  44554. */
  44555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44556. /**
  44557. * Clones the material.
  44558. * @param name The cloned name.
  44559. * @returns The cloned material.
  44560. */
  44561. clone(name: string): BackgroundMaterial;
  44562. /**
  44563. * Serializes the current material to its JSON representation.
  44564. * @returns The JSON representation.
  44565. */
  44566. serialize(): any;
  44567. /**
  44568. * Gets the class name of the material
  44569. * @returns "BackgroundMaterial"
  44570. */
  44571. getClassName(): string;
  44572. /**
  44573. * Parse a JSON input to create back a background material.
  44574. * @param source The JSON data to parse
  44575. * @param scene The scene to create the parsed material in
  44576. * @param rootUrl The root url of the assets the material depends upon
  44577. * @returns the instantiated BackgroundMaterial.
  44578. */
  44579. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44580. }
  44581. }
  44582. declare module BABYLON {
  44583. /**
  44584. * Represents the different options available during the creation of
  44585. * a Environment helper.
  44586. *
  44587. * This can control the default ground, skybox and image processing setup of your scene.
  44588. */
  44589. export interface IEnvironmentHelperOptions {
  44590. /**
  44591. * Specifies wether or not to create a ground.
  44592. * True by default.
  44593. */
  44594. createGround: boolean;
  44595. /**
  44596. * Specifies the ground size.
  44597. * 15 by default.
  44598. */
  44599. groundSize: number;
  44600. /**
  44601. * The texture used on the ground for the main color.
  44602. * Comes from the BabylonJS CDN by default.
  44603. *
  44604. * Remarks: Can be either a texture or a url.
  44605. */
  44606. groundTexture: string | BaseTexture;
  44607. /**
  44608. * The color mixed in the ground texture by default.
  44609. * BabylonJS clearColor by default.
  44610. */
  44611. groundColor: Color3;
  44612. /**
  44613. * Specifies the ground opacity.
  44614. * 1 by default.
  44615. */
  44616. groundOpacity: number;
  44617. /**
  44618. * Enables the ground to receive shadows.
  44619. * True by default.
  44620. */
  44621. enableGroundShadow: boolean;
  44622. /**
  44623. * Helps preventing the shadow to be fully black on the ground.
  44624. * 0.5 by default.
  44625. */
  44626. groundShadowLevel: number;
  44627. /**
  44628. * Creates a mirror texture attach to the ground.
  44629. * false by default.
  44630. */
  44631. enableGroundMirror: boolean;
  44632. /**
  44633. * Specifies the ground mirror size ratio.
  44634. * 0.3 by default as the default kernel is 64.
  44635. */
  44636. groundMirrorSizeRatio: number;
  44637. /**
  44638. * Specifies the ground mirror blur kernel size.
  44639. * 64 by default.
  44640. */
  44641. groundMirrorBlurKernel: number;
  44642. /**
  44643. * Specifies the ground mirror visibility amount.
  44644. * 1 by default
  44645. */
  44646. groundMirrorAmount: number;
  44647. /**
  44648. * Specifies the ground mirror reflectance weight.
  44649. * This uses the standard weight of the background material to setup the fresnel effect
  44650. * of the mirror.
  44651. * 1 by default.
  44652. */
  44653. groundMirrorFresnelWeight: number;
  44654. /**
  44655. * Specifies the ground mirror Falloff distance.
  44656. * This can helps reducing the size of the reflection.
  44657. * 0 by Default.
  44658. */
  44659. groundMirrorFallOffDistance: number;
  44660. /**
  44661. * Specifies the ground mirror texture type.
  44662. * Unsigned Int by Default.
  44663. */
  44664. groundMirrorTextureType: number;
  44665. /**
  44666. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44667. * the shown objects.
  44668. */
  44669. groundYBias: number;
  44670. /**
  44671. * Specifies wether or not to create a skybox.
  44672. * True by default.
  44673. */
  44674. createSkybox: boolean;
  44675. /**
  44676. * Specifies the skybox size.
  44677. * 20 by default.
  44678. */
  44679. skyboxSize: number;
  44680. /**
  44681. * The texture used on the skybox for the main color.
  44682. * Comes from the BabylonJS CDN by default.
  44683. *
  44684. * Remarks: Can be either a texture or a url.
  44685. */
  44686. skyboxTexture: string | BaseTexture;
  44687. /**
  44688. * The color mixed in the skybox texture by default.
  44689. * BabylonJS clearColor by default.
  44690. */
  44691. skyboxColor: Color3;
  44692. /**
  44693. * The background rotation around the Y axis of the scene.
  44694. * This helps aligning the key lights of your scene with the background.
  44695. * 0 by default.
  44696. */
  44697. backgroundYRotation: number;
  44698. /**
  44699. * Compute automatically the size of the elements to best fit with the scene.
  44700. */
  44701. sizeAuto: boolean;
  44702. /**
  44703. * Default position of the rootMesh if autoSize is not true.
  44704. */
  44705. rootPosition: Vector3;
  44706. /**
  44707. * Sets up the image processing in the scene.
  44708. * true by default.
  44709. */
  44710. setupImageProcessing: boolean;
  44711. /**
  44712. * The texture used as your environment texture in the scene.
  44713. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44714. *
  44715. * Remarks: Can be either a texture or a url.
  44716. */
  44717. environmentTexture: string | BaseTexture;
  44718. /**
  44719. * The value of the exposure to apply to the scene.
  44720. * 0.6 by default if setupImageProcessing is true.
  44721. */
  44722. cameraExposure: number;
  44723. /**
  44724. * The value of the contrast to apply to the scene.
  44725. * 1.6 by default if setupImageProcessing is true.
  44726. */
  44727. cameraContrast: number;
  44728. /**
  44729. * Specifies wether or not tonemapping should be enabled in the scene.
  44730. * true by default if setupImageProcessing is true.
  44731. */
  44732. toneMappingEnabled: boolean;
  44733. }
  44734. /**
  44735. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44736. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44737. * It also helps with the default setup of your imageProcessing configuration.
  44738. */
  44739. export class EnvironmentHelper {
  44740. /**
  44741. * Default ground texture URL.
  44742. */
  44743. private static _groundTextureCDNUrl;
  44744. /**
  44745. * Default skybox texture URL.
  44746. */
  44747. private static _skyboxTextureCDNUrl;
  44748. /**
  44749. * Default environment texture URL.
  44750. */
  44751. private static _environmentTextureCDNUrl;
  44752. /**
  44753. * Creates the default options for the helper.
  44754. */
  44755. private static _getDefaultOptions;
  44756. private _rootMesh;
  44757. /**
  44758. * Gets the root mesh created by the helper.
  44759. */
  44760. readonly rootMesh: Mesh;
  44761. private _skybox;
  44762. /**
  44763. * Gets the skybox created by the helper.
  44764. */
  44765. readonly skybox: Nullable<Mesh>;
  44766. private _skyboxTexture;
  44767. /**
  44768. * Gets the skybox texture created by the helper.
  44769. */
  44770. readonly skyboxTexture: Nullable<BaseTexture>;
  44771. private _skyboxMaterial;
  44772. /**
  44773. * Gets the skybox material created by the helper.
  44774. */
  44775. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44776. private _ground;
  44777. /**
  44778. * Gets the ground mesh created by the helper.
  44779. */
  44780. readonly ground: Nullable<Mesh>;
  44781. private _groundTexture;
  44782. /**
  44783. * Gets the ground texture created by the helper.
  44784. */
  44785. readonly groundTexture: Nullable<BaseTexture>;
  44786. private _groundMirror;
  44787. /**
  44788. * Gets the ground mirror created by the helper.
  44789. */
  44790. readonly groundMirror: Nullable<MirrorTexture>;
  44791. /**
  44792. * Gets the ground mirror render list to helps pushing the meshes
  44793. * you wish in the ground reflection.
  44794. */
  44795. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44796. private _groundMaterial;
  44797. /**
  44798. * Gets the ground material created by the helper.
  44799. */
  44800. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44801. /**
  44802. * Stores the creation options.
  44803. */
  44804. private readonly _scene;
  44805. private _options;
  44806. /**
  44807. * This observable will be notified with any error during the creation of the environment,
  44808. * mainly texture creation errors.
  44809. */
  44810. onErrorObservable: Observable<{
  44811. message?: string;
  44812. exception?: any;
  44813. }>;
  44814. /**
  44815. * constructor
  44816. * @param options Defines the options we want to customize the helper
  44817. * @param scene The scene to add the material to
  44818. */
  44819. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44820. /**
  44821. * Updates the background according to the new options
  44822. * @param options
  44823. */
  44824. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44825. /**
  44826. * Sets the primary color of all the available elements.
  44827. * @param color the main color to affect to the ground and the background
  44828. */
  44829. setMainColor(color: Color3): void;
  44830. /**
  44831. * Setup the image processing according to the specified options.
  44832. */
  44833. private _setupImageProcessing;
  44834. /**
  44835. * Setup the environment texture according to the specified options.
  44836. */
  44837. private _setupEnvironmentTexture;
  44838. /**
  44839. * Setup the background according to the specified options.
  44840. */
  44841. private _setupBackground;
  44842. /**
  44843. * Get the scene sizes according to the setup.
  44844. */
  44845. private _getSceneSize;
  44846. /**
  44847. * Setup the ground according to the specified options.
  44848. */
  44849. private _setupGround;
  44850. /**
  44851. * Setup the ground material according to the specified options.
  44852. */
  44853. private _setupGroundMaterial;
  44854. /**
  44855. * Setup the ground diffuse texture according to the specified options.
  44856. */
  44857. private _setupGroundDiffuseTexture;
  44858. /**
  44859. * Setup the ground mirror texture according to the specified options.
  44860. */
  44861. private _setupGroundMirrorTexture;
  44862. /**
  44863. * Setup the ground to receive the mirror texture.
  44864. */
  44865. private _setupMirrorInGroundMaterial;
  44866. /**
  44867. * Setup the skybox according to the specified options.
  44868. */
  44869. private _setupSkybox;
  44870. /**
  44871. * Setup the skybox material according to the specified options.
  44872. */
  44873. private _setupSkyboxMaterial;
  44874. /**
  44875. * Setup the skybox reflection texture according to the specified options.
  44876. */
  44877. private _setupSkyboxReflectionTexture;
  44878. private _errorHandler;
  44879. /**
  44880. * Dispose all the elements created by the Helper.
  44881. */
  44882. dispose(): void;
  44883. }
  44884. }
  44885. declare module BABYLON {
  44886. /**
  44887. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44888. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44889. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44890. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44891. */
  44892. export class PhotoDome extends TransformNode {
  44893. /**
  44894. * Define the image as a Monoscopic panoramic 360 image.
  44895. */
  44896. static readonly MODE_MONOSCOPIC: number;
  44897. /**
  44898. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44899. */
  44900. static readonly MODE_TOPBOTTOM: number;
  44901. /**
  44902. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44903. */
  44904. static readonly MODE_SIDEBYSIDE: number;
  44905. private _useDirectMapping;
  44906. /**
  44907. * The texture being displayed on the sphere
  44908. */
  44909. protected _photoTexture: Texture;
  44910. /**
  44911. * Gets or sets the texture being displayed on the sphere
  44912. */
  44913. photoTexture: Texture;
  44914. /**
  44915. * Observable raised when an error occured while loading the 360 image
  44916. */
  44917. onLoadErrorObservable: Observable<string>;
  44918. /**
  44919. * The skybox material
  44920. */
  44921. protected _material: BackgroundMaterial;
  44922. /**
  44923. * The surface used for the skybox
  44924. */
  44925. protected _mesh: Mesh;
  44926. /**
  44927. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44928. * Also see the options.resolution property.
  44929. */
  44930. fovMultiplier: number;
  44931. private _imageMode;
  44932. /**
  44933. * Gets or set the current video mode for the video. It can be:
  44934. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44935. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44936. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44937. */
  44938. imageMode: number;
  44939. /**
  44940. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44941. * @param name Element's name, child elements will append suffixes for their own names.
  44942. * @param urlsOfPhoto defines the url of the photo to display
  44943. * @param options defines an object containing optional or exposed sub element properties
  44944. * @param onError defines a callback called when an error occured while loading the texture
  44945. */
  44946. constructor(name: string, urlOfPhoto: string, options: {
  44947. resolution?: number;
  44948. size?: number;
  44949. useDirectMapping?: boolean;
  44950. faceForward?: boolean;
  44951. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44952. private _onBeforeCameraRenderObserver;
  44953. private _changeImageMode;
  44954. /**
  44955. * Releases resources associated with this node.
  44956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44958. */
  44959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44960. }
  44961. }
  44962. declare module BABYLON {
  44963. /** @hidden */
  44964. export var rgbdDecodePixelShader: {
  44965. name: string;
  44966. shader: string;
  44967. };
  44968. }
  44969. declare module BABYLON {
  44970. /**
  44971. * Class used to host texture specific utilities
  44972. */
  44973. export class BRDFTextureTools {
  44974. /**
  44975. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44976. * @param texture the texture to expand.
  44977. */
  44978. private static _ExpandDefaultBRDFTexture;
  44979. /**
  44980. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44981. * @param scene defines the hosting scene
  44982. * @returns the environment BRDF texture
  44983. */
  44984. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44985. private static _environmentBRDFBase64Texture;
  44986. }
  44987. }
  44988. declare module BABYLON {
  44989. /**
  44990. * @hidden
  44991. */
  44992. export interface IMaterialClearCoatDefines {
  44993. CLEARCOAT: boolean;
  44994. CLEARCOAT_DEFAULTIOR: boolean;
  44995. CLEARCOAT_TEXTURE: boolean;
  44996. CLEARCOAT_TEXTUREDIRECTUV: number;
  44997. CLEARCOAT_BUMP: boolean;
  44998. CLEARCOAT_BUMPDIRECTUV: number;
  44999. CLEARCOAT_TINT: boolean;
  45000. CLEARCOAT_TINT_TEXTURE: boolean;
  45001. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45002. /** @hidden */
  45003. _areTexturesDirty: boolean;
  45004. }
  45005. /**
  45006. * Define the code related to the clear coat parameters of the pbr material.
  45007. */
  45008. export class PBRClearCoatConfiguration {
  45009. /**
  45010. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45011. * The default fits with a polyurethane material.
  45012. */
  45013. private static readonly _DefaultIndexOfRefraction;
  45014. private _isEnabled;
  45015. /**
  45016. * Defines if the clear coat is enabled in the material.
  45017. */
  45018. isEnabled: boolean;
  45019. /**
  45020. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45021. */
  45022. intensity: number;
  45023. /**
  45024. * Defines the clear coat layer roughness.
  45025. */
  45026. roughness: number;
  45027. private _indexOfRefraction;
  45028. /**
  45029. * Defines the index of refraction of the clear coat.
  45030. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45031. * The default fits with a polyurethane material.
  45032. * Changing the default value is more performance intensive.
  45033. */
  45034. indexOfRefraction: number;
  45035. private _texture;
  45036. /**
  45037. * Stores the clear coat values in a texture.
  45038. */
  45039. texture: Nullable<BaseTexture>;
  45040. private _bumpTexture;
  45041. /**
  45042. * Define the clear coat specific bump texture.
  45043. */
  45044. bumpTexture: Nullable<BaseTexture>;
  45045. private _isTintEnabled;
  45046. /**
  45047. * Defines if the clear coat tint is enabled in the material.
  45048. */
  45049. isTintEnabled: boolean;
  45050. /**
  45051. * Defines the clear coat tint of the material.
  45052. * This is only use if tint is enabled
  45053. */
  45054. tintColor: Color3;
  45055. /**
  45056. * Defines the distance at which the tint color should be found in the
  45057. * clear coat media.
  45058. * This is only use if tint is enabled
  45059. */
  45060. tintColorAtDistance: number;
  45061. /**
  45062. * Defines the clear coat layer thickness.
  45063. * This is only use if tint is enabled
  45064. */
  45065. tintThickness: number;
  45066. private _tintTexture;
  45067. /**
  45068. * Stores the clear tint values in a texture.
  45069. * rgb is tint
  45070. * a is a thickness factor
  45071. */
  45072. tintTexture: Nullable<BaseTexture>;
  45073. /** @hidden */
  45074. private _internalMarkAllSubMeshesAsTexturesDirty;
  45075. /** @hidden */
  45076. _markAllSubMeshesAsTexturesDirty(): void;
  45077. /**
  45078. * Instantiate a new istance of clear coat configuration.
  45079. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45080. */
  45081. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45082. /**
  45083. * Gets wehter the submesh is ready to be used or not.
  45084. * @param defines the list of "defines" to update.
  45085. * @param scene defines the scene the material belongs to.
  45086. * @param engine defines the engine the material belongs to.
  45087. * @param disableBumpMap defines wether the material disables bump or not.
  45088. * @returns - boolean indicating that the submesh is ready or not.
  45089. */
  45090. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45091. /**
  45092. * Checks to see if a texture is used in the material.
  45093. * @param defines the list of "defines" to update.
  45094. * @param scene defines the scene to the material belongs to.
  45095. */
  45096. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45097. /**
  45098. * Binds the material data.
  45099. * @param uniformBuffer defines the Uniform buffer to fill in.
  45100. * @param scene defines the scene the material belongs to.
  45101. * @param engine defines the engine the material belongs to.
  45102. * @param disableBumpMap defines wether the material disables bump or not.
  45103. * @param isFrozen defines wether the material is frozen or not.
  45104. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45105. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45106. */
  45107. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45108. /**
  45109. * Checks to see if a texture is used in the material.
  45110. * @param texture - Base texture to use.
  45111. * @returns - Boolean specifying if a texture is used in the material.
  45112. */
  45113. hasTexture(texture: BaseTexture): boolean;
  45114. /**
  45115. * Returns an array of the actively used textures.
  45116. * @param activeTextures Array of BaseTextures
  45117. */
  45118. getActiveTextures(activeTextures: BaseTexture[]): void;
  45119. /**
  45120. * Returns the animatable textures.
  45121. * @param animatables Array of animatable textures.
  45122. */
  45123. getAnimatables(animatables: IAnimatable[]): void;
  45124. /**
  45125. * Disposes the resources of the material.
  45126. * @param forceDisposeTextures - Forces the disposal of all textures.
  45127. */
  45128. dispose(forceDisposeTextures?: boolean): void;
  45129. /**
  45130. * Get the current class name of the texture useful for serialization or dynamic coding.
  45131. * @returns "PBRClearCoatConfiguration"
  45132. */
  45133. getClassName(): string;
  45134. /**
  45135. * Add fallbacks to the effect fallbacks list.
  45136. * @param defines defines the Base texture to use.
  45137. * @param fallbacks defines the current fallback list.
  45138. * @param currentRank defines the current fallback rank.
  45139. * @returns the new fallback rank.
  45140. */
  45141. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45142. /**
  45143. * Add the required uniforms to the current list.
  45144. * @param uniforms defines the current uniform list.
  45145. */
  45146. static AddUniforms(uniforms: string[]): void;
  45147. /**
  45148. * Add the required samplers to the current list.
  45149. * @param samplers defines the current sampler list.
  45150. */
  45151. static AddSamplers(samplers: string[]): void;
  45152. /**
  45153. * Add the required uniforms to the current buffer.
  45154. * @param uniformBuffer defines the current uniform buffer.
  45155. */
  45156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45157. /**
  45158. * Makes a duplicate of the current configuration into another one.
  45159. * @param clearCoatConfiguration define the config where to copy the info
  45160. */
  45161. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45162. /**
  45163. * Serializes this clear coat configuration.
  45164. * @returns - An object with the serialized config.
  45165. */
  45166. serialize(): any;
  45167. /**
  45168. * Parses a anisotropy Configuration from a serialized object.
  45169. * @param source - Serialized object.
  45170. * @param scene Defines the scene we are parsing for
  45171. * @param rootUrl Defines the rootUrl to load from
  45172. */
  45173. parse(source: any, scene: Scene, rootUrl: string): void;
  45174. }
  45175. }
  45176. declare module BABYLON {
  45177. /**
  45178. * @hidden
  45179. */
  45180. export interface IMaterialAnisotropicDefines {
  45181. ANISOTROPIC: boolean;
  45182. ANISOTROPIC_TEXTURE: boolean;
  45183. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45184. MAINUV1: boolean;
  45185. _areTexturesDirty: boolean;
  45186. _needUVs: boolean;
  45187. }
  45188. /**
  45189. * Define the code related to the anisotropic parameters of the pbr material.
  45190. */
  45191. export class PBRAnisotropicConfiguration {
  45192. private _isEnabled;
  45193. /**
  45194. * Defines if the anisotropy is enabled in the material.
  45195. */
  45196. isEnabled: boolean;
  45197. /**
  45198. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45199. */
  45200. intensity: number;
  45201. /**
  45202. * Defines if the effect is along the tangents, bitangents or in between.
  45203. * By default, the effect is "strectching" the highlights along the tangents.
  45204. */
  45205. direction: Vector2;
  45206. private _texture;
  45207. /**
  45208. * Stores the anisotropy values in a texture.
  45209. * rg is direction (like normal from -1 to 1)
  45210. * b is a intensity
  45211. */
  45212. texture: Nullable<BaseTexture>;
  45213. /** @hidden */
  45214. private _internalMarkAllSubMeshesAsTexturesDirty;
  45215. /** @hidden */
  45216. _markAllSubMeshesAsTexturesDirty(): void;
  45217. /**
  45218. * Instantiate a new istance of anisotropy configuration.
  45219. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45220. */
  45221. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45222. /**
  45223. * Specifies that the submesh is ready to be used.
  45224. * @param defines the list of "defines" to update.
  45225. * @param scene defines the scene the material belongs to.
  45226. * @returns - boolean indicating that the submesh is ready or not.
  45227. */
  45228. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45229. /**
  45230. * Checks to see if a texture is used in the material.
  45231. * @param defines the list of "defines" to update.
  45232. * @param mesh the mesh we are preparing the defines for.
  45233. * @param scene defines the scene the material belongs to.
  45234. */
  45235. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45236. /**
  45237. * Binds the material data.
  45238. * @param uniformBuffer defines the Uniform buffer to fill in.
  45239. * @param scene defines the scene the material belongs to.
  45240. * @param isFrozen defines wether the material is frozen or not.
  45241. */
  45242. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45243. /**
  45244. * Checks to see if a texture is used in the material.
  45245. * @param texture - Base texture to use.
  45246. * @returns - Boolean specifying if a texture is used in the material.
  45247. */
  45248. hasTexture(texture: BaseTexture): boolean;
  45249. /**
  45250. * Returns an array of the actively used textures.
  45251. * @param activeTextures Array of BaseTextures
  45252. */
  45253. getActiveTextures(activeTextures: BaseTexture[]): void;
  45254. /**
  45255. * Returns the animatable textures.
  45256. * @param animatables Array of animatable textures.
  45257. */
  45258. getAnimatables(animatables: IAnimatable[]): void;
  45259. /**
  45260. * Disposes the resources of the material.
  45261. * @param forceDisposeTextures - Forces the disposal of all textures.
  45262. */
  45263. dispose(forceDisposeTextures?: boolean): void;
  45264. /**
  45265. * Get the current class name of the texture useful for serialization or dynamic coding.
  45266. * @returns "PBRAnisotropicConfiguration"
  45267. */
  45268. getClassName(): string;
  45269. /**
  45270. * Add fallbacks to the effect fallbacks list.
  45271. * @param defines defines the Base texture to use.
  45272. * @param fallbacks defines the current fallback list.
  45273. * @param currentRank defines the current fallback rank.
  45274. * @returns the new fallback rank.
  45275. */
  45276. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45277. /**
  45278. * Add the required uniforms to the current list.
  45279. * @param uniforms defines the current uniform list.
  45280. */
  45281. static AddUniforms(uniforms: string[]): void;
  45282. /**
  45283. * Add the required uniforms to the current buffer.
  45284. * @param uniformBuffer defines the current uniform buffer.
  45285. */
  45286. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45287. /**
  45288. * Add the required samplers to the current list.
  45289. * @param samplers defines the current sampler list.
  45290. */
  45291. static AddSamplers(samplers: string[]): void;
  45292. /**
  45293. * Makes a duplicate of the current configuration into another one.
  45294. * @param anisotropicConfiguration define the config where to copy the info
  45295. */
  45296. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45297. /**
  45298. * Serializes this anisotropy configuration.
  45299. * @returns - An object with the serialized config.
  45300. */
  45301. serialize(): any;
  45302. /**
  45303. * Parses a anisotropy Configuration from a serialized object.
  45304. * @param source - Serialized object.
  45305. * @param scene Defines the scene we are parsing for
  45306. * @param rootUrl Defines the rootUrl to load from
  45307. */
  45308. parse(source: any, scene: Scene, rootUrl: string): void;
  45309. }
  45310. }
  45311. declare module BABYLON {
  45312. /**
  45313. * @hidden
  45314. */
  45315. export interface IMaterialBRDFDefines {
  45316. BRDF_V_HEIGHT_CORRELATED: boolean;
  45317. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45318. SPHERICAL_HARMONICS: boolean;
  45319. /** @hidden */
  45320. _areMiscDirty: boolean;
  45321. }
  45322. /**
  45323. * Define the code related to the BRDF parameters of the pbr material.
  45324. */
  45325. export class PBRBRDFConfiguration {
  45326. /**
  45327. * Default value used for the energy conservation.
  45328. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45329. */
  45330. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45331. /**
  45332. * Default value used for the Smith Visibility Height Correlated mode.
  45333. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45334. */
  45335. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45336. /**
  45337. * Default value used for the IBL diffuse part.
  45338. * This can help switching back to the polynomials mode globally which is a tiny bit
  45339. * less GPU intensive at the drawback of a lower quality.
  45340. */
  45341. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45342. private _useEnergyConservation;
  45343. /**
  45344. * Defines if the material uses energy conservation.
  45345. */
  45346. useEnergyConservation: boolean;
  45347. private _useSmithVisibilityHeightCorrelated;
  45348. /**
  45349. * LEGACY Mode set to false
  45350. * Defines if the material uses height smith correlated visibility term.
  45351. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45352. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45353. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45354. * Not relying on height correlated will also disable energy conservation.
  45355. */
  45356. useSmithVisibilityHeightCorrelated: boolean;
  45357. private _useSphericalHarmonics;
  45358. /**
  45359. * LEGACY Mode set to false
  45360. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45361. * diffuse part of the IBL.
  45362. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45363. * to the ground truth.
  45364. */
  45365. useSphericalHarmonics: boolean;
  45366. /** @hidden */
  45367. private _internalMarkAllSubMeshesAsMiscDirty;
  45368. /** @hidden */
  45369. _markAllSubMeshesAsMiscDirty(): void;
  45370. /**
  45371. * Instantiate a new istance of clear coat configuration.
  45372. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45373. */
  45374. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45375. /**
  45376. * Checks to see if a texture is used in the material.
  45377. * @param defines the list of "defines" to update.
  45378. */
  45379. prepareDefines(defines: IMaterialBRDFDefines): void;
  45380. /**
  45381. * Get the current class name of the texture useful for serialization or dynamic coding.
  45382. * @returns "PBRClearCoatConfiguration"
  45383. */
  45384. getClassName(): string;
  45385. /**
  45386. * Makes a duplicate of the current configuration into another one.
  45387. * @param brdfConfiguration define the config where to copy the info
  45388. */
  45389. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45390. /**
  45391. * Serializes this BRDF configuration.
  45392. * @returns - An object with the serialized config.
  45393. */
  45394. serialize(): any;
  45395. /**
  45396. * Parses a anisotropy Configuration from a serialized object.
  45397. * @param source - Serialized object.
  45398. * @param scene Defines the scene we are parsing for
  45399. * @param rootUrl Defines the rootUrl to load from
  45400. */
  45401. parse(source: any, scene: Scene, rootUrl: string): void;
  45402. }
  45403. }
  45404. declare module BABYLON {
  45405. /**
  45406. * @hidden
  45407. */
  45408. export interface IMaterialSheenDefines {
  45409. SHEEN: boolean;
  45410. SHEEN_TEXTURE: boolean;
  45411. SHEEN_TEXTUREDIRECTUV: number;
  45412. SHEEN_LINKWITHALBEDO: boolean;
  45413. /** @hidden */
  45414. _areTexturesDirty: boolean;
  45415. }
  45416. /**
  45417. * Define the code related to the Sheen parameters of the pbr material.
  45418. */
  45419. export class PBRSheenConfiguration {
  45420. private _isEnabled;
  45421. /**
  45422. * Defines if the material uses sheen.
  45423. */
  45424. isEnabled: boolean;
  45425. private _linkSheenWithAlbedo;
  45426. /**
  45427. * Defines if the sheen is linked to the sheen color.
  45428. */
  45429. linkSheenWithAlbedo: boolean;
  45430. /**
  45431. * Defines the sheen intensity.
  45432. */
  45433. intensity: number;
  45434. /**
  45435. * Defines the sheen color.
  45436. */
  45437. color: Color3;
  45438. private _texture;
  45439. /**
  45440. * Stores the sheen tint values in a texture.
  45441. * rgb is tint
  45442. * a is a intensity
  45443. */
  45444. texture: Nullable<BaseTexture>;
  45445. /** @hidden */
  45446. private _internalMarkAllSubMeshesAsTexturesDirty;
  45447. /** @hidden */
  45448. _markAllSubMeshesAsTexturesDirty(): void;
  45449. /**
  45450. * Instantiate a new istance of clear coat configuration.
  45451. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45452. */
  45453. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45454. /**
  45455. * Specifies that the submesh is ready to be used.
  45456. * @param defines the list of "defines" to update.
  45457. * @param scene defines the scene the material belongs to.
  45458. * @returns - boolean indicating that the submesh is ready or not.
  45459. */
  45460. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45461. /**
  45462. * Checks to see if a texture is used in the material.
  45463. * @param defines the list of "defines" to update.
  45464. * @param scene defines the scene the material belongs to.
  45465. */
  45466. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45467. /**
  45468. * Binds the material data.
  45469. * @param uniformBuffer defines the Uniform buffer to fill in.
  45470. * @param scene defines the scene the material belongs to.
  45471. * @param isFrozen defines wether the material is frozen or not.
  45472. */
  45473. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45474. /**
  45475. * Checks to see if a texture is used in the material.
  45476. * @param texture - Base texture to use.
  45477. * @returns - Boolean specifying if a texture is used in the material.
  45478. */
  45479. hasTexture(texture: BaseTexture): boolean;
  45480. /**
  45481. * Returns an array of the actively used textures.
  45482. * @param activeTextures Array of BaseTextures
  45483. */
  45484. getActiveTextures(activeTextures: BaseTexture[]): void;
  45485. /**
  45486. * Returns the animatable textures.
  45487. * @param animatables Array of animatable textures.
  45488. */
  45489. getAnimatables(animatables: IAnimatable[]): void;
  45490. /**
  45491. * Disposes the resources of the material.
  45492. * @param forceDisposeTextures - Forces the disposal of all textures.
  45493. */
  45494. dispose(forceDisposeTextures?: boolean): void;
  45495. /**
  45496. * Get the current class name of the texture useful for serialization or dynamic coding.
  45497. * @returns "PBRSheenConfiguration"
  45498. */
  45499. getClassName(): string;
  45500. /**
  45501. * Add fallbacks to the effect fallbacks list.
  45502. * @param defines defines the Base texture to use.
  45503. * @param fallbacks defines the current fallback list.
  45504. * @param currentRank defines the current fallback rank.
  45505. * @returns the new fallback rank.
  45506. */
  45507. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45508. /**
  45509. * Add the required uniforms to the current list.
  45510. * @param uniforms defines the current uniform list.
  45511. */
  45512. static AddUniforms(uniforms: string[]): void;
  45513. /**
  45514. * Add the required uniforms to the current buffer.
  45515. * @param uniformBuffer defines the current uniform buffer.
  45516. */
  45517. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45518. /**
  45519. * Add the required samplers to the current list.
  45520. * @param samplers defines the current sampler list.
  45521. */
  45522. static AddSamplers(samplers: string[]): void;
  45523. /**
  45524. * Makes a duplicate of the current configuration into another one.
  45525. * @param sheenConfiguration define the config where to copy the info
  45526. */
  45527. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45528. /**
  45529. * Serializes this BRDF configuration.
  45530. * @returns - An object with the serialized config.
  45531. */
  45532. serialize(): any;
  45533. /**
  45534. * Parses a anisotropy Configuration from a serialized object.
  45535. * @param source - Serialized object.
  45536. * @param scene Defines the scene we are parsing for
  45537. * @param rootUrl Defines the rootUrl to load from
  45538. */
  45539. parse(source: any, scene: Scene, rootUrl: string): void;
  45540. }
  45541. }
  45542. declare module BABYLON {
  45543. /**
  45544. * @hidden
  45545. */
  45546. export interface IMaterialSubSurfaceDefines {
  45547. SUBSURFACE: boolean;
  45548. SS_REFRACTION: boolean;
  45549. SS_TRANSLUCENCY: boolean;
  45550. SS_SCATERRING: boolean;
  45551. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45552. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45553. SS_REFRACTIONMAP_3D: boolean;
  45554. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45555. SS_LODINREFRACTIONALPHA: boolean;
  45556. SS_GAMMAREFRACTION: boolean;
  45557. SS_RGBDREFRACTION: boolean;
  45558. SS_LINEARSPECULARREFRACTION: boolean;
  45559. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45560. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45561. /** @hidden */
  45562. _areTexturesDirty: boolean;
  45563. }
  45564. /**
  45565. * Define the code related to the sub surface parameters of the pbr material.
  45566. */
  45567. export class PBRSubSurfaceConfiguration {
  45568. private _isRefractionEnabled;
  45569. /**
  45570. * Defines if the refraction is enabled in the material.
  45571. */
  45572. isRefractionEnabled: boolean;
  45573. private _isTranslucencyEnabled;
  45574. /**
  45575. * Defines if the translucency is enabled in the material.
  45576. */
  45577. isTranslucencyEnabled: boolean;
  45578. private _isScatteringEnabled;
  45579. /**
  45580. * Defines the refraction intensity of the material.
  45581. * The refraction when enabled replaces the Diffuse part of the material.
  45582. * The intensity helps transitionning between diffuse and refraction.
  45583. */
  45584. refractionIntensity: number;
  45585. /**
  45586. * Defines the translucency intensity of the material.
  45587. * When translucency has been enabled, this defines how much of the "translucency"
  45588. * is addded to the diffuse part of the material.
  45589. */
  45590. translucencyIntensity: number;
  45591. /**
  45592. * Defines the scattering intensity of the material.
  45593. * When scattering has been enabled, this defines how much of the "scattered light"
  45594. * is addded to the diffuse part of the material.
  45595. */
  45596. scatteringIntensity: number;
  45597. private _thicknessTexture;
  45598. /**
  45599. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45600. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45601. * 0 would mean minimumThickness
  45602. * 1 would mean maximumThickness
  45603. * The other channels might be use as a mask to vary the different effects intensity.
  45604. */
  45605. thicknessTexture: Nullable<BaseTexture>;
  45606. private _refractionTexture;
  45607. /**
  45608. * Defines the texture to use for refraction.
  45609. */
  45610. refractionTexture: Nullable<BaseTexture>;
  45611. private _indexOfRefraction;
  45612. /**
  45613. * Defines the index of refraction used in the material.
  45614. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45615. */
  45616. indexOfRefraction: number;
  45617. private _invertRefractionY;
  45618. /**
  45619. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45620. */
  45621. invertRefractionY: boolean;
  45622. private _linkRefractionWithTransparency;
  45623. /**
  45624. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45625. * Materials half opaque for instance using refraction could benefit from this control.
  45626. */
  45627. linkRefractionWithTransparency: boolean;
  45628. /**
  45629. * Defines the minimum thickness stored in the thickness map.
  45630. * If no thickness map is defined, this value will be used to simulate thickness.
  45631. */
  45632. minimumThickness: number;
  45633. /**
  45634. * Defines the maximum thickness stored in the thickness map.
  45635. */
  45636. maximumThickness: number;
  45637. /**
  45638. * Defines the volume tint of the material.
  45639. * This is used for both translucency and scattering.
  45640. */
  45641. tintColor: Color3;
  45642. /**
  45643. * Defines the distance at which the tint color should be found in the media.
  45644. * This is used for refraction only.
  45645. */
  45646. tintColorAtDistance: number;
  45647. /**
  45648. * Defines how far each channel transmit through the media.
  45649. * It is defined as a color to simplify it selection.
  45650. */
  45651. diffusionDistance: Color3;
  45652. private _useMaskFromThicknessTexture;
  45653. /**
  45654. * Stores the intensity of the different subsurface effects in the thickness texture.
  45655. * * the green channel is the translucency intensity.
  45656. * * the blue channel is the scattering intensity.
  45657. * * the alpha channel is the refraction intensity.
  45658. */
  45659. useMaskFromThicknessTexture: boolean;
  45660. /** @hidden */
  45661. private _internalMarkAllSubMeshesAsTexturesDirty;
  45662. /** @hidden */
  45663. _markAllSubMeshesAsTexturesDirty(): void;
  45664. /**
  45665. * Instantiate a new istance of sub surface configuration.
  45666. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45667. */
  45668. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45669. /**
  45670. * Gets wehter the submesh is ready to be used or not.
  45671. * @param defines the list of "defines" to update.
  45672. * @param scene defines the scene the material belongs to.
  45673. * @returns - boolean indicating that the submesh is ready or not.
  45674. */
  45675. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45676. /**
  45677. * Checks to see if a texture is used in the material.
  45678. * @param defines the list of "defines" to update.
  45679. * @param scene defines the scene to the material belongs to.
  45680. */
  45681. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45682. /**
  45683. * Binds the material data.
  45684. * @param uniformBuffer defines the Uniform buffer to fill in.
  45685. * @param scene defines the scene the material belongs to.
  45686. * @param engine defines the engine the material belongs to.
  45687. * @param isFrozen defines wether the material is frozen or not.
  45688. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45689. */
  45690. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45691. /**
  45692. * Unbinds the material from the mesh.
  45693. * @param activeEffect defines the effect that should be unbound from.
  45694. * @returns true if unbound, otherwise false
  45695. */
  45696. unbind(activeEffect: Effect): boolean;
  45697. /**
  45698. * Returns the texture used for refraction or null if none is used.
  45699. * @param scene defines the scene the material belongs to.
  45700. * @returns - Refraction texture if present. If no refraction texture and refraction
  45701. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45702. */
  45703. private _getRefractionTexture;
  45704. /**
  45705. * Returns true if alpha blending should be disabled.
  45706. */
  45707. readonly disableAlphaBlending: boolean;
  45708. /**
  45709. * Fills the list of render target textures.
  45710. * @param renderTargets the list of render targets to update
  45711. */
  45712. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45713. /**
  45714. * Checks to see if a texture is used in the material.
  45715. * @param texture - Base texture to use.
  45716. * @returns - Boolean specifying if a texture is used in the material.
  45717. */
  45718. hasTexture(texture: BaseTexture): boolean;
  45719. /**
  45720. * Gets a boolean indicating that current material needs to register RTT
  45721. * @returns true if this uses a render target otherwise false.
  45722. */
  45723. hasRenderTargetTextures(): boolean;
  45724. /**
  45725. * Returns an array of the actively used textures.
  45726. * @param activeTextures Array of BaseTextures
  45727. */
  45728. getActiveTextures(activeTextures: BaseTexture[]): void;
  45729. /**
  45730. * Returns the animatable textures.
  45731. * @param animatables Array of animatable textures.
  45732. */
  45733. getAnimatables(animatables: IAnimatable[]): void;
  45734. /**
  45735. * Disposes the resources of the material.
  45736. * @param forceDisposeTextures - Forces the disposal of all textures.
  45737. */
  45738. dispose(forceDisposeTextures?: boolean): void;
  45739. /**
  45740. * Get the current class name of the texture useful for serialization or dynamic coding.
  45741. * @returns "PBRSubSurfaceConfiguration"
  45742. */
  45743. getClassName(): string;
  45744. /**
  45745. * Add fallbacks to the effect fallbacks list.
  45746. * @param defines defines the Base texture to use.
  45747. * @param fallbacks defines the current fallback list.
  45748. * @param currentRank defines the current fallback rank.
  45749. * @returns the new fallback rank.
  45750. */
  45751. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45752. /**
  45753. * Add the required uniforms to the current list.
  45754. * @param uniforms defines the current uniform list.
  45755. */
  45756. static AddUniforms(uniforms: string[]): void;
  45757. /**
  45758. * Add the required samplers to the current list.
  45759. * @param samplers defines the current sampler list.
  45760. */
  45761. static AddSamplers(samplers: string[]): void;
  45762. /**
  45763. * Add the required uniforms to the current buffer.
  45764. * @param uniformBuffer defines the current uniform buffer.
  45765. */
  45766. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45767. /**
  45768. * Makes a duplicate of the current configuration into another one.
  45769. * @param configuration define the config where to copy the info
  45770. */
  45771. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45772. /**
  45773. * Serializes this Sub Surface configuration.
  45774. * @returns - An object with the serialized config.
  45775. */
  45776. serialize(): any;
  45777. /**
  45778. * Parses a anisotropy Configuration from a serialized object.
  45779. * @param source - Serialized object.
  45780. * @param scene Defines the scene we are parsing for
  45781. * @param rootUrl Defines the rootUrl to load from
  45782. */
  45783. parse(source: any, scene: Scene, rootUrl: string): void;
  45784. }
  45785. }
  45786. declare module BABYLON {
  45787. /** @hidden */
  45788. export var pbrFragmentDeclaration: {
  45789. name: string;
  45790. shader: string;
  45791. };
  45792. }
  45793. declare module BABYLON {
  45794. /** @hidden */
  45795. export var pbrUboDeclaration: {
  45796. name: string;
  45797. shader: string;
  45798. };
  45799. }
  45800. declare module BABYLON {
  45801. /** @hidden */
  45802. export var pbrFragmentExtraDeclaration: {
  45803. name: string;
  45804. shader: string;
  45805. };
  45806. }
  45807. declare module BABYLON {
  45808. /** @hidden */
  45809. export var pbrFragmentSamplersDeclaration: {
  45810. name: string;
  45811. shader: string;
  45812. };
  45813. }
  45814. declare module BABYLON {
  45815. /** @hidden */
  45816. export var pbrHelperFunctions: {
  45817. name: string;
  45818. shader: string;
  45819. };
  45820. }
  45821. declare module BABYLON {
  45822. /** @hidden */
  45823. export var harmonicsFunctions: {
  45824. name: string;
  45825. shader: string;
  45826. };
  45827. }
  45828. declare module BABYLON {
  45829. /** @hidden */
  45830. export var pbrDirectLightingSetupFunctions: {
  45831. name: string;
  45832. shader: string;
  45833. };
  45834. }
  45835. declare module BABYLON {
  45836. /** @hidden */
  45837. export var pbrDirectLightingFalloffFunctions: {
  45838. name: string;
  45839. shader: string;
  45840. };
  45841. }
  45842. declare module BABYLON {
  45843. /** @hidden */
  45844. export var pbrBRDFFunctions: {
  45845. name: string;
  45846. shader: string;
  45847. };
  45848. }
  45849. declare module BABYLON {
  45850. /** @hidden */
  45851. export var pbrDirectLightingFunctions: {
  45852. name: string;
  45853. shader: string;
  45854. };
  45855. }
  45856. declare module BABYLON {
  45857. /** @hidden */
  45858. export var pbrIBLFunctions: {
  45859. name: string;
  45860. shader: string;
  45861. };
  45862. }
  45863. declare module BABYLON {
  45864. /** @hidden */
  45865. export var pbrDebug: {
  45866. name: string;
  45867. shader: string;
  45868. };
  45869. }
  45870. declare module BABYLON {
  45871. /** @hidden */
  45872. export var pbrPixelShader: {
  45873. name: string;
  45874. shader: string;
  45875. };
  45876. }
  45877. declare module BABYLON {
  45878. /** @hidden */
  45879. export var pbrVertexDeclaration: {
  45880. name: string;
  45881. shader: string;
  45882. };
  45883. }
  45884. declare module BABYLON {
  45885. /** @hidden */
  45886. export var pbrVertexShader: {
  45887. name: string;
  45888. shader: string;
  45889. };
  45890. }
  45891. declare module BABYLON {
  45892. /**
  45893. * Manages the defines for the PBR Material.
  45894. * @hidden
  45895. */
  45896. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45897. PBR: boolean;
  45898. MAINUV1: boolean;
  45899. MAINUV2: boolean;
  45900. UV1: boolean;
  45901. UV2: boolean;
  45902. ALBEDO: boolean;
  45903. ALBEDODIRECTUV: number;
  45904. VERTEXCOLOR: boolean;
  45905. AMBIENT: boolean;
  45906. AMBIENTDIRECTUV: number;
  45907. AMBIENTINGRAYSCALE: boolean;
  45908. OPACITY: boolean;
  45909. VERTEXALPHA: boolean;
  45910. OPACITYDIRECTUV: number;
  45911. OPACITYRGB: boolean;
  45912. ALPHATEST: boolean;
  45913. DEPTHPREPASS: boolean;
  45914. ALPHABLEND: boolean;
  45915. ALPHAFROMALBEDO: boolean;
  45916. ALPHATESTVALUE: string;
  45917. SPECULAROVERALPHA: boolean;
  45918. RADIANCEOVERALPHA: boolean;
  45919. ALPHAFRESNEL: boolean;
  45920. LINEARALPHAFRESNEL: boolean;
  45921. PREMULTIPLYALPHA: boolean;
  45922. EMISSIVE: boolean;
  45923. EMISSIVEDIRECTUV: number;
  45924. REFLECTIVITY: boolean;
  45925. REFLECTIVITYDIRECTUV: number;
  45926. SPECULARTERM: boolean;
  45927. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45928. MICROSURFACEAUTOMATIC: boolean;
  45929. LODBASEDMICROSFURACE: boolean;
  45930. MICROSURFACEMAP: boolean;
  45931. MICROSURFACEMAPDIRECTUV: number;
  45932. METALLICWORKFLOW: boolean;
  45933. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45934. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45935. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45936. AOSTOREINMETALMAPRED: boolean;
  45937. ENVIRONMENTBRDF: boolean;
  45938. ENVIRONMENTBRDF_RGBD: boolean;
  45939. NORMAL: boolean;
  45940. TANGENT: boolean;
  45941. BUMP: boolean;
  45942. BUMPDIRECTUV: number;
  45943. OBJECTSPACE_NORMALMAP: boolean;
  45944. PARALLAX: boolean;
  45945. PARALLAXOCCLUSION: boolean;
  45946. NORMALXYSCALE: boolean;
  45947. LIGHTMAP: boolean;
  45948. LIGHTMAPDIRECTUV: number;
  45949. USELIGHTMAPASSHADOWMAP: boolean;
  45950. GAMMALIGHTMAP: boolean;
  45951. REFLECTION: boolean;
  45952. REFLECTIONMAP_3D: boolean;
  45953. REFLECTIONMAP_SPHERICAL: boolean;
  45954. REFLECTIONMAP_PLANAR: boolean;
  45955. REFLECTIONMAP_CUBIC: boolean;
  45956. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45957. REFLECTIONMAP_PROJECTION: boolean;
  45958. REFLECTIONMAP_SKYBOX: boolean;
  45959. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45960. REFLECTIONMAP_EXPLICIT: boolean;
  45961. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45962. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45963. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45964. INVERTCUBICMAP: boolean;
  45965. USESPHERICALFROMREFLECTIONMAP: boolean;
  45966. USEIRRADIANCEMAP: boolean;
  45967. SPHERICAL_HARMONICS: boolean;
  45968. USESPHERICALINVERTEX: boolean;
  45969. REFLECTIONMAP_OPPOSITEZ: boolean;
  45970. LODINREFLECTIONALPHA: boolean;
  45971. GAMMAREFLECTION: boolean;
  45972. RGBDREFLECTION: boolean;
  45973. LINEARSPECULARREFLECTION: boolean;
  45974. RADIANCEOCCLUSION: boolean;
  45975. HORIZONOCCLUSION: boolean;
  45976. INSTANCES: boolean;
  45977. NUM_BONE_INFLUENCERS: number;
  45978. BonesPerMesh: number;
  45979. BONETEXTURE: boolean;
  45980. NONUNIFORMSCALING: boolean;
  45981. MORPHTARGETS: boolean;
  45982. MORPHTARGETS_NORMAL: boolean;
  45983. MORPHTARGETS_TANGENT: boolean;
  45984. MORPHTARGETS_UV: boolean;
  45985. NUM_MORPH_INFLUENCERS: number;
  45986. IMAGEPROCESSING: boolean;
  45987. VIGNETTE: boolean;
  45988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45989. VIGNETTEBLENDMODEOPAQUE: boolean;
  45990. TONEMAPPING: boolean;
  45991. TONEMAPPING_ACES: boolean;
  45992. CONTRAST: boolean;
  45993. COLORCURVES: boolean;
  45994. COLORGRADING: boolean;
  45995. COLORGRADING3D: boolean;
  45996. SAMPLER3DGREENDEPTH: boolean;
  45997. SAMPLER3DBGRMAP: boolean;
  45998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45999. EXPOSURE: boolean;
  46000. MULTIVIEW: boolean;
  46001. USEPHYSICALLIGHTFALLOFF: boolean;
  46002. USEGLTFLIGHTFALLOFF: boolean;
  46003. TWOSIDEDLIGHTING: boolean;
  46004. SHADOWFLOAT: boolean;
  46005. CLIPPLANE: boolean;
  46006. CLIPPLANE2: boolean;
  46007. CLIPPLANE3: boolean;
  46008. CLIPPLANE4: boolean;
  46009. POINTSIZE: boolean;
  46010. FOG: boolean;
  46011. LOGARITHMICDEPTH: boolean;
  46012. FORCENORMALFORWARD: boolean;
  46013. SPECULARAA: boolean;
  46014. CLEARCOAT: boolean;
  46015. CLEARCOAT_DEFAULTIOR: boolean;
  46016. CLEARCOAT_TEXTURE: boolean;
  46017. CLEARCOAT_TEXTUREDIRECTUV: number;
  46018. CLEARCOAT_BUMP: boolean;
  46019. CLEARCOAT_BUMPDIRECTUV: number;
  46020. CLEARCOAT_TINT: boolean;
  46021. CLEARCOAT_TINT_TEXTURE: boolean;
  46022. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46023. ANISOTROPIC: boolean;
  46024. ANISOTROPIC_TEXTURE: boolean;
  46025. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46026. BRDF_V_HEIGHT_CORRELATED: boolean;
  46027. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46028. SHEEN: boolean;
  46029. SHEEN_TEXTURE: boolean;
  46030. SHEEN_TEXTUREDIRECTUV: number;
  46031. SHEEN_LINKWITHALBEDO: boolean;
  46032. SUBSURFACE: boolean;
  46033. SS_REFRACTION: boolean;
  46034. SS_TRANSLUCENCY: boolean;
  46035. SS_SCATERRING: boolean;
  46036. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46037. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46038. SS_REFRACTIONMAP_3D: boolean;
  46039. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46040. SS_LODINREFRACTIONALPHA: boolean;
  46041. SS_GAMMAREFRACTION: boolean;
  46042. SS_RGBDREFRACTION: boolean;
  46043. SS_LINEARSPECULARREFRACTION: boolean;
  46044. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46045. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46046. UNLIT: boolean;
  46047. DEBUGMODE: number;
  46048. /**
  46049. * Initializes the PBR Material defines.
  46050. */
  46051. constructor();
  46052. /**
  46053. * Resets the PBR Material defines.
  46054. */
  46055. reset(): void;
  46056. }
  46057. /**
  46058. * The Physically based material base class of BJS.
  46059. *
  46060. * This offers the main features of a standard PBR material.
  46061. * For more information, please refer to the documentation :
  46062. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46063. */
  46064. export abstract class PBRBaseMaterial extends PushMaterial {
  46065. /**
  46066. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46067. */
  46068. static readonly PBRMATERIAL_OPAQUE: number;
  46069. /**
  46070. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46071. */
  46072. static readonly PBRMATERIAL_ALPHATEST: number;
  46073. /**
  46074. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46075. */
  46076. static readonly PBRMATERIAL_ALPHABLEND: number;
  46077. /**
  46078. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46079. * They are also discarded below the alpha cutoff threshold to improve performances.
  46080. */
  46081. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46082. /**
  46083. * Defines the default value of how much AO map is occluding the analytical lights
  46084. * (point spot...).
  46085. */
  46086. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46087. /**
  46088. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46089. */
  46090. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46091. /**
  46092. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46093. * to enhance interoperability with other engines.
  46094. */
  46095. static readonly LIGHTFALLOFF_GLTF: number;
  46096. /**
  46097. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46098. * to enhance interoperability with other materials.
  46099. */
  46100. static readonly LIGHTFALLOFF_STANDARD: number;
  46101. /**
  46102. * Intensity of the direct lights e.g. the four lights available in your scene.
  46103. * This impacts both the direct diffuse and specular highlights.
  46104. */
  46105. protected _directIntensity: number;
  46106. /**
  46107. * Intensity of the emissive part of the material.
  46108. * This helps controlling the emissive effect without modifying the emissive color.
  46109. */
  46110. protected _emissiveIntensity: number;
  46111. /**
  46112. * Intensity of the environment e.g. how much the environment will light the object
  46113. * either through harmonics for rough material or through the refelction for shiny ones.
  46114. */
  46115. protected _environmentIntensity: number;
  46116. /**
  46117. * This is a special control allowing the reduction of the specular highlights coming from the
  46118. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46119. */
  46120. protected _specularIntensity: number;
  46121. /**
  46122. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46123. */
  46124. private _lightingInfos;
  46125. /**
  46126. * Debug Control allowing disabling the bump map on this material.
  46127. */
  46128. protected _disableBumpMap: boolean;
  46129. /**
  46130. * AKA Diffuse Texture in standard nomenclature.
  46131. */
  46132. protected _albedoTexture: Nullable<BaseTexture>;
  46133. /**
  46134. * AKA Occlusion Texture in other nomenclature.
  46135. */
  46136. protected _ambientTexture: Nullable<BaseTexture>;
  46137. /**
  46138. * AKA Occlusion Texture Intensity in other nomenclature.
  46139. */
  46140. protected _ambientTextureStrength: number;
  46141. /**
  46142. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46143. * 1 means it completely occludes it
  46144. * 0 mean it has no impact
  46145. */
  46146. protected _ambientTextureImpactOnAnalyticalLights: number;
  46147. /**
  46148. * Stores the alpha values in a texture.
  46149. */
  46150. protected _opacityTexture: Nullable<BaseTexture>;
  46151. /**
  46152. * Stores the reflection values in a texture.
  46153. */
  46154. protected _reflectionTexture: Nullable<BaseTexture>;
  46155. /**
  46156. * Stores the emissive values in a texture.
  46157. */
  46158. protected _emissiveTexture: Nullable<BaseTexture>;
  46159. /**
  46160. * AKA Specular texture in other nomenclature.
  46161. */
  46162. protected _reflectivityTexture: Nullable<BaseTexture>;
  46163. /**
  46164. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46165. */
  46166. protected _metallicTexture: Nullable<BaseTexture>;
  46167. /**
  46168. * Specifies the metallic scalar of the metallic/roughness workflow.
  46169. * Can also be used to scale the metalness values of the metallic texture.
  46170. */
  46171. protected _metallic: Nullable<number>;
  46172. /**
  46173. * Specifies the roughness scalar of the metallic/roughness workflow.
  46174. * Can also be used to scale the roughness values of the metallic texture.
  46175. */
  46176. protected _roughness: Nullable<number>;
  46177. /**
  46178. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46179. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46180. */
  46181. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46182. /**
  46183. * Stores surface normal data used to displace a mesh in a texture.
  46184. */
  46185. protected _bumpTexture: Nullable<BaseTexture>;
  46186. /**
  46187. * Stores the pre-calculated light information of a mesh in a texture.
  46188. */
  46189. protected _lightmapTexture: Nullable<BaseTexture>;
  46190. /**
  46191. * The color of a material in ambient lighting.
  46192. */
  46193. protected _ambientColor: Color3;
  46194. /**
  46195. * AKA Diffuse Color in other nomenclature.
  46196. */
  46197. protected _albedoColor: Color3;
  46198. /**
  46199. * AKA Specular Color in other nomenclature.
  46200. */
  46201. protected _reflectivityColor: Color3;
  46202. /**
  46203. * The color applied when light is reflected from a material.
  46204. */
  46205. protected _reflectionColor: Color3;
  46206. /**
  46207. * The color applied when light is emitted from a material.
  46208. */
  46209. protected _emissiveColor: Color3;
  46210. /**
  46211. * AKA Glossiness in other nomenclature.
  46212. */
  46213. protected _microSurface: number;
  46214. /**
  46215. * Specifies that the material will use the light map as a show map.
  46216. */
  46217. protected _useLightmapAsShadowmap: boolean;
  46218. /**
  46219. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46220. * makes the reflect vector face the model (under horizon).
  46221. */
  46222. protected _useHorizonOcclusion: boolean;
  46223. /**
  46224. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46225. * too much the area relying on ambient texture to define their ambient occlusion.
  46226. */
  46227. protected _useRadianceOcclusion: boolean;
  46228. /**
  46229. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46230. */
  46231. protected _useAlphaFromAlbedoTexture: boolean;
  46232. /**
  46233. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46234. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46235. */
  46236. protected _useSpecularOverAlpha: boolean;
  46237. /**
  46238. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46239. */
  46240. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46241. /**
  46242. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46243. */
  46244. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46245. /**
  46246. * Specifies if the metallic texture contains the roughness information in its green channel.
  46247. */
  46248. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46249. /**
  46250. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46251. */
  46252. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46253. /**
  46254. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46255. */
  46256. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46257. /**
  46258. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46259. */
  46260. protected _useAmbientInGrayScale: boolean;
  46261. /**
  46262. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46263. * The material will try to infer what glossiness each pixel should be.
  46264. */
  46265. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46266. /**
  46267. * Defines the falloff type used in this material.
  46268. * It by default is Physical.
  46269. */
  46270. protected _lightFalloff: number;
  46271. /**
  46272. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46273. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46274. */
  46275. protected _useRadianceOverAlpha: boolean;
  46276. /**
  46277. * Allows using an object space normal map (instead of tangent space).
  46278. */
  46279. protected _useObjectSpaceNormalMap: boolean;
  46280. /**
  46281. * Allows using the bump map in parallax mode.
  46282. */
  46283. protected _useParallax: boolean;
  46284. /**
  46285. * Allows using the bump map in parallax occlusion mode.
  46286. */
  46287. protected _useParallaxOcclusion: boolean;
  46288. /**
  46289. * Controls the scale bias of the parallax mode.
  46290. */
  46291. protected _parallaxScaleBias: number;
  46292. /**
  46293. * If sets to true, disables all the lights affecting the material.
  46294. */
  46295. protected _disableLighting: boolean;
  46296. /**
  46297. * Number of Simultaneous lights allowed on the material.
  46298. */
  46299. protected _maxSimultaneousLights: number;
  46300. /**
  46301. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46302. */
  46303. protected _invertNormalMapX: boolean;
  46304. /**
  46305. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46306. */
  46307. protected _invertNormalMapY: boolean;
  46308. /**
  46309. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46310. */
  46311. protected _twoSidedLighting: boolean;
  46312. /**
  46313. * Defines the alpha limits in alpha test mode.
  46314. */
  46315. protected _alphaCutOff: number;
  46316. /**
  46317. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46318. */
  46319. protected _forceAlphaTest: boolean;
  46320. /**
  46321. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46322. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46323. */
  46324. protected _useAlphaFresnel: boolean;
  46325. /**
  46326. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46327. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46328. */
  46329. protected _useLinearAlphaFresnel: boolean;
  46330. /**
  46331. * The transparency mode of the material.
  46332. */
  46333. protected _transparencyMode: Nullable<number>;
  46334. /**
  46335. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46336. * from cos thetav and roughness:
  46337. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46338. */
  46339. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46340. /**
  46341. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46342. */
  46343. protected _forceIrradianceInFragment: boolean;
  46344. /**
  46345. * Force normal to face away from face.
  46346. */
  46347. protected _forceNormalForward: boolean;
  46348. /**
  46349. * Enables specular anti aliasing in the PBR shader.
  46350. * It will both interacts on the Geometry for analytical and IBL lighting.
  46351. * It also prefilter the roughness map based on the bump values.
  46352. */
  46353. protected _enableSpecularAntiAliasing: boolean;
  46354. /**
  46355. * Default configuration related to image processing available in the PBR Material.
  46356. */
  46357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46358. /**
  46359. * Keep track of the image processing observer to allow dispose and replace.
  46360. */
  46361. private _imageProcessingObserver;
  46362. /**
  46363. * Attaches a new image processing configuration to the PBR Material.
  46364. * @param configuration
  46365. */
  46366. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46367. /**
  46368. * Stores the available render targets.
  46369. */
  46370. private _renderTargets;
  46371. /**
  46372. * Sets the global ambient color for the material used in lighting calculations.
  46373. */
  46374. private _globalAmbientColor;
  46375. /**
  46376. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46377. */
  46378. private _useLogarithmicDepth;
  46379. /**
  46380. * If set to true, no lighting calculations will be applied.
  46381. */
  46382. private _unlit;
  46383. private _debugMode;
  46384. /**
  46385. * @hidden
  46386. * This is reserved for the inspector.
  46387. * Defines the material debug mode.
  46388. * It helps seeing only some components of the material while troubleshooting.
  46389. */
  46390. debugMode: number;
  46391. /**
  46392. * @hidden
  46393. * This is reserved for the inspector.
  46394. * Specify from where on screen the debug mode should start.
  46395. * The value goes from -1 (full screen) to 1 (not visible)
  46396. * It helps with side by side comparison against the final render
  46397. * This defaults to -1
  46398. */
  46399. private debugLimit;
  46400. /**
  46401. * @hidden
  46402. * This is reserved for the inspector.
  46403. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46404. * You can use the factor to better multiply the final value.
  46405. */
  46406. private debugFactor;
  46407. /**
  46408. * Defines the clear coat layer parameters for the material.
  46409. */
  46410. readonly clearCoat: PBRClearCoatConfiguration;
  46411. /**
  46412. * Defines the anisotropic parameters for the material.
  46413. */
  46414. readonly anisotropy: PBRAnisotropicConfiguration;
  46415. /**
  46416. * Defines the BRDF parameters for the material.
  46417. */
  46418. readonly brdf: PBRBRDFConfiguration;
  46419. /**
  46420. * Defines the Sheen parameters for the material.
  46421. */
  46422. readonly sheen: PBRSheenConfiguration;
  46423. /**
  46424. * Defines the SubSurface parameters for the material.
  46425. */
  46426. readonly subSurface: PBRSubSurfaceConfiguration;
  46427. /**
  46428. * Custom callback helping to override the default shader used in the material.
  46429. */
  46430. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46431. /**
  46432. * Instantiates a new PBRMaterial instance.
  46433. *
  46434. * @param name The material name
  46435. * @param scene The scene the material will be use in.
  46436. */
  46437. constructor(name: string, scene: Scene);
  46438. /**
  46439. * Gets a boolean indicating that current material needs to register RTT
  46440. */
  46441. readonly hasRenderTargetTextures: boolean;
  46442. /**
  46443. * Gets the name of the material class.
  46444. */
  46445. getClassName(): string;
  46446. /**
  46447. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46448. */
  46449. /**
  46450. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46451. */
  46452. useLogarithmicDepth: boolean;
  46453. /**
  46454. * Gets the current transparency mode.
  46455. */
  46456. /**
  46457. * Sets the transparency mode of the material.
  46458. *
  46459. * | Value | Type | Description |
  46460. * | ----- | ----------------------------------- | ----------- |
  46461. * | 0 | OPAQUE | |
  46462. * | 1 | ALPHATEST | |
  46463. * | 2 | ALPHABLEND | |
  46464. * | 3 | ALPHATESTANDBLEND | |
  46465. *
  46466. */
  46467. transparencyMode: Nullable<number>;
  46468. /**
  46469. * Returns true if alpha blending should be disabled.
  46470. */
  46471. private readonly _disableAlphaBlending;
  46472. /**
  46473. * Specifies whether or not this material should be rendered in alpha blend mode.
  46474. */
  46475. needAlphaBlending(): boolean;
  46476. /**
  46477. * Specifies if the mesh will require alpha blending.
  46478. * @param mesh - BJS mesh.
  46479. */
  46480. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46481. /**
  46482. * Specifies whether or not this material should be rendered in alpha test mode.
  46483. */
  46484. needAlphaTesting(): boolean;
  46485. /**
  46486. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46487. */
  46488. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46489. /**
  46490. * Gets the texture used for the alpha test.
  46491. */
  46492. getAlphaTestTexture(): Nullable<BaseTexture>;
  46493. /**
  46494. * Specifies that the submesh is ready to be used.
  46495. * @param mesh - BJS mesh.
  46496. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46497. * @param useInstances - Specifies that instances should be used.
  46498. * @returns - boolean indicating that the submesh is ready or not.
  46499. */
  46500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46501. /**
  46502. * Specifies if the material uses metallic roughness workflow.
  46503. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46504. */
  46505. isMetallicWorkflow(): boolean;
  46506. private _prepareEffect;
  46507. private _prepareDefines;
  46508. /**
  46509. * Force shader compilation
  46510. */
  46511. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46512. clipPlane: boolean;
  46513. }>): void;
  46514. /**
  46515. * Initializes the uniform buffer layout for the shader.
  46516. */
  46517. buildUniformLayout(): void;
  46518. /**
  46519. * Unbinds the material from the mesh
  46520. */
  46521. unbind(): void;
  46522. /**
  46523. * Binds the submesh data.
  46524. * @param world - The world matrix.
  46525. * @param mesh - The BJS mesh.
  46526. * @param subMesh - A submesh of the BJS mesh.
  46527. */
  46528. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46529. /**
  46530. * Returns the animatable textures.
  46531. * @returns - Array of animatable textures.
  46532. */
  46533. getAnimatables(): IAnimatable[];
  46534. /**
  46535. * Returns the texture used for reflections.
  46536. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46537. */
  46538. private _getReflectionTexture;
  46539. /**
  46540. * Returns an array of the actively used textures.
  46541. * @returns - Array of BaseTextures
  46542. */
  46543. getActiveTextures(): BaseTexture[];
  46544. /**
  46545. * Checks to see if a texture is used in the material.
  46546. * @param texture - Base texture to use.
  46547. * @returns - Boolean specifying if a texture is used in the material.
  46548. */
  46549. hasTexture(texture: BaseTexture): boolean;
  46550. /**
  46551. * Disposes the resources of the material.
  46552. * @param forceDisposeEffect - Forces the disposal of effects.
  46553. * @param forceDisposeTextures - Forces the disposal of all textures.
  46554. */
  46555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46556. }
  46557. }
  46558. declare module BABYLON {
  46559. /**
  46560. * The Physically based material of BJS.
  46561. *
  46562. * This offers the main features of a standard PBR material.
  46563. * For more information, please refer to the documentation :
  46564. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46565. */
  46566. export class PBRMaterial extends PBRBaseMaterial {
  46567. /**
  46568. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46569. */
  46570. static readonly PBRMATERIAL_OPAQUE: number;
  46571. /**
  46572. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46573. */
  46574. static readonly PBRMATERIAL_ALPHATEST: number;
  46575. /**
  46576. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46577. */
  46578. static readonly PBRMATERIAL_ALPHABLEND: number;
  46579. /**
  46580. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46581. * They are also discarded below the alpha cutoff threshold to improve performances.
  46582. */
  46583. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46584. /**
  46585. * Defines the default value of how much AO map is occluding the analytical lights
  46586. * (point spot...).
  46587. */
  46588. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46589. /**
  46590. * Intensity of the direct lights e.g. the four lights available in your scene.
  46591. * This impacts both the direct diffuse and specular highlights.
  46592. */
  46593. directIntensity: number;
  46594. /**
  46595. * Intensity of the emissive part of the material.
  46596. * This helps controlling the emissive effect without modifying the emissive color.
  46597. */
  46598. emissiveIntensity: number;
  46599. /**
  46600. * Intensity of the environment e.g. how much the environment will light the object
  46601. * either through harmonics for rough material or through the refelction for shiny ones.
  46602. */
  46603. environmentIntensity: number;
  46604. /**
  46605. * This is a special control allowing the reduction of the specular highlights coming from the
  46606. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46607. */
  46608. specularIntensity: number;
  46609. /**
  46610. * Debug Control allowing disabling the bump map on this material.
  46611. */
  46612. disableBumpMap: boolean;
  46613. /**
  46614. * AKA Diffuse Texture in standard nomenclature.
  46615. */
  46616. albedoTexture: BaseTexture;
  46617. /**
  46618. * AKA Occlusion Texture in other nomenclature.
  46619. */
  46620. ambientTexture: BaseTexture;
  46621. /**
  46622. * AKA Occlusion Texture Intensity in other nomenclature.
  46623. */
  46624. ambientTextureStrength: number;
  46625. /**
  46626. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46627. * 1 means it completely occludes it
  46628. * 0 mean it has no impact
  46629. */
  46630. ambientTextureImpactOnAnalyticalLights: number;
  46631. /**
  46632. * Stores the alpha values in a texture.
  46633. */
  46634. opacityTexture: BaseTexture;
  46635. /**
  46636. * Stores the reflection values in a texture.
  46637. */
  46638. reflectionTexture: Nullable<BaseTexture>;
  46639. /**
  46640. * Stores the emissive values in a texture.
  46641. */
  46642. emissiveTexture: BaseTexture;
  46643. /**
  46644. * AKA Specular texture in other nomenclature.
  46645. */
  46646. reflectivityTexture: BaseTexture;
  46647. /**
  46648. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46649. */
  46650. metallicTexture: BaseTexture;
  46651. /**
  46652. * Specifies the metallic scalar of the metallic/roughness workflow.
  46653. * Can also be used to scale the metalness values of the metallic texture.
  46654. */
  46655. metallic: Nullable<number>;
  46656. /**
  46657. * Specifies the roughness scalar of the metallic/roughness workflow.
  46658. * Can also be used to scale the roughness values of the metallic texture.
  46659. */
  46660. roughness: Nullable<number>;
  46661. /**
  46662. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46663. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46664. */
  46665. microSurfaceTexture: BaseTexture;
  46666. /**
  46667. * Stores surface normal data used to displace a mesh in a texture.
  46668. */
  46669. bumpTexture: BaseTexture;
  46670. /**
  46671. * Stores the pre-calculated light information of a mesh in a texture.
  46672. */
  46673. lightmapTexture: BaseTexture;
  46674. /**
  46675. * Stores the refracted light information in a texture.
  46676. */
  46677. refractionTexture: Nullable<BaseTexture>;
  46678. /**
  46679. * The color of a material in ambient lighting.
  46680. */
  46681. ambientColor: Color3;
  46682. /**
  46683. * AKA Diffuse Color in other nomenclature.
  46684. */
  46685. albedoColor: Color3;
  46686. /**
  46687. * AKA Specular Color in other nomenclature.
  46688. */
  46689. reflectivityColor: Color3;
  46690. /**
  46691. * The color reflected from the material.
  46692. */
  46693. reflectionColor: Color3;
  46694. /**
  46695. * The color emitted from the material.
  46696. */
  46697. emissiveColor: Color3;
  46698. /**
  46699. * AKA Glossiness in other nomenclature.
  46700. */
  46701. microSurface: number;
  46702. /**
  46703. * source material index of refraction (IOR)' / 'destination material IOR.
  46704. */
  46705. indexOfRefraction: number;
  46706. /**
  46707. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46708. */
  46709. invertRefractionY: boolean;
  46710. /**
  46711. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46712. * Materials half opaque for instance using refraction could benefit from this control.
  46713. */
  46714. linkRefractionWithTransparency: boolean;
  46715. /**
  46716. * If true, the light map contains occlusion information instead of lighting info.
  46717. */
  46718. useLightmapAsShadowmap: boolean;
  46719. /**
  46720. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46721. */
  46722. useAlphaFromAlbedoTexture: boolean;
  46723. /**
  46724. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46725. */
  46726. forceAlphaTest: boolean;
  46727. /**
  46728. * Defines the alpha limits in alpha test mode.
  46729. */
  46730. alphaCutOff: number;
  46731. /**
  46732. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46733. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46734. */
  46735. useSpecularOverAlpha: boolean;
  46736. /**
  46737. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46738. */
  46739. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46740. /**
  46741. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46742. */
  46743. useRoughnessFromMetallicTextureAlpha: boolean;
  46744. /**
  46745. * Specifies if the metallic texture contains the roughness information in its green channel.
  46746. */
  46747. useRoughnessFromMetallicTextureGreen: boolean;
  46748. /**
  46749. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46750. */
  46751. useMetallnessFromMetallicTextureBlue: boolean;
  46752. /**
  46753. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46754. */
  46755. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46756. /**
  46757. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46758. */
  46759. useAmbientInGrayScale: boolean;
  46760. /**
  46761. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46762. * The material will try to infer what glossiness each pixel should be.
  46763. */
  46764. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46765. /**
  46766. * BJS is using an harcoded light falloff based on a manually sets up range.
  46767. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46768. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46769. */
  46770. /**
  46771. * BJS is using an harcoded light falloff based on a manually sets up range.
  46772. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46773. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46774. */
  46775. usePhysicalLightFalloff: boolean;
  46776. /**
  46777. * In order to support the falloff compatibility with gltf, a special mode has been added
  46778. * to reproduce the gltf light falloff.
  46779. */
  46780. /**
  46781. * In order to support the falloff compatibility with gltf, a special mode has been added
  46782. * to reproduce the gltf light falloff.
  46783. */
  46784. useGLTFLightFalloff: boolean;
  46785. /**
  46786. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46787. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46788. */
  46789. useRadianceOverAlpha: boolean;
  46790. /**
  46791. * Allows using an object space normal map (instead of tangent space).
  46792. */
  46793. useObjectSpaceNormalMap: boolean;
  46794. /**
  46795. * Allows using the bump map in parallax mode.
  46796. */
  46797. useParallax: boolean;
  46798. /**
  46799. * Allows using the bump map in parallax occlusion mode.
  46800. */
  46801. useParallaxOcclusion: boolean;
  46802. /**
  46803. * Controls the scale bias of the parallax mode.
  46804. */
  46805. parallaxScaleBias: number;
  46806. /**
  46807. * If sets to true, disables all the lights affecting the material.
  46808. */
  46809. disableLighting: boolean;
  46810. /**
  46811. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46812. */
  46813. forceIrradianceInFragment: boolean;
  46814. /**
  46815. * Number of Simultaneous lights allowed on the material.
  46816. */
  46817. maxSimultaneousLights: number;
  46818. /**
  46819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46820. */
  46821. invertNormalMapX: boolean;
  46822. /**
  46823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46824. */
  46825. invertNormalMapY: boolean;
  46826. /**
  46827. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46828. */
  46829. twoSidedLighting: boolean;
  46830. /**
  46831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46832. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46833. */
  46834. useAlphaFresnel: boolean;
  46835. /**
  46836. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46837. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46838. */
  46839. useLinearAlphaFresnel: boolean;
  46840. /**
  46841. * Let user defines the brdf lookup texture used for IBL.
  46842. * A default 8bit version is embedded but you could point at :
  46843. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46844. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46845. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46846. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46847. */
  46848. environmentBRDFTexture: Nullable<BaseTexture>;
  46849. /**
  46850. * Force normal to face away from face.
  46851. */
  46852. forceNormalForward: boolean;
  46853. /**
  46854. * Enables specular anti aliasing in the PBR shader.
  46855. * It will both interacts on the Geometry for analytical and IBL lighting.
  46856. * It also prefilter the roughness map based on the bump values.
  46857. */
  46858. enableSpecularAntiAliasing: boolean;
  46859. /**
  46860. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46861. * makes the reflect vector face the model (under horizon).
  46862. */
  46863. useHorizonOcclusion: boolean;
  46864. /**
  46865. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46866. * too much the area relying on ambient texture to define their ambient occlusion.
  46867. */
  46868. useRadianceOcclusion: boolean;
  46869. /**
  46870. * If set to true, no lighting calculations will be applied.
  46871. */
  46872. unlit: boolean;
  46873. /**
  46874. * Gets the image processing configuration used either in this material.
  46875. */
  46876. /**
  46877. * Sets the Default image processing configuration used either in the this material.
  46878. *
  46879. * If sets to null, the scene one is in use.
  46880. */
  46881. imageProcessingConfiguration: ImageProcessingConfiguration;
  46882. /**
  46883. * Gets wether the color curves effect is enabled.
  46884. */
  46885. /**
  46886. * Sets wether the color curves effect is enabled.
  46887. */
  46888. cameraColorCurvesEnabled: boolean;
  46889. /**
  46890. * Gets wether the color grading effect is enabled.
  46891. */
  46892. /**
  46893. * Gets wether the color grading effect is enabled.
  46894. */
  46895. cameraColorGradingEnabled: boolean;
  46896. /**
  46897. * Gets wether tonemapping is enabled or not.
  46898. */
  46899. /**
  46900. * Sets wether tonemapping is enabled or not
  46901. */
  46902. cameraToneMappingEnabled: boolean;
  46903. /**
  46904. * The camera exposure used on this material.
  46905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46906. * This corresponds to a photographic exposure.
  46907. */
  46908. /**
  46909. * The camera exposure used on this material.
  46910. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46911. * This corresponds to a photographic exposure.
  46912. */
  46913. cameraExposure: number;
  46914. /**
  46915. * Gets The camera contrast used on this material.
  46916. */
  46917. /**
  46918. * Sets The camera contrast used on this material.
  46919. */
  46920. cameraContrast: number;
  46921. /**
  46922. * Gets the Color Grading 2D Lookup Texture.
  46923. */
  46924. /**
  46925. * Sets the Color Grading 2D Lookup Texture.
  46926. */
  46927. cameraColorGradingTexture: Nullable<BaseTexture>;
  46928. /**
  46929. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46931. * 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;
  46932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46933. */
  46934. /**
  46935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46937. * 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;
  46938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46939. */
  46940. cameraColorCurves: Nullable<ColorCurves>;
  46941. /**
  46942. * Instantiates a new PBRMaterial instance.
  46943. *
  46944. * @param name The material name
  46945. * @param scene The scene the material will be use in.
  46946. */
  46947. constructor(name: string, scene: Scene);
  46948. /**
  46949. * Returns the name of this material class.
  46950. */
  46951. getClassName(): string;
  46952. /**
  46953. * Makes a duplicate of the current material.
  46954. * @param name - name to use for the new material.
  46955. */
  46956. clone(name: string): PBRMaterial;
  46957. /**
  46958. * Serializes this PBR Material.
  46959. * @returns - An object with the serialized material.
  46960. */
  46961. serialize(): any;
  46962. /**
  46963. * Parses a PBR Material from a serialized object.
  46964. * @param source - Serialized object.
  46965. * @param scene - BJS scene instance.
  46966. * @param rootUrl - url for the scene object
  46967. * @returns - PBRMaterial
  46968. */
  46969. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46970. }
  46971. }
  46972. declare module BABYLON {
  46973. /**
  46974. * Direct draw surface info
  46975. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46976. */
  46977. export interface DDSInfo {
  46978. /**
  46979. * Width of the texture
  46980. */
  46981. width: number;
  46982. /**
  46983. * Width of the texture
  46984. */
  46985. height: number;
  46986. /**
  46987. * Number of Mipmaps for the texture
  46988. * @see https://en.wikipedia.org/wiki/Mipmap
  46989. */
  46990. mipmapCount: number;
  46991. /**
  46992. * If the textures format is a known fourCC format
  46993. * @see https://www.fourcc.org/
  46994. */
  46995. isFourCC: boolean;
  46996. /**
  46997. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46998. */
  46999. isRGB: boolean;
  47000. /**
  47001. * If the texture is a lumincance format
  47002. */
  47003. isLuminance: boolean;
  47004. /**
  47005. * If this is a cube texture
  47006. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47007. */
  47008. isCube: boolean;
  47009. /**
  47010. * If the texture is a compressed format eg. FOURCC_DXT1
  47011. */
  47012. isCompressed: boolean;
  47013. /**
  47014. * The dxgiFormat of the texture
  47015. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47016. */
  47017. dxgiFormat: number;
  47018. /**
  47019. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47020. */
  47021. textureType: number;
  47022. /**
  47023. * Sphericle polynomial created for the dds texture
  47024. */
  47025. sphericalPolynomial?: SphericalPolynomial;
  47026. }
  47027. /**
  47028. * Class used to provide DDS decompression tools
  47029. */
  47030. export class DDSTools {
  47031. /**
  47032. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47033. */
  47034. static StoreLODInAlphaChannel: boolean;
  47035. /**
  47036. * Gets DDS information from an array buffer
  47037. * @param arrayBuffer defines the array buffer to read data from
  47038. * @returns the DDS information
  47039. */
  47040. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47041. private static _FloatView;
  47042. private static _Int32View;
  47043. private static _ToHalfFloat;
  47044. private static _FromHalfFloat;
  47045. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47046. private static _GetHalfFloatRGBAArrayBuffer;
  47047. private static _GetFloatRGBAArrayBuffer;
  47048. private static _GetFloatAsUIntRGBAArrayBuffer;
  47049. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47050. private static _GetRGBAArrayBuffer;
  47051. private static _ExtractLongWordOrder;
  47052. private static _GetRGBArrayBuffer;
  47053. private static _GetLuminanceArrayBuffer;
  47054. /**
  47055. * Uploads DDS Levels to a Babylon Texture
  47056. * @hidden
  47057. */
  47058. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47059. }
  47060. interface Engine {
  47061. /**
  47062. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47063. * @param rootUrl defines the url where the file to load is located
  47064. * @param scene defines the current scene
  47065. * @param lodScale defines scale to apply to the mip map selection
  47066. * @param lodOffset defines offset to apply to the mip map selection
  47067. * @param onLoad defines an optional callback raised when the texture is loaded
  47068. * @param onError defines an optional callback raised if there is an issue to load the texture
  47069. * @param format defines the format of the data
  47070. * @param forcedExtension defines the extension to use to pick the right loader
  47071. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47072. * @returns the cube texture as an InternalTexture
  47073. */
  47074. 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;
  47075. }
  47076. }
  47077. declare module BABYLON {
  47078. /**
  47079. * Implementation of the DDS Texture Loader.
  47080. * @hidden
  47081. */
  47082. export class _DDSTextureLoader implements IInternalTextureLoader {
  47083. /**
  47084. * Defines wether the loader supports cascade loading the different faces.
  47085. */
  47086. readonly supportCascades: boolean;
  47087. /**
  47088. * This returns if the loader support the current file information.
  47089. * @param extension defines the file extension of the file being loaded
  47090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47091. * @param fallback defines the fallback internal texture if any
  47092. * @param isBase64 defines whether the texture is encoded as a base64
  47093. * @param isBuffer defines whether the texture data are stored as a buffer
  47094. * @returns true if the loader can load the specified file
  47095. */
  47096. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47097. /**
  47098. * Transform the url before loading if required.
  47099. * @param rootUrl the url of the texture
  47100. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47101. * @returns the transformed texture
  47102. */
  47103. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47104. /**
  47105. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47106. * @param rootUrl the url of the texture
  47107. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47108. * @returns the fallback texture
  47109. */
  47110. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47111. /**
  47112. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47113. * @param data contains the texture data
  47114. * @param texture defines the BabylonJS internal texture
  47115. * @param createPolynomials will be true if polynomials have been requested
  47116. * @param onLoad defines the callback to trigger once the texture is ready
  47117. * @param onError defines the callback to trigger in case of error
  47118. */
  47119. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47120. /**
  47121. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47122. * @param data contains the texture data
  47123. * @param texture defines the BabylonJS internal texture
  47124. * @param callback defines the method to call once ready to upload
  47125. */
  47126. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47127. }
  47128. }
  47129. declare module BABYLON {
  47130. /** @hidden */
  47131. export var rgbdEncodePixelShader: {
  47132. name: string;
  47133. shader: string;
  47134. };
  47135. }
  47136. declare module BABYLON {
  47137. /**
  47138. * Raw texture data and descriptor sufficient for WebGL texture upload
  47139. */
  47140. export interface EnvironmentTextureInfo {
  47141. /**
  47142. * Version of the environment map
  47143. */
  47144. version: number;
  47145. /**
  47146. * Width of image
  47147. */
  47148. width: number;
  47149. /**
  47150. * Irradiance information stored in the file.
  47151. */
  47152. irradiance: any;
  47153. /**
  47154. * Specular information stored in the file.
  47155. */
  47156. specular: any;
  47157. }
  47158. /**
  47159. * Sets of helpers addressing the serialization and deserialization of environment texture
  47160. * stored in a BabylonJS env file.
  47161. * Those files are usually stored as .env files.
  47162. */
  47163. export class EnvironmentTextureTools {
  47164. /**
  47165. * Magic number identifying the env file.
  47166. */
  47167. private static _MagicBytes;
  47168. /**
  47169. * Gets the environment info from an env file.
  47170. * @param data The array buffer containing the .env bytes.
  47171. * @returns the environment file info (the json header) if successfully parsed.
  47172. */
  47173. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47174. /**
  47175. * Creates an environment texture from a loaded cube texture.
  47176. * @param texture defines the cube texture to convert in env file
  47177. * @return a promise containing the environment data if succesfull.
  47178. */
  47179. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47180. /**
  47181. * Creates a JSON representation of the spherical data.
  47182. * @param texture defines the texture containing the polynomials
  47183. * @return the JSON representation of the spherical info
  47184. */
  47185. private static _CreateEnvTextureIrradiance;
  47186. /**
  47187. * Uploads the texture info contained in the env file to the GPU.
  47188. * @param texture defines the internal texture to upload to
  47189. * @param arrayBuffer defines the buffer cotaining the data to load
  47190. * @param info defines the texture info retrieved through the GetEnvInfo method
  47191. * @returns a promise
  47192. */
  47193. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47194. /**
  47195. * Uploads the levels of image data to the GPU.
  47196. * @param texture defines the internal texture to upload to
  47197. * @param imageData defines the array buffer views of image data [mipmap][face]
  47198. * @returns a promise
  47199. */
  47200. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47201. /**
  47202. * Uploads spherical polynomials information to the texture.
  47203. * @param texture defines the texture we are trying to upload the information to
  47204. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47205. */
  47206. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47207. /** @hidden */
  47208. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47209. }
  47210. }
  47211. declare module BABYLON {
  47212. /**
  47213. * Implementation of the ENV Texture Loader.
  47214. * @hidden
  47215. */
  47216. export class _ENVTextureLoader implements IInternalTextureLoader {
  47217. /**
  47218. * Defines wether the loader supports cascade loading the different faces.
  47219. */
  47220. readonly supportCascades: boolean;
  47221. /**
  47222. * This returns if the loader support the current file information.
  47223. * @param extension defines the file extension of the file being loaded
  47224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47225. * @param fallback defines the fallback internal texture if any
  47226. * @param isBase64 defines whether the texture is encoded as a base64
  47227. * @param isBuffer defines whether the texture data are stored as a buffer
  47228. * @returns true if the loader can load the specified file
  47229. */
  47230. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47231. /**
  47232. * Transform the url before loading if required.
  47233. * @param rootUrl the url of the texture
  47234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47235. * @returns the transformed texture
  47236. */
  47237. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47238. /**
  47239. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47240. * @param rootUrl the url of the texture
  47241. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47242. * @returns the fallback texture
  47243. */
  47244. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47245. /**
  47246. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47247. * @param data contains the texture data
  47248. * @param texture defines the BabylonJS internal texture
  47249. * @param createPolynomials will be true if polynomials have been requested
  47250. * @param onLoad defines the callback to trigger once the texture is ready
  47251. * @param onError defines the callback to trigger in case of error
  47252. */
  47253. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47254. /**
  47255. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47256. * @param data contains the texture data
  47257. * @param texture defines the BabylonJS internal texture
  47258. * @param callback defines the method to call once ready to upload
  47259. */
  47260. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47261. }
  47262. }
  47263. declare module BABYLON {
  47264. /**
  47265. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47266. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47267. */
  47268. export class KhronosTextureContainer {
  47269. /** contents of the KTX container file */
  47270. arrayBuffer: any;
  47271. private static HEADER_LEN;
  47272. private static COMPRESSED_2D;
  47273. private static COMPRESSED_3D;
  47274. private static TEX_2D;
  47275. private static TEX_3D;
  47276. /**
  47277. * Gets the openGL type
  47278. */
  47279. glType: number;
  47280. /**
  47281. * Gets the openGL type size
  47282. */
  47283. glTypeSize: number;
  47284. /**
  47285. * Gets the openGL format
  47286. */
  47287. glFormat: number;
  47288. /**
  47289. * Gets the openGL internal format
  47290. */
  47291. glInternalFormat: number;
  47292. /**
  47293. * Gets the base internal format
  47294. */
  47295. glBaseInternalFormat: number;
  47296. /**
  47297. * Gets image width in pixel
  47298. */
  47299. pixelWidth: number;
  47300. /**
  47301. * Gets image height in pixel
  47302. */
  47303. pixelHeight: number;
  47304. /**
  47305. * Gets image depth in pixels
  47306. */
  47307. pixelDepth: number;
  47308. /**
  47309. * Gets the number of array elements
  47310. */
  47311. numberOfArrayElements: number;
  47312. /**
  47313. * Gets the number of faces
  47314. */
  47315. numberOfFaces: number;
  47316. /**
  47317. * Gets the number of mipmap levels
  47318. */
  47319. numberOfMipmapLevels: number;
  47320. /**
  47321. * Gets the bytes of key value data
  47322. */
  47323. bytesOfKeyValueData: number;
  47324. /**
  47325. * Gets the load type
  47326. */
  47327. loadType: number;
  47328. /**
  47329. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47330. */
  47331. isInvalid: boolean;
  47332. /**
  47333. * Creates a new KhronosTextureContainer
  47334. * @param arrayBuffer contents of the KTX container file
  47335. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47336. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47337. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47338. */
  47339. constructor(
  47340. /** contents of the KTX container file */
  47341. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47342. /**
  47343. * Uploads KTX content to a Babylon Texture.
  47344. * It is assumed that the texture has already been created & is currently bound
  47345. * @hidden
  47346. */
  47347. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47348. private _upload2DCompressedLevels;
  47349. }
  47350. }
  47351. declare module BABYLON {
  47352. /**
  47353. * Implementation of the KTX Texture Loader.
  47354. * @hidden
  47355. */
  47356. export class _KTXTextureLoader implements IInternalTextureLoader {
  47357. /**
  47358. * Defines wether the loader supports cascade loading the different faces.
  47359. */
  47360. readonly supportCascades: boolean;
  47361. /**
  47362. * This returns if the loader support the current file information.
  47363. * @param extension defines the file extension of the file being loaded
  47364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47365. * @param fallback defines the fallback internal texture if any
  47366. * @param isBase64 defines whether the texture is encoded as a base64
  47367. * @param isBuffer defines whether the texture data are stored as a buffer
  47368. * @returns true if the loader can load the specified file
  47369. */
  47370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47371. /**
  47372. * Transform the url before loading if required.
  47373. * @param rootUrl the url of the texture
  47374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47375. * @returns the transformed texture
  47376. */
  47377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47378. /**
  47379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47380. * @param rootUrl the url of the texture
  47381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47382. * @returns the fallback texture
  47383. */
  47384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47385. /**
  47386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47387. * @param data contains the texture data
  47388. * @param texture defines the BabylonJS internal texture
  47389. * @param createPolynomials will be true if polynomials have been requested
  47390. * @param onLoad defines the callback to trigger once the texture is ready
  47391. * @param onError defines the callback to trigger in case of error
  47392. */
  47393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47394. /**
  47395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47396. * @param data contains the texture data
  47397. * @param texture defines the BabylonJS internal texture
  47398. * @param callback defines the method to call once ready to upload
  47399. */
  47400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47401. }
  47402. }
  47403. declare module BABYLON {
  47404. /**
  47405. * Options for the default xr helper
  47406. */
  47407. export class WebXRDefaultExperienceOptions {
  47408. /**
  47409. * Floor meshes that should be used for teleporting
  47410. */
  47411. floorMeshes: Array<AbstractMesh>;
  47412. }
  47413. /**
  47414. * Default experience which provides a similar setup to the previous webVRExperience
  47415. */
  47416. export class WebXRDefaultExperience {
  47417. /**
  47418. * Base experience
  47419. */
  47420. baseExperience: WebXRExperienceHelper;
  47421. /**
  47422. * Input experience extension
  47423. */
  47424. input: WebXRInput;
  47425. /**
  47426. * Loads the controller models
  47427. */
  47428. controllerModelLoader: WebXRControllerModelLoader;
  47429. /**
  47430. * Enables laser pointer and selection
  47431. */
  47432. pointerSelection: WebXRControllerPointerSelection;
  47433. /**
  47434. * Enables teleportation
  47435. */
  47436. teleportation: WebXRControllerTeleportation;
  47437. /**
  47438. * Enables ui for enetering/exiting xr
  47439. */
  47440. enterExitUI: WebXREnterExitUI;
  47441. /**
  47442. * Default output canvas xr should render to
  47443. */
  47444. outputCanvas: WebXRManagedOutputCanvas;
  47445. /**
  47446. * Creates the default xr experience
  47447. * @param scene scene
  47448. * @param options options for basic configuration
  47449. * @returns resulting WebXRDefaultExperience
  47450. */
  47451. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47452. private constructor();
  47453. /**
  47454. * DIsposes of the experience helper
  47455. */
  47456. dispose(): void;
  47457. }
  47458. }
  47459. declare module BABYLON {
  47460. /** @hidden */
  47461. export var _forceSceneHelpersToBundle: boolean;
  47462. interface Scene {
  47463. /**
  47464. * Creates a default light for the scene.
  47465. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47466. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47467. */
  47468. createDefaultLight(replace?: boolean): void;
  47469. /**
  47470. * Creates a default camera for the scene.
  47471. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47473. * @param replace has default false, when true replaces the active camera in the scene
  47474. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47475. */
  47476. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47477. /**
  47478. * Creates a default camera and a default light.
  47479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47480. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47481. * @param replace has the default false, when true replaces the active camera/light in the scene
  47482. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47483. */
  47484. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47485. /**
  47486. * Creates a new sky box
  47487. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47488. * @param environmentTexture defines the texture to use as environment texture
  47489. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47490. * @param scale defines the overall scale of the skybox
  47491. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47492. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47493. * @returns a new mesh holding the sky box
  47494. */
  47495. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47496. /**
  47497. * Creates a new environment
  47498. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47499. * @param options defines the options you can use to configure the environment
  47500. * @returns the new EnvironmentHelper
  47501. */
  47502. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47503. /**
  47504. * Creates a new VREXperienceHelper
  47505. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47506. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47507. * @returns a new VREXperienceHelper
  47508. */
  47509. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47510. /**
  47511. * Creates a new WebXRDefaultExperience
  47512. * @see http://doc.babylonjs.com/how_to/webxr
  47513. * @param options experience options
  47514. * @returns a promise for a new WebXRDefaultExperience
  47515. */
  47516. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47522. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47523. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47524. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47525. */
  47526. export class VideoDome extends TransformNode {
  47527. /**
  47528. * Define the video source as a Monoscopic panoramic 360 video.
  47529. */
  47530. static readonly MODE_MONOSCOPIC: number;
  47531. /**
  47532. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47533. */
  47534. static readonly MODE_TOPBOTTOM: number;
  47535. /**
  47536. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47537. */
  47538. static readonly MODE_SIDEBYSIDE: number;
  47539. private _useDirectMapping;
  47540. /**
  47541. * The video texture being displayed on the sphere
  47542. */
  47543. protected _videoTexture: VideoTexture;
  47544. /**
  47545. * Gets the video texture being displayed on the sphere
  47546. */
  47547. readonly videoTexture: VideoTexture;
  47548. /**
  47549. * The skybox material
  47550. */
  47551. protected _material: BackgroundMaterial;
  47552. /**
  47553. * The surface used for the skybox
  47554. */
  47555. protected _mesh: Mesh;
  47556. /**
  47557. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47558. * Also see the options.resolution property.
  47559. */
  47560. fovMultiplier: number;
  47561. private _videoMode;
  47562. /**
  47563. * Gets or set the current video mode for the video. It can be:
  47564. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47565. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47566. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47567. */
  47568. videoMode: number;
  47569. /**
  47570. * Oberserver used in Stereoscopic VR Mode.
  47571. */
  47572. private _onBeforeCameraRenderObserver;
  47573. /**
  47574. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47575. * @param name Element's name, child elements will append suffixes for their own names.
  47576. * @param urlsOrVideo defines the url(s) or the video element to use
  47577. * @param options An object containing optional or exposed sub element properties
  47578. */
  47579. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47580. resolution?: number;
  47581. clickToPlay?: boolean;
  47582. autoPlay?: boolean;
  47583. loop?: boolean;
  47584. size?: number;
  47585. poster?: string;
  47586. faceForward?: boolean;
  47587. useDirectMapping?: boolean;
  47588. }, scene: Scene);
  47589. private _changeVideoMode;
  47590. /**
  47591. * Releases resources associated with this node.
  47592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47594. */
  47595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47596. }
  47597. }
  47598. declare module BABYLON {
  47599. /**
  47600. * This class can be used to get instrumentation data from a Babylon engine
  47601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47602. */
  47603. export class EngineInstrumentation implements IDisposable {
  47604. /**
  47605. * Define the instrumented engine.
  47606. */
  47607. engine: Engine;
  47608. private _captureGPUFrameTime;
  47609. private _gpuFrameTimeToken;
  47610. private _gpuFrameTime;
  47611. private _captureShaderCompilationTime;
  47612. private _shaderCompilationTime;
  47613. private _onBeginFrameObserver;
  47614. private _onEndFrameObserver;
  47615. private _onBeforeShaderCompilationObserver;
  47616. private _onAfterShaderCompilationObserver;
  47617. /**
  47618. * Gets the perf counter used for GPU frame time
  47619. */
  47620. readonly gpuFrameTimeCounter: PerfCounter;
  47621. /**
  47622. * Gets the GPU frame time capture status
  47623. */
  47624. /**
  47625. * Enable or disable the GPU frame time capture
  47626. */
  47627. captureGPUFrameTime: boolean;
  47628. /**
  47629. * Gets the perf counter used for shader compilation time
  47630. */
  47631. readonly shaderCompilationTimeCounter: PerfCounter;
  47632. /**
  47633. * Gets the shader compilation time capture status
  47634. */
  47635. /**
  47636. * Enable or disable the shader compilation time capture
  47637. */
  47638. captureShaderCompilationTime: boolean;
  47639. /**
  47640. * Instantiates a new engine instrumentation.
  47641. * This class can be used to get instrumentation data from a Babylon engine
  47642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47643. * @param engine Defines the engine to instrument
  47644. */
  47645. constructor(
  47646. /**
  47647. * Define the instrumented engine.
  47648. */
  47649. engine: Engine);
  47650. /**
  47651. * Dispose and release associated resources.
  47652. */
  47653. dispose(): void;
  47654. }
  47655. }
  47656. declare module BABYLON {
  47657. /**
  47658. * This class can be used to get instrumentation data from a Babylon engine
  47659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47660. */
  47661. export class SceneInstrumentation implements IDisposable {
  47662. /**
  47663. * Defines the scene to instrument
  47664. */
  47665. scene: Scene;
  47666. private _captureActiveMeshesEvaluationTime;
  47667. private _activeMeshesEvaluationTime;
  47668. private _captureRenderTargetsRenderTime;
  47669. private _renderTargetsRenderTime;
  47670. private _captureFrameTime;
  47671. private _frameTime;
  47672. private _captureRenderTime;
  47673. private _renderTime;
  47674. private _captureInterFrameTime;
  47675. private _interFrameTime;
  47676. private _captureParticlesRenderTime;
  47677. private _particlesRenderTime;
  47678. private _captureSpritesRenderTime;
  47679. private _spritesRenderTime;
  47680. private _capturePhysicsTime;
  47681. private _physicsTime;
  47682. private _captureAnimationsTime;
  47683. private _animationsTime;
  47684. private _captureCameraRenderTime;
  47685. private _cameraRenderTime;
  47686. private _onBeforeActiveMeshesEvaluationObserver;
  47687. private _onAfterActiveMeshesEvaluationObserver;
  47688. private _onBeforeRenderTargetsRenderObserver;
  47689. private _onAfterRenderTargetsRenderObserver;
  47690. private _onAfterRenderObserver;
  47691. private _onBeforeDrawPhaseObserver;
  47692. private _onAfterDrawPhaseObserver;
  47693. private _onBeforeAnimationsObserver;
  47694. private _onBeforeParticlesRenderingObserver;
  47695. private _onAfterParticlesRenderingObserver;
  47696. private _onBeforeSpritesRenderingObserver;
  47697. private _onAfterSpritesRenderingObserver;
  47698. private _onBeforePhysicsObserver;
  47699. private _onAfterPhysicsObserver;
  47700. private _onAfterAnimationsObserver;
  47701. private _onBeforeCameraRenderObserver;
  47702. private _onAfterCameraRenderObserver;
  47703. /**
  47704. * Gets the perf counter used for active meshes evaluation time
  47705. */
  47706. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47707. /**
  47708. * Gets the active meshes evaluation time capture status
  47709. */
  47710. /**
  47711. * Enable or disable the active meshes evaluation time capture
  47712. */
  47713. captureActiveMeshesEvaluationTime: boolean;
  47714. /**
  47715. * Gets the perf counter used for render targets render time
  47716. */
  47717. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47718. /**
  47719. * Gets the render targets render time capture status
  47720. */
  47721. /**
  47722. * Enable or disable the render targets render time capture
  47723. */
  47724. captureRenderTargetsRenderTime: boolean;
  47725. /**
  47726. * Gets the perf counter used for particles render time
  47727. */
  47728. readonly particlesRenderTimeCounter: PerfCounter;
  47729. /**
  47730. * Gets the particles render time capture status
  47731. */
  47732. /**
  47733. * Enable or disable the particles render time capture
  47734. */
  47735. captureParticlesRenderTime: boolean;
  47736. /**
  47737. * Gets the perf counter used for sprites render time
  47738. */
  47739. readonly spritesRenderTimeCounter: PerfCounter;
  47740. /**
  47741. * Gets the sprites render time capture status
  47742. */
  47743. /**
  47744. * Enable or disable the sprites render time capture
  47745. */
  47746. captureSpritesRenderTime: boolean;
  47747. /**
  47748. * Gets the perf counter used for physics time
  47749. */
  47750. readonly physicsTimeCounter: PerfCounter;
  47751. /**
  47752. * Gets the physics time capture status
  47753. */
  47754. /**
  47755. * Enable or disable the physics time capture
  47756. */
  47757. capturePhysicsTime: boolean;
  47758. /**
  47759. * Gets the perf counter used for animations time
  47760. */
  47761. readonly animationsTimeCounter: PerfCounter;
  47762. /**
  47763. * Gets the animations time capture status
  47764. */
  47765. /**
  47766. * Enable or disable the animations time capture
  47767. */
  47768. captureAnimationsTime: boolean;
  47769. /**
  47770. * Gets the perf counter used for frame time capture
  47771. */
  47772. readonly frameTimeCounter: PerfCounter;
  47773. /**
  47774. * Gets the frame time capture status
  47775. */
  47776. /**
  47777. * Enable or disable the frame time capture
  47778. */
  47779. captureFrameTime: boolean;
  47780. /**
  47781. * Gets the perf counter used for inter-frames time capture
  47782. */
  47783. readonly interFrameTimeCounter: PerfCounter;
  47784. /**
  47785. * Gets the inter-frames time capture status
  47786. */
  47787. /**
  47788. * Enable or disable the inter-frames time capture
  47789. */
  47790. captureInterFrameTime: boolean;
  47791. /**
  47792. * Gets the perf counter used for render time capture
  47793. */
  47794. readonly renderTimeCounter: PerfCounter;
  47795. /**
  47796. * Gets the render time capture status
  47797. */
  47798. /**
  47799. * Enable or disable the render time capture
  47800. */
  47801. captureRenderTime: boolean;
  47802. /**
  47803. * Gets the perf counter used for camera render time capture
  47804. */
  47805. readonly cameraRenderTimeCounter: PerfCounter;
  47806. /**
  47807. * Gets the camera render time capture status
  47808. */
  47809. /**
  47810. * Enable or disable the camera render time capture
  47811. */
  47812. captureCameraRenderTime: boolean;
  47813. /**
  47814. * Gets the perf counter used for draw calls
  47815. */
  47816. readonly drawCallsCounter: PerfCounter;
  47817. /**
  47818. * Instantiates a new scene instrumentation.
  47819. * This class can be used to get instrumentation data from a Babylon engine
  47820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47821. * @param scene Defines the scene to instrument
  47822. */
  47823. constructor(
  47824. /**
  47825. * Defines the scene to instrument
  47826. */
  47827. scene: Scene);
  47828. /**
  47829. * Dispose and release associated resources.
  47830. */
  47831. dispose(): void;
  47832. }
  47833. }
  47834. declare module BABYLON {
  47835. /** @hidden */
  47836. export var glowMapGenerationPixelShader: {
  47837. name: string;
  47838. shader: string;
  47839. };
  47840. }
  47841. declare module BABYLON {
  47842. /** @hidden */
  47843. export var glowMapGenerationVertexShader: {
  47844. name: string;
  47845. shader: string;
  47846. };
  47847. }
  47848. declare module BABYLON {
  47849. /**
  47850. * Effect layer options. This helps customizing the behaviour
  47851. * of the effect layer.
  47852. */
  47853. export interface IEffectLayerOptions {
  47854. /**
  47855. * Multiplication factor apply to the canvas size to compute the render target size
  47856. * used to generated the objects (the smaller the faster).
  47857. */
  47858. mainTextureRatio: number;
  47859. /**
  47860. * Enforces a fixed size texture to ensure effect stability across devices.
  47861. */
  47862. mainTextureFixedSize?: number;
  47863. /**
  47864. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47865. */
  47866. alphaBlendingMode: number;
  47867. /**
  47868. * The camera attached to the layer.
  47869. */
  47870. camera: Nullable<Camera>;
  47871. /**
  47872. * The rendering group to draw the layer in.
  47873. */
  47874. renderingGroupId: number;
  47875. }
  47876. /**
  47877. * The effect layer Helps adding post process effect blended with the main pass.
  47878. *
  47879. * This can be for instance use to generate glow or higlight effects on the scene.
  47880. *
  47881. * The effect layer class can not be used directly and is intented to inherited from to be
  47882. * customized per effects.
  47883. */
  47884. export abstract class EffectLayer {
  47885. private _vertexBuffers;
  47886. private _indexBuffer;
  47887. private _cachedDefines;
  47888. private _effectLayerMapGenerationEffect;
  47889. private _effectLayerOptions;
  47890. private _mergeEffect;
  47891. protected _scene: Scene;
  47892. protected _engine: Engine;
  47893. protected _maxSize: number;
  47894. protected _mainTextureDesiredSize: ISize;
  47895. protected _mainTexture: RenderTargetTexture;
  47896. protected _shouldRender: boolean;
  47897. protected _postProcesses: PostProcess[];
  47898. protected _textures: BaseTexture[];
  47899. protected _emissiveTextureAndColor: {
  47900. texture: Nullable<BaseTexture>;
  47901. color: Color4;
  47902. };
  47903. /**
  47904. * The name of the layer
  47905. */
  47906. name: string;
  47907. /**
  47908. * The clear color of the texture used to generate the glow map.
  47909. */
  47910. neutralColor: Color4;
  47911. /**
  47912. * Specifies wether the highlight layer is enabled or not.
  47913. */
  47914. isEnabled: boolean;
  47915. /**
  47916. * Gets the camera attached to the layer.
  47917. */
  47918. readonly camera: Nullable<Camera>;
  47919. /**
  47920. * Gets the rendering group id the layer should render in.
  47921. */
  47922. renderingGroupId: number;
  47923. /**
  47924. * An event triggered when the effect layer has been disposed.
  47925. */
  47926. onDisposeObservable: Observable<EffectLayer>;
  47927. /**
  47928. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47929. */
  47930. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47931. /**
  47932. * An event triggered when the generated texture is being merged in the scene.
  47933. */
  47934. onBeforeComposeObservable: Observable<EffectLayer>;
  47935. /**
  47936. * An event triggered when the generated texture has been merged in the scene.
  47937. */
  47938. onAfterComposeObservable: Observable<EffectLayer>;
  47939. /**
  47940. * An event triggered when the efffect layer changes its size.
  47941. */
  47942. onSizeChangedObservable: Observable<EffectLayer>;
  47943. /** @hidden */
  47944. static _SceneComponentInitialization: (scene: Scene) => void;
  47945. /**
  47946. * Instantiates a new effect Layer and references it in the scene.
  47947. * @param name The name of the layer
  47948. * @param scene The scene to use the layer in
  47949. */
  47950. constructor(
  47951. /** The Friendly of the effect in the scene */
  47952. name: string, scene: Scene);
  47953. /**
  47954. * Get the effect name of the layer.
  47955. * @return The effect name
  47956. */
  47957. abstract getEffectName(): string;
  47958. /**
  47959. * Checks for the readiness of the element composing the layer.
  47960. * @param subMesh the mesh to check for
  47961. * @param useInstances specify wether or not to use instances to render the mesh
  47962. * @return true if ready otherwise, false
  47963. */
  47964. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47965. /**
  47966. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47967. * @returns true if the effect requires stencil during the main canvas render pass.
  47968. */
  47969. abstract needStencil(): boolean;
  47970. /**
  47971. * Create the merge effect. This is the shader use to blit the information back
  47972. * to the main canvas at the end of the scene rendering.
  47973. * @returns The effect containing the shader used to merge the effect on the main canvas
  47974. */
  47975. protected abstract _createMergeEffect(): Effect;
  47976. /**
  47977. * Creates the render target textures and post processes used in the effect layer.
  47978. */
  47979. protected abstract _createTextureAndPostProcesses(): void;
  47980. /**
  47981. * Implementation specific of rendering the generating effect on the main canvas.
  47982. * @param effect The effect used to render through
  47983. */
  47984. protected abstract _internalRender(effect: Effect): void;
  47985. /**
  47986. * Sets the required values for both the emissive texture and and the main color.
  47987. */
  47988. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47989. /**
  47990. * Free any resources and references associated to a mesh.
  47991. * Internal use
  47992. * @param mesh The mesh to free.
  47993. */
  47994. abstract _disposeMesh(mesh: Mesh): void;
  47995. /**
  47996. * Serializes this layer (Glow or Highlight for example)
  47997. * @returns a serialized layer object
  47998. */
  47999. abstract serialize?(): any;
  48000. /**
  48001. * Initializes the effect layer with the required options.
  48002. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48003. */
  48004. protected _init(options: Partial<IEffectLayerOptions>): void;
  48005. /**
  48006. * Generates the index buffer of the full screen quad blending to the main canvas.
  48007. */
  48008. private _generateIndexBuffer;
  48009. /**
  48010. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48011. */
  48012. private _generateVertexBuffer;
  48013. /**
  48014. * Sets the main texture desired size which is the closest power of two
  48015. * of the engine canvas size.
  48016. */
  48017. private _setMainTextureSize;
  48018. /**
  48019. * Creates the main texture for the effect layer.
  48020. */
  48021. protected _createMainTexture(): void;
  48022. /**
  48023. * Adds specific effects defines.
  48024. * @param defines The defines to add specifics to.
  48025. */
  48026. protected _addCustomEffectDefines(defines: string[]): void;
  48027. /**
  48028. * Checks for the readiness of the element composing the layer.
  48029. * @param subMesh the mesh to check for
  48030. * @param useInstances specify wether or not to use instances to render the mesh
  48031. * @param emissiveTexture the associated emissive texture used to generate the glow
  48032. * @return true if ready otherwise, false
  48033. */
  48034. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48035. /**
  48036. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48037. */
  48038. render(): void;
  48039. /**
  48040. * Determine if a given mesh will be used in the current effect.
  48041. * @param mesh mesh to test
  48042. * @returns true if the mesh will be used
  48043. */
  48044. hasMesh(mesh: AbstractMesh): boolean;
  48045. /**
  48046. * Returns true if the layer contains information to display, otherwise false.
  48047. * @returns true if the glow layer should be rendered
  48048. */
  48049. shouldRender(): boolean;
  48050. /**
  48051. * Returns true if the mesh should render, otherwise false.
  48052. * @param mesh The mesh to render
  48053. * @returns true if it should render otherwise false
  48054. */
  48055. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48056. /**
  48057. * Returns true if the mesh can be rendered, otherwise false.
  48058. * @param mesh The mesh to render
  48059. * @param material The material used on the mesh
  48060. * @returns true if it can be rendered otherwise false
  48061. */
  48062. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48063. /**
  48064. * Returns true if the mesh should render, otherwise false.
  48065. * @param mesh The mesh to render
  48066. * @returns true if it should render otherwise false
  48067. */
  48068. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48069. /**
  48070. * Renders the submesh passed in parameter to the generation map.
  48071. */
  48072. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48073. /**
  48074. * Rebuild the required buffers.
  48075. * @hidden Internal use only.
  48076. */
  48077. _rebuild(): void;
  48078. /**
  48079. * Dispose only the render target textures and post process.
  48080. */
  48081. private _disposeTextureAndPostProcesses;
  48082. /**
  48083. * Dispose the highlight layer and free resources.
  48084. */
  48085. dispose(): void;
  48086. /**
  48087. * Gets the class name of the effect layer
  48088. * @returns the string with the class name of the effect layer
  48089. */
  48090. getClassName(): string;
  48091. /**
  48092. * Creates an effect layer from parsed effect layer data
  48093. * @param parsedEffectLayer defines effect layer data
  48094. * @param scene defines the current scene
  48095. * @param rootUrl defines the root URL containing the effect layer information
  48096. * @returns a parsed effect Layer
  48097. */
  48098. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48099. }
  48100. }
  48101. declare module BABYLON {
  48102. interface AbstractScene {
  48103. /**
  48104. * The list of effect layers (highlights/glow) added to the scene
  48105. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48106. * @see http://doc.babylonjs.com/how_to/glow_layer
  48107. */
  48108. effectLayers: Array<EffectLayer>;
  48109. /**
  48110. * Removes the given effect layer from this scene.
  48111. * @param toRemove defines the effect layer to remove
  48112. * @returns the index of the removed effect layer
  48113. */
  48114. removeEffectLayer(toRemove: EffectLayer): number;
  48115. /**
  48116. * Adds the given effect layer to this scene
  48117. * @param newEffectLayer defines the effect layer to add
  48118. */
  48119. addEffectLayer(newEffectLayer: EffectLayer): void;
  48120. }
  48121. /**
  48122. * Defines the layer scene component responsible to manage any effect layers
  48123. * in a given scene.
  48124. */
  48125. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48126. /**
  48127. * The component name helpfull to identify the component in the list of scene components.
  48128. */
  48129. readonly name: string;
  48130. /**
  48131. * The scene the component belongs to.
  48132. */
  48133. scene: Scene;
  48134. private _engine;
  48135. private _renderEffects;
  48136. private _needStencil;
  48137. private _previousStencilState;
  48138. /**
  48139. * Creates a new instance of the component for the given scene
  48140. * @param scene Defines the scene to register the component in
  48141. */
  48142. constructor(scene: Scene);
  48143. /**
  48144. * Registers the component in a given scene
  48145. */
  48146. register(): void;
  48147. /**
  48148. * Rebuilds the elements related to this component in case of
  48149. * context lost for instance.
  48150. */
  48151. rebuild(): void;
  48152. /**
  48153. * Serializes the component data to the specified json object
  48154. * @param serializationObject The object to serialize to
  48155. */
  48156. serialize(serializationObject: any): void;
  48157. /**
  48158. * Adds all the elements from the container to the scene
  48159. * @param container the container holding the elements
  48160. */
  48161. addFromContainer(container: AbstractScene): void;
  48162. /**
  48163. * Removes all the elements in the container from the scene
  48164. * @param container contains the elements to remove
  48165. * @param dispose if the removed element should be disposed (default: false)
  48166. */
  48167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48168. /**
  48169. * Disposes the component and the associated ressources.
  48170. */
  48171. dispose(): void;
  48172. private _isReadyForMesh;
  48173. private _renderMainTexture;
  48174. private _setStencil;
  48175. private _setStencilBack;
  48176. private _draw;
  48177. private _drawCamera;
  48178. private _drawRenderingGroup;
  48179. }
  48180. }
  48181. declare module BABYLON {
  48182. /** @hidden */
  48183. export var glowMapMergePixelShader: {
  48184. name: string;
  48185. shader: string;
  48186. };
  48187. }
  48188. declare module BABYLON {
  48189. /** @hidden */
  48190. export var glowMapMergeVertexShader: {
  48191. name: string;
  48192. shader: string;
  48193. };
  48194. }
  48195. declare module BABYLON {
  48196. interface AbstractScene {
  48197. /**
  48198. * Return a the first highlight layer of the scene with a given name.
  48199. * @param name The name of the highlight layer to look for.
  48200. * @return The highlight layer if found otherwise null.
  48201. */
  48202. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48203. }
  48204. /**
  48205. * Glow layer options. This helps customizing the behaviour
  48206. * of the glow layer.
  48207. */
  48208. export interface IGlowLayerOptions {
  48209. /**
  48210. * Multiplication factor apply to the canvas size to compute the render target size
  48211. * used to generated the glowing objects (the smaller the faster).
  48212. */
  48213. mainTextureRatio: number;
  48214. /**
  48215. * Enforces a fixed size texture to ensure resize independant blur.
  48216. */
  48217. mainTextureFixedSize?: number;
  48218. /**
  48219. * How big is the kernel of the blur texture.
  48220. */
  48221. blurKernelSize: number;
  48222. /**
  48223. * The camera attached to the layer.
  48224. */
  48225. camera: Nullable<Camera>;
  48226. /**
  48227. * Enable MSAA by chosing the number of samples.
  48228. */
  48229. mainTextureSamples?: number;
  48230. /**
  48231. * The rendering group to draw the layer in.
  48232. */
  48233. renderingGroupId: number;
  48234. }
  48235. /**
  48236. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48237. *
  48238. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48239. * glowy meshes to your scene.
  48240. *
  48241. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48242. */
  48243. export class GlowLayer extends EffectLayer {
  48244. /**
  48245. * Effect Name of the layer.
  48246. */
  48247. static readonly EffectName: string;
  48248. /**
  48249. * The default blur kernel size used for the glow.
  48250. */
  48251. static DefaultBlurKernelSize: number;
  48252. /**
  48253. * The default texture size ratio used for the glow.
  48254. */
  48255. static DefaultTextureRatio: number;
  48256. /**
  48257. * Sets the kernel size of the blur.
  48258. */
  48259. /**
  48260. * Gets the kernel size of the blur.
  48261. */
  48262. blurKernelSize: number;
  48263. /**
  48264. * Sets the glow intensity.
  48265. */
  48266. /**
  48267. * Gets the glow intensity.
  48268. */
  48269. intensity: number;
  48270. private _options;
  48271. private _intensity;
  48272. private _horizontalBlurPostprocess1;
  48273. private _verticalBlurPostprocess1;
  48274. private _horizontalBlurPostprocess2;
  48275. private _verticalBlurPostprocess2;
  48276. private _blurTexture1;
  48277. private _blurTexture2;
  48278. private _postProcesses1;
  48279. private _postProcesses2;
  48280. private _includedOnlyMeshes;
  48281. private _excludedMeshes;
  48282. /**
  48283. * Callback used to let the user override the color selection on a per mesh basis
  48284. */
  48285. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48286. /**
  48287. * Callback used to let the user override the texture selection on a per mesh basis
  48288. */
  48289. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48290. /**
  48291. * Instantiates a new glow Layer and references it to the scene.
  48292. * @param name The name of the layer
  48293. * @param scene The scene to use the layer in
  48294. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48295. */
  48296. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48297. /**
  48298. * Get the effect name of the layer.
  48299. * @return The effect name
  48300. */
  48301. getEffectName(): string;
  48302. /**
  48303. * Create the merge effect. This is the shader use to blit the information back
  48304. * to the main canvas at the end of the scene rendering.
  48305. */
  48306. protected _createMergeEffect(): Effect;
  48307. /**
  48308. * Creates the render target textures and post processes used in the glow layer.
  48309. */
  48310. protected _createTextureAndPostProcesses(): void;
  48311. /**
  48312. * Checks for the readiness of the element composing the layer.
  48313. * @param subMesh the mesh to check for
  48314. * @param useInstances specify wether or not to use instances to render the mesh
  48315. * @param emissiveTexture the associated emissive texture used to generate the glow
  48316. * @return true if ready otherwise, false
  48317. */
  48318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48319. /**
  48320. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48321. */
  48322. needStencil(): boolean;
  48323. /**
  48324. * Returns true if the mesh can be rendered, otherwise false.
  48325. * @param mesh The mesh to render
  48326. * @param material The material used on the mesh
  48327. * @returns true if it can be rendered otherwise false
  48328. */
  48329. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48330. /**
  48331. * Implementation specific of rendering the generating effect on the main canvas.
  48332. * @param effect The effect used to render through
  48333. */
  48334. protected _internalRender(effect: Effect): void;
  48335. /**
  48336. * Sets the required values for both the emissive texture and and the main color.
  48337. */
  48338. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48339. /**
  48340. * Returns true if the mesh should render, otherwise false.
  48341. * @param mesh The mesh to render
  48342. * @returns true if it should render otherwise false
  48343. */
  48344. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48345. /**
  48346. * Adds specific effects defines.
  48347. * @param defines The defines to add specifics to.
  48348. */
  48349. protected _addCustomEffectDefines(defines: string[]): void;
  48350. /**
  48351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48352. * @param mesh The mesh to exclude from the glow layer
  48353. */
  48354. addExcludedMesh(mesh: Mesh): void;
  48355. /**
  48356. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48357. * @param mesh The mesh to remove
  48358. */
  48359. removeExcludedMesh(mesh: Mesh): void;
  48360. /**
  48361. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48362. * @param mesh The mesh to include in the glow layer
  48363. */
  48364. addIncludedOnlyMesh(mesh: Mesh): void;
  48365. /**
  48366. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48367. * @param mesh The mesh to remove
  48368. */
  48369. removeIncludedOnlyMesh(mesh: Mesh): void;
  48370. /**
  48371. * Determine if a given mesh will be used in the glow layer
  48372. * @param mesh The mesh to test
  48373. * @returns true if the mesh will be highlighted by the current glow layer
  48374. */
  48375. hasMesh(mesh: AbstractMesh): boolean;
  48376. /**
  48377. * Free any resources and references associated to a mesh.
  48378. * Internal use
  48379. * @param mesh The mesh to free.
  48380. * @hidden
  48381. */
  48382. _disposeMesh(mesh: Mesh): void;
  48383. /**
  48384. * Gets the class name of the effect layer
  48385. * @returns the string with the class name of the effect layer
  48386. */
  48387. getClassName(): string;
  48388. /**
  48389. * Serializes this glow layer
  48390. * @returns a serialized glow layer object
  48391. */
  48392. serialize(): any;
  48393. /**
  48394. * Creates a Glow Layer from parsed glow layer data
  48395. * @param parsedGlowLayer defines glow layer data
  48396. * @param scene defines the current scene
  48397. * @param rootUrl defines the root URL containing the glow layer information
  48398. * @returns a parsed Glow Layer
  48399. */
  48400. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48401. }
  48402. }
  48403. declare module BABYLON {
  48404. /** @hidden */
  48405. export var glowBlurPostProcessPixelShader: {
  48406. name: string;
  48407. shader: string;
  48408. };
  48409. }
  48410. declare module BABYLON {
  48411. interface AbstractScene {
  48412. /**
  48413. * Return a the first highlight layer of the scene with a given name.
  48414. * @param name The name of the highlight layer to look for.
  48415. * @return The highlight layer if found otherwise null.
  48416. */
  48417. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48418. }
  48419. /**
  48420. * Highlight layer options. This helps customizing the behaviour
  48421. * of the highlight layer.
  48422. */
  48423. export interface IHighlightLayerOptions {
  48424. /**
  48425. * Multiplication factor apply to the canvas size to compute the render target size
  48426. * used to generated the glowing objects (the smaller the faster).
  48427. */
  48428. mainTextureRatio: number;
  48429. /**
  48430. * Enforces a fixed size texture to ensure resize independant blur.
  48431. */
  48432. mainTextureFixedSize?: number;
  48433. /**
  48434. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48435. * of the picture to blur (the smaller the faster).
  48436. */
  48437. blurTextureSizeRatio: number;
  48438. /**
  48439. * How big in texel of the blur texture is the vertical blur.
  48440. */
  48441. blurVerticalSize: number;
  48442. /**
  48443. * How big in texel of the blur texture is the horizontal blur.
  48444. */
  48445. blurHorizontalSize: number;
  48446. /**
  48447. * Alpha blending mode used to apply the blur. Default is combine.
  48448. */
  48449. alphaBlendingMode: number;
  48450. /**
  48451. * The camera attached to the layer.
  48452. */
  48453. camera: Nullable<Camera>;
  48454. /**
  48455. * Should we display highlight as a solid stroke?
  48456. */
  48457. isStroke?: boolean;
  48458. /**
  48459. * The rendering group to draw the layer in.
  48460. */
  48461. renderingGroupId: number;
  48462. }
  48463. /**
  48464. * The highlight layer Helps adding a glow effect around a mesh.
  48465. *
  48466. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48467. * glowy meshes to your scene.
  48468. *
  48469. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48470. */
  48471. export class HighlightLayer extends EffectLayer {
  48472. name: string;
  48473. /**
  48474. * Effect Name of the highlight layer.
  48475. */
  48476. static readonly EffectName: string;
  48477. /**
  48478. * The neutral color used during the preparation of the glow effect.
  48479. * This is black by default as the blend operation is a blend operation.
  48480. */
  48481. static NeutralColor: Color4;
  48482. /**
  48483. * Stencil value used for glowing meshes.
  48484. */
  48485. static GlowingMeshStencilReference: number;
  48486. /**
  48487. * Stencil value used for the other meshes in the scene.
  48488. */
  48489. static NormalMeshStencilReference: number;
  48490. /**
  48491. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48492. */
  48493. innerGlow: boolean;
  48494. /**
  48495. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48496. */
  48497. outerGlow: boolean;
  48498. /**
  48499. * Specifies the horizontal size of the blur.
  48500. */
  48501. /**
  48502. * Gets the horizontal size of the blur.
  48503. */
  48504. blurHorizontalSize: number;
  48505. /**
  48506. * Specifies the vertical size of the blur.
  48507. */
  48508. /**
  48509. * Gets the vertical size of the blur.
  48510. */
  48511. blurVerticalSize: number;
  48512. /**
  48513. * An event triggered when the highlight layer is being blurred.
  48514. */
  48515. onBeforeBlurObservable: Observable<HighlightLayer>;
  48516. /**
  48517. * An event triggered when the highlight layer has been blurred.
  48518. */
  48519. onAfterBlurObservable: Observable<HighlightLayer>;
  48520. private _instanceGlowingMeshStencilReference;
  48521. private _options;
  48522. private _downSamplePostprocess;
  48523. private _horizontalBlurPostprocess;
  48524. private _verticalBlurPostprocess;
  48525. private _blurTexture;
  48526. private _meshes;
  48527. private _excludedMeshes;
  48528. /**
  48529. * Instantiates a new highlight Layer and references it to the scene..
  48530. * @param name The name of the layer
  48531. * @param scene The scene to use the layer in
  48532. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48533. */
  48534. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48535. /**
  48536. * Get the effect name of the layer.
  48537. * @return The effect name
  48538. */
  48539. getEffectName(): string;
  48540. /**
  48541. * Create the merge effect. This is the shader use to blit the information back
  48542. * to the main canvas at the end of the scene rendering.
  48543. */
  48544. protected _createMergeEffect(): Effect;
  48545. /**
  48546. * Creates the render target textures and post processes used in the highlight layer.
  48547. */
  48548. protected _createTextureAndPostProcesses(): void;
  48549. /**
  48550. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48551. */
  48552. needStencil(): boolean;
  48553. /**
  48554. * Checks for the readiness of the element composing the layer.
  48555. * @param subMesh the mesh to check for
  48556. * @param useInstances specify wether or not to use instances to render the mesh
  48557. * @param emissiveTexture the associated emissive texture used to generate the glow
  48558. * @return true if ready otherwise, false
  48559. */
  48560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48561. /**
  48562. * Implementation specific of rendering the generating effect on the main canvas.
  48563. * @param effect The effect used to render through
  48564. */
  48565. protected _internalRender(effect: Effect): void;
  48566. /**
  48567. * Returns true if the layer contains information to display, otherwise false.
  48568. */
  48569. shouldRender(): boolean;
  48570. /**
  48571. * Returns true if the mesh should render, otherwise false.
  48572. * @param mesh The mesh to render
  48573. * @returns true if it should render otherwise false
  48574. */
  48575. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48576. /**
  48577. * Sets the required values for both the emissive texture and and the main color.
  48578. */
  48579. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48580. /**
  48581. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48582. * @param mesh The mesh to exclude from the highlight layer
  48583. */
  48584. addExcludedMesh(mesh: Mesh): void;
  48585. /**
  48586. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48587. * @param mesh The mesh to highlight
  48588. */
  48589. removeExcludedMesh(mesh: Mesh): void;
  48590. /**
  48591. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48592. * @param mesh mesh to test
  48593. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48594. */
  48595. hasMesh(mesh: AbstractMesh): boolean;
  48596. /**
  48597. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48598. * @param mesh The mesh to highlight
  48599. * @param color The color of the highlight
  48600. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48601. */
  48602. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48603. /**
  48604. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48605. * @param mesh The mesh to highlight
  48606. */
  48607. removeMesh(mesh: Mesh): void;
  48608. /**
  48609. * Force the stencil to the normal expected value for none glowing parts
  48610. */
  48611. private _defaultStencilReference;
  48612. /**
  48613. * Free any resources and references associated to a mesh.
  48614. * Internal use
  48615. * @param mesh The mesh to free.
  48616. * @hidden
  48617. */
  48618. _disposeMesh(mesh: Mesh): void;
  48619. /**
  48620. * Dispose the highlight layer and free resources.
  48621. */
  48622. dispose(): void;
  48623. /**
  48624. * Gets the class name of the effect layer
  48625. * @returns the string with the class name of the effect layer
  48626. */
  48627. getClassName(): string;
  48628. /**
  48629. * Serializes this Highlight layer
  48630. * @returns a serialized Highlight layer object
  48631. */
  48632. serialize(): any;
  48633. /**
  48634. * Creates a Highlight layer from parsed Highlight layer data
  48635. * @param parsedHightlightLayer defines the Highlight layer data
  48636. * @param scene defines the current scene
  48637. * @param rootUrl defines the root URL containing the Highlight layer information
  48638. * @returns a parsed Highlight layer
  48639. */
  48640. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48641. }
  48642. }
  48643. declare module BABYLON {
  48644. interface AbstractScene {
  48645. /**
  48646. * The list of layers (background and foreground) of the scene
  48647. */
  48648. layers: Array<Layer>;
  48649. }
  48650. /**
  48651. * Defines the layer scene component responsible to manage any layers
  48652. * in a given scene.
  48653. */
  48654. export class LayerSceneComponent implements ISceneComponent {
  48655. /**
  48656. * The component name helpfull to identify the component in the list of scene components.
  48657. */
  48658. readonly name: string;
  48659. /**
  48660. * The scene the component belongs to.
  48661. */
  48662. scene: Scene;
  48663. private _engine;
  48664. /**
  48665. * Creates a new instance of the component for the given scene
  48666. * @param scene Defines the scene to register the component in
  48667. */
  48668. constructor(scene: Scene);
  48669. /**
  48670. * Registers the component in a given scene
  48671. */
  48672. register(): void;
  48673. /**
  48674. * Rebuilds the elements related to this component in case of
  48675. * context lost for instance.
  48676. */
  48677. rebuild(): void;
  48678. /**
  48679. * Disposes the component and the associated ressources.
  48680. */
  48681. dispose(): void;
  48682. private _draw;
  48683. private _drawCameraPredicate;
  48684. private _drawCameraBackground;
  48685. private _drawCameraForeground;
  48686. private _drawRenderTargetPredicate;
  48687. private _drawRenderTargetBackground;
  48688. private _drawRenderTargetForeground;
  48689. /**
  48690. * Adds all the elements from the container to the scene
  48691. * @param container the container holding the elements
  48692. */
  48693. addFromContainer(container: AbstractScene): void;
  48694. /**
  48695. * Removes all the elements in the container from the scene
  48696. * @param container contains the elements to remove
  48697. * @param dispose if the removed element should be disposed (default: false)
  48698. */
  48699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48700. }
  48701. }
  48702. declare module BABYLON {
  48703. /** @hidden */
  48704. export var layerPixelShader: {
  48705. name: string;
  48706. shader: string;
  48707. };
  48708. }
  48709. declare module BABYLON {
  48710. /** @hidden */
  48711. export var layerVertexShader: {
  48712. name: string;
  48713. shader: string;
  48714. };
  48715. }
  48716. declare module BABYLON {
  48717. /**
  48718. * This represents a full screen 2d layer.
  48719. * This can be useful to display a picture in the background of your scene for instance.
  48720. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48721. */
  48722. export class Layer {
  48723. /**
  48724. * Define the name of the layer.
  48725. */
  48726. name: string;
  48727. /**
  48728. * Define the texture the layer should display.
  48729. */
  48730. texture: Nullable<Texture>;
  48731. /**
  48732. * Is the layer in background or foreground.
  48733. */
  48734. isBackground: boolean;
  48735. /**
  48736. * Define the color of the layer (instead of texture).
  48737. */
  48738. color: Color4;
  48739. /**
  48740. * Define the scale of the layer in order to zoom in out of the texture.
  48741. */
  48742. scale: Vector2;
  48743. /**
  48744. * Define an offset for the layer in order to shift the texture.
  48745. */
  48746. offset: Vector2;
  48747. /**
  48748. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48749. */
  48750. alphaBlendingMode: number;
  48751. /**
  48752. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48753. * Alpha test will not mix with the background color in case of transparency.
  48754. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48755. */
  48756. alphaTest: boolean;
  48757. /**
  48758. * Define a mask to restrict the layer to only some of the scene cameras.
  48759. */
  48760. layerMask: number;
  48761. /**
  48762. * Define the list of render target the layer is visible into.
  48763. */
  48764. renderTargetTextures: RenderTargetTexture[];
  48765. /**
  48766. * Define if the layer is only used in renderTarget or if it also
  48767. * renders in the main frame buffer of the canvas.
  48768. */
  48769. renderOnlyInRenderTargetTextures: boolean;
  48770. private _scene;
  48771. private _vertexBuffers;
  48772. private _indexBuffer;
  48773. private _effect;
  48774. private _alphaTestEffect;
  48775. /**
  48776. * An event triggered when the layer is disposed.
  48777. */
  48778. onDisposeObservable: Observable<Layer>;
  48779. private _onDisposeObserver;
  48780. /**
  48781. * Back compatibility with callback before the onDisposeObservable existed.
  48782. * The set callback will be triggered when the layer has been disposed.
  48783. */
  48784. onDispose: () => void;
  48785. /**
  48786. * An event triggered before rendering the scene
  48787. */
  48788. onBeforeRenderObservable: Observable<Layer>;
  48789. private _onBeforeRenderObserver;
  48790. /**
  48791. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48792. * The set callback will be triggered just before rendering the layer.
  48793. */
  48794. onBeforeRender: () => void;
  48795. /**
  48796. * An event triggered after rendering the scene
  48797. */
  48798. onAfterRenderObservable: Observable<Layer>;
  48799. private _onAfterRenderObserver;
  48800. /**
  48801. * Back compatibility with callback before the onAfterRenderObservable existed.
  48802. * The set callback will be triggered just after rendering the layer.
  48803. */
  48804. onAfterRender: () => void;
  48805. /**
  48806. * Instantiates a new layer.
  48807. * This represents a full screen 2d layer.
  48808. * This can be useful to display a picture in the background of your scene for instance.
  48809. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48810. * @param name Define the name of the layer in the scene
  48811. * @param imgUrl Define the url of the texture to display in the layer
  48812. * @param scene Define the scene the layer belongs to
  48813. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48814. * @param color Defines a color for the layer
  48815. */
  48816. constructor(
  48817. /**
  48818. * Define the name of the layer.
  48819. */
  48820. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48821. private _createIndexBuffer;
  48822. /** @hidden */
  48823. _rebuild(): void;
  48824. /**
  48825. * Renders the layer in the scene.
  48826. */
  48827. render(): void;
  48828. /**
  48829. * Disposes and releases the associated ressources.
  48830. */
  48831. dispose(): void;
  48832. }
  48833. }
  48834. declare module BABYLON {
  48835. /** @hidden */
  48836. export var lensFlarePixelShader: {
  48837. name: string;
  48838. shader: string;
  48839. };
  48840. }
  48841. declare module BABYLON {
  48842. /** @hidden */
  48843. export var lensFlareVertexShader: {
  48844. name: string;
  48845. shader: string;
  48846. };
  48847. }
  48848. declare module BABYLON {
  48849. /**
  48850. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48851. * It is usually composed of several `lensFlare`.
  48852. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48853. */
  48854. export class LensFlareSystem {
  48855. /**
  48856. * Define the name of the lens flare system
  48857. */
  48858. name: string;
  48859. /**
  48860. * List of lens flares used in this system.
  48861. */
  48862. lensFlares: LensFlare[];
  48863. /**
  48864. * Define a limit from the border the lens flare can be visible.
  48865. */
  48866. borderLimit: number;
  48867. /**
  48868. * Define a viewport border we do not want to see the lens flare in.
  48869. */
  48870. viewportBorder: number;
  48871. /**
  48872. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48873. */
  48874. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48875. /**
  48876. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48877. */
  48878. layerMask: number;
  48879. /**
  48880. * Define the id of the lens flare system in the scene.
  48881. * (equal to name by default)
  48882. */
  48883. id: string;
  48884. private _scene;
  48885. private _emitter;
  48886. private _vertexBuffers;
  48887. private _indexBuffer;
  48888. private _effect;
  48889. private _positionX;
  48890. private _positionY;
  48891. private _isEnabled;
  48892. /** @hidden */
  48893. static _SceneComponentInitialization: (scene: Scene) => void;
  48894. /**
  48895. * Instantiates a lens flare system.
  48896. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48897. * It is usually composed of several `lensFlare`.
  48898. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48899. * @param name Define the name of the lens flare system in the scene
  48900. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48901. * @param scene Define the scene the lens flare system belongs to
  48902. */
  48903. constructor(
  48904. /**
  48905. * Define the name of the lens flare system
  48906. */
  48907. name: string, emitter: any, scene: Scene);
  48908. /**
  48909. * Define if the lens flare system is enabled.
  48910. */
  48911. isEnabled: boolean;
  48912. /**
  48913. * Get the scene the effects belongs to.
  48914. * @returns the scene holding the lens flare system
  48915. */
  48916. getScene(): Scene;
  48917. /**
  48918. * Get the emitter of the lens flare system.
  48919. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48920. * @returns the emitter of the lens flare system
  48921. */
  48922. getEmitter(): any;
  48923. /**
  48924. * Set the emitter of the lens flare system.
  48925. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48926. * @param newEmitter Define the new emitter of the system
  48927. */
  48928. setEmitter(newEmitter: any): void;
  48929. /**
  48930. * Get the lens flare system emitter position.
  48931. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48932. * @returns the position
  48933. */
  48934. getEmitterPosition(): Vector3;
  48935. /**
  48936. * @hidden
  48937. */
  48938. computeEffectivePosition(globalViewport: Viewport): boolean;
  48939. /** @hidden */
  48940. _isVisible(): boolean;
  48941. /**
  48942. * @hidden
  48943. */
  48944. render(): boolean;
  48945. /**
  48946. * Dispose and release the lens flare with its associated resources.
  48947. */
  48948. dispose(): void;
  48949. /**
  48950. * Parse a lens flare system from a JSON repressentation
  48951. * @param parsedLensFlareSystem Define the JSON to parse
  48952. * @param scene Define the scene the parsed system should be instantiated in
  48953. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48954. * @returns the parsed system
  48955. */
  48956. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48957. /**
  48958. * Serialize the current Lens Flare System into a JSON representation.
  48959. * @returns the serialized JSON
  48960. */
  48961. serialize(): any;
  48962. }
  48963. }
  48964. declare module BABYLON {
  48965. /**
  48966. * This represents one of the lens effect in a `lensFlareSystem`.
  48967. * It controls one of the indiviual texture used in the effect.
  48968. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48969. */
  48970. export class LensFlare {
  48971. /**
  48972. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48973. */
  48974. size: number;
  48975. /**
  48976. * 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.
  48977. */
  48978. position: number;
  48979. /**
  48980. * Define the lens color.
  48981. */
  48982. color: Color3;
  48983. /**
  48984. * Define the lens texture.
  48985. */
  48986. texture: Nullable<Texture>;
  48987. /**
  48988. * Define the alpha mode to render this particular lens.
  48989. */
  48990. alphaMode: number;
  48991. private _system;
  48992. /**
  48993. * Creates a new Lens Flare.
  48994. * This represents one of the lens effect in a `lensFlareSystem`.
  48995. * It controls one of the indiviual texture used in the effect.
  48996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48997. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48998. * @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.
  48999. * @param color Define the lens color
  49000. * @param imgUrl Define the lens texture url
  49001. * @param system Define the `lensFlareSystem` this flare is part of
  49002. * @returns The newly created Lens Flare
  49003. */
  49004. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49005. /**
  49006. * Instantiates a new Lens Flare.
  49007. * This represents one of the lens effect in a `lensFlareSystem`.
  49008. * It controls one of the indiviual texture used in the effect.
  49009. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49010. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49011. * @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.
  49012. * @param color Define the lens color
  49013. * @param imgUrl Define the lens texture url
  49014. * @param system Define the `lensFlareSystem` this flare is part of
  49015. */
  49016. constructor(
  49017. /**
  49018. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49019. */
  49020. size: number,
  49021. /**
  49022. * 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.
  49023. */
  49024. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49025. /**
  49026. * Dispose and release the lens flare with its associated resources.
  49027. */
  49028. dispose(): void;
  49029. }
  49030. }
  49031. declare module BABYLON {
  49032. interface AbstractScene {
  49033. /**
  49034. * The list of lens flare system added to the scene
  49035. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49036. */
  49037. lensFlareSystems: Array<LensFlareSystem>;
  49038. /**
  49039. * Removes the given lens flare system from this scene.
  49040. * @param toRemove The lens flare system to remove
  49041. * @returns The index of the removed lens flare system
  49042. */
  49043. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49044. /**
  49045. * Adds the given lens flare system to this scene
  49046. * @param newLensFlareSystem The lens flare system to add
  49047. */
  49048. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49049. /**
  49050. * Gets a lens flare system using its name
  49051. * @param name defines the name to look for
  49052. * @returns the lens flare system or null if not found
  49053. */
  49054. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49055. /**
  49056. * Gets a lens flare system using its id
  49057. * @param id defines the id to look for
  49058. * @returns the lens flare system or null if not found
  49059. */
  49060. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49061. }
  49062. /**
  49063. * Defines the lens flare scene component responsible to manage any lens flares
  49064. * in a given scene.
  49065. */
  49066. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49067. /**
  49068. * The component name helpfull to identify the component in the list of scene components.
  49069. */
  49070. readonly name: string;
  49071. /**
  49072. * The scene the component belongs to.
  49073. */
  49074. scene: Scene;
  49075. /**
  49076. * Creates a new instance of the component for the given scene
  49077. * @param scene Defines the scene to register the component in
  49078. */
  49079. constructor(scene: Scene);
  49080. /**
  49081. * Registers the component in a given scene
  49082. */
  49083. register(): void;
  49084. /**
  49085. * Rebuilds the elements related to this component in case of
  49086. * context lost for instance.
  49087. */
  49088. rebuild(): void;
  49089. /**
  49090. * Adds all the elements from the container to the scene
  49091. * @param container the container holding the elements
  49092. */
  49093. addFromContainer(container: AbstractScene): void;
  49094. /**
  49095. * Removes all the elements in the container from the scene
  49096. * @param container contains the elements to remove
  49097. * @param dispose if the removed element should be disposed (default: false)
  49098. */
  49099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49100. /**
  49101. * Serializes the component data to the specified json object
  49102. * @param serializationObject The object to serialize to
  49103. */
  49104. serialize(serializationObject: any): void;
  49105. /**
  49106. * Disposes the component and the associated ressources.
  49107. */
  49108. dispose(): void;
  49109. private _draw;
  49110. }
  49111. }
  49112. declare module BABYLON {
  49113. /**
  49114. * Defines the shadow generator component responsible to manage any shadow generators
  49115. * in a given scene.
  49116. */
  49117. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49118. /**
  49119. * The component name helpfull to identify the component in the list of scene components.
  49120. */
  49121. readonly name: string;
  49122. /**
  49123. * The scene the component belongs to.
  49124. */
  49125. scene: Scene;
  49126. /**
  49127. * Creates a new instance of the component for the given scene
  49128. * @param scene Defines the scene to register the component in
  49129. */
  49130. constructor(scene: Scene);
  49131. /**
  49132. * Registers the component in a given scene
  49133. */
  49134. register(): void;
  49135. /**
  49136. * Rebuilds the elements related to this component in case of
  49137. * context lost for instance.
  49138. */
  49139. rebuild(): void;
  49140. /**
  49141. * Serializes the component data to the specified json object
  49142. * @param serializationObject The object to serialize to
  49143. */
  49144. serialize(serializationObject: any): void;
  49145. /**
  49146. * Adds all the elements from the container to the scene
  49147. * @param container the container holding the elements
  49148. */
  49149. addFromContainer(container: AbstractScene): void;
  49150. /**
  49151. * Removes all the elements in the container from the scene
  49152. * @param container contains the elements to remove
  49153. * @param dispose if the removed element should be disposed (default: false)
  49154. */
  49155. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49156. /**
  49157. * Rebuilds the elements related to this component in case of
  49158. * context lost for instance.
  49159. */
  49160. dispose(): void;
  49161. private _gatherRenderTargets;
  49162. }
  49163. }
  49164. declare module BABYLON {
  49165. /**
  49166. * A point light is a light defined by an unique point in world space.
  49167. * The light is emitted in every direction from this point.
  49168. * A good example of a point light is a standard light bulb.
  49169. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49170. */
  49171. export class PointLight extends ShadowLight {
  49172. private _shadowAngle;
  49173. /**
  49174. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49175. * This specifies what angle the shadow will use to be created.
  49176. *
  49177. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49178. */
  49179. /**
  49180. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49181. * This specifies what angle the shadow will use to be created.
  49182. *
  49183. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49184. */
  49185. shadowAngle: number;
  49186. /**
  49187. * Gets the direction if it has been set.
  49188. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49189. */
  49190. /**
  49191. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49192. */
  49193. direction: Vector3;
  49194. /**
  49195. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49196. * A PointLight emits the light in every direction.
  49197. * It can cast shadows.
  49198. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49199. * ```javascript
  49200. * var pointLight = new PointLight("pl", camera.position, scene);
  49201. * ```
  49202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49203. * @param name The light friendly name
  49204. * @param position The position of the point light in the scene
  49205. * @param scene The scene the lights belongs to
  49206. */
  49207. constructor(name: string, position: Vector3, scene: Scene);
  49208. /**
  49209. * Returns the string "PointLight"
  49210. * @returns the class name
  49211. */
  49212. getClassName(): string;
  49213. /**
  49214. * Returns the integer 0.
  49215. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49216. */
  49217. getTypeID(): number;
  49218. /**
  49219. * Specifies wether or not the shadowmap should be a cube texture.
  49220. * @returns true if the shadowmap needs to be a cube texture.
  49221. */
  49222. needCube(): boolean;
  49223. /**
  49224. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49225. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49226. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49227. */
  49228. getShadowDirection(faceIndex?: number): Vector3;
  49229. /**
  49230. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49231. * - fov = PI / 2
  49232. * - aspect ratio : 1.0
  49233. * - z-near and far equal to the active camera minZ and maxZ.
  49234. * Returns the PointLight.
  49235. */
  49236. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49237. protected _buildUniformLayout(): void;
  49238. /**
  49239. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49240. * @param effect The effect to update
  49241. * @param lightIndex The index of the light in the effect to update
  49242. * @returns The point light
  49243. */
  49244. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49245. /**
  49246. * Prepares the list of defines specific to the light type.
  49247. * @param defines the list of defines
  49248. * @param lightIndex defines the index of the light for the effect
  49249. */
  49250. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49251. }
  49252. }
  49253. declare module BABYLON {
  49254. /**
  49255. * Header information of HDR texture files.
  49256. */
  49257. export interface HDRInfo {
  49258. /**
  49259. * The height of the texture in pixels.
  49260. */
  49261. height: number;
  49262. /**
  49263. * The width of the texture in pixels.
  49264. */
  49265. width: number;
  49266. /**
  49267. * The index of the beginning of the data in the binary file.
  49268. */
  49269. dataPosition: number;
  49270. }
  49271. /**
  49272. * This groups tools to convert HDR texture to native colors array.
  49273. */
  49274. export class HDRTools {
  49275. private static Ldexp;
  49276. private static Rgbe2float;
  49277. private static readStringLine;
  49278. /**
  49279. * Reads header information from an RGBE texture stored in a native array.
  49280. * More information on this format are available here:
  49281. * https://en.wikipedia.org/wiki/RGBE_image_format
  49282. *
  49283. * @param uint8array The binary file stored in native array.
  49284. * @return The header information.
  49285. */
  49286. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49287. /**
  49288. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49289. * This RGBE texture needs to store the information as a panorama.
  49290. *
  49291. * More information on this format are available here:
  49292. * https://en.wikipedia.org/wiki/RGBE_image_format
  49293. *
  49294. * @param buffer The binary file stored in an array buffer.
  49295. * @param size The expected size of the extracted cubemap.
  49296. * @return The Cube Map information.
  49297. */
  49298. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49299. /**
  49300. * Returns the pixels data extracted from an RGBE texture.
  49301. * This pixels will be stored left to right up to down in the R G B order in one array.
  49302. *
  49303. * More information on this format are available here:
  49304. * https://en.wikipedia.org/wiki/RGBE_image_format
  49305. *
  49306. * @param uint8array The binary file stored in an array buffer.
  49307. * @param hdrInfo The header information of the file.
  49308. * @return The pixels data in RGB right to left up to down order.
  49309. */
  49310. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49311. private static RGBE_ReadPixels_RLE;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * This represents a texture coming from an HDR input.
  49317. *
  49318. * The only supported format is currently panorama picture stored in RGBE format.
  49319. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49320. */
  49321. export class HDRCubeTexture extends BaseTexture {
  49322. private static _facesMapping;
  49323. private _generateHarmonics;
  49324. private _noMipmap;
  49325. private _textureMatrix;
  49326. private _size;
  49327. private _onLoad;
  49328. private _onError;
  49329. /**
  49330. * The texture URL.
  49331. */
  49332. url: string;
  49333. /**
  49334. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49335. */
  49336. coordinatesMode: number;
  49337. protected _isBlocking: boolean;
  49338. /**
  49339. * Sets wether or not the texture is blocking during loading.
  49340. */
  49341. /**
  49342. * Gets wether or not the texture is blocking during loading.
  49343. */
  49344. isBlocking: boolean;
  49345. protected _rotationY: number;
  49346. /**
  49347. * Sets texture matrix rotation angle around Y axis in radians.
  49348. */
  49349. /**
  49350. * Gets texture matrix rotation angle around Y axis radians.
  49351. */
  49352. rotationY: number;
  49353. /**
  49354. * Gets or sets the center of the bounding box associated with the cube texture
  49355. * It must define where the camera used to render the texture was set
  49356. */
  49357. boundingBoxPosition: Vector3;
  49358. private _boundingBoxSize;
  49359. /**
  49360. * Gets or sets the size of the bounding box associated with the cube texture
  49361. * When defined, the cubemap will switch to local mode
  49362. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49363. * @example https://www.babylonjs-playground.com/#RNASML
  49364. */
  49365. boundingBoxSize: Vector3;
  49366. /**
  49367. * Instantiates an HDRTexture from the following parameters.
  49368. *
  49369. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49370. * @param scene The scene the texture will be used in
  49371. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49372. * @param noMipmap Forces to not generate the mipmap if true
  49373. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49374. * @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)
  49375. * @param reserved Reserved flag for internal use.
  49376. */
  49377. 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>);
  49378. /**
  49379. * Get the current class name of the texture useful for serialization or dynamic coding.
  49380. * @returns "HDRCubeTexture"
  49381. */
  49382. getClassName(): string;
  49383. /**
  49384. * Occurs when the file is raw .hdr file.
  49385. */
  49386. private loadTexture;
  49387. clone(): HDRCubeTexture;
  49388. delayLoad(): void;
  49389. /**
  49390. * Get the texture reflection matrix used to rotate/transform the reflection.
  49391. * @returns the reflection matrix
  49392. */
  49393. getReflectionTextureMatrix(): Matrix;
  49394. /**
  49395. * Set the texture reflection matrix used to rotate/transform the reflection.
  49396. * @param value Define the reflection matrix to set
  49397. */
  49398. setReflectionTextureMatrix(value: Matrix): void;
  49399. /**
  49400. * Parses a JSON representation of an HDR Texture in order to create the texture
  49401. * @param parsedTexture Define the JSON representation
  49402. * @param scene Define the scene the texture should be created in
  49403. * @param rootUrl Define the root url in case we need to load relative dependencies
  49404. * @returns the newly created texture after parsing
  49405. */
  49406. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49407. serialize(): any;
  49408. }
  49409. }
  49410. declare module BABYLON {
  49411. /**
  49412. * Class used to control physics engine
  49413. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49414. */
  49415. export class PhysicsEngine implements IPhysicsEngine {
  49416. private _physicsPlugin;
  49417. /**
  49418. * Global value used to control the smallest number supported by the simulation
  49419. */
  49420. static Epsilon: number;
  49421. private _impostors;
  49422. private _joints;
  49423. /**
  49424. * Gets the gravity vector used by the simulation
  49425. */
  49426. gravity: Vector3;
  49427. /**
  49428. * Factory used to create the default physics plugin.
  49429. * @returns The default physics plugin
  49430. */
  49431. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49432. /**
  49433. * Creates a new Physics Engine
  49434. * @param gravity defines the gravity vector used by the simulation
  49435. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49436. */
  49437. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49438. /**
  49439. * Sets the gravity vector used by the simulation
  49440. * @param gravity defines the gravity vector to use
  49441. */
  49442. setGravity(gravity: Vector3): void;
  49443. /**
  49444. * Set the time step of the physics engine.
  49445. * Default is 1/60.
  49446. * To slow it down, enter 1/600 for example.
  49447. * To speed it up, 1/30
  49448. * @param newTimeStep defines the new timestep to apply to this world.
  49449. */
  49450. setTimeStep(newTimeStep?: number): void;
  49451. /**
  49452. * Get the time step of the physics engine.
  49453. * @returns the current time step
  49454. */
  49455. getTimeStep(): number;
  49456. /**
  49457. * Release all resources
  49458. */
  49459. dispose(): void;
  49460. /**
  49461. * Gets the name of the current physics plugin
  49462. * @returns the name of the plugin
  49463. */
  49464. getPhysicsPluginName(): string;
  49465. /**
  49466. * Adding a new impostor for the impostor tracking.
  49467. * This will be done by the impostor itself.
  49468. * @param impostor the impostor to add
  49469. */
  49470. addImpostor(impostor: PhysicsImpostor): void;
  49471. /**
  49472. * Remove an impostor from the engine.
  49473. * This impostor and its mesh will not longer be updated by the physics engine.
  49474. * @param impostor the impostor to remove
  49475. */
  49476. removeImpostor(impostor: PhysicsImpostor): void;
  49477. /**
  49478. * Add a joint to the physics engine
  49479. * @param mainImpostor defines the main impostor to which the joint is added.
  49480. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49481. * @param joint defines the joint that will connect both impostors.
  49482. */
  49483. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49484. /**
  49485. * Removes a joint from the simulation
  49486. * @param mainImpostor defines the impostor used with the joint
  49487. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49488. * @param joint defines the joint to remove
  49489. */
  49490. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49491. /**
  49492. * Called by the scene. No need to call it.
  49493. * @param delta defines the timespam between frames
  49494. */
  49495. _step(delta: number): void;
  49496. /**
  49497. * Gets the current plugin used to run the simulation
  49498. * @returns current plugin
  49499. */
  49500. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49501. /**
  49502. * Gets the list of physic impostors
  49503. * @returns an array of PhysicsImpostor
  49504. */
  49505. getImpostors(): Array<PhysicsImpostor>;
  49506. /**
  49507. * Gets the impostor for a physics enabled object
  49508. * @param object defines the object impersonated by the impostor
  49509. * @returns the PhysicsImpostor or null if not found
  49510. */
  49511. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49512. /**
  49513. * Gets the impostor for a physics body object
  49514. * @param body defines physics body used by the impostor
  49515. * @returns the PhysicsImpostor or null if not found
  49516. */
  49517. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49518. /**
  49519. * Does a raycast in the physics world
  49520. * @param from when should the ray start?
  49521. * @param to when should the ray end?
  49522. * @returns PhysicsRaycastResult
  49523. */
  49524. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49525. }
  49526. }
  49527. declare module BABYLON {
  49528. /** @hidden */
  49529. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49530. private _useDeltaForWorldStep;
  49531. world: any;
  49532. name: string;
  49533. private _physicsMaterials;
  49534. private _fixedTimeStep;
  49535. private _cannonRaycastResult;
  49536. private _raycastResult;
  49537. private _physicsBodysToRemoveAfterStep;
  49538. BJSCANNON: any;
  49539. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49540. setGravity(gravity: Vector3): void;
  49541. setTimeStep(timeStep: number): void;
  49542. getTimeStep(): number;
  49543. executeStep(delta: number): void;
  49544. private _removeMarkedPhysicsBodiesFromWorld;
  49545. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49546. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49547. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49548. private _processChildMeshes;
  49549. removePhysicsBody(impostor: PhysicsImpostor): void;
  49550. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49551. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49552. private _addMaterial;
  49553. private _checkWithEpsilon;
  49554. private _createShape;
  49555. private _createHeightmap;
  49556. private _minus90X;
  49557. private _plus90X;
  49558. private _tmpPosition;
  49559. private _tmpDeltaPosition;
  49560. private _tmpUnityRotation;
  49561. private _updatePhysicsBodyTransformation;
  49562. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49563. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49564. isSupported(): boolean;
  49565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49566. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49567. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49568. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49569. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49570. getBodyMass(impostor: PhysicsImpostor): number;
  49571. getBodyFriction(impostor: PhysicsImpostor): number;
  49572. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49573. getBodyRestitution(impostor: PhysicsImpostor): number;
  49574. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49575. sleepBody(impostor: PhysicsImpostor): void;
  49576. wakeUpBody(impostor: PhysicsImpostor): void;
  49577. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49578. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49579. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49580. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49581. getRadius(impostor: PhysicsImpostor): number;
  49582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49583. dispose(): void;
  49584. private _extendNamespace;
  49585. /**
  49586. * Does a raycast in the physics world
  49587. * @param from when should the ray start?
  49588. * @param to when should the ray end?
  49589. * @returns PhysicsRaycastResult
  49590. */
  49591. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49592. }
  49593. }
  49594. declare module BABYLON {
  49595. /** @hidden */
  49596. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49597. world: any;
  49598. name: string;
  49599. BJSOIMO: any;
  49600. private _raycastResult;
  49601. constructor(iterations?: number, oimoInjection?: any);
  49602. setGravity(gravity: Vector3): void;
  49603. setTimeStep(timeStep: number): void;
  49604. getTimeStep(): number;
  49605. private _tmpImpostorsArray;
  49606. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49607. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49608. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49609. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49610. private _tmpPositionVector;
  49611. removePhysicsBody(impostor: PhysicsImpostor): void;
  49612. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49613. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49614. isSupported(): boolean;
  49615. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49616. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49617. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49618. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49619. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49620. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49621. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49622. getBodyMass(impostor: PhysicsImpostor): number;
  49623. getBodyFriction(impostor: PhysicsImpostor): number;
  49624. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49625. getBodyRestitution(impostor: PhysicsImpostor): number;
  49626. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49627. sleepBody(impostor: PhysicsImpostor): void;
  49628. wakeUpBody(impostor: PhysicsImpostor): void;
  49629. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49630. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49631. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49632. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49633. getRadius(impostor: PhysicsImpostor): number;
  49634. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49635. dispose(): void;
  49636. /**
  49637. * Does a raycast in the physics world
  49638. * @param from when should the ray start?
  49639. * @param to when should the ray end?
  49640. * @returns PhysicsRaycastResult
  49641. */
  49642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * Class containing static functions to help procedurally build meshes
  49648. */
  49649. export class RibbonBuilder {
  49650. /**
  49651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49655. * * 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
  49656. * * 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
  49657. * * 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
  49658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49659. * * 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
  49660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49661. * * 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
  49662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49663. * * 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
  49664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49666. * @param name defines the name of the mesh
  49667. * @param options defines the options used to create the mesh
  49668. * @param scene defines the hosting scene
  49669. * @returns the ribbon mesh
  49670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49672. */
  49673. static CreateRibbon(name: string, options: {
  49674. pathArray: Vector3[][];
  49675. closeArray?: boolean;
  49676. closePath?: boolean;
  49677. offset?: number;
  49678. updatable?: boolean;
  49679. sideOrientation?: number;
  49680. frontUVs?: Vector4;
  49681. backUVs?: Vector4;
  49682. instance?: Mesh;
  49683. invertUV?: boolean;
  49684. uvs?: Vector2[];
  49685. colors?: Color4[];
  49686. }, scene?: Nullable<Scene>): Mesh;
  49687. }
  49688. }
  49689. declare module BABYLON {
  49690. /**
  49691. * Class containing static functions to help procedurally build meshes
  49692. */
  49693. export class ShapeBuilder {
  49694. /**
  49695. * 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.
  49696. * * 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.
  49697. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49698. * * 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.
  49699. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49700. * * 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
  49701. * * 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
  49702. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49704. * * 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
  49705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49707. * @param name defines the name of the mesh
  49708. * @param options defines the options used to create the mesh
  49709. * @param scene defines the hosting scene
  49710. * @returns the extruded shape mesh
  49711. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49713. */
  49714. static ExtrudeShape(name: string, options: {
  49715. shape: Vector3[];
  49716. path: Vector3[];
  49717. scale?: number;
  49718. rotation?: number;
  49719. cap?: number;
  49720. updatable?: boolean;
  49721. sideOrientation?: number;
  49722. frontUVs?: Vector4;
  49723. backUVs?: Vector4;
  49724. instance?: Mesh;
  49725. invertUV?: boolean;
  49726. }, scene?: Nullable<Scene>): Mesh;
  49727. /**
  49728. * Creates an custom extruded shape mesh.
  49729. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49730. * * 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.
  49731. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49732. * * 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
  49733. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49734. * * 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
  49735. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49736. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49737. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49738. * * 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
  49739. * * 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
  49740. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49742. * * 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
  49743. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49745. * @param name defines the name of the mesh
  49746. * @param options defines the options used to create the mesh
  49747. * @param scene defines the hosting scene
  49748. * @returns the custom extruded shape mesh
  49749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49752. */
  49753. static ExtrudeShapeCustom(name: string, options: {
  49754. shape: Vector3[];
  49755. path: Vector3[];
  49756. scaleFunction?: any;
  49757. rotationFunction?: any;
  49758. ribbonCloseArray?: boolean;
  49759. ribbonClosePath?: boolean;
  49760. cap?: number;
  49761. updatable?: boolean;
  49762. sideOrientation?: number;
  49763. frontUVs?: Vector4;
  49764. backUVs?: Vector4;
  49765. instance?: Mesh;
  49766. invertUV?: boolean;
  49767. }, scene?: Nullable<Scene>): Mesh;
  49768. private static _ExtrudeShapeGeneric;
  49769. }
  49770. }
  49771. declare module BABYLON {
  49772. /**
  49773. * AmmoJS Physics plugin
  49774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49775. * @see https://github.com/kripken/ammo.js/
  49776. */
  49777. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49778. private _useDeltaForWorldStep;
  49779. /**
  49780. * Reference to the Ammo library
  49781. */
  49782. bjsAMMO: any;
  49783. /**
  49784. * Created ammoJS world which physics bodies are added to
  49785. */
  49786. world: any;
  49787. /**
  49788. * Name of the plugin
  49789. */
  49790. name: string;
  49791. private _timeStep;
  49792. private _fixedTimeStep;
  49793. private _maxSteps;
  49794. private _tmpQuaternion;
  49795. private _tmpAmmoTransform;
  49796. private _tmpAmmoQuaternion;
  49797. private _tmpAmmoConcreteContactResultCallback;
  49798. private _collisionConfiguration;
  49799. private _dispatcher;
  49800. private _overlappingPairCache;
  49801. private _solver;
  49802. private _softBodySolver;
  49803. private _tmpAmmoVectorA;
  49804. private _tmpAmmoVectorB;
  49805. private _tmpAmmoVectorC;
  49806. private _tmpAmmoVectorD;
  49807. private _tmpContactCallbackResult;
  49808. private _tmpAmmoVectorRCA;
  49809. private _tmpAmmoVectorRCB;
  49810. private _raycastResult;
  49811. private static readonly DISABLE_COLLISION_FLAG;
  49812. private static readonly KINEMATIC_FLAG;
  49813. private static readonly DISABLE_DEACTIVATION_FLAG;
  49814. /**
  49815. * Initializes the ammoJS plugin
  49816. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49817. * @param ammoInjection can be used to inject your own ammo reference
  49818. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49819. */
  49820. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49821. /**
  49822. * Sets the gravity of the physics world (m/(s^2))
  49823. * @param gravity Gravity to set
  49824. */
  49825. setGravity(gravity: Vector3): void;
  49826. /**
  49827. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49828. * @param timeStep timestep to use in seconds
  49829. */
  49830. setTimeStep(timeStep: number): void;
  49831. /**
  49832. * 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)
  49833. * @param fixedTimeStep fixedTimeStep to use in seconds
  49834. */
  49835. setFixedTimeStep(fixedTimeStep: number): void;
  49836. /**
  49837. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49838. * @param maxSteps the maximum number of steps by the physics engine per frame
  49839. */
  49840. setMaxSteps(maxSteps: number): void;
  49841. /**
  49842. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49843. * @returns the current timestep in seconds
  49844. */
  49845. getTimeStep(): number;
  49846. private _isImpostorInContact;
  49847. private _isImpostorPairInContact;
  49848. private _stepSimulation;
  49849. /**
  49850. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49851. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49852. * After the step the babylon meshes are set to the position of the physics imposters
  49853. * @param delta amount of time to step forward
  49854. * @param impostors array of imposters to update before/after the step
  49855. */
  49856. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49857. /**
  49858. * Update babylon mesh to match physics world object
  49859. * @param impostor imposter to match
  49860. */
  49861. private _afterSoftStep;
  49862. /**
  49863. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49864. * @param impostor imposter to match
  49865. */
  49866. private _ropeStep;
  49867. /**
  49868. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49869. * @param impostor imposter to match
  49870. */
  49871. private _softbodyOrClothStep;
  49872. private _tmpVector;
  49873. private _tmpMatrix;
  49874. /**
  49875. * Applies an impulse on the imposter
  49876. * @param impostor imposter to apply impulse to
  49877. * @param force amount of force to be applied to the imposter
  49878. * @param contactPoint the location to apply the impulse on the imposter
  49879. */
  49880. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49881. /**
  49882. * Applies a force on the imposter
  49883. * @param impostor imposter to apply force
  49884. * @param force amount of force to be applied to the imposter
  49885. * @param contactPoint the location to apply the force on the imposter
  49886. */
  49887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49888. /**
  49889. * Creates a physics body using the plugin
  49890. * @param impostor the imposter to create the physics body on
  49891. */
  49892. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49893. /**
  49894. * Removes the physics body from the imposter and disposes of the body's memory
  49895. * @param impostor imposter to remove the physics body from
  49896. */
  49897. removePhysicsBody(impostor: PhysicsImpostor): void;
  49898. /**
  49899. * Generates a joint
  49900. * @param impostorJoint the imposter joint to create the joint with
  49901. */
  49902. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49903. /**
  49904. * Removes a joint
  49905. * @param impostorJoint the imposter joint to remove the joint from
  49906. */
  49907. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49908. private _addMeshVerts;
  49909. /**
  49910. * Initialise the soft body vertices to match its object's (mesh) vertices
  49911. * Softbody vertices (nodes) are in world space and to match this
  49912. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49913. * @param impostor to create the softbody for
  49914. */
  49915. private _softVertexData;
  49916. /**
  49917. * Create an impostor's soft body
  49918. * @param impostor to create the softbody for
  49919. */
  49920. private _createSoftbody;
  49921. /**
  49922. * Create cloth for an impostor
  49923. * @param impostor to create the softbody for
  49924. */
  49925. private _createCloth;
  49926. /**
  49927. * Create rope for an impostor
  49928. * @param impostor to create the softbody for
  49929. */
  49930. private _createRope;
  49931. private _addHullVerts;
  49932. private _createShape;
  49933. /**
  49934. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49935. * @param impostor imposter containing the physics body and babylon object
  49936. */
  49937. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49938. /**
  49939. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49940. * @param impostor imposter containing the physics body and babylon object
  49941. * @param newPosition new position
  49942. * @param newRotation new rotation
  49943. */
  49944. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49945. /**
  49946. * If this plugin is supported
  49947. * @returns true if its supported
  49948. */
  49949. isSupported(): boolean;
  49950. /**
  49951. * Sets the linear velocity of the physics body
  49952. * @param impostor imposter to set the velocity on
  49953. * @param velocity velocity to set
  49954. */
  49955. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49956. /**
  49957. * Sets the angular velocity of the physics body
  49958. * @param impostor imposter to set the velocity on
  49959. * @param velocity velocity to set
  49960. */
  49961. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49962. /**
  49963. * gets the linear velocity
  49964. * @param impostor imposter to get linear velocity from
  49965. * @returns linear velocity
  49966. */
  49967. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49968. /**
  49969. * gets the angular velocity
  49970. * @param impostor imposter to get angular velocity from
  49971. * @returns angular velocity
  49972. */
  49973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49974. /**
  49975. * Sets the mass of physics body
  49976. * @param impostor imposter to set the mass on
  49977. * @param mass mass to set
  49978. */
  49979. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49980. /**
  49981. * Gets the mass of the physics body
  49982. * @param impostor imposter to get the mass from
  49983. * @returns mass
  49984. */
  49985. getBodyMass(impostor: PhysicsImpostor): number;
  49986. /**
  49987. * Gets friction of the impostor
  49988. * @param impostor impostor to get friction from
  49989. * @returns friction value
  49990. */
  49991. getBodyFriction(impostor: PhysicsImpostor): number;
  49992. /**
  49993. * Sets friction of the impostor
  49994. * @param impostor impostor to set friction on
  49995. * @param friction friction value
  49996. */
  49997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49998. /**
  49999. * Gets restitution of the impostor
  50000. * @param impostor impostor to get restitution from
  50001. * @returns restitution value
  50002. */
  50003. getBodyRestitution(impostor: PhysicsImpostor): number;
  50004. /**
  50005. * Sets resitution of the impostor
  50006. * @param impostor impostor to set resitution on
  50007. * @param restitution resitution value
  50008. */
  50009. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50010. /**
  50011. * Gets pressure inside the impostor
  50012. * @param impostor impostor to get pressure from
  50013. * @returns pressure value
  50014. */
  50015. getBodyPressure(impostor: PhysicsImpostor): number;
  50016. /**
  50017. * Sets pressure inside a soft body impostor
  50018. * Cloth and rope must remain 0 pressure
  50019. * @param impostor impostor to set pressure on
  50020. * @param pressure pressure value
  50021. */
  50022. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50023. /**
  50024. * Gets stiffness of the impostor
  50025. * @param impostor impostor to get stiffness from
  50026. * @returns pressure value
  50027. */
  50028. getBodyStiffness(impostor: PhysicsImpostor): number;
  50029. /**
  50030. * Sets stiffness of the impostor
  50031. * @param impostor impostor to set stiffness on
  50032. * @param stiffness stiffness value from 0 to 1
  50033. */
  50034. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50035. /**
  50036. * Gets velocityIterations of the impostor
  50037. * @param impostor impostor to get velocity iterations from
  50038. * @returns velocityIterations value
  50039. */
  50040. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50041. /**
  50042. * Sets velocityIterations of the impostor
  50043. * @param impostor impostor to set velocity iterations on
  50044. * @param velocityIterations velocityIterations value
  50045. */
  50046. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50047. /**
  50048. * Gets positionIterations of the impostor
  50049. * @param impostor impostor to get position iterations from
  50050. * @returns positionIterations value
  50051. */
  50052. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50053. /**
  50054. * Sets positionIterations of the impostor
  50055. * @param impostor impostor to set position on
  50056. * @param positionIterations positionIterations value
  50057. */
  50058. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50059. /**
  50060. * Append an anchor to a cloth object
  50061. * @param impostor is the cloth impostor to add anchor to
  50062. * @param otherImpostor is the rigid impostor to anchor to
  50063. * @param width ratio across width from 0 to 1
  50064. * @param height ratio up height from 0 to 1
  50065. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50066. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50067. */
  50068. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50069. /**
  50070. * Append an hook to a rope object
  50071. * @param impostor is the rope impostor to add hook to
  50072. * @param otherImpostor is the rigid impostor to hook to
  50073. * @param length ratio along the rope from 0 to 1
  50074. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50075. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50076. */
  50077. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50078. /**
  50079. * Sleeps the physics body and stops it from being active
  50080. * @param impostor impostor to sleep
  50081. */
  50082. sleepBody(impostor: PhysicsImpostor): void;
  50083. /**
  50084. * Activates the physics body
  50085. * @param impostor impostor to activate
  50086. */
  50087. wakeUpBody(impostor: PhysicsImpostor): void;
  50088. /**
  50089. * Updates the distance parameters of the joint
  50090. * @param joint joint to update
  50091. * @param maxDistance maximum distance of the joint
  50092. * @param minDistance minimum distance of the joint
  50093. */
  50094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50095. /**
  50096. * Sets a motor on the joint
  50097. * @param joint joint to set motor on
  50098. * @param speed speed of the motor
  50099. * @param maxForce maximum force of the motor
  50100. * @param motorIndex index of the motor
  50101. */
  50102. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50103. /**
  50104. * Sets the motors limit
  50105. * @param joint joint to set limit on
  50106. * @param upperLimit upper limit
  50107. * @param lowerLimit lower limit
  50108. */
  50109. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50110. /**
  50111. * Syncs the position and rotation of a mesh with the impostor
  50112. * @param mesh mesh to sync
  50113. * @param impostor impostor to update the mesh with
  50114. */
  50115. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50116. /**
  50117. * Gets the radius of the impostor
  50118. * @param impostor impostor to get radius from
  50119. * @returns the radius
  50120. */
  50121. getRadius(impostor: PhysicsImpostor): number;
  50122. /**
  50123. * Gets the box size of the impostor
  50124. * @param impostor impostor to get box size from
  50125. * @param result the resulting box size
  50126. */
  50127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50128. /**
  50129. * Disposes of the impostor
  50130. */
  50131. dispose(): void;
  50132. /**
  50133. * Does a raycast in the physics world
  50134. * @param from when should the ray start?
  50135. * @param to when should the ray end?
  50136. * @returns PhysicsRaycastResult
  50137. */
  50138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50139. }
  50140. }
  50141. declare module BABYLON {
  50142. interface AbstractScene {
  50143. /**
  50144. * The list of reflection probes added to the scene
  50145. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50146. */
  50147. reflectionProbes: Array<ReflectionProbe>;
  50148. /**
  50149. * Removes the given reflection probe from this scene.
  50150. * @param toRemove The reflection probe to remove
  50151. * @returns The index of the removed reflection probe
  50152. */
  50153. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50154. /**
  50155. * Adds the given reflection probe to this scene.
  50156. * @param newReflectionProbe The reflection probe to add
  50157. */
  50158. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50159. }
  50160. /**
  50161. * Class used to generate realtime reflection / refraction cube textures
  50162. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50163. */
  50164. export class ReflectionProbe {
  50165. /** defines the name of the probe */
  50166. name: string;
  50167. private _scene;
  50168. private _renderTargetTexture;
  50169. private _projectionMatrix;
  50170. private _viewMatrix;
  50171. private _target;
  50172. private _add;
  50173. private _attachedMesh;
  50174. private _invertYAxis;
  50175. /** Gets or sets probe position (center of the cube map) */
  50176. position: Vector3;
  50177. /**
  50178. * Creates a new reflection probe
  50179. * @param name defines the name of the probe
  50180. * @param size defines the texture resolution (for each face)
  50181. * @param scene defines the hosting scene
  50182. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50183. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50184. */
  50185. constructor(
  50186. /** defines the name of the probe */
  50187. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50188. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50189. samples: number;
  50190. /** Gets or sets the refresh rate to use (on every frame by default) */
  50191. refreshRate: number;
  50192. /**
  50193. * Gets the hosting scene
  50194. * @returns a Scene
  50195. */
  50196. getScene(): Scene;
  50197. /** Gets the internal CubeTexture used to render to */
  50198. readonly cubeTexture: RenderTargetTexture;
  50199. /** Gets the list of meshes to render */
  50200. readonly renderList: Nullable<AbstractMesh[]>;
  50201. /**
  50202. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50203. * @param mesh defines the mesh to attach to
  50204. */
  50205. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50206. /**
  50207. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50208. * @param renderingGroupId The rendering group id corresponding to its index
  50209. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50210. */
  50211. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50212. /**
  50213. * Clean all associated resources
  50214. */
  50215. dispose(): void;
  50216. /**
  50217. * Converts the reflection probe information to a readable string for debug purpose.
  50218. * @param fullDetails Supports for multiple levels of logging within scene loading
  50219. * @returns the human readable reflection probe info
  50220. */
  50221. toString(fullDetails?: boolean): string;
  50222. /**
  50223. * Get the class name of the relfection probe.
  50224. * @returns "ReflectionProbe"
  50225. */
  50226. getClassName(): string;
  50227. /**
  50228. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50229. * @returns The JSON representation of the texture
  50230. */
  50231. serialize(): any;
  50232. /**
  50233. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50234. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50235. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50236. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50237. * @returns The parsed reflection probe if successful
  50238. */
  50239. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /** @hidden */
  50244. export var _BabylonLoaderRegistered: boolean;
  50245. }
  50246. declare module BABYLON {
  50247. /**
  50248. * The Physically based simple base material of BJS.
  50249. *
  50250. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50251. * It is used as the base class for both the specGloss and metalRough conventions.
  50252. */
  50253. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50254. /**
  50255. * Number of Simultaneous lights allowed on the material.
  50256. */
  50257. maxSimultaneousLights: number;
  50258. /**
  50259. * If sets to true, disables all the lights affecting the material.
  50260. */
  50261. disableLighting: boolean;
  50262. /**
  50263. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50264. */
  50265. environmentTexture: BaseTexture;
  50266. /**
  50267. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50268. */
  50269. invertNormalMapX: boolean;
  50270. /**
  50271. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50272. */
  50273. invertNormalMapY: boolean;
  50274. /**
  50275. * Normal map used in the model.
  50276. */
  50277. normalTexture: BaseTexture;
  50278. /**
  50279. * Emissivie color used to self-illuminate the model.
  50280. */
  50281. emissiveColor: Color3;
  50282. /**
  50283. * Emissivie texture used to self-illuminate the model.
  50284. */
  50285. emissiveTexture: BaseTexture;
  50286. /**
  50287. * Occlusion Channel Strenght.
  50288. */
  50289. occlusionStrength: number;
  50290. /**
  50291. * Occlusion Texture of the material (adding extra occlusion effects).
  50292. */
  50293. occlusionTexture: BaseTexture;
  50294. /**
  50295. * Defines the alpha limits in alpha test mode.
  50296. */
  50297. alphaCutOff: number;
  50298. /**
  50299. * Gets the current double sided mode.
  50300. */
  50301. /**
  50302. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50303. */
  50304. doubleSided: boolean;
  50305. /**
  50306. * Stores the pre-calculated light information of a mesh in a texture.
  50307. */
  50308. lightmapTexture: BaseTexture;
  50309. /**
  50310. * If true, the light map contains occlusion information instead of lighting info.
  50311. */
  50312. useLightmapAsShadowmap: boolean;
  50313. /**
  50314. * Instantiates a new PBRMaterial instance.
  50315. *
  50316. * @param name The material name
  50317. * @param scene The scene the material will be use in.
  50318. */
  50319. constructor(name: string, scene: Scene);
  50320. getClassName(): string;
  50321. }
  50322. }
  50323. declare module BABYLON {
  50324. /**
  50325. * The PBR material of BJS following the metal roughness convention.
  50326. *
  50327. * This fits to the PBR convention in the GLTF definition:
  50328. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50329. */
  50330. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50331. /**
  50332. * The base color has two different interpretations depending on the value of metalness.
  50333. * When the material is a metal, the base color is the specific measured reflectance value
  50334. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50335. * of the material.
  50336. */
  50337. baseColor: Color3;
  50338. /**
  50339. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50340. * well as opacity information in the alpha channel.
  50341. */
  50342. baseTexture: BaseTexture;
  50343. /**
  50344. * Specifies the metallic scalar value of the material.
  50345. * Can also be used to scale the metalness values of the metallic texture.
  50346. */
  50347. metallic: number;
  50348. /**
  50349. * Specifies the roughness scalar value of the material.
  50350. * Can also be used to scale the roughness values of the metallic texture.
  50351. */
  50352. roughness: number;
  50353. /**
  50354. * Texture containing both the metallic value in the B channel and the
  50355. * roughness value in the G channel to keep better precision.
  50356. */
  50357. metallicRoughnessTexture: BaseTexture;
  50358. /**
  50359. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50360. *
  50361. * @param name The material name
  50362. * @param scene The scene the material will be use in.
  50363. */
  50364. constructor(name: string, scene: Scene);
  50365. /**
  50366. * Return the currrent class name of the material.
  50367. */
  50368. getClassName(): string;
  50369. /**
  50370. * Makes a duplicate of the current material.
  50371. * @param name - name to use for the new material.
  50372. */
  50373. clone(name: string): PBRMetallicRoughnessMaterial;
  50374. /**
  50375. * Serialize the material to a parsable JSON object.
  50376. */
  50377. serialize(): any;
  50378. /**
  50379. * Parses a JSON object correponding to the serialize function.
  50380. */
  50381. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50382. }
  50383. }
  50384. declare module BABYLON {
  50385. /**
  50386. * The PBR material of BJS following the specular glossiness convention.
  50387. *
  50388. * This fits to the PBR convention in the GLTF definition:
  50389. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50390. */
  50391. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50392. /**
  50393. * Specifies the diffuse color of the material.
  50394. */
  50395. diffuseColor: Color3;
  50396. /**
  50397. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50398. * channel.
  50399. */
  50400. diffuseTexture: BaseTexture;
  50401. /**
  50402. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50403. */
  50404. specularColor: Color3;
  50405. /**
  50406. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50407. */
  50408. glossiness: number;
  50409. /**
  50410. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50411. */
  50412. specularGlossinessTexture: BaseTexture;
  50413. /**
  50414. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50415. *
  50416. * @param name The material name
  50417. * @param scene The scene the material will be use in.
  50418. */
  50419. constructor(name: string, scene: Scene);
  50420. /**
  50421. * Return the currrent class name of the material.
  50422. */
  50423. getClassName(): string;
  50424. /**
  50425. * Makes a duplicate of the current material.
  50426. * @param name - name to use for the new material.
  50427. */
  50428. clone(name: string): PBRSpecularGlossinessMaterial;
  50429. /**
  50430. * Serialize the material to a parsable JSON object.
  50431. */
  50432. serialize(): any;
  50433. /**
  50434. * Parses a JSON object correponding to the serialize function.
  50435. */
  50436. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50437. }
  50438. }
  50439. declare module BABYLON {
  50440. /**
  50441. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50442. * It can help converting any input color in a desired output one. This can then be used to create effects
  50443. * from sepia, black and white to sixties or futuristic rendering...
  50444. *
  50445. * The only supported format is currently 3dl.
  50446. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50447. */
  50448. export class ColorGradingTexture extends BaseTexture {
  50449. /**
  50450. * The current texture matrix. (will always be identity in color grading texture)
  50451. */
  50452. private _textureMatrix;
  50453. /**
  50454. * The texture URL.
  50455. */
  50456. url: string;
  50457. /**
  50458. * Empty line regex stored for GC.
  50459. */
  50460. private static _noneEmptyLineRegex;
  50461. private _engine;
  50462. /**
  50463. * Instantiates a ColorGradingTexture from the following parameters.
  50464. *
  50465. * @param url The location of the color gradind data (currently only supporting 3dl)
  50466. * @param scene The scene the texture will be used in
  50467. */
  50468. constructor(url: string, scene: Scene);
  50469. /**
  50470. * Returns the texture matrix used in most of the material.
  50471. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50472. */
  50473. getTextureMatrix(): Matrix;
  50474. /**
  50475. * Occurs when the file being loaded is a .3dl LUT file.
  50476. */
  50477. private load3dlTexture;
  50478. /**
  50479. * Starts the loading process of the texture.
  50480. */
  50481. private loadTexture;
  50482. /**
  50483. * Clones the color gradind texture.
  50484. */
  50485. clone(): ColorGradingTexture;
  50486. /**
  50487. * Called during delayed load for textures.
  50488. */
  50489. delayLoad(): void;
  50490. /**
  50491. * Parses a color grading texture serialized by Babylon.
  50492. * @param parsedTexture The texture information being parsedTexture
  50493. * @param scene The scene to load the texture in
  50494. * @param rootUrl The root url of the data assets to load
  50495. * @return A color gradind texture
  50496. */
  50497. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50498. /**
  50499. * Serializes the LUT texture to json format.
  50500. */
  50501. serialize(): any;
  50502. }
  50503. }
  50504. declare module BABYLON {
  50505. /**
  50506. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50507. */
  50508. export class EquiRectangularCubeTexture extends BaseTexture {
  50509. /** The six faces of the cube. */
  50510. private static _FacesMapping;
  50511. private _noMipmap;
  50512. private _onLoad;
  50513. private _onError;
  50514. /** The size of the cubemap. */
  50515. private _size;
  50516. /** The buffer of the image. */
  50517. private _buffer;
  50518. /** The width of the input image. */
  50519. private _width;
  50520. /** The height of the input image. */
  50521. private _height;
  50522. /** The URL to the image. */
  50523. url: string;
  50524. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50525. coordinatesMode: number;
  50526. /**
  50527. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50528. * @param url The location of the image
  50529. * @param scene The scene the texture will be used in
  50530. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50531. * @param noMipmap Forces to not generate the mipmap if true
  50532. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50533. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50534. * @param onLoad — defines a callback called when texture is loaded
  50535. * @param onError — defines a callback called if there is an error
  50536. */
  50537. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50538. /**
  50539. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50540. */
  50541. private loadImage;
  50542. /**
  50543. * Convert the image buffer into a cubemap and create a CubeTexture.
  50544. */
  50545. private loadTexture;
  50546. /**
  50547. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50548. * @param buffer The ArrayBuffer that should be converted.
  50549. * @returns The buffer as Float32Array.
  50550. */
  50551. private getFloat32ArrayFromArrayBuffer;
  50552. /**
  50553. * Get the current class name of the texture useful for serialization or dynamic coding.
  50554. * @returns "EquiRectangularCubeTexture"
  50555. */
  50556. getClassName(): string;
  50557. /**
  50558. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50559. * @returns A clone of the current EquiRectangularCubeTexture.
  50560. */
  50561. clone(): EquiRectangularCubeTexture;
  50562. }
  50563. }
  50564. declare module BABYLON {
  50565. /**
  50566. * Based on jsTGALoader - Javascript loader for TGA file
  50567. * By Vincent Thibault
  50568. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50569. */
  50570. export class TGATools {
  50571. private static _TYPE_INDEXED;
  50572. private static _TYPE_RGB;
  50573. private static _TYPE_GREY;
  50574. private static _TYPE_RLE_INDEXED;
  50575. private static _TYPE_RLE_RGB;
  50576. private static _TYPE_RLE_GREY;
  50577. private static _ORIGIN_MASK;
  50578. private static _ORIGIN_SHIFT;
  50579. private static _ORIGIN_BL;
  50580. private static _ORIGIN_BR;
  50581. private static _ORIGIN_UL;
  50582. private static _ORIGIN_UR;
  50583. /**
  50584. * Gets the header of a TGA file
  50585. * @param data defines the TGA data
  50586. * @returns the header
  50587. */
  50588. static GetTGAHeader(data: Uint8Array): any;
  50589. /**
  50590. * Uploads TGA content to a Babylon Texture
  50591. * @hidden
  50592. */
  50593. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50594. /** @hidden */
  50595. 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;
  50596. /** @hidden */
  50597. 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;
  50598. /** @hidden */
  50599. 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;
  50600. /** @hidden */
  50601. 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;
  50602. /** @hidden */
  50603. 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;
  50604. /** @hidden */
  50605. 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;
  50606. }
  50607. }
  50608. declare module BABYLON {
  50609. /**
  50610. * Implementation of the TGA Texture Loader.
  50611. * @hidden
  50612. */
  50613. export class _TGATextureLoader implements IInternalTextureLoader {
  50614. /**
  50615. * Defines wether the loader supports cascade loading the different faces.
  50616. */
  50617. readonly supportCascades: boolean;
  50618. /**
  50619. * This returns if the loader support the current file information.
  50620. * @param extension defines the file extension of the file being loaded
  50621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50622. * @param fallback defines the fallback internal texture if any
  50623. * @param isBase64 defines whether the texture is encoded as a base64
  50624. * @param isBuffer defines whether the texture data are stored as a buffer
  50625. * @returns true if the loader can load the specified file
  50626. */
  50627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50628. /**
  50629. * Transform the url before loading if required.
  50630. * @param rootUrl the url of the texture
  50631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50632. * @returns the transformed texture
  50633. */
  50634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50635. /**
  50636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50637. * @param rootUrl the url of the texture
  50638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50639. * @returns the fallback texture
  50640. */
  50641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50642. /**
  50643. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50644. * @param data contains the texture data
  50645. * @param texture defines the BabylonJS internal texture
  50646. * @param createPolynomials will be true if polynomials have been requested
  50647. * @param onLoad defines the callback to trigger once the texture is ready
  50648. * @param onError defines the callback to trigger in case of error
  50649. */
  50650. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50651. /**
  50652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50653. * @param data contains the texture data
  50654. * @param texture defines the BabylonJS internal texture
  50655. * @param callback defines the method to call once ready to upload
  50656. */
  50657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50658. }
  50659. }
  50660. declare module BABYLON {
  50661. /**
  50662. * Info about the .basis files
  50663. */
  50664. class BasisFileInfo {
  50665. /**
  50666. * If the file has alpha
  50667. */
  50668. hasAlpha: boolean;
  50669. /**
  50670. * Info about each image of the basis file
  50671. */
  50672. images: Array<{
  50673. levels: Array<{
  50674. width: number;
  50675. height: number;
  50676. transcodedPixels: ArrayBufferView;
  50677. }>;
  50678. }>;
  50679. }
  50680. /**
  50681. * Result of transcoding a basis file
  50682. */
  50683. class TranscodeResult {
  50684. /**
  50685. * Info about the .basis file
  50686. */
  50687. fileInfo: BasisFileInfo;
  50688. /**
  50689. * Format to use when loading the file
  50690. */
  50691. format: number;
  50692. }
  50693. /**
  50694. * Configuration options for the Basis transcoder
  50695. */
  50696. export class BasisTranscodeConfiguration {
  50697. /**
  50698. * Supported compression formats used to determine the supported output format of the transcoder
  50699. */
  50700. supportedCompressionFormats?: {
  50701. /**
  50702. * etc1 compression format
  50703. */
  50704. etc1?: boolean;
  50705. /**
  50706. * s3tc compression format
  50707. */
  50708. s3tc?: boolean;
  50709. /**
  50710. * pvrtc compression format
  50711. */
  50712. pvrtc?: boolean;
  50713. /**
  50714. * etc2 compression format
  50715. */
  50716. etc2?: boolean;
  50717. };
  50718. /**
  50719. * If mipmap levels should be loaded for transcoded images (Default: true)
  50720. */
  50721. loadMipmapLevels?: boolean;
  50722. /**
  50723. * Index of a single image to load (Default: all images)
  50724. */
  50725. loadSingleImage?: number;
  50726. }
  50727. /**
  50728. * Used to load .Basis files
  50729. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50730. */
  50731. export class BasisTools {
  50732. private static _IgnoreSupportedFormats;
  50733. /**
  50734. * URL to use when loading the basis transcoder
  50735. */
  50736. static JSModuleURL: string;
  50737. /**
  50738. * URL to use when loading the wasm module for the transcoder
  50739. */
  50740. static WasmModuleURL: string;
  50741. /**
  50742. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50743. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50744. * @returns internal format corresponding to the Basis format
  50745. */
  50746. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50747. private static _WorkerPromise;
  50748. private static _Worker;
  50749. private static _actionId;
  50750. private static _CreateWorkerAsync;
  50751. /**
  50752. * Transcodes a loaded image file to compressed pixel data
  50753. * @param imageData image data to transcode
  50754. * @param config configuration options for the transcoding
  50755. * @returns a promise resulting in the transcoded image
  50756. */
  50757. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50758. /**
  50759. * Loads a texture from the transcode result
  50760. * @param texture texture load to
  50761. * @param transcodeResult the result of transcoding the basis file to load from
  50762. */
  50763. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50764. }
  50765. }
  50766. declare module BABYLON {
  50767. /**
  50768. * Loader for .basis file format
  50769. */
  50770. export class _BasisTextureLoader implements IInternalTextureLoader {
  50771. /**
  50772. * Defines whether the loader supports cascade loading the different faces.
  50773. */
  50774. readonly supportCascades: boolean;
  50775. /**
  50776. * This returns if the loader support the current file information.
  50777. * @param extension defines the file extension of the file being loaded
  50778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50779. * @param fallback defines the fallback internal texture if any
  50780. * @param isBase64 defines whether the texture is encoded as a base64
  50781. * @param isBuffer defines whether the texture data are stored as a buffer
  50782. * @returns true if the loader can load the specified file
  50783. */
  50784. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50785. /**
  50786. * Transform the url before loading if required.
  50787. * @param rootUrl the url of the texture
  50788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50789. * @returns the transformed texture
  50790. */
  50791. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50792. /**
  50793. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50794. * @param rootUrl the url of the texture
  50795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50796. * @returns the fallback texture
  50797. */
  50798. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50799. /**
  50800. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50801. * @param data contains the texture data
  50802. * @param texture defines the BabylonJS internal texture
  50803. * @param createPolynomials will be true if polynomials have been requested
  50804. * @param onLoad defines the callback to trigger once the texture is ready
  50805. * @param onError defines the callback to trigger in case of error
  50806. */
  50807. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50808. /**
  50809. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50810. * @param data contains the texture data
  50811. * @param texture defines the BabylonJS internal texture
  50812. * @param callback defines the method to call once ready to upload
  50813. */
  50814. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50815. }
  50816. }
  50817. declare module BABYLON {
  50818. /**
  50819. * 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.
  50820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50822. */
  50823. export class CustomProceduralTexture extends ProceduralTexture {
  50824. private _animate;
  50825. private _time;
  50826. private _config;
  50827. private _texturePath;
  50828. /**
  50829. * Instantiates a new Custom Procedural Texture.
  50830. * 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.
  50831. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50832. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50833. * @param name Define the name of the texture
  50834. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50835. * @param size Define the size of the texture to create
  50836. * @param scene Define the scene the texture belongs to
  50837. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50838. * @param generateMipMaps Define if the texture should creates mip maps or not
  50839. */
  50840. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50841. private _loadJson;
  50842. /**
  50843. * Is the texture ready to be used ? (rendered at least once)
  50844. * @returns true if ready, otherwise, false.
  50845. */
  50846. isReady(): boolean;
  50847. /**
  50848. * Render the texture to its associated render target.
  50849. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50850. */
  50851. render(useCameraPostProcess?: boolean): void;
  50852. /**
  50853. * Update the list of dependant textures samplers in the shader.
  50854. */
  50855. updateTextures(): void;
  50856. /**
  50857. * Update the uniform values of the procedural texture in the shader.
  50858. */
  50859. updateShaderUniforms(): void;
  50860. /**
  50861. * Define if the texture animates or not.
  50862. */
  50863. animate: boolean;
  50864. }
  50865. }
  50866. declare module BABYLON {
  50867. /** @hidden */
  50868. export var noisePixelShader: {
  50869. name: string;
  50870. shader: string;
  50871. };
  50872. }
  50873. declare module BABYLON {
  50874. /**
  50875. * Class used to generate noise procedural textures
  50876. */
  50877. export class NoiseProceduralTexture extends ProceduralTexture {
  50878. private _time;
  50879. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50880. brightness: number;
  50881. /** Defines the number of octaves to process */
  50882. octaves: number;
  50883. /** Defines the level of persistence (0.8 by default) */
  50884. persistence: number;
  50885. /** Gets or sets animation speed factor (default is 1) */
  50886. animationSpeedFactor: number;
  50887. /**
  50888. * Creates a new NoiseProceduralTexture
  50889. * @param name defines the name fo the texture
  50890. * @param size defines the size of the texture (default is 256)
  50891. * @param scene defines the hosting scene
  50892. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50893. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50894. */
  50895. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50896. private _updateShaderUniforms;
  50897. protected _getDefines(): string;
  50898. /** Generate the current state of the procedural texture */
  50899. render(useCameraPostProcess?: boolean): void;
  50900. /**
  50901. * Serializes this noise procedural texture
  50902. * @returns a serialized noise procedural texture object
  50903. */
  50904. serialize(): any;
  50905. /**
  50906. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50907. * @param parsedTexture defines parsed texture data
  50908. * @param scene defines the current scene
  50909. * @param rootUrl defines the root URL containing noise procedural texture information
  50910. * @returns a parsed NoiseProceduralTexture
  50911. */
  50912. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50913. }
  50914. }
  50915. declare module BABYLON {
  50916. /**
  50917. * Raw cube texture where the raw buffers are passed in
  50918. */
  50919. export class RawCubeTexture extends CubeTexture {
  50920. /**
  50921. * Creates a cube texture where the raw buffers are passed in.
  50922. * @param scene defines the scene the texture is attached to
  50923. * @param data defines the array of data to use to create each face
  50924. * @param size defines the size of the textures
  50925. * @param format defines the format of the data
  50926. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50927. * @param generateMipMaps defines if the engine should generate the mip levels
  50928. * @param invertY defines if data must be stored with Y axis inverted
  50929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50930. * @param compression defines the compression used (null by default)
  50931. */
  50932. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50933. /**
  50934. * Updates the raw cube texture.
  50935. * @param data defines the data to store
  50936. * @param format defines the data format
  50937. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50938. * @param invertY defines if data must be stored with Y axis inverted
  50939. * @param compression defines the compression used (null by default)
  50940. * @param level defines which level of the texture to update
  50941. */
  50942. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50943. /**
  50944. * Updates a raw cube texture with RGBD encoded data.
  50945. * @param data defines the array of data [mipmap][face] to use to create each face
  50946. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50949. * @returns a promsie that resolves when the operation is complete
  50950. */
  50951. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50952. /**
  50953. * Clones the raw cube texture.
  50954. * @return a new cube texture
  50955. */
  50956. clone(): CubeTexture;
  50957. /** @hidden */
  50958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50959. }
  50960. }
  50961. declare module BABYLON {
  50962. /**
  50963. * Class used to store 3D textures containing user data
  50964. */
  50965. export class RawTexture3D extends Texture {
  50966. /** Gets or sets the texture format to use */
  50967. format: number;
  50968. private _engine;
  50969. /**
  50970. * Create a new RawTexture3D
  50971. * @param data defines the data of the texture
  50972. * @param width defines the width of the texture
  50973. * @param height defines the height of the texture
  50974. * @param depth defines the depth of the texture
  50975. * @param format defines the texture format to use
  50976. * @param scene defines the hosting scene
  50977. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50978. * @param invertY defines if texture must be stored with Y axis inverted
  50979. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50980. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50981. */
  50982. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50983. /** Gets or sets the texture format to use */
  50984. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50985. /**
  50986. * Update the texture with new data
  50987. * @param data defines the data to store in the texture
  50988. */
  50989. update(data: ArrayBufferView): void;
  50990. }
  50991. }
  50992. declare module BABYLON {
  50993. /**
  50994. * Creates a refraction texture used by refraction channel of the standard material.
  50995. * It is like a mirror but to see through a material.
  50996. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50997. */
  50998. export class RefractionTexture extends RenderTargetTexture {
  50999. /**
  51000. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51001. * 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.
  51002. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51003. */
  51004. refractionPlane: Plane;
  51005. /**
  51006. * Define how deep under the surface we should see.
  51007. */
  51008. depth: number;
  51009. /**
  51010. * Creates a refraction texture used by refraction channel of the standard material.
  51011. * It is like a mirror but to see through a material.
  51012. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51013. * @param name Define the texture name
  51014. * @param size Define the size of the underlying texture
  51015. * @param scene Define the scene the refraction belongs to
  51016. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51017. */
  51018. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51019. /**
  51020. * Clone the refraction texture.
  51021. * @returns the cloned texture
  51022. */
  51023. clone(): RefractionTexture;
  51024. /**
  51025. * Serialize the texture to a JSON representation you could use in Parse later on
  51026. * @returns the serialized JSON representation
  51027. */
  51028. serialize(): any;
  51029. }
  51030. }
  51031. declare module BABYLON {
  51032. /**
  51033. * Defines the options related to the creation of an HtmlElementTexture
  51034. */
  51035. export interface IHtmlElementTextureOptions {
  51036. /**
  51037. * Defines wether mip maps should be created or not.
  51038. */
  51039. generateMipMaps?: boolean;
  51040. /**
  51041. * Defines the sampling mode of the texture.
  51042. */
  51043. samplingMode?: number;
  51044. /**
  51045. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51046. */
  51047. engine: Nullable<Engine>;
  51048. /**
  51049. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51050. */
  51051. scene: Nullable<Scene>;
  51052. }
  51053. /**
  51054. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51055. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51056. * is automatically managed.
  51057. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51058. * in your application.
  51059. *
  51060. * As the update is not automatic, you need to call them manually.
  51061. */
  51062. export class HtmlElementTexture extends BaseTexture {
  51063. /**
  51064. * The texture URL.
  51065. */
  51066. element: HTMLVideoElement | HTMLCanvasElement;
  51067. private static readonly DefaultOptions;
  51068. private _textureMatrix;
  51069. private _engine;
  51070. private _isVideo;
  51071. private _generateMipMaps;
  51072. private _samplingMode;
  51073. /**
  51074. * Instantiates a HtmlElementTexture from the following parameters.
  51075. *
  51076. * @param name Defines the name of the texture
  51077. * @param element Defines the video or canvas the texture is filled with
  51078. * @param options Defines the other none mandatory texture creation options
  51079. */
  51080. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51081. private _createInternalTexture;
  51082. /**
  51083. * Returns the texture matrix used in most of the material.
  51084. */
  51085. getTextureMatrix(): Matrix;
  51086. /**
  51087. * Updates the content of the texture.
  51088. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51089. */
  51090. update(invertY?: Nullable<boolean>): void;
  51091. }
  51092. }
  51093. declare module BABYLON {
  51094. /**
  51095. * Enum used to define the target of a block
  51096. */
  51097. export enum NodeMaterialBlockTargets {
  51098. /** Vertex shader */
  51099. Vertex = 1,
  51100. /** Fragment shader */
  51101. Fragment = 2,
  51102. /** Neutral */
  51103. Neutral = 4,
  51104. /** Vertex and Fragment */
  51105. VertexAndFragment = 3
  51106. }
  51107. }
  51108. declare module BABYLON {
  51109. /**
  51110. * Defines the kind of connection point for node based material
  51111. */
  51112. export enum NodeMaterialBlockConnectionPointTypes {
  51113. /** Float */
  51114. Float = 1,
  51115. /** Int */
  51116. Int = 2,
  51117. /** Vector2 */
  51118. Vector2 = 4,
  51119. /** Vector3 */
  51120. Vector3 = 8,
  51121. /** Vector4 */
  51122. Vector4 = 16,
  51123. /** Color3 */
  51124. Color3 = 32,
  51125. /** Color4 */
  51126. Color4 = 64,
  51127. /** Matrix */
  51128. Matrix = 128,
  51129. /** Vector3 or Color3 */
  51130. Vector3OrColor3 = 40,
  51131. /** Vector3 or Vector4 */
  51132. Vector3OrVector4 = 24,
  51133. /** Vector4 or Color4 */
  51134. Vector4OrColor4 = 80,
  51135. /** Color3 or Color4 */
  51136. Color3OrColor4 = 96,
  51137. /** Vector2 or Color3 or Color4 */
  51138. Vector2OrColor3OrColor4 = 100,
  51139. /** Vector3 or Color3 or Color4 or Vector4 */
  51140. Vector3OrColor3OrVector4OrColor4 = 120,
  51141. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  51142. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  51143. /** Detect type based on connection */
  51144. AutoDetect = 1024,
  51145. /** Output type that will be defined by input type */
  51146. BasedOnInput = 2048
  51147. }
  51148. }
  51149. declare module BABYLON {
  51150. /**
  51151. * Root class for all node material optimizers
  51152. */
  51153. export class NodeMaterialOptimizer {
  51154. /**
  51155. * Function used to optimize a NodeMaterial graph
  51156. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51157. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51158. */
  51159. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51160. }
  51161. }
  51162. declare module BABYLON {
  51163. /**
  51164. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51165. */
  51166. export class TransformBlock extends NodeMaterialBlock {
  51167. /**
  51168. * Defines the value to use to complement W value to transform it to a Vector4
  51169. */
  51170. complementW: number;
  51171. /**
  51172. * Defines the value to use to complement z value to transform it to a Vector4
  51173. */
  51174. complementZ: number;
  51175. /**
  51176. * Creates a new TransformBlock
  51177. * @param name defines the block name
  51178. */
  51179. constructor(name: string);
  51180. /**
  51181. * Gets the current class name
  51182. * @returns the class name
  51183. */
  51184. getClassName(): string;
  51185. /**
  51186. * Gets the vector input
  51187. */
  51188. readonly vector: NodeMaterialConnectionPoint;
  51189. /**
  51190. * Gets the output component
  51191. */
  51192. readonly output: NodeMaterialConnectionPoint;
  51193. /**
  51194. * Gets the matrix transform input
  51195. */
  51196. readonly transform: NodeMaterialConnectionPoint;
  51197. protected _buildBlock(state: NodeMaterialBuildState): this;
  51198. }
  51199. }
  51200. declare module BABYLON {
  51201. /**
  51202. * Block used to output the vertex position
  51203. */
  51204. export class VertexOutputBlock extends NodeMaterialBlock {
  51205. /**
  51206. * Creates a new VertexOutputBlock
  51207. * @param name defines the block name
  51208. */
  51209. constructor(name: string);
  51210. /**
  51211. * Gets the current class name
  51212. * @returns the class name
  51213. */
  51214. getClassName(): string;
  51215. /**
  51216. * Gets the vector input component
  51217. */
  51218. readonly vector: NodeMaterialConnectionPoint;
  51219. protected _buildBlock(state: NodeMaterialBuildState): this;
  51220. }
  51221. }
  51222. declare module BABYLON {
  51223. /**
  51224. * Block used to output the final color
  51225. */
  51226. export class FragmentOutputBlock extends NodeMaterialBlock {
  51227. /**
  51228. * Gets or sets a boolean indicating if this block will output an alpha value
  51229. */
  51230. alphaBlendingEnabled: boolean;
  51231. /**
  51232. * Create a new FragmentOutputBlock
  51233. * @param name defines the block name
  51234. */
  51235. constructor(name: string);
  51236. /**
  51237. * Gets the current class name
  51238. * @returns the class name
  51239. */
  51240. getClassName(): string;
  51241. /**
  51242. * Gets the color input component
  51243. */
  51244. readonly color: NodeMaterialConnectionPoint;
  51245. protected _buildBlock(state: NodeMaterialBuildState): this;
  51246. }
  51247. }
  51248. declare module BABYLON {
  51249. /**
  51250. * Interface used to configure the node material editor
  51251. */
  51252. export interface INodeMaterialEditorOptions {
  51253. /** Define the URl to load node editor script */
  51254. editorURL?: string;
  51255. }
  51256. /** @hidden */
  51257. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51258. /** BONES */
  51259. NUM_BONE_INFLUENCERS: number;
  51260. BonesPerMesh: number;
  51261. BONETEXTURE: boolean;
  51262. /** MORPH TARGETS */
  51263. MORPHTARGETS: boolean;
  51264. MORPHTARGETS_NORMAL: boolean;
  51265. MORPHTARGETS_TANGENT: boolean;
  51266. MORPHTARGETS_UV: boolean;
  51267. NUM_MORPH_INFLUENCERS: number;
  51268. /** IMAGE PROCESSING */
  51269. IMAGEPROCESSING: boolean;
  51270. VIGNETTE: boolean;
  51271. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51272. VIGNETTEBLENDMODEOPAQUE: boolean;
  51273. TONEMAPPING: boolean;
  51274. TONEMAPPING_ACES: boolean;
  51275. CONTRAST: boolean;
  51276. EXPOSURE: boolean;
  51277. COLORCURVES: boolean;
  51278. COLORGRADING: boolean;
  51279. COLORGRADING3D: boolean;
  51280. SAMPLER3DGREENDEPTH: boolean;
  51281. SAMPLER3DBGRMAP: boolean;
  51282. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51283. constructor();
  51284. setValue(name: string, value: boolean): void;
  51285. }
  51286. /**
  51287. * Class used to configure NodeMaterial
  51288. */
  51289. export interface INodeMaterialOptions {
  51290. /**
  51291. * Defines if blocks should emit comments
  51292. */
  51293. emitComments: boolean;
  51294. }
  51295. /**
  51296. * Class used to create a node based material built by assembling shader blocks
  51297. */
  51298. export class NodeMaterial extends PushMaterial {
  51299. private _options;
  51300. private _vertexCompilationState;
  51301. private _fragmentCompilationState;
  51302. private _sharedData;
  51303. private _buildId;
  51304. private _buildWasSuccessful;
  51305. private _cachedWorldViewMatrix;
  51306. private _cachedWorldViewProjectionMatrix;
  51307. private _optimizers;
  51308. /** Define the URl to load node editor script */
  51309. static EditorURL: string;
  51310. private BJSNODEMATERIALEDITOR;
  51311. /** Get the inspector from bundle or global */
  51312. private _getGlobalNodeMaterialEditor;
  51313. /**
  51314. * Defines the maximum number of lights that can be used in the material
  51315. */
  51316. maxSimultaneousLights: number;
  51317. /**
  51318. * Observable raised when the material is built
  51319. */
  51320. onBuildObservable: Observable<NodeMaterial>;
  51321. /**
  51322. * Gets or sets the root nodes of the material vertex shader
  51323. */
  51324. _vertexOutputNodes: NodeMaterialBlock[];
  51325. /**
  51326. * Gets or sets the root nodes of the material fragment (pixel) shader
  51327. */
  51328. _fragmentOutputNodes: NodeMaterialBlock[];
  51329. /** Gets or sets options to control the node material overall behavior */
  51330. options: INodeMaterialOptions;
  51331. /**
  51332. * Default configuration related to image processing available in the standard Material.
  51333. */
  51334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51335. /**
  51336. * Gets the image processing configuration used either in this material.
  51337. */
  51338. /**
  51339. * Sets the Default image processing configuration used either in the this material.
  51340. *
  51341. * If sets to null, the scene one is in use.
  51342. */
  51343. imageProcessingConfiguration: ImageProcessingConfiguration;
  51344. /**
  51345. * Create a new node based material
  51346. * @param name defines the material name
  51347. * @param scene defines the hosting scene
  51348. * @param options defines creation option
  51349. */
  51350. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51351. /**
  51352. * Gets the current class name of the material e.g. "NodeMaterial"
  51353. * @returns the class name
  51354. */
  51355. getClassName(): string;
  51356. /**
  51357. * Keep track of the image processing observer to allow dispose and replace.
  51358. */
  51359. private _imageProcessingObserver;
  51360. /**
  51361. * Attaches a new image processing configuration to the Standard Material.
  51362. * @param configuration
  51363. */
  51364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51365. /**
  51366. * Adds a new optimizer to the list of optimizers
  51367. * @param optimizer defines the optimizers to add
  51368. * @returns the current material
  51369. */
  51370. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51371. /**
  51372. * Remove an optimizer from the list of optimizers
  51373. * @param optimizer defines the optimizers to remove
  51374. * @returns the current material
  51375. */
  51376. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51377. /**
  51378. * Add a new block to the list of output nodes
  51379. * @param node defines the node to add
  51380. * @returns the current material
  51381. */
  51382. addOutputNode(node: NodeMaterialBlock): this;
  51383. /**
  51384. * Remove a block from the list of root nodes
  51385. * @param node defines the node to remove
  51386. * @returns the current material
  51387. */
  51388. removeOutputNode(node: NodeMaterialBlock): this;
  51389. private _addVertexOutputNode;
  51390. private _removeVertexOutputNode;
  51391. private _addFragmentOutputNode;
  51392. private _removeFragmentOutputNode;
  51393. /**
  51394. * Specifies if the material will require alpha blending
  51395. * @returns a boolean specifying if alpha blending is needed
  51396. */
  51397. needAlphaBlending(): boolean;
  51398. /**
  51399. * Specifies if this material should be rendered in alpha test mode
  51400. * @returns a boolean specifying if an alpha test is needed.
  51401. */
  51402. needAlphaTesting(): boolean;
  51403. private _initializeBlock;
  51404. private _resetDualBlocks;
  51405. /**
  51406. * Build the material and generates the inner effect
  51407. * @param verbose defines if the build should log activity
  51408. */
  51409. build(verbose?: boolean): void;
  51410. /**
  51411. * Runs an otpimization phase to try to improve the shader code
  51412. */
  51413. optimize(): void;
  51414. private _prepareDefinesForAttributes;
  51415. /**
  51416. * Get if the submesh is ready to be used and all its information available.
  51417. * Child classes can use it to update shaders
  51418. * @param mesh defines the mesh to check
  51419. * @param subMesh defines which submesh to check
  51420. * @param useInstances specifies that instances should be used
  51421. * @returns a boolean indicating that the submesh is ready or not
  51422. */
  51423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51424. /**
  51425. * Get a string representing the shaders built by the current node graph
  51426. */
  51427. readonly compiledShaders: string;
  51428. /**
  51429. * Binds the world matrix to the material
  51430. * @param world defines the world transformation matrix
  51431. */
  51432. bindOnlyWorldMatrix(world: Matrix): void;
  51433. /**
  51434. * Binds the submesh to this material by preparing the effect and shader to draw
  51435. * @param world defines the world transformation matrix
  51436. * @param mesh defines the mesh containing the submesh
  51437. * @param subMesh defines the submesh to bind the material to
  51438. */
  51439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51440. /**
  51441. * Gets the active textures from the material
  51442. * @returns an array of textures
  51443. */
  51444. getActiveTextures(): BaseTexture[];
  51445. /**
  51446. * Specifies if the material uses a texture
  51447. * @param texture defines the texture to check against the material
  51448. * @returns a boolean specifying if the material uses the texture
  51449. */
  51450. hasTexture(texture: BaseTexture): boolean;
  51451. /**
  51452. * Disposes the material
  51453. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51454. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51455. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51456. */
  51457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51458. /** Creates the node editor window. */
  51459. private _createNodeEditor;
  51460. /**
  51461. * Launch the node material editor
  51462. * @param config Define the configuration of the editor
  51463. * @return a promise fulfilled when the node editor is visible
  51464. */
  51465. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51466. /**
  51467. * Clear the current material
  51468. */
  51469. clear(): void;
  51470. /**
  51471. * Clear the current material and set it to a default state
  51472. */
  51473. setToDefault(): void;
  51474. private _gatherBlocks;
  51475. /**
  51476. * Serializes this material in a JSON representation
  51477. * @returns the serialized material object
  51478. */
  51479. serialize(): any;
  51480. /**
  51481. * Clear the current graph and load a new one from a serialization object
  51482. * @param source defines the JSON representation of the material
  51483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51484. */
  51485. loadFromSerialization(source: any, rootUrl?: string): void;
  51486. /**
  51487. * Creates a node material from parsed material data
  51488. * @param source defines the JSON representation of the material
  51489. * @param scene defines the hosting scene
  51490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51491. * @returns a new node material
  51492. */
  51493. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51494. }
  51495. }
  51496. declare module BABYLON {
  51497. /**
  51498. * Block used to read a texture from a sampler
  51499. */
  51500. export class TextureBlock extends NodeMaterialBlock {
  51501. private _defineName;
  51502. private _samplerName;
  51503. private _transformedUVName;
  51504. private _textureTransformName;
  51505. private _textureInfoName;
  51506. private _mainUVName;
  51507. private _mainUVDefineName;
  51508. /**
  51509. * Gets or sets the texture associated with the node
  51510. */
  51511. texture: Nullable<BaseTexture>;
  51512. /**
  51513. * Create a new TextureBlock
  51514. * @param name defines the block name
  51515. */
  51516. constructor(name: string);
  51517. /**
  51518. * Gets the current class name
  51519. * @returns the class name
  51520. */
  51521. getClassName(): string;
  51522. /**
  51523. * Gets the uv input component
  51524. */
  51525. readonly uv: NodeMaterialConnectionPoint;
  51526. /**
  51527. * Gets the output component
  51528. */
  51529. readonly output: NodeMaterialConnectionPoint;
  51530. autoConfigure(): void;
  51531. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51532. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51533. isReady(): boolean;
  51534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51535. private _injectVertexCode;
  51536. private _writeOutput;
  51537. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51538. serialize(): any;
  51539. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51540. }
  51541. }
  51542. declare module BABYLON {
  51543. /**
  51544. * Class used to store shared data between 2 NodeMaterialBuildState
  51545. */
  51546. export class NodeMaterialBuildStateSharedData {
  51547. /**
  51548. * Gets the list of emitted varyings
  51549. */
  51550. varyings: string[];
  51551. /**
  51552. * Gets the varying declaration string
  51553. */
  51554. varyingDeclaration: string;
  51555. /**
  51556. * Input blocks
  51557. */
  51558. inputBlocks: InputBlock[];
  51559. /**
  51560. * Input blocks
  51561. */
  51562. textureBlocks: TextureBlock[];
  51563. /**
  51564. * Bindable blocks (Blocks that need to set data to the effect)
  51565. */
  51566. bindableBlocks: NodeMaterialBlock[];
  51567. /**
  51568. * List of blocks that can provide a compilation fallback
  51569. */
  51570. blocksWithFallbacks: NodeMaterialBlock[];
  51571. /**
  51572. * List of blocks that can provide a define update
  51573. */
  51574. blocksWithDefines: NodeMaterialBlock[];
  51575. /**
  51576. * List of blocks that can provide a repeatable content
  51577. */
  51578. repeatableContentBlocks: NodeMaterialBlock[];
  51579. /**
  51580. * List of blocks that can provide a dynamic list of uniforms
  51581. */
  51582. dynamicUniformBlocks: NodeMaterialBlock[];
  51583. /**
  51584. * List of blocks that can block the isReady function for the material
  51585. */
  51586. blockingBlocks: NodeMaterialBlock[];
  51587. /**
  51588. * Build Id used to avoid multiple recompilations
  51589. */
  51590. buildId: number;
  51591. /** List of emitted variables */
  51592. variableNames: {
  51593. [key: string]: number;
  51594. };
  51595. /** List of emitted defines */
  51596. defineNames: {
  51597. [key: string]: number;
  51598. };
  51599. /** Should emit comments? */
  51600. emitComments: boolean;
  51601. /** Emit build activity */
  51602. verbose: boolean;
  51603. /**
  51604. * Gets the compilation hints emitted at compilation time
  51605. */
  51606. hints: {
  51607. needWorldViewMatrix: boolean;
  51608. needWorldViewProjectionMatrix: boolean;
  51609. needAlphaBlending: boolean;
  51610. needAlphaTesting: boolean;
  51611. };
  51612. /**
  51613. * List of compilation checks
  51614. */
  51615. checks: {
  51616. emitVertex: boolean;
  51617. emitFragment: boolean;
  51618. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51619. };
  51620. /** Creates a new shared data */
  51621. constructor();
  51622. /**
  51623. * Emits console errors and exceptions if there is a failing check
  51624. */
  51625. emitErrors(): void;
  51626. }
  51627. }
  51628. declare module BABYLON {
  51629. /**
  51630. * Class used to store node based material build state
  51631. */
  51632. export class NodeMaterialBuildState {
  51633. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51634. supportUniformBuffers: boolean;
  51635. /**
  51636. * Gets the list of emitted attributes
  51637. */
  51638. attributes: string[];
  51639. /**
  51640. * Gets the list of emitted uniforms
  51641. */
  51642. uniforms: string[];
  51643. /**
  51644. * Gets the list of emitted uniform buffers
  51645. */
  51646. uniformBuffers: string[];
  51647. /**
  51648. * Gets the list of emitted samplers
  51649. */
  51650. samplers: string[];
  51651. /**
  51652. * Gets the list of emitted functions
  51653. */
  51654. functions: {
  51655. [key: string]: string;
  51656. };
  51657. /**
  51658. * Gets the target of the compilation state
  51659. */
  51660. target: NodeMaterialBlockTargets;
  51661. /**
  51662. * Gets the list of emitted counters
  51663. */
  51664. counters: {
  51665. [key: string]: number;
  51666. };
  51667. /**
  51668. * Shared data between multiple NodeMaterialBuildState instances
  51669. */
  51670. sharedData: NodeMaterialBuildStateSharedData;
  51671. /** @hidden */
  51672. _vertexState: NodeMaterialBuildState;
  51673. /** @hidden */
  51674. _attributeDeclaration: string;
  51675. /** @hidden */
  51676. _uniformDeclaration: string;
  51677. /** @hidden */
  51678. _samplerDeclaration: string;
  51679. /** @hidden */
  51680. _varyingTransfer: string;
  51681. private _repeatableContentAnchorIndex;
  51682. /** @hidden */
  51683. _builtCompilationString: string;
  51684. /**
  51685. * Gets the emitted compilation strings
  51686. */
  51687. compilationString: string;
  51688. /**
  51689. * Finalize the compilation strings
  51690. * @param state defines the current compilation state
  51691. */
  51692. finalize(state: NodeMaterialBuildState): void;
  51693. /** @hidden */
  51694. readonly _repeatableContentAnchor: string;
  51695. /** @hidden */
  51696. _getFreeVariableName(prefix: string): string;
  51697. /** @hidden */
  51698. _getFreeDefineName(prefix: string): string;
  51699. /** @hidden */
  51700. _excludeVariableName(name: string): void;
  51701. /** @hidden */
  51702. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51703. /** @hidden */
  51704. _emitFunction(name: string, code: string, comments: string): void;
  51705. /** @hidden */
  51706. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51707. replaceStrings?: {
  51708. search: RegExp;
  51709. replace: string;
  51710. }[];
  51711. repeatKey?: string;
  51712. }): string;
  51713. /** @hidden */
  51714. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51715. repeatKey?: string;
  51716. removeAttributes?: boolean;
  51717. removeUniforms?: boolean;
  51718. removeVaryings?: boolean;
  51719. removeIfDef?: boolean;
  51720. replaceStrings?: {
  51721. search: RegExp;
  51722. replace: string;
  51723. }[];
  51724. }, storeKey?: string): void;
  51725. /** @hidden */
  51726. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51727. /** @hidden */
  51728. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51729. }
  51730. }
  51731. declare module BABYLON {
  51732. /**
  51733. * Defines a block that can be used inside a node based material
  51734. */
  51735. export class NodeMaterialBlock {
  51736. private _buildId;
  51737. private _buildTarget;
  51738. private _target;
  51739. private _isFinalMerger;
  51740. private _isInput;
  51741. /** @hidden */
  51742. _inputs: NodeMaterialConnectionPoint[];
  51743. /** @hidden */
  51744. _outputs: NodeMaterialConnectionPoint[];
  51745. /**
  51746. * Gets or sets the name of the block
  51747. */
  51748. name: string;
  51749. /**
  51750. * Gets or sets the unique id of the node
  51751. */
  51752. uniqueId: number;
  51753. /**
  51754. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51755. */
  51756. readonly isFinalMerger: boolean;
  51757. /**
  51758. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51759. */
  51760. readonly isInput: boolean;
  51761. /**
  51762. * Gets or sets the build Id
  51763. */
  51764. buildId: number;
  51765. /**
  51766. * Gets or sets the target of the block
  51767. */
  51768. target: NodeMaterialBlockTargets;
  51769. /**
  51770. * Gets the list of input points
  51771. */
  51772. readonly inputs: NodeMaterialConnectionPoint[];
  51773. /** Gets the list of output points */
  51774. readonly outputs: NodeMaterialConnectionPoint[];
  51775. /**
  51776. * Find an input by its name
  51777. * @param name defines the name of the input to look for
  51778. * @returns the input or null if not found
  51779. */
  51780. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51781. /**
  51782. * Find an output by its name
  51783. * @param name defines the name of the outputto look for
  51784. * @returns the output or null if not found
  51785. */
  51786. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51787. /**
  51788. * Creates a new NodeMaterialBlock
  51789. * @param name defines the block name
  51790. * @param target defines the target of that block (Vertex by default)
  51791. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51792. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51793. */
  51794. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51795. /**
  51796. * Initialize the block and prepare the context for build
  51797. * @param state defines the state that will be used for the build
  51798. */
  51799. initialize(state: NodeMaterialBuildState): void;
  51800. /**
  51801. * Bind data to effect. Will only be called for blocks with isBindable === true
  51802. * @param effect defines the effect to bind data to
  51803. * @param nodeMaterial defines the hosting NodeMaterial
  51804. * @param mesh defines the mesh that will be rendered
  51805. */
  51806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51807. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51808. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51809. protected _writeFloat(value: number): string;
  51810. /**
  51811. * Gets the current class name e.g. "NodeMaterialBlock"
  51812. * @returns the class name
  51813. */
  51814. getClassName(): string;
  51815. /**
  51816. * Register a new input. Must be called inside a block constructor
  51817. * @param name defines the connection point name
  51818. * @param type defines the connection point type
  51819. * @param isOptional defines a boolean indicating that this input can be omitted
  51820. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51821. * @returns the current block
  51822. */
  51823. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51824. /**
  51825. * Register a new output. Must be called inside a block constructor
  51826. * @param name defines the connection point name
  51827. * @param type defines the connection point type
  51828. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51829. * @returns the current block
  51830. */
  51831. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51832. /**
  51833. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51834. * @param forOutput defines an optional connection point to check compatibility with
  51835. * @returns the first available input or null
  51836. */
  51837. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51838. /**
  51839. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51840. * @param forBlock defines an optional block to check compatibility with
  51841. * @returns the first available input or null
  51842. */
  51843. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51844. /**
  51845. * Connect current block with another block
  51846. * @param other defines the block to connect with
  51847. * @param options define the various options to help pick the right connections
  51848. * @returns the current block
  51849. */
  51850. connectTo(other: NodeMaterialBlock, options?: {
  51851. input?: string;
  51852. output?: string;
  51853. outputSwizzle?: string;
  51854. }): this | undefined;
  51855. protected _buildBlock(state: NodeMaterialBuildState): void;
  51856. /**
  51857. * Add uniforms, samplers and uniform buffers at compilation time
  51858. * @param state defines the state to update
  51859. * @param nodeMaterial defines the node material requesting the update
  51860. * @param defines defines the material defines to update
  51861. */
  51862. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51863. /**
  51864. * Add potential fallbacks if shader compilation fails
  51865. * @param mesh defines the mesh to be rendered
  51866. * @param fallbacks defines the current prioritized list of fallbacks
  51867. */
  51868. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51869. /**
  51870. * Update defines for shader compilation
  51871. * @param mesh defines the mesh to be rendered
  51872. * @param nodeMaterial defines the node material requesting the update
  51873. * @param defines defines the material defines to update
  51874. * @param useInstances specifies that instances should be used
  51875. */
  51876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51877. /**
  51878. * Initialize defines for shader compilation
  51879. * @param mesh defines the mesh to be rendered
  51880. * @param nodeMaterial defines the node material requesting the update
  51881. * @param defines defines the material defines to be prepared
  51882. * @param useInstances specifies that instances should be used
  51883. */
  51884. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51885. /**
  51886. * Lets the block try to connect some inputs automatically
  51887. */
  51888. autoConfigure(): void;
  51889. /**
  51890. * Function called when a block is declared as repeatable content generator
  51891. * @param vertexShaderState defines the current compilation state for the vertex shader
  51892. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51893. * @param mesh defines the mesh to be rendered
  51894. * @param defines defines the material defines to update
  51895. */
  51896. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51897. /**
  51898. * Checks if the block is ready
  51899. * @param mesh defines the mesh to be rendered
  51900. * @param nodeMaterial defines the node material requesting the update
  51901. * @param defines defines the material defines to update
  51902. * @param useInstances specifies that instances should be used
  51903. * @returns true if the block is ready
  51904. */
  51905. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51906. private _processBuild;
  51907. /**
  51908. * Compile the current node and generate the shader code
  51909. * @param state defines the current compilation state (uniforms, samplers, current string)
  51910. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51911. * @returns true if already built
  51912. */
  51913. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51914. /**
  51915. * Serializes this block in a JSON representation
  51916. * @returns the serialized block object
  51917. */
  51918. serialize(): any;
  51919. /** @hidden */
  51920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /**
  51925. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51926. */
  51927. export enum NodeMaterialBlockConnectionPointMode {
  51928. /** Value is an uniform */
  51929. Uniform = 0,
  51930. /** Value is a mesh attribute */
  51931. Attribute = 1,
  51932. /** Value is a varying between vertex and fragment shaders */
  51933. Varying = 2,
  51934. /** Mode is undefined */
  51935. Undefined = 3
  51936. }
  51937. }
  51938. declare module BABYLON {
  51939. /**
  51940. * Enum used to define well known values e.g. values automatically provided by the system
  51941. */
  51942. export enum NodeMaterialWellKnownValues {
  51943. /** World */
  51944. World = 1,
  51945. /** View */
  51946. View = 2,
  51947. /** Projection */
  51948. Projection = 3,
  51949. /** ViewProjection */
  51950. ViewProjection = 4,
  51951. /** WorldView */
  51952. WorldView = 5,
  51953. /** WorldViewProjection */
  51954. WorldViewProjection = 6,
  51955. /** CameraPosition */
  51956. CameraPosition = 7,
  51957. /** Fog Color */
  51958. FogColor = 8
  51959. }
  51960. }
  51961. declare module BABYLON {
  51962. /**
  51963. * Contains position and normal vectors for a vertex
  51964. */
  51965. export class PositionNormalVertex {
  51966. /** the position of the vertex (defaut: 0,0,0) */
  51967. position: Vector3;
  51968. /** the normal of the vertex (defaut: 0,1,0) */
  51969. normal: Vector3;
  51970. /**
  51971. * Creates a PositionNormalVertex
  51972. * @param position the position of the vertex (defaut: 0,0,0)
  51973. * @param normal the normal of the vertex (defaut: 0,1,0)
  51974. */
  51975. constructor(
  51976. /** the position of the vertex (defaut: 0,0,0) */
  51977. position?: Vector3,
  51978. /** the normal of the vertex (defaut: 0,1,0) */
  51979. normal?: Vector3);
  51980. /**
  51981. * Clones the PositionNormalVertex
  51982. * @returns the cloned PositionNormalVertex
  51983. */
  51984. clone(): PositionNormalVertex;
  51985. }
  51986. /**
  51987. * Contains position, normal and uv vectors for a vertex
  51988. */
  51989. export class PositionNormalTextureVertex {
  51990. /** the position of the vertex (defaut: 0,0,0) */
  51991. position: Vector3;
  51992. /** the normal of the vertex (defaut: 0,1,0) */
  51993. normal: Vector3;
  51994. /** the uv of the vertex (default: 0,0) */
  51995. uv: Vector2;
  51996. /**
  51997. * Creates a PositionNormalTextureVertex
  51998. * @param position the position of the vertex (defaut: 0,0,0)
  51999. * @param normal the normal of the vertex (defaut: 0,1,0)
  52000. * @param uv the uv of the vertex (default: 0,0)
  52001. */
  52002. constructor(
  52003. /** the position of the vertex (defaut: 0,0,0) */
  52004. position?: Vector3,
  52005. /** the normal of the vertex (defaut: 0,1,0) */
  52006. normal?: Vector3,
  52007. /** the uv of the vertex (default: 0,0) */
  52008. uv?: Vector2);
  52009. /**
  52010. * Clones the PositionNormalTextureVertex
  52011. * @returns the cloned PositionNormalTextureVertex
  52012. */
  52013. clone(): PositionNormalTextureVertex;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Block used to expose an input value
  52019. */
  52020. export class InputBlock extends NodeMaterialBlock {
  52021. private _mode;
  52022. private _associatedVariableName;
  52023. private _storedValue;
  52024. private _valueCallback;
  52025. private _type;
  52026. /** @hidden */
  52027. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52028. /**
  52029. * Gets or sets the connection point type (default is float)
  52030. */
  52031. readonly type: NodeMaterialBlockConnectionPointTypes;
  52032. /**
  52033. * Creates a new InputBlock
  52034. * @param name defines the block name
  52035. * @param target defines the target of that block (Vertex by default)
  52036. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52037. */
  52038. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52039. /**
  52040. * Gets the output component
  52041. */
  52042. readonly output: NodeMaterialConnectionPoint;
  52043. /**
  52044. * Set the source of this connection point to a vertex attribute
  52045. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52046. * @returns the current connection point
  52047. */
  52048. setAsAttribute(attributeName?: string): InputBlock;
  52049. /**
  52050. * Set the source of this connection point to a well known value
  52051. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52052. * @returns the current connection point
  52053. */
  52054. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52055. /**
  52056. * Gets or sets the value of that point.
  52057. * Please note that this value will be ignored if valueCallback is defined
  52058. */
  52059. value: any;
  52060. /**
  52061. * Gets or sets a callback used to get the value of that point.
  52062. * Please note that setting this value will force the connection point to ignore the value property
  52063. */
  52064. valueCallback: () => any;
  52065. /**
  52066. * Gets or sets the associated variable name in the shader
  52067. */
  52068. associatedVariableName: string;
  52069. /**
  52070. * Gets a boolean indicating that this connection point not defined yet
  52071. */
  52072. readonly isUndefined: boolean;
  52073. /**
  52074. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52075. * In this case the connection point name must be the name of the uniform to use.
  52076. * Can only be set on inputs
  52077. */
  52078. isUniform: boolean;
  52079. /**
  52080. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52081. * In this case the connection point name must be the name of the attribute to use
  52082. * Can only be set on inputs
  52083. */
  52084. isAttribute: boolean;
  52085. /**
  52086. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52087. * Can only be set on exit points
  52088. */
  52089. isVarying: boolean;
  52090. /**
  52091. * Gets a boolean indicating that the current connection point is a well known value
  52092. */
  52093. readonly isWellKnownValue: boolean;
  52094. /**
  52095. * Gets or sets the current well known value or null if not defined as well know value
  52096. */
  52097. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52098. /**
  52099. * Gets the current class name
  52100. * @returns the class name
  52101. */
  52102. getClassName(): string;
  52103. private _emitDefine;
  52104. /**
  52105. * Set the input block to its default value (based on its type)
  52106. */
  52107. setDefaultValue(): void;
  52108. private _emit;
  52109. /** @hidden */
  52110. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52111. /** @hidden */
  52112. _transmit(effect: Effect, scene: Scene): void;
  52113. protected _buildBlock(state: NodeMaterialBuildState): void;
  52114. serialize(): any;
  52115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52116. }
  52117. }
  52118. declare module BABYLON {
  52119. /**
  52120. * Defines a connection point for a block
  52121. */
  52122. export class NodeMaterialConnectionPoint {
  52123. /** @hidden */
  52124. _ownerBlock: NodeMaterialBlock;
  52125. /** @hidden */
  52126. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52127. private _endpoints;
  52128. private _associatedVariableName;
  52129. /** @hidden */
  52130. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52131. private _type;
  52132. /** @hidden */
  52133. _enforceAssociatedVariableName: boolean;
  52134. /**
  52135. * Gets or sets the associated variable name in the shader
  52136. */
  52137. associatedVariableName: string;
  52138. /**
  52139. * Gets or sets the connection point type (default is float)
  52140. */
  52141. type: NodeMaterialBlockConnectionPointTypes;
  52142. /**
  52143. * Gets or sets the connection point name
  52144. */
  52145. name: string;
  52146. /**
  52147. * Gets or sets the swizzle to apply to this connection point when reading or writing
  52148. */
  52149. swizzle: string;
  52150. /**
  52151. * Gets or sets a boolean indicating that this connection point can be omitted
  52152. */
  52153. isOptional: boolean;
  52154. /**
  52155. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52156. */
  52157. define: string;
  52158. /** Gets or sets the target of that connection point */
  52159. target: NodeMaterialBlockTargets;
  52160. /**
  52161. * Gets a boolean indicating that the current point is connected
  52162. */
  52163. readonly isConnected: boolean;
  52164. /**
  52165. * Gets a boolean indicating that the current point is connected to an input block
  52166. */
  52167. readonly isConnectedToInput: boolean;
  52168. /**
  52169. * Gets a the connected input block (if any)
  52170. */
  52171. readonly connectInputBlock: Nullable<InputBlock>;
  52172. /** Get the other side of the connection (if any) */
  52173. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52174. /** Get the block that owns this connection point */
  52175. readonly ownerBlock: NodeMaterialBlock;
  52176. /** Get the block connected on the other side of this connection (if any) */
  52177. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52178. /** Get the block connected on the endpoints of this connection (if any) */
  52179. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52180. /** Gets the list of connected endpoints */
  52181. readonly endpoints: NodeMaterialConnectionPoint[];
  52182. /**
  52183. * Creates a new connection point
  52184. * @param name defines the connection point name
  52185. * @param ownerBlock defines the block hosting this connection point
  52186. */
  52187. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52188. /**
  52189. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52190. * @returns the class name
  52191. */
  52192. getClassName(): string;
  52193. /**
  52194. * Gets an boolean indicating if the current point can be connected to another point
  52195. * @param connectionPoint defines the other connection point
  52196. * @returns true if the connection is possible
  52197. */
  52198. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52199. /**
  52200. * Connect this point to another connection point
  52201. * @param connectionPoint defines the other connection point
  52202. * @returns the current connection point
  52203. */
  52204. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52205. /**
  52206. * Disconnect this point from one of his endpoint
  52207. * @param endpoint defines the other connection point
  52208. * @returns the current connection point
  52209. */
  52210. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52211. /**
  52212. * Serializes this point in a JSON representation
  52213. * @returns the serialized point object
  52214. */
  52215. serialize(): any;
  52216. private static _GetTypeLength;
  52217. }
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * Block used to add support for vertex skinning (bones)
  52222. */
  52223. export class BonesBlock extends NodeMaterialBlock {
  52224. /**
  52225. * Creates a new BonesBlock
  52226. * @param name defines the block name
  52227. */
  52228. constructor(name: string);
  52229. /**
  52230. * Initialize the block and prepare the context for build
  52231. * @param state defines the state that will be used for the build
  52232. */
  52233. initialize(state: NodeMaterialBuildState): void;
  52234. /**
  52235. * Gets the current class name
  52236. * @returns the class name
  52237. */
  52238. getClassName(): string;
  52239. /**
  52240. * Gets the matrix indices input component
  52241. */
  52242. readonly matricesIndices: NodeMaterialConnectionPoint;
  52243. /**
  52244. * Gets the matrix weights input component
  52245. */
  52246. readonly matricesWeights: NodeMaterialConnectionPoint;
  52247. /**
  52248. * Gets the extra matrix indices input component
  52249. */
  52250. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52251. /**
  52252. * Gets the extra matrix weights input component
  52253. */
  52254. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52255. /**
  52256. * Gets the world input component
  52257. */
  52258. readonly world: NodeMaterialConnectionPoint;
  52259. /**
  52260. * Gets the output component
  52261. */
  52262. readonly output: NodeMaterialConnectionPoint;
  52263. autoConfigure(): void;
  52264. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52267. protected _buildBlock(state: NodeMaterialBuildState): this;
  52268. }
  52269. }
  52270. declare module BABYLON {
  52271. /**
  52272. * Block used to add support for instances
  52273. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52274. */
  52275. export class InstancesBlock extends NodeMaterialBlock {
  52276. /**
  52277. * Creates a new InstancesBlock
  52278. * @param name defines the block name
  52279. */
  52280. constructor(name: string);
  52281. /**
  52282. * Gets the current class name
  52283. * @returns the class name
  52284. */
  52285. getClassName(): string;
  52286. /**
  52287. * Gets the first world row input component
  52288. */
  52289. readonly world0: NodeMaterialConnectionPoint;
  52290. /**
  52291. * Gets the second world row input component
  52292. */
  52293. readonly world1: NodeMaterialConnectionPoint;
  52294. /**
  52295. * Gets the third world row input component
  52296. */
  52297. readonly world2: NodeMaterialConnectionPoint;
  52298. /**
  52299. * Gets the forth world row input component
  52300. */
  52301. readonly world3: NodeMaterialConnectionPoint;
  52302. /**
  52303. * Gets the world input component
  52304. */
  52305. readonly world: NodeMaterialConnectionPoint;
  52306. /**
  52307. * Gets the output component
  52308. */
  52309. readonly output: NodeMaterialConnectionPoint;
  52310. autoConfigure(): void;
  52311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52312. protected _buildBlock(state: NodeMaterialBuildState): this;
  52313. }
  52314. }
  52315. declare module BABYLON {
  52316. /**
  52317. * Block used to add morph targets support to vertex shader
  52318. */
  52319. export class MorphTargetsBlock extends NodeMaterialBlock {
  52320. private _repeatableContentAnchor;
  52321. private _repeatebleContentGenerated;
  52322. /**
  52323. * Create a new MorphTargetsBlock
  52324. * @param name defines the block name
  52325. */
  52326. constructor(name: string);
  52327. /**
  52328. * Gets the current class name
  52329. * @returns the class name
  52330. */
  52331. getClassName(): string;
  52332. /**
  52333. * Gets the position input component
  52334. */
  52335. readonly position: NodeMaterialConnectionPoint;
  52336. /**
  52337. * Gets the normal input component
  52338. */
  52339. readonly normal: NodeMaterialConnectionPoint;
  52340. /**
  52341. * Gets the tangent input component
  52342. */
  52343. readonly tangent: NodeMaterialConnectionPoint;
  52344. /**
  52345. * Gets the tangent input component
  52346. */
  52347. readonly uv: NodeMaterialConnectionPoint;
  52348. /**
  52349. * Gets the position output component
  52350. */
  52351. readonly positionOutput: NodeMaterialConnectionPoint;
  52352. /**
  52353. * Gets the normal output component
  52354. */
  52355. readonly normalOutput: NodeMaterialConnectionPoint;
  52356. /**
  52357. * Gets the tangent output component
  52358. */
  52359. readonly tangentOutput: NodeMaterialConnectionPoint;
  52360. /**
  52361. * Gets the tangent output component
  52362. */
  52363. readonly uvOutput: NodeMaterialConnectionPoint;
  52364. initialize(state: NodeMaterialBuildState): void;
  52365. autoConfigure(): void;
  52366. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52367. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52368. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52369. protected _buildBlock(state: NodeMaterialBuildState): this;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * Block used to add an alpha test in the fragment shader
  52375. */
  52376. export class AlphaTestBlock extends NodeMaterialBlock {
  52377. /**
  52378. * Gets or sets the alpha value where alpha testing happens
  52379. */
  52380. alphaCutOff: number;
  52381. /**
  52382. * Create a new AlphaTestBlock
  52383. * @param name defines the block name
  52384. */
  52385. constructor(name: string);
  52386. /**
  52387. * Gets the current class name
  52388. * @returns the class name
  52389. */
  52390. getClassName(): string;
  52391. /**
  52392. * Gets the color input component
  52393. */
  52394. readonly color: NodeMaterialConnectionPoint;
  52395. protected _buildBlock(state: NodeMaterialBuildState): this;
  52396. }
  52397. }
  52398. declare module BABYLON {
  52399. /**
  52400. * Block used to create a Color4 out of 4 inputs (one for each component)
  52401. */
  52402. export class RGBAMergerBlock extends NodeMaterialBlock {
  52403. /**
  52404. * Create a new RGBAMergerBlock
  52405. * @param name defines the block name
  52406. */
  52407. constructor(name: string);
  52408. /**
  52409. * Gets the current class name
  52410. * @returns the class name
  52411. */
  52412. getClassName(): string;
  52413. /**
  52414. * Gets the R input component
  52415. */
  52416. readonly r: NodeMaterialConnectionPoint;
  52417. /**
  52418. * Gets the G input component
  52419. */
  52420. readonly g: NodeMaterialConnectionPoint;
  52421. /**
  52422. * Gets the B input component
  52423. */
  52424. readonly b: NodeMaterialConnectionPoint;
  52425. /**
  52426. * Gets the RGB input component
  52427. */
  52428. readonly rgb: NodeMaterialConnectionPoint;
  52429. /**
  52430. * Gets the R input component
  52431. */
  52432. readonly a: NodeMaterialConnectionPoint;
  52433. /**
  52434. * Gets the output component
  52435. */
  52436. readonly output: NodeMaterialConnectionPoint;
  52437. protected _buildBlock(state: NodeMaterialBuildState): this;
  52438. }
  52439. }
  52440. declare module BABYLON {
  52441. /**
  52442. * Block used to create a Color3 out of 3 inputs (one for each component)
  52443. */
  52444. export class RGBMergerBlock extends NodeMaterialBlock {
  52445. /**
  52446. * Create a new RGBMergerBlock
  52447. * @param name defines the block name
  52448. */
  52449. constructor(name: string);
  52450. /**
  52451. * Gets the current class name
  52452. * @returns the class name
  52453. */
  52454. getClassName(): string;
  52455. /**
  52456. * Gets the R component input
  52457. */
  52458. readonly r: NodeMaterialConnectionPoint;
  52459. /**
  52460. * Gets the G component input
  52461. */
  52462. readonly g: NodeMaterialConnectionPoint;
  52463. /**
  52464. * Gets the B component input
  52465. */
  52466. readonly b: NodeMaterialConnectionPoint;
  52467. /**
  52468. * Gets the output component
  52469. */
  52470. readonly output: NodeMaterialConnectionPoint;
  52471. protected _buildBlock(state: NodeMaterialBuildState): this;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /**
  52476. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  52477. */
  52478. export class RGBASplitterBlock extends NodeMaterialBlock {
  52479. /**
  52480. * Create a new RGBASplitterBlock
  52481. * @param name defines the block name
  52482. */
  52483. constructor(name: string);
  52484. /**
  52485. * Gets the current class name
  52486. * @returns the class name
  52487. */
  52488. getClassName(): string;
  52489. /**
  52490. * Gets the input component
  52491. */
  52492. readonly input: NodeMaterialConnectionPoint;
  52493. protected _buildBlock(state: NodeMaterialBuildState): this;
  52494. }
  52495. }
  52496. declare module BABYLON {
  52497. /**
  52498. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  52499. */
  52500. export class RGBSplitterBlock extends NodeMaterialBlock {
  52501. /**
  52502. * Create a new RGBSplitterBlock
  52503. * @param name defines the block name
  52504. */
  52505. constructor(name: string);
  52506. /**
  52507. * Gets the current class name
  52508. * @returns the class name
  52509. */
  52510. getClassName(): string;
  52511. /**
  52512. * Gets the input component
  52513. */
  52514. readonly input: NodeMaterialConnectionPoint;
  52515. protected _buildBlock(state: NodeMaterialBuildState): this;
  52516. }
  52517. }
  52518. declare module BABYLON {
  52519. /**
  52520. * Block used to add image processing support to fragment shader
  52521. */
  52522. export class ImageProcessingBlock extends NodeMaterialBlock {
  52523. /**
  52524. * Create a new ImageProcessingBlock
  52525. * @param name defines the block name
  52526. */
  52527. constructor(name: string);
  52528. /**
  52529. * Gets the current class name
  52530. * @returns the class name
  52531. */
  52532. getClassName(): string;
  52533. /**
  52534. * Gets the color input component
  52535. */
  52536. readonly color: NodeMaterialConnectionPoint;
  52537. /**
  52538. * Gets the output component
  52539. */
  52540. readonly output: NodeMaterialConnectionPoint;
  52541. /**
  52542. * Initialize the block and prepare the context for build
  52543. * @param state defines the state that will be used for the build
  52544. */
  52545. initialize(state: NodeMaterialBuildState): void;
  52546. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52548. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52549. protected _buildBlock(state: NodeMaterialBuildState): this;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * Block used to add support for scene fog
  52555. */
  52556. export class FogBlock extends NodeMaterialBlock {
  52557. private _fogDistanceName;
  52558. private _fogParameters;
  52559. /**
  52560. * Create a new FogBlock
  52561. * @param name defines the block name
  52562. */
  52563. constructor(name: string);
  52564. /**
  52565. * Gets the current class name
  52566. * @returns the class name
  52567. */
  52568. getClassName(): string;
  52569. /**
  52570. * Gets the world position input component
  52571. */
  52572. readonly worldPosition: NodeMaterialConnectionPoint;
  52573. /**
  52574. * Gets the view input component
  52575. */
  52576. readonly view: NodeMaterialConnectionPoint;
  52577. /**
  52578. * Gets the color input component
  52579. */
  52580. readonly color: NodeMaterialConnectionPoint;
  52581. /**
  52582. * Gets the fog color input component
  52583. */
  52584. readonly fogColor: NodeMaterialConnectionPoint;
  52585. /**
  52586. * Gets the output component
  52587. */
  52588. readonly output: NodeMaterialConnectionPoint;
  52589. autoConfigure(): void;
  52590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52591. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52592. protected _buildBlock(state: NodeMaterialBuildState): this;
  52593. }
  52594. }
  52595. declare module BABYLON {
  52596. /**
  52597. * Block used to add light in the fragment shader
  52598. */
  52599. export class LightBlock extends NodeMaterialBlock {
  52600. private _lightId;
  52601. /**
  52602. * Gets or sets the light associated with this block
  52603. */
  52604. light: Nullable<Light>;
  52605. /**
  52606. * Create a new LightBlock
  52607. * @param name defines the block name
  52608. */
  52609. constructor(name: string);
  52610. /**
  52611. * Gets the current class name
  52612. * @returns the class name
  52613. */
  52614. getClassName(): string;
  52615. /**
  52616. * Gets the world position input component
  52617. */
  52618. readonly worldPosition: NodeMaterialConnectionPoint;
  52619. /**
  52620. * Gets the world normal input component
  52621. */
  52622. readonly worldNormal: NodeMaterialConnectionPoint;
  52623. /**
  52624. * Gets the camera (or eye) position component
  52625. */
  52626. readonly cameraPosition: NodeMaterialConnectionPoint;
  52627. /**
  52628. * Gets the diffuse output component
  52629. */
  52630. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52631. /**
  52632. * Gets the specular output component
  52633. */
  52634. readonly specularOutput: NodeMaterialConnectionPoint;
  52635. autoConfigure(): void;
  52636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52637. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52639. private _injectVertexCode;
  52640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52641. serialize(): any;
  52642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52643. }
  52644. }
  52645. declare module BABYLON {
  52646. /**
  52647. * Block used to multiply 2 values
  52648. */
  52649. export class MultiplyBlock extends NodeMaterialBlock {
  52650. /**
  52651. * Creates a new MultiplyBlock
  52652. * @param name defines the block name
  52653. */
  52654. constructor(name: string);
  52655. /**
  52656. * Gets the current class name
  52657. * @returns the class name
  52658. */
  52659. getClassName(): string;
  52660. /**
  52661. * Gets the left operand input component
  52662. */
  52663. readonly left: NodeMaterialConnectionPoint;
  52664. /**
  52665. * Gets the right operand input component
  52666. */
  52667. readonly right: NodeMaterialConnectionPoint;
  52668. /**
  52669. * Gets the output component
  52670. */
  52671. readonly output: NodeMaterialConnectionPoint;
  52672. protected _buildBlock(state: NodeMaterialBuildState): this;
  52673. }
  52674. }
  52675. declare module BABYLON {
  52676. /**
  52677. * Block used to add 2 vectors
  52678. */
  52679. export class AddBlock extends NodeMaterialBlock {
  52680. /**
  52681. * Creates a new AddBlock
  52682. * @param name defines the block name
  52683. */
  52684. constructor(name: string);
  52685. /**
  52686. * Gets the current class name
  52687. * @returns the class name
  52688. */
  52689. getClassName(): string;
  52690. /**
  52691. * Gets the left operand input component
  52692. */
  52693. readonly left: NodeMaterialConnectionPoint;
  52694. /**
  52695. * Gets the right operand input component
  52696. */
  52697. readonly right: NodeMaterialConnectionPoint;
  52698. /**
  52699. * Gets the output component
  52700. */
  52701. readonly output: NodeMaterialConnectionPoint;
  52702. protected _buildBlock(state: NodeMaterialBuildState): this;
  52703. }
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * Block used to clamp a float
  52708. */
  52709. export class ClampBlock extends NodeMaterialBlock {
  52710. /** Gets or sets the minimum range */
  52711. minimum: number;
  52712. /** Gets or sets the maximum range */
  52713. maximum: number;
  52714. /**
  52715. * Creates a new ClampBlock
  52716. * @param name defines the block name
  52717. */
  52718. constructor(name: string);
  52719. /**
  52720. * Gets the current class name
  52721. * @returns the class name
  52722. */
  52723. getClassName(): string;
  52724. /**
  52725. * Gets the value input component
  52726. */
  52727. readonly value: NodeMaterialConnectionPoint;
  52728. /**
  52729. * Gets the output component
  52730. */
  52731. readonly output: NodeMaterialConnectionPoint;
  52732. protected _buildBlock(state: NodeMaterialBuildState): this;
  52733. }
  52734. }
  52735. declare module BABYLON {
  52736. /**
  52737. * Block used to apply a cross product between 2 vectors
  52738. */
  52739. export class CrossBlock extends NodeMaterialBlock {
  52740. /**
  52741. * Creates a new CrossBlock
  52742. * @param name defines the block name
  52743. */
  52744. constructor(name: string);
  52745. /**
  52746. * Gets the current class name
  52747. * @returns the class name
  52748. */
  52749. getClassName(): string;
  52750. /**
  52751. * Gets the left operand input component
  52752. */
  52753. readonly left: NodeMaterialConnectionPoint;
  52754. /**
  52755. * Gets the right operand input component
  52756. */
  52757. readonly right: NodeMaterialConnectionPoint;
  52758. /**
  52759. * Gets the output component
  52760. */
  52761. readonly output: NodeMaterialConnectionPoint;
  52762. protected _buildBlock(state: NodeMaterialBuildState): this;
  52763. }
  52764. }
  52765. declare module BABYLON {
  52766. /**
  52767. * Block used to apply a dot product between 2 vectors
  52768. */
  52769. export class DotBlock extends NodeMaterialBlock {
  52770. /**
  52771. * Creates a new DotBlock
  52772. * @param name defines the block name
  52773. */
  52774. constructor(name: string);
  52775. /**
  52776. * Gets the current class name
  52777. * @returns the class name
  52778. */
  52779. getClassName(): string;
  52780. /**
  52781. * Gets the left operand input component
  52782. */
  52783. readonly left: NodeMaterialConnectionPoint;
  52784. /**
  52785. * Gets the right operand input component
  52786. */
  52787. readonly right: NodeMaterialConnectionPoint;
  52788. /**
  52789. * Gets the output component
  52790. */
  52791. readonly output: NodeMaterialConnectionPoint;
  52792. protected _buildBlock(state: NodeMaterialBuildState): this;
  52793. }
  52794. }
  52795. declare module BABYLON {
  52796. /**
  52797. * Effect Render Options
  52798. */
  52799. export interface IEffectRendererOptions {
  52800. /**
  52801. * Defines the vertices positions.
  52802. */
  52803. positions?: number[];
  52804. /**
  52805. * Defines the indices.
  52806. */
  52807. indices?: number[];
  52808. }
  52809. /**
  52810. * Helper class to render one or more effects
  52811. */
  52812. export class EffectRenderer {
  52813. private engine;
  52814. private static _DefaultOptions;
  52815. private _vertexBuffers;
  52816. private _indexBuffer;
  52817. private _ringBufferIndex;
  52818. private _ringScreenBuffer;
  52819. private _fullscreenViewport;
  52820. private _getNextFrameBuffer;
  52821. /**
  52822. * Creates an effect renderer
  52823. * @param engine the engine to use for rendering
  52824. * @param options defines the options of the effect renderer
  52825. */
  52826. constructor(engine: Engine, options?: IEffectRendererOptions);
  52827. /**
  52828. * Sets the current viewport in normalized coordinates 0-1
  52829. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52830. */
  52831. setViewport(viewport?: Viewport): void;
  52832. /**
  52833. * Sets the current effect wrapper to use during draw.
  52834. * The effect needs to be ready before calling this api.
  52835. * This also sets the default full screen position attribute.
  52836. * @param effectWrapper Defines the effect to draw with
  52837. */
  52838. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52839. /**
  52840. * Draws a full screen quad.
  52841. */
  52842. draw(): void;
  52843. /**
  52844. * renders one or more effects to a specified texture
  52845. * @param effectWrappers list of effects to renderer
  52846. * @param outputTexture texture to draw to, if null it will render to the screen
  52847. */
  52848. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52849. /**
  52850. * Disposes of the effect renderer
  52851. */
  52852. dispose(): void;
  52853. }
  52854. /**
  52855. * Options to create an EffectWrapper
  52856. */
  52857. interface EffectWrapperCreationOptions {
  52858. /**
  52859. * Engine to use to create the effect
  52860. */
  52861. engine: Engine;
  52862. /**
  52863. * Fragment shader for the effect
  52864. */
  52865. fragmentShader: string;
  52866. /**
  52867. * Vertex shader for the effect
  52868. */
  52869. vertexShader: string;
  52870. /**
  52871. * Attributes to use in the shader
  52872. */
  52873. attributeNames?: Array<string>;
  52874. /**
  52875. * Uniforms to use in the shader
  52876. */
  52877. uniformNames?: Array<string>;
  52878. /**
  52879. * Texture sampler names to use in the shader
  52880. */
  52881. samplerNames?: Array<string>;
  52882. /**
  52883. * The friendly name of the effect displayed in Spector.
  52884. */
  52885. name?: string;
  52886. }
  52887. /**
  52888. * Wraps an effect to be used for rendering
  52889. */
  52890. export class EffectWrapper {
  52891. /**
  52892. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52893. */
  52894. onApplyObservable: Observable<{}>;
  52895. /**
  52896. * The underlying effect
  52897. */
  52898. effect: Effect;
  52899. /**
  52900. * Creates an effect to be renderer
  52901. * @param creationOptions options to create the effect
  52902. */
  52903. constructor(creationOptions: EffectWrapperCreationOptions);
  52904. /**
  52905. * Disposes of the effect wrapper
  52906. */
  52907. dispose(): void;
  52908. }
  52909. }
  52910. declare module BABYLON {
  52911. /**
  52912. * Helper class to push actions to a pool of workers.
  52913. */
  52914. export class WorkerPool implements IDisposable {
  52915. private _workerInfos;
  52916. private _pendingActions;
  52917. /**
  52918. * Constructor
  52919. * @param workers Array of workers to use for actions
  52920. */
  52921. constructor(workers: Array<Worker>);
  52922. /**
  52923. * Terminates all workers and clears any pending actions.
  52924. */
  52925. dispose(): void;
  52926. /**
  52927. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52928. * pended until a worker has completed its action.
  52929. * @param action The action to perform. Call onComplete when the action is complete.
  52930. */
  52931. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52932. private _execute;
  52933. }
  52934. }
  52935. declare module BABYLON {
  52936. /**
  52937. * Configuration for Draco compression
  52938. */
  52939. export interface IDracoCompressionConfiguration {
  52940. /**
  52941. * Configuration for the decoder.
  52942. */
  52943. decoder: {
  52944. /**
  52945. * The url to the WebAssembly module.
  52946. */
  52947. wasmUrl?: string;
  52948. /**
  52949. * The url to the WebAssembly binary.
  52950. */
  52951. wasmBinaryUrl?: string;
  52952. /**
  52953. * The url to the fallback JavaScript module.
  52954. */
  52955. fallbackUrl?: string;
  52956. };
  52957. }
  52958. /**
  52959. * Draco compression (https://google.github.io/draco/)
  52960. *
  52961. * This class wraps the Draco module.
  52962. *
  52963. * **Encoder**
  52964. *
  52965. * The encoder is not currently implemented.
  52966. *
  52967. * **Decoder**
  52968. *
  52969. * 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.
  52970. *
  52971. * To update the configuration, use the following code:
  52972. * ```javascript
  52973. * DracoCompression.Configuration = {
  52974. * decoder: {
  52975. * wasmUrl: "<url to the WebAssembly library>",
  52976. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52977. * fallbackUrl: "<url to the fallback JavaScript library>",
  52978. * }
  52979. * };
  52980. * ```
  52981. *
  52982. * 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.
  52983. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52984. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52985. *
  52986. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52987. * ```javascript
  52988. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52989. * ```
  52990. *
  52991. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52992. */
  52993. export class DracoCompression implements IDisposable {
  52994. private _workerPoolPromise?;
  52995. private _decoderModulePromise?;
  52996. /**
  52997. * The configuration. Defaults to the following urls:
  52998. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52999. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53000. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53001. */
  53002. static Configuration: IDracoCompressionConfiguration;
  53003. /**
  53004. * Returns true if the decoder configuration is available.
  53005. */
  53006. static readonly DecoderAvailable: boolean;
  53007. /**
  53008. * Default number of workers to create when creating the draco compression object.
  53009. */
  53010. static DefaultNumWorkers: number;
  53011. private static GetDefaultNumWorkers;
  53012. private static _Default;
  53013. /**
  53014. * Default instance for the draco compression object.
  53015. */
  53016. static readonly Default: DracoCompression;
  53017. /**
  53018. * Constructor
  53019. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53020. */
  53021. constructor(numWorkers?: number);
  53022. /**
  53023. * Stop all async operations and release resources.
  53024. */
  53025. dispose(): void;
  53026. /**
  53027. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53028. * @returns a promise that resolves when ready
  53029. */
  53030. whenReadyAsync(): Promise<void>;
  53031. /**
  53032. * Decode Draco compressed mesh data to vertex data.
  53033. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53034. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53035. * @returns A promise that resolves with the decoded vertex data
  53036. */
  53037. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53038. [kind: string]: number;
  53039. }): Promise<VertexData>;
  53040. }
  53041. }
  53042. declare module BABYLON {
  53043. /**
  53044. * Class for building Constructive Solid Geometry
  53045. */
  53046. export class CSG {
  53047. private polygons;
  53048. /**
  53049. * The world matrix
  53050. */
  53051. matrix: Matrix;
  53052. /**
  53053. * Stores the position
  53054. */
  53055. position: Vector3;
  53056. /**
  53057. * Stores the rotation
  53058. */
  53059. rotation: Vector3;
  53060. /**
  53061. * Stores the rotation quaternion
  53062. */
  53063. rotationQuaternion: Nullable<Quaternion>;
  53064. /**
  53065. * Stores the scaling vector
  53066. */
  53067. scaling: Vector3;
  53068. /**
  53069. * Convert the Mesh to CSG
  53070. * @param mesh The Mesh to convert to CSG
  53071. * @returns A new CSG from the Mesh
  53072. */
  53073. static FromMesh(mesh: Mesh): CSG;
  53074. /**
  53075. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53076. * @param polygons Polygons used to construct a CSG solid
  53077. */
  53078. private static FromPolygons;
  53079. /**
  53080. * Clones, or makes a deep copy, of the CSG
  53081. * @returns A new CSG
  53082. */
  53083. clone(): CSG;
  53084. /**
  53085. * Unions this CSG with another CSG
  53086. * @param csg The CSG to union against this CSG
  53087. * @returns The unioned CSG
  53088. */
  53089. union(csg: CSG): CSG;
  53090. /**
  53091. * Unions this CSG with another CSG in place
  53092. * @param csg The CSG to union against this CSG
  53093. */
  53094. unionInPlace(csg: CSG): void;
  53095. /**
  53096. * Subtracts this CSG with another CSG
  53097. * @param csg The CSG to subtract against this CSG
  53098. * @returns A new CSG
  53099. */
  53100. subtract(csg: CSG): CSG;
  53101. /**
  53102. * Subtracts this CSG with another CSG in place
  53103. * @param csg The CSG to subtact against this CSG
  53104. */
  53105. subtractInPlace(csg: CSG): void;
  53106. /**
  53107. * Intersect this CSG with another CSG
  53108. * @param csg The CSG to intersect against this CSG
  53109. * @returns A new CSG
  53110. */
  53111. intersect(csg: CSG): CSG;
  53112. /**
  53113. * Intersects this CSG with another CSG in place
  53114. * @param csg The CSG to intersect against this CSG
  53115. */
  53116. intersectInPlace(csg: CSG): void;
  53117. /**
  53118. * Return a new CSG solid with solid and empty space switched. This solid is
  53119. * not modified.
  53120. * @returns A new CSG solid with solid and empty space switched
  53121. */
  53122. inverse(): CSG;
  53123. /**
  53124. * Inverses the CSG in place
  53125. */
  53126. inverseInPlace(): void;
  53127. /**
  53128. * This is used to keep meshes transformations so they can be restored
  53129. * when we build back a Babylon Mesh
  53130. * NB : All CSG operations are performed in world coordinates
  53131. * @param csg The CSG to copy the transform attributes from
  53132. * @returns This CSG
  53133. */
  53134. copyTransformAttributes(csg: CSG): CSG;
  53135. /**
  53136. * Build Raw mesh from CSG
  53137. * Coordinates here are in world space
  53138. * @param name The name of the mesh geometry
  53139. * @param scene The Scene
  53140. * @param keepSubMeshes Specifies if the submeshes should be kept
  53141. * @returns A new Mesh
  53142. */
  53143. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53144. /**
  53145. * Build Mesh from CSG taking material and transforms into account
  53146. * @param name The name of the Mesh
  53147. * @param material The material of the Mesh
  53148. * @param scene The Scene
  53149. * @param keepSubMeshes Specifies if submeshes should be kept
  53150. * @returns The new Mesh
  53151. */
  53152. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53153. }
  53154. }
  53155. declare module BABYLON {
  53156. /**
  53157. * Class used to create a trail following a mesh
  53158. */
  53159. export class TrailMesh extends Mesh {
  53160. private _generator;
  53161. private _autoStart;
  53162. private _running;
  53163. private _diameter;
  53164. private _length;
  53165. private _sectionPolygonPointsCount;
  53166. private _sectionVectors;
  53167. private _sectionNormalVectors;
  53168. private _beforeRenderObserver;
  53169. /**
  53170. * @constructor
  53171. * @param name The value used by scene.getMeshByName() to do a lookup.
  53172. * @param generator The mesh to generate a trail.
  53173. * @param scene The scene to add this mesh to.
  53174. * @param diameter Diameter of trailing mesh. Default is 1.
  53175. * @param length Length of trailing mesh. Default is 60.
  53176. * @param autoStart Automatically start trailing mesh. Default true.
  53177. */
  53178. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53179. /**
  53180. * "TrailMesh"
  53181. * @returns "TrailMesh"
  53182. */
  53183. getClassName(): string;
  53184. private _createMesh;
  53185. /**
  53186. * Start trailing mesh.
  53187. */
  53188. start(): void;
  53189. /**
  53190. * Stop trailing mesh.
  53191. */
  53192. stop(): void;
  53193. /**
  53194. * Update trailing mesh geometry.
  53195. */
  53196. update(): void;
  53197. /**
  53198. * Returns a new TrailMesh object.
  53199. * @param name is a string, the name given to the new mesh
  53200. * @param newGenerator use new generator object for cloned trail mesh
  53201. * @returns a new mesh
  53202. */
  53203. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53204. /**
  53205. * Serializes this trail mesh
  53206. * @param serializationObject object to write serialization to
  53207. */
  53208. serialize(serializationObject: any): void;
  53209. /**
  53210. * Parses a serialized trail mesh
  53211. * @param parsedMesh the serialized mesh
  53212. * @param scene the scene to create the trail mesh in
  53213. * @returns the created trail mesh
  53214. */
  53215. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53216. }
  53217. }
  53218. declare module BABYLON {
  53219. /**
  53220. * Class containing static functions to help procedurally build meshes
  53221. */
  53222. export class TiledBoxBuilder {
  53223. /**
  53224. * Creates a box mesh
  53225. * 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)
  53226. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53228. * * 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
  53229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53230. * @param name defines the name of the mesh
  53231. * @param options defines the options used to create the mesh
  53232. * @param scene defines the hosting scene
  53233. * @returns the box mesh
  53234. */
  53235. static CreateTiledBox(name: string, options: {
  53236. pattern?: number;
  53237. width?: number;
  53238. height?: number;
  53239. depth?: number;
  53240. tileSize?: number;
  53241. tileWidth?: number;
  53242. tileHeight?: number;
  53243. alignHorizontal?: number;
  53244. alignVertical?: number;
  53245. faceUV?: Vector4[];
  53246. faceColors?: Color4[];
  53247. sideOrientation?: number;
  53248. updatable?: boolean;
  53249. }, scene?: Nullable<Scene>): Mesh;
  53250. }
  53251. }
  53252. declare module BABYLON {
  53253. /**
  53254. * Class containing static functions to help procedurally build meshes
  53255. */
  53256. export class TorusKnotBuilder {
  53257. /**
  53258. * Creates a torus knot mesh
  53259. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53260. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53261. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53262. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53264. * * 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
  53265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53266. * @param name defines the name of the mesh
  53267. * @param options defines the options used to create the mesh
  53268. * @param scene defines the hosting scene
  53269. * @returns the torus knot mesh
  53270. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53271. */
  53272. static CreateTorusKnot(name: string, options: {
  53273. radius?: number;
  53274. tube?: number;
  53275. radialSegments?: number;
  53276. tubularSegments?: number;
  53277. p?: number;
  53278. q?: number;
  53279. updatable?: boolean;
  53280. sideOrientation?: number;
  53281. frontUVs?: Vector4;
  53282. backUVs?: Vector4;
  53283. }, scene: any): Mesh;
  53284. }
  53285. }
  53286. declare module BABYLON {
  53287. /**
  53288. * Polygon
  53289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53290. */
  53291. export class Polygon {
  53292. /**
  53293. * Creates a rectangle
  53294. * @param xmin bottom X coord
  53295. * @param ymin bottom Y coord
  53296. * @param xmax top X coord
  53297. * @param ymax top Y coord
  53298. * @returns points that make the resulting rectation
  53299. */
  53300. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53301. /**
  53302. * Creates a circle
  53303. * @param radius radius of circle
  53304. * @param cx scale in x
  53305. * @param cy scale in y
  53306. * @param numberOfSides number of sides that make up the circle
  53307. * @returns points that make the resulting circle
  53308. */
  53309. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53310. /**
  53311. * Creates a polygon from input string
  53312. * @param input Input polygon data
  53313. * @returns the parsed points
  53314. */
  53315. static Parse(input: string): Vector2[];
  53316. /**
  53317. * Starts building a polygon from x and y coordinates
  53318. * @param x x coordinate
  53319. * @param y y coordinate
  53320. * @returns the started path2
  53321. */
  53322. static StartingAt(x: number, y: number): Path2;
  53323. }
  53324. /**
  53325. * Builds a polygon
  53326. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53327. */
  53328. export class PolygonMeshBuilder {
  53329. private _points;
  53330. private _outlinepoints;
  53331. private _holes;
  53332. private _name;
  53333. private _scene;
  53334. private _epoints;
  53335. private _eholes;
  53336. private _addToepoint;
  53337. /**
  53338. * Babylon reference to the earcut plugin.
  53339. */
  53340. bjsEarcut: any;
  53341. /**
  53342. * Creates a PolygonMeshBuilder
  53343. * @param name name of the builder
  53344. * @param contours Path of the polygon
  53345. * @param scene scene to add to when creating the mesh
  53346. * @param earcutInjection can be used to inject your own earcut reference
  53347. */
  53348. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53349. /**
  53350. * Adds a whole within the polygon
  53351. * @param hole Array of points defining the hole
  53352. * @returns this
  53353. */
  53354. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53355. /**
  53356. * Creates the polygon
  53357. * @param updatable If the mesh should be updatable
  53358. * @param depth The depth of the mesh created
  53359. * @returns the created mesh
  53360. */
  53361. build(updatable?: boolean, depth?: number): Mesh;
  53362. /**
  53363. * Creates the polygon
  53364. * @param depth The depth of the mesh created
  53365. * @returns the created VertexData
  53366. */
  53367. buildVertexData(depth?: number): VertexData;
  53368. /**
  53369. * Adds a side to the polygon
  53370. * @param positions points that make the polygon
  53371. * @param normals normals of the polygon
  53372. * @param uvs uvs of the polygon
  53373. * @param indices indices of the polygon
  53374. * @param bounds bounds of the polygon
  53375. * @param points points of the polygon
  53376. * @param depth depth of the polygon
  53377. * @param flip flip of the polygon
  53378. */
  53379. private addSide;
  53380. }
  53381. }
  53382. declare module BABYLON {
  53383. /**
  53384. * Class containing static functions to help procedurally build meshes
  53385. */
  53386. export class PolygonBuilder {
  53387. /**
  53388. * Creates a polygon mesh
  53389. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53390. * * 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
  53391. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53393. * * 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)
  53394. * * Remember you can only change the shape positions, not their number when updating a polygon
  53395. * @param name defines the name of the mesh
  53396. * @param options defines the options used to create the mesh
  53397. * @param scene defines the hosting scene
  53398. * @param earcutInjection can be used to inject your own earcut reference
  53399. * @returns the polygon mesh
  53400. */
  53401. static CreatePolygon(name: string, options: {
  53402. shape: Vector3[];
  53403. holes?: Vector3[][];
  53404. depth?: number;
  53405. faceUV?: Vector4[];
  53406. faceColors?: Color4[];
  53407. updatable?: boolean;
  53408. sideOrientation?: number;
  53409. frontUVs?: Vector4;
  53410. backUVs?: Vector4;
  53411. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53412. /**
  53413. * Creates an extruded polygon mesh, with depth in the Y direction.
  53414. * * 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)
  53415. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53416. * @param name defines the name of the mesh
  53417. * @param options defines the options used to create the mesh
  53418. * @param scene defines the hosting scene
  53419. * @param earcutInjection can be used to inject your own earcut reference
  53420. * @returns the polygon mesh
  53421. */
  53422. static ExtrudePolygon(name: string, options: {
  53423. shape: Vector3[];
  53424. holes?: Vector3[][];
  53425. depth?: number;
  53426. faceUV?: Vector4[];
  53427. faceColors?: Color4[];
  53428. updatable?: boolean;
  53429. sideOrientation?: number;
  53430. frontUVs?: Vector4;
  53431. backUVs?: Vector4;
  53432. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53433. }
  53434. }
  53435. declare module BABYLON {
  53436. /**
  53437. * Class containing static functions to help procedurally build meshes
  53438. */
  53439. export class LatheBuilder {
  53440. /**
  53441. * Creates lathe mesh.
  53442. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53443. * * 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
  53444. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53445. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53446. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53447. * * 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
  53448. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53449. * * 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
  53450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53451. * * 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
  53452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53454. * @param name defines the name of the mesh
  53455. * @param options defines the options used to create the mesh
  53456. * @param scene defines the hosting scene
  53457. * @returns the lathe mesh
  53458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53459. */
  53460. static CreateLathe(name: string, options: {
  53461. shape: Vector3[];
  53462. radius?: number;
  53463. tessellation?: number;
  53464. clip?: number;
  53465. arc?: number;
  53466. closed?: boolean;
  53467. updatable?: boolean;
  53468. sideOrientation?: number;
  53469. frontUVs?: Vector4;
  53470. backUVs?: Vector4;
  53471. cap?: number;
  53472. invertUV?: boolean;
  53473. }, scene?: Nullable<Scene>): Mesh;
  53474. }
  53475. }
  53476. declare module BABYLON {
  53477. /**
  53478. * Class containing static functions to help procedurally build meshes
  53479. */
  53480. export class TiledPlaneBuilder {
  53481. /**
  53482. * Creates a tiled plane mesh
  53483. * * The parameter `pattern` will, depending on value, do nothing or
  53484. * * * flip (reflect about central vertical) alternate tiles across and up
  53485. * * * flip every tile on alternate rows
  53486. * * * rotate (180 degs) alternate tiles across and up
  53487. * * * rotate every tile on alternate rows
  53488. * * * flip and rotate alternate tiles across and up
  53489. * * * flip and rotate every tile on alternate rows
  53490. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53491. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53492. * * 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
  53493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53494. * * 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)
  53495. * * 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)
  53496. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53497. * @param name defines the name of the mesh
  53498. * @param options defines the options used to create the mesh
  53499. * @param scene defines the hosting scene
  53500. * @returns the box mesh
  53501. */
  53502. static CreateTiledPlane(name: string, options: {
  53503. pattern?: number;
  53504. tileSize?: number;
  53505. tileWidth?: number;
  53506. tileHeight?: number;
  53507. size?: number;
  53508. width?: number;
  53509. height?: number;
  53510. alignHorizontal?: number;
  53511. alignVertical?: number;
  53512. sideOrientation?: number;
  53513. frontUVs?: Vector4;
  53514. backUVs?: Vector4;
  53515. updatable?: boolean;
  53516. }, scene?: Nullable<Scene>): Mesh;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. /**
  53521. * Class containing static functions to help procedurally build meshes
  53522. */
  53523. export class TubeBuilder {
  53524. /**
  53525. * Creates a tube mesh.
  53526. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53527. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53528. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53529. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53530. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53531. * * 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)
  53532. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53533. * * 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
  53534. * * 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
  53535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53536. * * 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
  53537. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53539. * @param name defines the name of the mesh
  53540. * @param options defines the options used to create the mesh
  53541. * @param scene defines the hosting scene
  53542. * @returns the tube mesh
  53543. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53544. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53545. */
  53546. static CreateTube(name: string, options: {
  53547. path: Vector3[];
  53548. radius?: number;
  53549. tessellation?: number;
  53550. radiusFunction?: {
  53551. (i: number, distance: number): number;
  53552. };
  53553. cap?: number;
  53554. arc?: number;
  53555. updatable?: boolean;
  53556. sideOrientation?: number;
  53557. frontUVs?: Vector4;
  53558. backUVs?: Vector4;
  53559. instance?: Mesh;
  53560. invertUV?: boolean;
  53561. }, scene?: Nullable<Scene>): Mesh;
  53562. }
  53563. }
  53564. declare module BABYLON {
  53565. /**
  53566. * Class containing static functions to help procedurally build meshes
  53567. */
  53568. export class IcoSphereBuilder {
  53569. /**
  53570. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53571. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53572. * * 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`)
  53573. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53574. * * 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
  53575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53576. * * 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
  53577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53578. * @param name defines the name of the mesh
  53579. * @param options defines the options used to create the mesh
  53580. * @param scene defines the hosting scene
  53581. * @returns the icosahedron mesh
  53582. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53583. */
  53584. static CreateIcoSphere(name: string, options: {
  53585. radius?: number;
  53586. radiusX?: number;
  53587. radiusY?: number;
  53588. radiusZ?: number;
  53589. flat?: boolean;
  53590. subdivisions?: number;
  53591. sideOrientation?: number;
  53592. frontUVs?: Vector4;
  53593. backUVs?: Vector4;
  53594. updatable?: boolean;
  53595. }, scene?: Nullable<Scene>): Mesh;
  53596. }
  53597. }
  53598. declare module BABYLON {
  53599. /**
  53600. * Class containing static functions to help procedurally build meshes
  53601. */
  53602. export class DecalBuilder {
  53603. /**
  53604. * Creates a decal mesh.
  53605. * 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
  53606. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53607. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53608. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53609. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53610. * @param name defines the name of the mesh
  53611. * @param sourceMesh defines the mesh where the decal must be applied
  53612. * @param options defines the options used to create the mesh
  53613. * @param scene defines the hosting scene
  53614. * @returns the decal mesh
  53615. * @see https://doc.babylonjs.com/how_to/decals
  53616. */
  53617. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53618. position?: Vector3;
  53619. normal?: Vector3;
  53620. size?: Vector3;
  53621. angle?: number;
  53622. }): Mesh;
  53623. }
  53624. }
  53625. declare module BABYLON {
  53626. /**
  53627. * Class containing static functions to help procedurally build meshes
  53628. */
  53629. export class MeshBuilder {
  53630. /**
  53631. * Creates a box mesh
  53632. * * The parameter `size` sets the size (float) of each box side (default 1)
  53633. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53634. * * 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)
  53635. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53637. * * 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
  53638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53639. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53640. * @param name defines the name of the mesh
  53641. * @param options defines the options used to create the mesh
  53642. * @param scene defines the hosting scene
  53643. * @returns the box mesh
  53644. */
  53645. static CreateBox(name: string, options: {
  53646. size?: number;
  53647. width?: number;
  53648. height?: number;
  53649. depth?: number;
  53650. faceUV?: Vector4[];
  53651. faceColors?: Color4[];
  53652. sideOrientation?: number;
  53653. frontUVs?: Vector4;
  53654. backUVs?: Vector4;
  53655. updatable?: boolean;
  53656. }, scene?: Nullable<Scene>): Mesh;
  53657. /**
  53658. * Creates a tiled box mesh
  53659. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53661. * @param name defines the name of the mesh
  53662. * @param options defines the options used to create the mesh
  53663. * @param scene defines the hosting scene
  53664. * @returns the tiled box mesh
  53665. */
  53666. static CreateTiledBox(name: string, options: {
  53667. pattern?: number;
  53668. size?: number;
  53669. width?: number;
  53670. height?: number;
  53671. depth: number;
  53672. tileSize?: number;
  53673. tileWidth?: number;
  53674. tileHeight?: number;
  53675. faceUV?: Vector4[];
  53676. faceColors?: Color4[];
  53677. alignHorizontal?: number;
  53678. alignVertical?: number;
  53679. sideOrientation?: number;
  53680. updatable?: boolean;
  53681. }, scene?: Nullable<Scene>): Mesh;
  53682. /**
  53683. * Creates a sphere mesh
  53684. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53685. * * 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`)
  53686. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53687. * * 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
  53688. * * 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)
  53689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53690. * * 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
  53691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53692. * @param name defines the name of the mesh
  53693. * @param options defines the options used to create the mesh
  53694. * @param scene defines the hosting scene
  53695. * @returns the sphere mesh
  53696. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53697. */
  53698. static CreateSphere(name: string, options: {
  53699. segments?: number;
  53700. diameter?: number;
  53701. diameterX?: number;
  53702. diameterY?: number;
  53703. diameterZ?: number;
  53704. arc?: number;
  53705. slice?: number;
  53706. sideOrientation?: number;
  53707. frontUVs?: Vector4;
  53708. backUVs?: Vector4;
  53709. updatable?: boolean;
  53710. }, scene?: Nullable<Scene>): Mesh;
  53711. /**
  53712. * Creates a plane polygonal mesh. By default, this is a disc
  53713. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53714. * * 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
  53715. * * 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
  53716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53717. * * 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
  53718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53719. * @param name defines the name of the mesh
  53720. * @param options defines the options used to create the mesh
  53721. * @param scene defines the hosting scene
  53722. * @returns the plane polygonal mesh
  53723. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53724. */
  53725. static CreateDisc(name: string, options: {
  53726. radius?: number;
  53727. tessellation?: number;
  53728. arc?: number;
  53729. updatable?: boolean;
  53730. sideOrientation?: number;
  53731. frontUVs?: Vector4;
  53732. backUVs?: Vector4;
  53733. }, scene?: Nullable<Scene>): Mesh;
  53734. /**
  53735. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53736. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53737. * * 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`)
  53738. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53739. * * 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
  53740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53741. * * 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
  53742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53743. * @param name defines the name of the mesh
  53744. * @param options defines the options used to create the mesh
  53745. * @param scene defines the hosting scene
  53746. * @returns the icosahedron mesh
  53747. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53748. */
  53749. static CreateIcoSphere(name: string, options: {
  53750. radius?: number;
  53751. radiusX?: number;
  53752. radiusY?: number;
  53753. radiusZ?: number;
  53754. flat?: boolean;
  53755. subdivisions?: number;
  53756. sideOrientation?: number;
  53757. frontUVs?: Vector4;
  53758. backUVs?: Vector4;
  53759. updatable?: boolean;
  53760. }, scene?: Nullable<Scene>): Mesh;
  53761. /**
  53762. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53763. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53764. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53765. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53766. * * 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
  53767. * * 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
  53768. * * 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
  53769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53770. * * 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
  53771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53772. * * 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
  53773. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53774. * * 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
  53775. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53777. * @param name defines the name of the mesh
  53778. * @param options defines the options used to create the mesh
  53779. * @param scene defines the hosting scene
  53780. * @returns the ribbon mesh
  53781. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53782. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53783. */
  53784. static CreateRibbon(name: string, options: {
  53785. pathArray: Vector3[][];
  53786. closeArray?: boolean;
  53787. closePath?: boolean;
  53788. offset?: number;
  53789. updatable?: boolean;
  53790. sideOrientation?: number;
  53791. frontUVs?: Vector4;
  53792. backUVs?: Vector4;
  53793. instance?: Mesh;
  53794. invertUV?: boolean;
  53795. uvs?: Vector2[];
  53796. colors?: Color4[];
  53797. }, scene?: Nullable<Scene>): Mesh;
  53798. /**
  53799. * Creates a cylinder or a cone mesh
  53800. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53801. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53802. * * 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.
  53803. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53804. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53805. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53806. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53807. * * 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).
  53808. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53809. * * 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).
  53810. * * 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
  53811. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53812. * * 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
  53813. * * 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.
  53814. * * If `enclose` is false, a ring surface is one element.
  53815. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53816. * * 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
  53817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53818. * * 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
  53819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53820. * @param name defines the name of the mesh
  53821. * @param options defines the options used to create the mesh
  53822. * @param scene defines the hosting scene
  53823. * @returns the cylinder mesh
  53824. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53825. */
  53826. static CreateCylinder(name: string, options: {
  53827. height?: number;
  53828. diameterTop?: number;
  53829. diameterBottom?: number;
  53830. diameter?: number;
  53831. tessellation?: number;
  53832. subdivisions?: number;
  53833. arc?: number;
  53834. faceColors?: Color4[];
  53835. faceUV?: Vector4[];
  53836. updatable?: boolean;
  53837. hasRings?: boolean;
  53838. enclose?: boolean;
  53839. cap?: number;
  53840. sideOrientation?: number;
  53841. frontUVs?: Vector4;
  53842. backUVs?: Vector4;
  53843. }, scene?: Nullable<Scene>): Mesh;
  53844. /**
  53845. * Creates a torus mesh
  53846. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53847. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53848. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53850. * * 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
  53851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53852. * @param name defines the name of the mesh
  53853. * @param options defines the options used to create the mesh
  53854. * @param scene defines the hosting scene
  53855. * @returns the torus mesh
  53856. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53857. */
  53858. static CreateTorus(name: string, options: {
  53859. diameter?: number;
  53860. thickness?: number;
  53861. tessellation?: number;
  53862. updatable?: boolean;
  53863. sideOrientation?: number;
  53864. frontUVs?: Vector4;
  53865. backUVs?: Vector4;
  53866. }, scene?: Nullable<Scene>): Mesh;
  53867. /**
  53868. * Creates a torus knot mesh
  53869. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53870. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53871. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53872. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53874. * * 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
  53875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53876. * @param name defines the name of the mesh
  53877. * @param options defines the options used to create the mesh
  53878. * @param scene defines the hosting scene
  53879. * @returns the torus knot mesh
  53880. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53881. */
  53882. static CreateTorusKnot(name: string, options: {
  53883. radius?: number;
  53884. tube?: number;
  53885. radialSegments?: number;
  53886. tubularSegments?: number;
  53887. p?: number;
  53888. q?: number;
  53889. updatable?: boolean;
  53890. sideOrientation?: number;
  53891. frontUVs?: Vector4;
  53892. backUVs?: Vector4;
  53893. }, scene?: Nullable<Scene>): Mesh;
  53894. /**
  53895. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53896. * * 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
  53897. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53898. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53899. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53900. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53901. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53902. * * 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
  53903. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53906. * @param name defines the name of the new line system
  53907. * @param options defines the options used to create the line system
  53908. * @param scene defines the hosting scene
  53909. * @returns a new line system mesh
  53910. */
  53911. static CreateLineSystem(name: string, options: {
  53912. lines: Vector3[][];
  53913. updatable?: boolean;
  53914. instance?: Nullable<LinesMesh>;
  53915. colors?: Nullable<Color4[][]>;
  53916. useVertexAlpha?: boolean;
  53917. }, scene: Nullable<Scene>): LinesMesh;
  53918. /**
  53919. * Creates a line mesh
  53920. * 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
  53921. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53922. * * The parameter `points` is an array successive Vector3
  53923. * * 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
  53924. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53925. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53926. * * When updating an instance, remember that only point positions can change, not the number of points
  53927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53929. * @param name defines the name of the new line system
  53930. * @param options defines the options used to create the line system
  53931. * @param scene defines the hosting scene
  53932. * @returns a new line mesh
  53933. */
  53934. static CreateLines(name: string, options: {
  53935. points: Vector3[];
  53936. updatable?: boolean;
  53937. instance?: Nullable<LinesMesh>;
  53938. colors?: Color4[];
  53939. useVertexAlpha?: boolean;
  53940. }, scene?: Nullable<Scene>): LinesMesh;
  53941. /**
  53942. * Creates a dashed line mesh
  53943. * * 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
  53944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53945. * * The parameter `points` is an array successive Vector3
  53946. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53947. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53948. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53949. * * 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
  53950. * * When updating an instance, remember that only point positions can change, not the number of points
  53951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53952. * @param name defines the name of the mesh
  53953. * @param options defines the options used to create the mesh
  53954. * @param scene defines the hosting scene
  53955. * @returns the dashed line mesh
  53956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53957. */
  53958. static CreateDashedLines(name: string, options: {
  53959. points: Vector3[];
  53960. dashSize?: number;
  53961. gapSize?: number;
  53962. dashNb?: number;
  53963. updatable?: boolean;
  53964. instance?: LinesMesh;
  53965. }, scene?: Nullable<Scene>): LinesMesh;
  53966. /**
  53967. * 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.
  53968. * * 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.
  53969. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53970. * * 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.
  53971. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53972. * * 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
  53973. * * 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
  53974. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53976. * * 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
  53977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53979. * @param name defines the name of the mesh
  53980. * @param options defines the options used to create the mesh
  53981. * @param scene defines the hosting scene
  53982. * @returns the extruded shape mesh
  53983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53985. */
  53986. static ExtrudeShape(name: string, options: {
  53987. shape: Vector3[];
  53988. path: Vector3[];
  53989. scale?: number;
  53990. rotation?: number;
  53991. cap?: number;
  53992. updatable?: boolean;
  53993. sideOrientation?: number;
  53994. frontUVs?: Vector4;
  53995. backUVs?: Vector4;
  53996. instance?: Mesh;
  53997. invertUV?: boolean;
  53998. }, scene?: Nullable<Scene>): Mesh;
  53999. /**
  54000. * Creates an custom extruded shape mesh.
  54001. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54002. * * 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.
  54003. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54004. * * 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
  54005. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54006. * * 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
  54007. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54008. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54009. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54010. * * 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
  54011. * * 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
  54012. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54014. * * 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
  54015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54017. * @param name defines the name of the mesh
  54018. * @param options defines the options used to create the mesh
  54019. * @param scene defines the hosting scene
  54020. * @returns the custom extruded shape mesh
  54021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54024. */
  54025. static ExtrudeShapeCustom(name: string, options: {
  54026. shape: Vector3[];
  54027. path: Vector3[];
  54028. scaleFunction?: any;
  54029. rotationFunction?: any;
  54030. ribbonCloseArray?: boolean;
  54031. ribbonClosePath?: boolean;
  54032. cap?: number;
  54033. updatable?: boolean;
  54034. sideOrientation?: number;
  54035. frontUVs?: Vector4;
  54036. backUVs?: Vector4;
  54037. instance?: Mesh;
  54038. invertUV?: boolean;
  54039. }, scene?: Nullable<Scene>): Mesh;
  54040. /**
  54041. * Creates lathe mesh.
  54042. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54043. * * 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
  54044. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54045. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54046. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54047. * * 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
  54048. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54049. * * 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
  54050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54051. * * 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
  54052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54054. * @param name defines the name of the mesh
  54055. * @param options defines the options used to create the mesh
  54056. * @param scene defines the hosting scene
  54057. * @returns the lathe mesh
  54058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54059. */
  54060. static CreateLathe(name: string, options: {
  54061. shape: Vector3[];
  54062. radius?: number;
  54063. tessellation?: number;
  54064. clip?: number;
  54065. arc?: number;
  54066. closed?: boolean;
  54067. updatable?: boolean;
  54068. sideOrientation?: number;
  54069. frontUVs?: Vector4;
  54070. backUVs?: Vector4;
  54071. cap?: number;
  54072. invertUV?: boolean;
  54073. }, scene?: Nullable<Scene>): Mesh;
  54074. /**
  54075. * Creates a tiled plane mesh
  54076. * * You can set a limited pattern arrangement with the tiles
  54077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54078. * * 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
  54079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54080. * @param name defines the name of the mesh
  54081. * @param options defines the options used to create the mesh
  54082. * @param scene defines the hosting scene
  54083. * @returns the plane mesh
  54084. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54085. */
  54086. static CreateTiledPlane(name: string, options: {
  54087. pattern?: number;
  54088. tileSize?: number;
  54089. tileWidth?: number;
  54090. tileHeight?: number;
  54091. size?: number;
  54092. width?: number;
  54093. height?: number;
  54094. alignHorizontal?: number;
  54095. alignVertical?: number;
  54096. sideOrientation?: number;
  54097. frontUVs?: Vector4;
  54098. backUVs?: Vector4;
  54099. updatable?: boolean;
  54100. }, scene?: Nullable<Scene>): Mesh;
  54101. /**
  54102. * Creates a plane mesh
  54103. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54104. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54105. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54107. * * 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
  54108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54109. * @param name defines the name of the mesh
  54110. * @param options defines the options used to create the mesh
  54111. * @param scene defines the hosting scene
  54112. * @returns the plane mesh
  54113. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54114. */
  54115. static CreatePlane(name: string, options: {
  54116. size?: number;
  54117. width?: number;
  54118. height?: number;
  54119. sideOrientation?: number;
  54120. frontUVs?: Vector4;
  54121. backUVs?: Vector4;
  54122. updatable?: boolean;
  54123. sourcePlane?: Plane;
  54124. }, scene?: Nullable<Scene>): Mesh;
  54125. /**
  54126. * Creates a ground mesh
  54127. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54128. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54130. * @param name defines the name of the mesh
  54131. * @param options defines the options used to create the mesh
  54132. * @param scene defines the hosting scene
  54133. * @returns the ground mesh
  54134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54135. */
  54136. static CreateGround(name: string, options: {
  54137. width?: number;
  54138. height?: number;
  54139. subdivisions?: number;
  54140. subdivisionsX?: number;
  54141. subdivisionsY?: number;
  54142. updatable?: boolean;
  54143. }, scene?: Nullable<Scene>): Mesh;
  54144. /**
  54145. * Creates a tiled ground mesh
  54146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54148. * * 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
  54149. * * 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
  54150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54151. * @param name defines the name of the mesh
  54152. * @param options defines the options used to create the mesh
  54153. * @param scene defines the hosting scene
  54154. * @returns the tiled ground mesh
  54155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54156. */
  54157. static CreateTiledGround(name: string, options: {
  54158. xmin: number;
  54159. zmin: number;
  54160. xmax: number;
  54161. zmax: number;
  54162. subdivisions?: {
  54163. w: number;
  54164. h: number;
  54165. };
  54166. precision?: {
  54167. w: number;
  54168. h: number;
  54169. };
  54170. updatable?: boolean;
  54171. }, scene?: Nullable<Scene>): Mesh;
  54172. /**
  54173. * Creates a ground mesh from a height map
  54174. * * The parameter `url` sets the URL of the height map image resource.
  54175. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54176. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54177. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54178. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54179. * * 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.
  54180. * * 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).
  54181. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54183. * @param name defines the name of the mesh
  54184. * @param url defines the url to the height map
  54185. * @param options defines the options used to create the mesh
  54186. * @param scene defines the hosting scene
  54187. * @returns the ground mesh
  54188. * @see https://doc.babylonjs.com/babylon101/height_map
  54189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54190. */
  54191. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54192. width?: number;
  54193. height?: number;
  54194. subdivisions?: number;
  54195. minHeight?: number;
  54196. maxHeight?: number;
  54197. colorFilter?: Color3;
  54198. alphaFilter?: number;
  54199. updatable?: boolean;
  54200. onReady?: (mesh: GroundMesh) => void;
  54201. }, scene?: Nullable<Scene>): GroundMesh;
  54202. /**
  54203. * Creates a polygon mesh
  54204. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54205. * * 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
  54206. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54208. * * 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)
  54209. * * Remember you can only change the shape positions, not their number when updating a polygon
  54210. * @param name defines the name of the mesh
  54211. * @param options defines the options used to create the mesh
  54212. * @param scene defines the hosting scene
  54213. * @param earcutInjection can be used to inject your own earcut reference
  54214. * @returns the polygon mesh
  54215. */
  54216. static CreatePolygon(name: string, options: {
  54217. shape: Vector3[];
  54218. holes?: Vector3[][];
  54219. depth?: number;
  54220. faceUV?: Vector4[];
  54221. faceColors?: Color4[];
  54222. updatable?: boolean;
  54223. sideOrientation?: number;
  54224. frontUVs?: Vector4;
  54225. backUVs?: Vector4;
  54226. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54227. /**
  54228. * Creates an extruded polygon mesh, with depth in the Y direction.
  54229. * * 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)
  54230. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54231. * @param name defines the name of the mesh
  54232. * @param options defines the options used to create the mesh
  54233. * @param scene defines the hosting scene
  54234. * @param earcutInjection can be used to inject your own earcut reference
  54235. * @returns the polygon mesh
  54236. */
  54237. static ExtrudePolygon(name: string, options: {
  54238. shape: Vector3[];
  54239. holes?: Vector3[][];
  54240. depth?: number;
  54241. faceUV?: Vector4[];
  54242. faceColors?: Color4[];
  54243. updatable?: boolean;
  54244. sideOrientation?: number;
  54245. frontUVs?: Vector4;
  54246. backUVs?: Vector4;
  54247. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54248. /**
  54249. * Creates a tube mesh.
  54250. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54251. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54252. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54253. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54254. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54255. * * 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)
  54256. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54257. * * 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
  54258. * * 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
  54259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54260. * * 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
  54261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54263. * @param name defines the name of the mesh
  54264. * @param options defines the options used to create the mesh
  54265. * @param scene defines the hosting scene
  54266. * @returns the tube mesh
  54267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54268. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54269. */
  54270. static CreateTube(name: string, options: {
  54271. path: Vector3[];
  54272. radius?: number;
  54273. tessellation?: number;
  54274. radiusFunction?: {
  54275. (i: number, distance: number): number;
  54276. };
  54277. cap?: number;
  54278. arc?: number;
  54279. updatable?: boolean;
  54280. sideOrientation?: number;
  54281. frontUVs?: Vector4;
  54282. backUVs?: Vector4;
  54283. instance?: Mesh;
  54284. invertUV?: boolean;
  54285. }, scene?: Nullable<Scene>): Mesh;
  54286. /**
  54287. * Creates a polyhedron mesh
  54288. * * 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
  54289. * * The parameter `size` (positive float, default 1) sets the polygon size
  54290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54291. * * 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`
  54292. * * 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
  54293. * * 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)`)
  54294. * * 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
  54295. * * 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
  54296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54297. * * 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
  54298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54299. * @param name defines the name of the mesh
  54300. * @param options defines the options used to create the mesh
  54301. * @param scene defines the hosting scene
  54302. * @returns the polyhedron mesh
  54303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54304. */
  54305. static CreatePolyhedron(name: string, options: {
  54306. type?: number;
  54307. size?: number;
  54308. sizeX?: number;
  54309. sizeY?: number;
  54310. sizeZ?: number;
  54311. custom?: any;
  54312. faceUV?: Vector4[];
  54313. faceColors?: Color4[];
  54314. flat?: boolean;
  54315. updatable?: boolean;
  54316. sideOrientation?: number;
  54317. frontUVs?: Vector4;
  54318. backUVs?: Vector4;
  54319. }, scene?: Nullable<Scene>): Mesh;
  54320. /**
  54321. * Creates a decal mesh.
  54322. * 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
  54323. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54324. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54325. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54326. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54327. * @param name defines the name of the mesh
  54328. * @param sourceMesh defines the mesh where the decal must be applied
  54329. * @param options defines the options used to create the mesh
  54330. * @param scene defines the hosting scene
  54331. * @returns the decal mesh
  54332. * @see https://doc.babylonjs.com/how_to/decals
  54333. */
  54334. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54335. position?: Vector3;
  54336. normal?: Vector3;
  54337. size?: Vector3;
  54338. angle?: number;
  54339. }): Mesh;
  54340. }
  54341. }
  54342. declare module BABYLON {
  54343. /**
  54344. * A simplifier interface for future simplification implementations
  54345. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54346. */
  54347. export interface ISimplifier {
  54348. /**
  54349. * Simplification of a given mesh according to the given settings.
  54350. * Since this requires computation, it is assumed that the function runs async.
  54351. * @param settings The settings of the simplification, including quality and distance
  54352. * @param successCallback A callback that will be called after the mesh was simplified.
  54353. * @param errorCallback in case of an error, this callback will be called. optional.
  54354. */
  54355. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54356. }
  54357. /**
  54358. * Expected simplification settings.
  54359. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54360. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54361. */
  54362. export interface ISimplificationSettings {
  54363. /**
  54364. * Gets or sets the expected quality
  54365. */
  54366. quality: number;
  54367. /**
  54368. * Gets or sets the distance when this optimized version should be used
  54369. */
  54370. distance: number;
  54371. /**
  54372. * Gets an already optimized mesh
  54373. */
  54374. optimizeMesh?: boolean;
  54375. }
  54376. /**
  54377. * Class used to specify simplification options
  54378. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54379. */
  54380. export class SimplificationSettings implements ISimplificationSettings {
  54381. /** expected quality */
  54382. quality: number;
  54383. /** distance when this optimized version should be used */
  54384. distance: number;
  54385. /** already optimized mesh */
  54386. optimizeMesh?: boolean | undefined;
  54387. /**
  54388. * Creates a SimplificationSettings
  54389. * @param quality expected quality
  54390. * @param distance distance when this optimized version should be used
  54391. * @param optimizeMesh already optimized mesh
  54392. */
  54393. constructor(
  54394. /** expected quality */
  54395. quality: number,
  54396. /** distance when this optimized version should be used */
  54397. distance: number,
  54398. /** already optimized mesh */
  54399. optimizeMesh?: boolean | undefined);
  54400. }
  54401. /**
  54402. * Interface used to define a simplification task
  54403. */
  54404. export interface ISimplificationTask {
  54405. /**
  54406. * Array of settings
  54407. */
  54408. settings: Array<ISimplificationSettings>;
  54409. /**
  54410. * Simplification type
  54411. */
  54412. simplificationType: SimplificationType;
  54413. /**
  54414. * Mesh to simplify
  54415. */
  54416. mesh: Mesh;
  54417. /**
  54418. * Callback called on success
  54419. */
  54420. successCallback?: () => void;
  54421. /**
  54422. * Defines if parallel processing can be used
  54423. */
  54424. parallelProcessing: boolean;
  54425. }
  54426. /**
  54427. * Queue used to order the simplification tasks
  54428. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54429. */
  54430. export class SimplificationQueue {
  54431. private _simplificationArray;
  54432. /**
  54433. * Gets a boolean indicating that the process is still running
  54434. */
  54435. running: boolean;
  54436. /**
  54437. * Creates a new queue
  54438. */
  54439. constructor();
  54440. /**
  54441. * Adds a new simplification task
  54442. * @param task defines a task to add
  54443. */
  54444. addTask(task: ISimplificationTask): void;
  54445. /**
  54446. * Execute next task
  54447. */
  54448. executeNext(): void;
  54449. /**
  54450. * Execute a simplification task
  54451. * @param task defines the task to run
  54452. */
  54453. runSimplification(task: ISimplificationTask): void;
  54454. private getSimplifier;
  54455. }
  54456. /**
  54457. * The implemented types of simplification
  54458. * At the moment only Quadratic Error Decimation is implemented
  54459. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54460. */
  54461. export enum SimplificationType {
  54462. /** Quadratic error decimation */
  54463. QUADRATIC = 0
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. interface Scene {
  54468. /** @hidden (Backing field) */
  54469. _simplificationQueue: SimplificationQueue;
  54470. /**
  54471. * Gets or sets the simplification queue attached to the scene
  54472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54473. */
  54474. simplificationQueue: SimplificationQueue;
  54475. }
  54476. interface Mesh {
  54477. /**
  54478. * Simplify the mesh according to the given array of settings.
  54479. * Function will return immediately and will simplify async
  54480. * @param settings a collection of simplification settings
  54481. * @param parallelProcessing should all levels calculate parallel or one after the other
  54482. * @param simplificationType the type of simplification to run
  54483. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54484. * @returns the current mesh
  54485. */
  54486. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54487. }
  54488. /**
  54489. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54490. * created in a scene
  54491. */
  54492. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54493. /**
  54494. * The component name helpfull to identify the component in the list of scene components.
  54495. */
  54496. readonly name: string;
  54497. /**
  54498. * The scene the component belongs to.
  54499. */
  54500. scene: Scene;
  54501. /**
  54502. * Creates a new instance of the component for the given scene
  54503. * @param scene Defines the scene to register the component in
  54504. */
  54505. constructor(scene: Scene);
  54506. /**
  54507. * Registers the component in a given scene
  54508. */
  54509. register(): void;
  54510. /**
  54511. * Rebuilds the elements related to this component in case of
  54512. * context lost for instance.
  54513. */
  54514. rebuild(): void;
  54515. /**
  54516. * Disposes the component and the associated ressources
  54517. */
  54518. dispose(): void;
  54519. private _beforeCameraUpdate;
  54520. }
  54521. }
  54522. declare module BABYLON {
  54523. /**
  54524. * Navigation plugin interface to add navigation constrained by a navigation mesh
  54525. */
  54526. export interface INavigationEnginePlugin {
  54527. /**
  54528. * plugin name
  54529. */
  54530. name: string;
  54531. /**
  54532. * Creates a navigation mesh
  54533. * @param meshes array of all the geometry used to compute the navigatio mesh
  54534. * @param parameters bunch of parameters used to filter geometry
  54535. */
  54536. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54537. /**
  54538. * Create a navigation mesh debug mesh
  54539. * @param scene is where the mesh will be added
  54540. * @returns debug display mesh
  54541. */
  54542. createDebugNavMesh(scene: Scene): Mesh;
  54543. /**
  54544. * Get a navigation mesh constrained position, closest to the parameter position
  54545. * @param position world position
  54546. * @returns the closest point to position constrained by the navigation mesh
  54547. */
  54548. getClosestPoint(position: Vector3): Vector3;
  54549. /**
  54550. * Get a navigation mesh constrained position, within a particular radius
  54551. * @param position world position
  54552. * @param maxRadius the maximum distance to the constrained world position
  54553. * @returns the closest point to position constrained by the navigation mesh
  54554. */
  54555. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54556. /**
  54557. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54558. * @param start world position
  54559. * @param end world position
  54560. * @returns array containing world position composing the path
  54561. */
  54562. computePath(start: Vector3, end: Vector3): Vector3[];
  54563. /**
  54564. * If this plugin is supported
  54565. * @returns true if plugin is supported
  54566. */
  54567. isSupported(): boolean;
  54568. /**
  54569. * Create a new Crowd so you can add agents
  54570. * @param maxAgents the maximum agent count in the crowd
  54571. * @param maxAgentRadius the maximum radius an agent can have
  54572. * @param scene to attach the crowd to
  54573. * @returns the crowd you can add agents to
  54574. */
  54575. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54576. /**
  54577. * Release all resources
  54578. */
  54579. dispose(): void;
  54580. }
  54581. /**
  54582. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54583. */
  54584. export interface ICrowd {
  54585. /**
  54586. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54587. * You can attach anything to that node. The node position is updated in the scene update tick.
  54588. * @param pos world position that will be constrained by the navigation mesh
  54589. * @param parameters agent parameters
  54590. * @param transform hooked to the agent that will be update by the scene
  54591. * @returns agent index
  54592. */
  54593. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54594. /**
  54595. * Returns the agent position in world space
  54596. * @param index agent index returned by addAgent
  54597. * @returns world space position
  54598. */
  54599. getAgentPosition(index: number): Vector3;
  54600. /**
  54601. * Gets the agent velocity in world space
  54602. * @param index agent index returned by addAgent
  54603. * @returns world space velocity
  54604. */
  54605. getAgentVelocity(index: number): Vector3;
  54606. /**
  54607. * remove a particular agent previously created
  54608. * @param index agent index returned by addAgent
  54609. */
  54610. removeAgent(index: number): void;
  54611. /**
  54612. * get the list of all agents attached to this crowd
  54613. * @returns list of agent indices
  54614. */
  54615. getAgents(): number[];
  54616. /**
  54617. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54618. * @param deltaTime in seconds
  54619. */
  54620. update(deltaTime: number): void;
  54621. /**
  54622. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54623. * @param index agent index returned by addAgent
  54624. * @param destination targeted world position
  54625. */
  54626. agentGoto(index: number, destination: Vector3): void;
  54627. /**
  54628. * Release all resources
  54629. */
  54630. dispose(): void;
  54631. }
  54632. /**
  54633. * Configures an agent
  54634. */
  54635. export interface IAgentParameters {
  54636. /**
  54637. * Agent radius. [Limit: >= 0]
  54638. */
  54639. radius: number;
  54640. /**
  54641. * Agent height. [Limit: > 0]
  54642. */
  54643. height: number;
  54644. /**
  54645. * Maximum allowed acceleration. [Limit: >= 0]
  54646. */
  54647. maxAcceleration: number;
  54648. /**
  54649. * Maximum allowed speed. [Limit: >= 0]
  54650. */
  54651. maxSpeed: number;
  54652. /**
  54653. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54654. */
  54655. collisionQueryRange: number;
  54656. /**
  54657. * The path visibility optimization range. [Limit: > 0]
  54658. */
  54659. pathOptimizationRange: number;
  54660. /**
  54661. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54662. */
  54663. separationWeight: number;
  54664. }
  54665. /**
  54666. * Configures the navigation mesh creation
  54667. */
  54668. export interface INavMeshParameters {
  54669. /**
  54670. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54671. */
  54672. cs: number;
  54673. /**
  54674. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54675. */
  54676. ch: number;
  54677. /**
  54678. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54679. */
  54680. walkableSlopeAngle: number;
  54681. /**
  54682. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54683. * be considered walkable. [Limit: >= 3] [Units: vx]
  54684. */
  54685. walkableHeight: number;
  54686. /**
  54687. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54688. */
  54689. walkableClimb: number;
  54690. /**
  54691. * The distance to erode/shrink the walkable area of the heightfield away from
  54692. * obstructions. [Limit: >=0] [Units: vx]
  54693. */
  54694. walkableRadius: number;
  54695. /**
  54696. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54697. */
  54698. maxEdgeLen: number;
  54699. /**
  54700. * The maximum distance a simplfied contour's border edges should deviate
  54701. * the original raw contour. [Limit: >=0] [Units: vx]
  54702. */
  54703. maxSimplificationError: number;
  54704. /**
  54705. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54706. */
  54707. minRegionArea: number;
  54708. /**
  54709. * Any regions with a span count smaller than this value will, if possible,
  54710. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54711. */
  54712. mergeRegionArea: number;
  54713. /**
  54714. * The maximum number of vertices allowed for polygons generated during the
  54715. * contour to polygon conversion process. [Limit: >= 3]
  54716. */
  54717. maxVertsPerPoly: number;
  54718. /**
  54719. * Sets the sampling distance to use when generating the detail mesh.
  54720. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54721. */
  54722. detailSampleDist: number;
  54723. /**
  54724. * The maximum distance the detail mesh surface should deviate from heightfield
  54725. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54726. */
  54727. detailSampleMaxError: number;
  54728. }
  54729. }
  54730. declare module BABYLON {
  54731. /**
  54732. * RecastJS navigation plugin
  54733. */
  54734. export class RecastJSPlugin implements INavigationEnginePlugin {
  54735. /**
  54736. * Reference to the Recast library
  54737. */
  54738. bjsRECAST: any;
  54739. /**
  54740. * plugin name
  54741. */
  54742. name: string;
  54743. /**
  54744. * the first navmesh created. We might extend this to support multiple navmeshes
  54745. */
  54746. navMesh: any;
  54747. /**
  54748. * Initializes the recastJS plugin
  54749. * @param recastInjection can be used to inject your own recast reference
  54750. */
  54751. constructor(recastInjection?: any);
  54752. /**
  54753. * Creates a navigation mesh
  54754. * @param meshes array of all the geometry used to compute the navigatio mesh
  54755. * @param parameters bunch of parameters used to filter geometry
  54756. */
  54757. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54758. /**
  54759. * Create a navigation mesh debug mesh
  54760. * @param scene is where the mesh will be added
  54761. * @returns debug display mesh
  54762. */
  54763. createDebugNavMesh(scene: Scene): Mesh;
  54764. /**
  54765. * Get a navigation mesh constrained position, closest to the parameter position
  54766. * @param position world position
  54767. * @returns the closest point to position constrained by the navigation mesh
  54768. */
  54769. getClosestPoint(position: Vector3): Vector3;
  54770. /**
  54771. * Get a navigation mesh constrained position, within a particular radius
  54772. * @param position world position
  54773. * @param maxRadius the maximum distance to the constrained world position
  54774. * @returns the closest point to position constrained by the navigation mesh
  54775. */
  54776. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54777. /**
  54778. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54779. * @param start world position
  54780. * @param end world position
  54781. * @returns array containing world position composing the path
  54782. */
  54783. computePath(start: Vector3, end: Vector3): Vector3[];
  54784. /**
  54785. * Create a new Crowd so you can add agents
  54786. * @param maxAgents the maximum agent count in the crowd
  54787. * @param maxAgentRadius the maximum radius an agent can have
  54788. * @param scene to attach the crowd to
  54789. * @returns the crowd you can add agents to
  54790. */
  54791. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54792. /**
  54793. * Disposes
  54794. */
  54795. dispose(): void;
  54796. /**
  54797. * If this plugin is supported
  54798. * @returns true if plugin is supported
  54799. */
  54800. isSupported(): boolean;
  54801. }
  54802. /**
  54803. * Recast detour crowd implementation
  54804. */
  54805. export class RecastJSCrowd implements ICrowd {
  54806. /**
  54807. * Recast/detour plugin
  54808. */
  54809. bjsRECASTPlugin: RecastJSPlugin;
  54810. /**
  54811. * Link to the detour crowd
  54812. */
  54813. recastCrowd: any;
  54814. /**
  54815. * One transform per agent
  54816. */
  54817. transforms: TransformNode[];
  54818. /**
  54819. * All agents created
  54820. */
  54821. agents: number[];
  54822. /**
  54823. * Link to the scene is kept to unregister the crowd from the scene
  54824. */
  54825. private _scene;
  54826. /**
  54827. * Observer for crowd updates
  54828. */
  54829. private _onBeforeAnimationsObserver;
  54830. /**
  54831. * Constructor
  54832. * @param plugin recastJS plugin
  54833. * @param maxAgents the maximum agent count in the crowd
  54834. * @param maxAgentRadius the maximum radius an agent can have
  54835. * @param scene to attach the crowd to
  54836. * @returns the crowd you can add agents to
  54837. */
  54838. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  54839. /**
  54840. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54841. * You can attach anything to that node. The node position is updated in the scene update tick.
  54842. * @param pos world position that will be constrained by the navigation mesh
  54843. * @param parameters agent parameters
  54844. * @param transform hooked to the agent that will be update by the scene
  54845. * @returns agent index
  54846. */
  54847. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54848. /**
  54849. * Returns the agent position in world space
  54850. * @param index agent index returned by addAgent
  54851. * @returns world space position
  54852. */
  54853. getAgentPosition(index: number): Vector3;
  54854. /**
  54855. * Returns the agent velocity in world space
  54856. * @param index agent index returned by addAgent
  54857. * @returns world space velocity
  54858. */
  54859. getAgentVelocity(index: number): Vector3;
  54860. /**
  54861. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54862. * @param index agent index returned by addAgent
  54863. * @param destination targeted world position
  54864. */
  54865. agentGoto(index: number, destination: Vector3): void;
  54866. /**
  54867. * remove a particular agent previously created
  54868. * @param index agent index returned by addAgent
  54869. */
  54870. removeAgent(index: number): void;
  54871. /**
  54872. * get the list of all agents attached to this crowd
  54873. * @returns list of agent indices
  54874. */
  54875. getAgents(): number[];
  54876. /**
  54877. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54878. * @param deltaTime in seconds
  54879. */
  54880. update(deltaTime: number): void;
  54881. /**
  54882. * Release all resources
  54883. */
  54884. dispose(): void;
  54885. }
  54886. }
  54887. declare module BABYLON {
  54888. /**
  54889. * Class used to enable access to IndexedDB
  54890. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54891. */
  54892. export class Database implements IOfflineProvider {
  54893. private _callbackManifestChecked;
  54894. private _currentSceneUrl;
  54895. private _db;
  54896. private _enableSceneOffline;
  54897. private _enableTexturesOffline;
  54898. private _manifestVersionFound;
  54899. private _mustUpdateRessources;
  54900. private _hasReachedQuota;
  54901. private _isSupported;
  54902. private _idbFactory;
  54903. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54904. private static IsUASupportingBlobStorage;
  54905. /**
  54906. * Gets a boolean indicating if Database storate is enabled (off by default)
  54907. */
  54908. static IDBStorageEnabled: boolean;
  54909. /**
  54910. * Gets a boolean indicating if scene must be saved in the database
  54911. */
  54912. readonly enableSceneOffline: boolean;
  54913. /**
  54914. * Gets a boolean indicating if textures must be saved in the database
  54915. */
  54916. readonly enableTexturesOffline: boolean;
  54917. /**
  54918. * Creates a new Database
  54919. * @param urlToScene defines the url to load the scene
  54920. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54921. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54922. */
  54923. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54924. private static _ParseURL;
  54925. private static _ReturnFullUrlLocation;
  54926. private _checkManifestFile;
  54927. /**
  54928. * Open the database and make it available
  54929. * @param successCallback defines the callback to call on success
  54930. * @param errorCallback defines the callback to call on error
  54931. */
  54932. open(successCallback: () => void, errorCallback: () => void): void;
  54933. /**
  54934. * Loads an image from the database
  54935. * @param url defines the url to load from
  54936. * @param image defines the target DOM image
  54937. */
  54938. loadImage(url: string, image: HTMLImageElement): void;
  54939. private _loadImageFromDBAsync;
  54940. private _saveImageIntoDBAsync;
  54941. private _checkVersionFromDB;
  54942. private _loadVersionFromDBAsync;
  54943. private _saveVersionIntoDBAsync;
  54944. /**
  54945. * Loads a file from database
  54946. * @param url defines the URL to load from
  54947. * @param sceneLoaded defines a callback to call on success
  54948. * @param progressCallBack defines a callback to call when progress changed
  54949. * @param errorCallback defines a callback to call on error
  54950. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54951. */
  54952. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54953. private _loadFileAsync;
  54954. private _saveFileAsync;
  54955. /**
  54956. * Validates if xhr data is correct
  54957. * @param xhr defines the request to validate
  54958. * @param dataType defines the expected data type
  54959. * @returns true if data is correct
  54960. */
  54961. private static _ValidateXHRData;
  54962. }
  54963. }
  54964. declare module BABYLON {
  54965. /** @hidden */
  54966. export var gpuUpdateParticlesPixelShader: {
  54967. name: string;
  54968. shader: string;
  54969. };
  54970. }
  54971. declare module BABYLON {
  54972. /** @hidden */
  54973. export var gpuUpdateParticlesVertexShader: {
  54974. name: string;
  54975. shader: string;
  54976. };
  54977. }
  54978. declare module BABYLON {
  54979. /** @hidden */
  54980. export var clipPlaneFragmentDeclaration2: {
  54981. name: string;
  54982. shader: string;
  54983. };
  54984. }
  54985. declare module BABYLON {
  54986. /** @hidden */
  54987. export var gpuRenderParticlesPixelShader: {
  54988. name: string;
  54989. shader: string;
  54990. };
  54991. }
  54992. declare module BABYLON {
  54993. /** @hidden */
  54994. export var clipPlaneVertexDeclaration2: {
  54995. name: string;
  54996. shader: string;
  54997. };
  54998. }
  54999. declare module BABYLON {
  55000. /** @hidden */
  55001. export var gpuRenderParticlesVertexShader: {
  55002. name: string;
  55003. shader: string;
  55004. };
  55005. }
  55006. declare module BABYLON {
  55007. /**
  55008. * This represents a GPU particle system in Babylon
  55009. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55010. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55011. */
  55012. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55013. /**
  55014. * The layer mask we are rendering the particles through.
  55015. */
  55016. layerMask: number;
  55017. private _capacity;
  55018. private _activeCount;
  55019. private _currentActiveCount;
  55020. private _accumulatedCount;
  55021. private _renderEffect;
  55022. private _updateEffect;
  55023. private _buffer0;
  55024. private _buffer1;
  55025. private _spriteBuffer;
  55026. private _updateVAO;
  55027. private _renderVAO;
  55028. private _targetIndex;
  55029. private _sourceBuffer;
  55030. private _targetBuffer;
  55031. private _engine;
  55032. private _currentRenderId;
  55033. private _started;
  55034. private _stopped;
  55035. private _timeDelta;
  55036. private _randomTexture;
  55037. private _randomTexture2;
  55038. private _attributesStrideSize;
  55039. private _updateEffectOptions;
  55040. private _randomTextureSize;
  55041. private _actualFrame;
  55042. private readonly _rawTextureWidth;
  55043. /**
  55044. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55045. */
  55046. static readonly IsSupported: boolean;
  55047. /**
  55048. * An event triggered when the system is disposed.
  55049. */
  55050. onDisposeObservable: Observable<GPUParticleSystem>;
  55051. /**
  55052. * Gets the maximum number of particles active at the same time.
  55053. * @returns The max number of active particles.
  55054. */
  55055. getCapacity(): number;
  55056. /**
  55057. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55058. * to override the particles.
  55059. */
  55060. forceDepthWrite: boolean;
  55061. /**
  55062. * Gets or set the number of active particles
  55063. */
  55064. activeParticleCount: number;
  55065. private _preWarmDone;
  55066. /**
  55067. * Is this system ready to be used/rendered
  55068. * @return true if the system is ready
  55069. */
  55070. isReady(): boolean;
  55071. /**
  55072. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55073. * @returns True if it has been started, otherwise false.
  55074. */
  55075. isStarted(): boolean;
  55076. /**
  55077. * Starts the particle system and begins to emit
  55078. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55079. */
  55080. start(delay?: number): void;
  55081. /**
  55082. * Stops the particle system.
  55083. */
  55084. stop(): void;
  55085. /**
  55086. * Remove all active particles
  55087. */
  55088. reset(): void;
  55089. /**
  55090. * Returns the string "GPUParticleSystem"
  55091. * @returns a string containing the class name
  55092. */
  55093. getClassName(): string;
  55094. private _colorGradientsTexture;
  55095. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55096. /**
  55097. * Adds a new color gradient
  55098. * @param gradient defines the gradient to use (between 0 and 1)
  55099. * @param color1 defines the color to affect to the specified gradient
  55100. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55101. * @returns the current particle system
  55102. */
  55103. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55104. /**
  55105. * Remove a specific color gradient
  55106. * @param gradient defines the gradient to remove
  55107. * @returns the current particle system
  55108. */
  55109. removeColorGradient(gradient: number): GPUParticleSystem;
  55110. private _angularSpeedGradientsTexture;
  55111. private _sizeGradientsTexture;
  55112. private _velocityGradientsTexture;
  55113. private _limitVelocityGradientsTexture;
  55114. private _dragGradientsTexture;
  55115. private _addFactorGradient;
  55116. /**
  55117. * Adds a new size gradient
  55118. * @param gradient defines the gradient to use (between 0 and 1)
  55119. * @param factor defines the size factor to affect to the specified gradient
  55120. * @returns the current particle system
  55121. */
  55122. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55123. /**
  55124. * Remove a specific size gradient
  55125. * @param gradient defines the gradient to remove
  55126. * @returns the current particle system
  55127. */
  55128. removeSizeGradient(gradient: number): GPUParticleSystem;
  55129. /**
  55130. * Adds a new angular speed gradient
  55131. * @param gradient defines the gradient to use (between 0 and 1)
  55132. * @param factor defines the angular speed to affect to the specified gradient
  55133. * @returns the current particle system
  55134. */
  55135. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55136. /**
  55137. * Remove a specific angular speed gradient
  55138. * @param gradient defines the gradient to remove
  55139. * @returns the current particle system
  55140. */
  55141. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55142. /**
  55143. * Adds a new velocity gradient
  55144. * @param gradient defines the gradient to use (between 0 and 1)
  55145. * @param factor defines the velocity to affect to the specified gradient
  55146. * @returns the current particle system
  55147. */
  55148. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55149. /**
  55150. * Remove a specific velocity gradient
  55151. * @param gradient defines the gradient to remove
  55152. * @returns the current particle system
  55153. */
  55154. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55155. /**
  55156. * Adds a new limit velocity gradient
  55157. * @param gradient defines the gradient to use (between 0 and 1)
  55158. * @param factor defines the limit velocity value to affect to the specified gradient
  55159. * @returns the current particle system
  55160. */
  55161. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55162. /**
  55163. * Remove a specific limit velocity gradient
  55164. * @param gradient defines the gradient to remove
  55165. * @returns the current particle system
  55166. */
  55167. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55168. /**
  55169. * Adds a new drag gradient
  55170. * @param gradient defines the gradient to use (between 0 and 1)
  55171. * @param factor defines the drag value to affect to the specified gradient
  55172. * @returns the current particle system
  55173. */
  55174. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55175. /**
  55176. * Remove a specific drag gradient
  55177. * @param gradient defines the gradient to remove
  55178. * @returns the current particle system
  55179. */
  55180. removeDragGradient(gradient: number): GPUParticleSystem;
  55181. /**
  55182. * Not supported by GPUParticleSystem
  55183. * @param gradient defines the gradient to use (between 0 and 1)
  55184. * @param factor defines the emit rate value to affect to the specified gradient
  55185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55186. * @returns the current particle system
  55187. */
  55188. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55189. /**
  55190. * Not supported by GPUParticleSystem
  55191. * @param gradient defines the gradient to remove
  55192. * @returns the current particle system
  55193. */
  55194. removeEmitRateGradient(gradient: number): IParticleSystem;
  55195. /**
  55196. * Not supported by GPUParticleSystem
  55197. * @param gradient defines the gradient to use (between 0 and 1)
  55198. * @param factor defines the start size value to affect to the specified gradient
  55199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55200. * @returns the current particle system
  55201. */
  55202. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55203. /**
  55204. * Not supported by GPUParticleSystem
  55205. * @param gradient defines the gradient to remove
  55206. * @returns the current particle system
  55207. */
  55208. removeStartSizeGradient(gradient: number): IParticleSystem;
  55209. /**
  55210. * Not supported by GPUParticleSystem
  55211. * @param gradient defines the gradient to use (between 0 and 1)
  55212. * @param min defines the color remap minimal range
  55213. * @param max defines the color remap maximal range
  55214. * @returns the current particle system
  55215. */
  55216. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55217. /**
  55218. * Not supported by GPUParticleSystem
  55219. * @param gradient defines the gradient to remove
  55220. * @returns the current particle system
  55221. */
  55222. removeColorRemapGradient(): IParticleSystem;
  55223. /**
  55224. * Not supported by GPUParticleSystem
  55225. * @param gradient defines the gradient to use (between 0 and 1)
  55226. * @param min defines the alpha remap minimal range
  55227. * @param max defines the alpha remap maximal range
  55228. * @returns the current particle system
  55229. */
  55230. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55231. /**
  55232. * Not supported by GPUParticleSystem
  55233. * @param gradient defines the gradient to remove
  55234. * @returns the current particle system
  55235. */
  55236. removeAlphaRemapGradient(): IParticleSystem;
  55237. /**
  55238. * Not supported by GPUParticleSystem
  55239. * @param gradient defines the gradient to use (between 0 and 1)
  55240. * @param color defines the color to affect to the specified gradient
  55241. * @returns the current particle system
  55242. */
  55243. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55244. /**
  55245. * Not supported by GPUParticleSystem
  55246. * @param gradient defines the gradient to remove
  55247. * @returns the current particle system
  55248. */
  55249. removeRampGradient(): IParticleSystem;
  55250. /**
  55251. * Not supported by GPUParticleSystem
  55252. * @returns the list of ramp gradients
  55253. */
  55254. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55255. /**
  55256. * Not supported by GPUParticleSystem
  55257. * Gets or sets a boolean indicating that ramp gradients must be used
  55258. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55259. */
  55260. useRampGradients: boolean;
  55261. /**
  55262. * Not supported by GPUParticleSystem
  55263. * @param gradient defines the gradient to use (between 0 and 1)
  55264. * @param factor defines the life time factor to affect to the specified gradient
  55265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55266. * @returns the current particle system
  55267. */
  55268. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55269. /**
  55270. * Not supported by GPUParticleSystem
  55271. * @param gradient defines the gradient to remove
  55272. * @returns the current particle system
  55273. */
  55274. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55275. /**
  55276. * Instantiates a GPU particle system.
  55277. * 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.
  55278. * @param name The name of the particle system
  55279. * @param options The options used to create the system
  55280. * @param scene The scene the particle system belongs to
  55281. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55282. */
  55283. constructor(name: string, options: Partial<{
  55284. capacity: number;
  55285. randomTextureSize: number;
  55286. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55287. protected _reset(): void;
  55288. private _createUpdateVAO;
  55289. private _createRenderVAO;
  55290. private _initialize;
  55291. /** @hidden */
  55292. _recreateUpdateEffect(): void;
  55293. /** @hidden */
  55294. _recreateRenderEffect(): void;
  55295. /**
  55296. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55297. * @param preWarm defines if we are in the pre-warmimg phase
  55298. */
  55299. animate(preWarm?: boolean): void;
  55300. private _createFactorGradientTexture;
  55301. private _createSizeGradientTexture;
  55302. private _createAngularSpeedGradientTexture;
  55303. private _createVelocityGradientTexture;
  55304. private _createLimitVelocityGradientTexture;
  55305. private _createDragGradientTexture;
  55306. private _createColorGradientTexture;
  55307. /**
  55308. * Renders the particle system in its current state
  55309. * @param preWarm defines if the system should only update the particles but not render them
  55310. * @returns the current number of particles
  55311. */
  55312. render(preWarm?: boolean): number;
  55313. /**
  55314. * Rebuilds the particle system
  55315. */
  55316. rebuild(): void;
  55317. private _releaseBuffers;
  55318. private _releaseVAOs;
  55319. /**
  55320. * Disposes the particle system and free the associated resources
  55321. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55322. */
  55323. dispose(disposeTexture?: boolean): void;
  55324. /**
  55325. * Clones the particle system.
  55326. * @param name The name of the cloned object
  55327. * @param newEmitter The new emitter to use
  55328. * @returns the cloned particle system
  55329. */
  55330. clone(name: string, newEmitter: any): GPUParticleSystem;
  55331. /**
  55332. * Serializes the particle system to a JSON object.
  55333. * @returns the JSON object
  55334. */
  55335. serialize(): any;
  55336. /**
  55337. * Parses a JSON object to create a GPU particle system.
  55338. * @param parsedParticleSystem The JSON object to parse
  55339. * @param scene The scene to create the particle system in
  55340. * @param rootUrl The root url to use to load external dependencies like texture
  55341. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55342. * @returns the parsed GPU particle system
  55343. */
  55344. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55345. }
  55346. }
  55347. declare module BABYLON {
  55348. /**
  55349. * Represents a set of particle systems working together to create a specific effect
  55350. */
  55351. export class ParticleSystemSet implements IDisposable {
  55352. private _emitterCreationOptions;
  55353. private _emitterNode;
  55354. /**
  55355. * Gets the particle system list
  55356. */
  55357. systems: IParticleSystem[];
  55358. /**
  55359. * Gets the emitter node used with this set
  55360. */
  55361. readonly emitterNode: Nullable<TransformNode>;
  55362. /**
  55363. * Creates a new emitter mesh as a sphere
  55364. * @param options defines the options used to create the sphere
  55365. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55366. * @param scene defines the hosting scene
  55367. */
  55368. setEmitterAsSphere(options: {
  55369. diameter: number;
  55370. segments: number;
  55371. color: Color3;
  55372. }, renderingGroupId: number, scene: Scene): void;
  55373. /**
  55374. * Starts all particle systems of the set
  55375. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55376. */
  55377. start(emitter?: AbstractMesh): void;
  55378. /**
  55379. * Release all associated resources
  55380. */
  55381. dispose(): void;
  55382. /**
  55383. * Serialize the set into a JSON compatible object
  55384. * @returns a JSON compatible representation of the set
  55385. */
  55386. serialize(): any;
  55387. /**
  55388. * Parse a new ParticleSystemSet from a serialized source
  55389. * @param data defines a JSON compatible representation of the set
  55390. * @param scene defines the hosting scene
  55391. * @param gpu defines if we want GPU particles or CPU particles
  55392. * @returns a new ParticleSystemSet
  55393. */
  55394. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55395. }
  55396. }
  55397. declare module BABYLON {
  55398. /**
  55399. * This class is made for on one-liner static method to help creating particle system set.
  55400. */
  55401. export class ParticleHelper {
  55402. /**
  55403. * Gets or sets base Assets URL
  55404. */
  55405. static BaseAssetsUrl: string;
  55406. /**
  55407. * Create a default particle system that you can tweak
  55408. * @param emitter defines the emitter to use
  55409. * @param capacity defines the system capacity (default is 500 particles)
  55410. * @param scene defines the hosting scene
  55411. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55412. * @returns the new Particle system
  55413. */
  55414. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55415. /**
  55416. * This is the main static method (one-liner) of this helper to create different particle systems
  55417. * @param type This string represents the type to the particle system to create
  55418. * @param scene The scene where the particle system should live
  55419. * @param gpu If the system will use gpu
  55420. * @returns the ParticleSystemSet created
  55421. */
  55422. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55423. /**
  55424. * Static function used to export a particle system to a ParticleSystemSet variable.
  55425. * Please note that the emitter shape is not exported
  55426. * @param systems defines the particle systems to export
  55427. * @returns the created particle system set
  55428. */
  55429. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55430. }
  55431. }
  55432. declare module BABYLON {
  55433. interface Engine {
  55434. /**
  55435. * Create an effect to use with particle systems.
  55436. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55437. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55438. * @param uniformsNames defines a list of attribute names
  55439. * @param samplers defines an array of string used to represent textures
  55440. * @param defines defines the string containing the defines to use to compile the shaders
  55441. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55442. * @param onCompiled defines a function to call when the effect creation is successful
  55443. * @param onError defines a function to call when the effect creation has failed
  55444. * @returns the new Effect
  55445. */
  55446. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55447. }
  55448. interface Mesh {
  55449. /**
  55450. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55451. * @returns an array of IParticleSystem
  55452. */
  55453. getEmittedParticleSystems(): IParticleSystem[];
  55454. /**
  55455. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55456. * @returns an array of IParticleSystem
  55457. */
  55458. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55459. }
  55460. /**
  55461. * @hidden
  55462. */
  55463. export var _IDoNeedToBeInTheBuild: number;
  55464. }
  55465. declare module BABYLON {
  55466. interface Scene {
  55467. /** @hidden (Backing field) */
  55468. _physicsEngine: Nullable<IPhysicsEngine>;
  55469. /**
  55470. * Gets the current physics engine
  55471. * @returns a IPhysicsEngine or null if none attached
  55472. */
  55473. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55474. /**
  55475. * Enables physics to the current scene
  55476. * @param gravity defines the scene's gravity for the physics engine
  55477. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55478. * @return a boolean indicating if the physics engine was initialized
  55479. */
  55480. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55481. /**
  55482. * Disables and disposes the physics engine associated with the scene
  55483. */
  55484. disablePhysicsEngine(): void;
  55485. /**
  55486. * Gets a boolean indicating if there is an active physics engine
  55487. * @returns a boolean indicating if there is an active physics engine
  55488. */
  55489. isPhysicsEnabled(): boolean;
  55490. /**
  55491. * Deletes a physics compound impostor
  55492. * @param compound defines the compound to delete
  55493. */
  55494. deleteCompoundImpostor(compound: any): void;
  55495. /**
  55496. * An event triggered when physic simulation is about to be run
  55497. */
  55498. onBeforePhysicsObservable: Observable<Scene>;
  55499. /**
  55500. * An event triggered when physic simulation has been done
  55501. */
  55502. onAfterPhysicsObservable: Observable<Scene>;
  55503. }
  55504. interface AbstractMesh {
  55505. /** @hidden */
  55506. _physicsImpostor: Nullable<PhysicsImpostor>;
  55507. /**
  55508. * Gets or sets impostor used for physic simulation
  55509. * @see http://doc.babylonjs.com/features/physics_engine
  55510. */
  55511. physicsImpostor: Nullable<PhysicsImpostor>;
  55512. /**
  55513. * Gets the current physics impostor
  55514. * @see http://doc.babylonjs.com/features/physics_engine
  55515. * @returns a physics impostor or null
  55516. */
  55517. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55518. /** Apply a physic impulse to the mesh
  55519. * @param force defines the force to apply
  55520. * @param contactPoint defines where to apply the force
  55521. * @returns the current mesh
  55522. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55523. */
  55524. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55525. /**
  55526. * Creates a physic joint between two meshes
  55527. * @param otherMesh defines the other mesh to use
  55528. * @param pivot1 defines the pivot to use on this mesh
  55529. * @param pivot2 defines the pivot to use on the other mesh
  55530. * @param options defines additional options (can be plugin dependent)
  55531. * @returns the current mesh
  55532. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55533. */
  55534. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55535. /** @hidden */
  55536. _disposePhysicsObserver: Nullable<Observer<Node>>;
  55537. }
  55538. /**
  55539. * Defines the physics engine scene component responsible to manage a physics engine
  55540. */
  55541. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55542. /**
  55543. * The component name helpful to identify the component in the list of scene components.
  55544. */
  55545. readonly name: string;
  55546. /**
  55547. * The scene the component belongs to.
  55548. */
  55549. scene: Scene;
  55550. /**
  55551. * Creates a new instance of the component for the given scene
  55552. * @param scene Defines the scene to register the component in
  55553. */
  55554. constructor(scene: Scene);
  55555. /**
  55556. * Registers the component in a given scene
  55557. */
  55558. register(): void;
  55559. /**
  55560. * Rebuilds the elements related to this component in case of
  55561. * context lost for instance.
  55562. */
  55563. rebuild(): void;
  55564. /**
  55565. * Disposes the component and the associated ressources
  55566. */
  55567. dispose(): void;
  55568. }
  55569. }
  55570. declare module BABYLON {
  55571. /**
  55572. * A helper for physics simulations
  55573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55574. */
  55575. export class PhysicsHelper {
  55576. private _scene;
  55577. private _physicsEngine;
  55578. /**
  55579. * Initializes the Physics helper
  55580. * @param scene Babylon.js scene
  55581. */
  55582. constructor(scene: Scene);
  55583. /**
  55584. * Applies a radial explosion impulse
  55585. * @param origin the origin of the explosion
  55586. * @param radiusOrEventOptions the radius or the options of radial explosion
  55587. * @param strength the explosion strength
  55588. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55589. * @returns A physics radial explosion event, or null
  55590. */
  55591. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55592. /**
  55593. * Applies a radial explosion force
  55594. * @param origin the origin of the explosion
  55595. * @param radiusOrEventOptions the radius or the options of radial explosion
  55596. * @param strength the explosion strength
  55597. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55598. * @returns A physics radial explosion event, or null
  55599. */
  55600. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55601. /**
  55602. * Creates a gravitational field
  55603. * @param origin the origin of the explosion
  55604. * @param radiusOrEventOptions the radius or the options of radial explosion
  55605. * @param strength the explosion strength
  55606. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55607. * @returns A physics gravitational field event, or null
  55608. */
  55609. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55610. /**
  55611. * Creates a physics updraft event
  55612. * @param origin the origin of the updraft
  55613. * @param radiusOrEventOptions the radius or the options of the updraft
  55614. * @param strength the strength of the updraft
  55615. * @param height the height of the updraft
  55616. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55617. * @returns A physics updraft event, or null
  55618. */
  55619. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55620. /**
  55621. * Creates a physics vortex event
  55622. * @param origin the of the vortex
  55623. * @param radiusOrEventOptions the radius or the options of the vortex
  55624. * @param strength the strength of the vortex
  55625. * @param height the height of the vortex
  55626. * @returns a Physics vortex event, or null
  55627. * A physics vortex event or null
  55628. */
  55629. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55630. }
  55631. /**
  55632. * Represents a physics radial explosion event
  55633. */
  55634. class PhysicsRadialExplosionEvent {
  55635. private _scene;
  55636. private _options;
  55637. private _sphere;
  55638. private _dataFetched;
  55639. /**
  55640. * Initializes a radial explosioin event
  55641. * @param _scene BabylonJS scene
  55642. * @param _options The options for the vortex event
  55643. */
  55644. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55645. /**
  55646. * Returns the data related to the radial explosion event (sphere).
  55647. * @returns The radial explosion event data
  55648. */
  55649. getData(): PhysicsRadialExplosionEventData;
  55650. /**
  55651. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55652. * @param impostor A physics imposter
  55653. * @param origin the origin of the explosion
  55654. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55655. */
  55656. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55657. /**
  55658. * Triggers affecterd impostors callbacks
  55659. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55660. */
  55661. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55662. /**
  55663. * Disposes the sphere.
  55664. * @param force Specifies if the sphere should be disposed by force
  55665. */
  55666. dispose(force?: boolean): void;
  55667. /*** Helpers ***/
  55668. private _prepareSphere;
  55669. private _intersectsWithSphere;
  55670. }
  55671. /**
  55672. * Represents a gravitational field event
  55673. */
  55674. class PhysicsGravitationalFieldEvent {
  55675. private _physicsHelper;
  55676. private _scene;
  55677. private _origin;
  55678. private _options;
  55679. private _tickCallback;
  55680. private _sphere;
  55681. private _dataFetched;
  55682. /**
  55683. * Initializes the physics gravitational field event
  55684. * @param _physicsHelper A physics helper
  55685. * @param _scene BabylonJS scene
  55686. * @param _origin The origin position of the gravitational field event
  55687. * @param _options The options for the vortex event
  55688. */
  55689. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55690. /**
  55691. * Returns the data related to the gravitational field event (sphere).
  55692. * @returns A gravitational field event
  55693. */
  55694. getData(): PhysicsGravitationalFieldEventData;
  55695. /**
  55696. * Enables the gravitational field.
  55697. */
  55698. enable(): void;
  55699. /**
  55700. * Disables the gravitational field.
  55701. */
  55702. disable(): void;
  55703. /**
  55704. * Disposes the sphere.
  55705. * @param force The force to dispose from the gravitational field event
  55706. */
  55707. dispose(force?: boolean): void;
  55708. private _tick;
  55709. }
  55710. /**
  55711. * Represents a physics updraft event
  55712. */
  55713. class PhysicsUpdraftEvent {
  55714. private _scene;
  55715. private _origin;
  55716. private _options;
  55717. private _physicsEngine;
  55718. private _originTop;
  55719. private _originDirection;
  55720. private _tickCallback;
  55721. private _cylinder;
  55722. private _cylinderPosition;
  55723. private _dataFetched;
  55724. /**
  55725. * Initializes the physics updraft event
  55726. * @param _scene BabylonJS scene
  55727. * @param _origin The origin position of the updraft
  55728. * @param _options The options for the updraft event
  55729. */
  55730. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55731. /**
  55732. * Returns the data related to the updraft event (cylinder).
  55733. * @returns A physics updraft event
  55734. */
  55735. getData(): PhysicsUpdraftEventData;
  55736. /**
  55737. * Enables the updraft.
  55738. */
  55739. enable(): void;
  55740. /**
  55741. * Disables the updraft.
  55742. */
  55743. disable(): void;
  55744. /**
  55745. * Disposes the cylinder.
  55746. * @param force Specifies if the updraft should be disposed by force
  55747. */
  55748. dispose(force?: boolean): void;
  55749. private getImpostorHitData;
  55750. private _tick;
  55751. /*** Helpers ***/
  55752. private _prepareCylinder;
  55753. private _intersectsWithCylinder;
  55754. }
  55755. /**
  55756. * Represents a physics vortex event
  55757. */
  55758. class PhysicsVortexEvent {
  55759. private _scene;
  55760. private _origin;
  55761. private _options;
  55762. private _physicsEngine;
  55763. private _originTop;
  55764. private _tickCallback;
  55765. private _cylinder;
  55766. private _cylinderPosition;
  55767. private _dataFetched;
  55768. /**
  55769. * Initializes the physics vortex event
  55770. * @param _scene The BabylonJS scene
  55771. * @param _origin The origin position of the vortex
  55772. * @param _options The options for the vortex event
  55773. */
  55774. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55775. /**
  55776. * Returns the data related to the vortex event (cylinder).
  55777. * @returns The physics vortex event data
  55778. */
  55779. getData(): PhysicsVortexEventData;
  55780. /**
  55781. * Enables the vortex.
  55782. */
  55783. enable(): void;
  55784. /**
  55785. * Disables the cortex.
  55786. */
  55787. disable(): void;
  55788. /**
  55789. * Disposes the sphere.
  55790. * @param force
  55791. */
  55792. dispose(force?: boolean): void;
  55793. private getImpostorHitData;
  55794. private _tick;
  55795. /*** Helpers ***/
  55796. private _prepareCylinder;
  55797. private _intersectsWithCylinder;
  55798. }
  55799. /**
  55800. * Options fot the radial explosion event
  55801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55802. */
  55803. export class PhysicsRadialExplosionEventOptions {
  55804. /**
  55805. * The radius of the sphere for the radial explosion.
  55806. */
  55807. radius: number;
  55808. /**
  55809. * The strenth of the explosion.
  55810. */
  55811. strength: number;
  55812. /**
  55813. * The strenght of the force in correspondence to the distance of the affected object
  55814. */
  55815. falloff: PhysicsRadialImpulseFalloff;
  55816. /**
  55817. * Sphere options for the radial explosion.
  55818. */
  55819. sphere: {
  55820. segments: number;
  55821. diameter: number;
  55822. };
  55823. /**
  55824. * Sphere options for the radial explosion.
  55825. */
  55826. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55827. }
  55828. /**
  55829. * Options fot the updraft event
  55830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55831. */
  55832. export class PhysicsUpdraftEventOptions {
  55833. /**
  55834. * The radius of the cylinder for the vortex
  55835. */
  55836. radius: number;
  55837. /**
  55838. * The strenth of the updraft.
  55839. */
  55840. strength: number;
  55841. /**
  55842. * The height of the cylinder for the updraft.
  55843. */
  55844. height: number;
  55845. /**
  55846. * The mode for the the updraft.
  55847. */
  55848. updraftMode: PhysicsUpdraftMode;
  55849. }
  55850. /**
  55851. * Options fot the vortex event
  55852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55853. */
  55854. export class PhysicsVortexEventOptions {
  55855. /**
  55856. * The radius of the cylinder for the vortex
  55857. */
  55858. radius: number;
  55859. /**
  55860. * The strenth of the vortex.
  55861. */
  55862. strength: number;
  55863. /**
  55864. * The height of the cylinder for the vortex.
  55865. */
  55866. height: number;
  55867. /**
  55868. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55869. */
  55870. centripetalForceThreshold: number;
  55871. /**
  55872. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55873. */
  55874. centripetalForceMultiplier: number;
  55875. /**
  55876. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55877. */
  55878. centrifugalForceMultiplier: number;
  55879. /**
  55880. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55881. */
  55882. updraftForceMultiplier: number;
  55883. }
  55884. /**
  55885. * The strenght of the force in correspondence to the distance of the affected object
  55886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55887. */
  55888. export enum PhysicsRadialImpulseFalloff {
  55889. /** Defines that impulse is constant in strength across it's whole radius */
  55890. Constant = 0,
  55891. /** Defines that impulse gets weaker if it's further from the origin */
  55892. Linear = 1
  55893. }
  55894. /**
  55895. * The strength of the force in correspondence to the distance of the affected object
  55896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55897. */
  55898. export enum PhysicsUpdraftMode {
  55899. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55900. Center = 0,
  55901. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55902. Perpendicular = 1
  55903. }
  55904. /**
  55905. * Interface for a physics hit data
  55906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55907. */
  55908. export interface PhysicsHitData {
  55909. /**
  55910. * The force applied at the contact point
  55911. */
  55912. force: Vector3;
  55913. /**
  55914. * The contact point
  55915. */
  55916. contactPoint: Vector3;
  55917. /**
  55918. * The distance from the origin to the contact point
  55919. */
  55920. distanceFromOrigin: number;
  55921. }
  55922. /**
  55923. * Interface for radial explosion event data
  55924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55925. */
  55926. export interface PhysicsRadialExplosionEventData {
  55927. /**
  55928. * A sphere used for the radial explosion event
  55929. */
  55930. sphere: Mesh;
  55931. }
  55932. /**
  55933. * Interface for gravitational field event data
  55934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55935. */
  55936. export interface PhysicsGravitationalFieldEventData {
  55937. /**
  55938. * A sphere mesh used for the gravitational field event
  55939. */
  55940. sphere: Mesh;
  55941. }
  55942. /**
  55943. * Interface for updraft event data
  55944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55945. */
  55946. export interface PhysicsUpdraftEventData {
  55947. /**
  55948. * A cylinder used for the updraft event
  55949. */
  55950. cylinder: Mesh;
  55951. }
  55952. /**
  55953. * Interface for vortex event data
  55954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55955. */
  55956. export interface PhysicsVortexEventData {
  55957. /**
  55958. * A cylinder used for the vortex event
  55959. */
  55960. cylinder: Mesh;
  55961. }
  55962. /**
  55963. * Interface for an affected physics impostor
  55964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55965. */
  55966. export interface PhysicsAffectedImpostorWithData {
  55967. /**
  55968. * The impostor affected by the effect
  55969. */
  55970. impostor: PhysicsImpostor;
  55971. /**
  55972. * The data about the hit/horce from the explosion
  55973. */
  55974. hitData: PhysicsHitData;
  55975. }
  55976. }
  55977. declare module BABYLON {
  55978. /** @hidden */
  55979. export var blackAndWhitePixelShader: {
  55980. name: string;
  55981. shader: string;
  55982. };
  55983. }
  55984. declare module BABYLON {
  55985. /**
  55986. * Post process used to render in black and white
  55987. */
  55988. export class BlackAndWhitePostProcess extends PostProcess {
  55989. /**
  55990. * Linear about to convert he result to black and white (default: 1)
  55991. */
  55992. degree: number;
  55993. /**
  55994. * Creates a black and white post process
  55995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55996. * @param name The name of the effect.
  55997. * @param options The required width/height ratio to downsize to before computing the render pass.
  55998. * @param camera The camera to apply the render pass to.
  55999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56000. * @param engine The engine which the post process will be applied. (default: current engine)
  56001. * @param reusable If the post process can be reused on the same frame. (default: false)
  56002. */
  56003. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56004. }
  56005. }
  56006. declare module BABYLON {
  56007. /**
  56008. * This represents a set of one or more post processes in Babylon.
  56009. * A post process can be used to apply a shader to a texture after it is rendered.
  56010. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56011. */
  56012. export class PostProcessRenderEffect {
  56013. private _postProcesses;
  56014. private _getPostProcesses;
  56015. private _singleInstance;
  56016. private _cameras;
  56017. private _indicesForCamera;
  56018. /**
  56019. * Name of the effect
  56020. * @hidden
  56021. */
  56022. _name: string;
  56023. /**
  56024. * Instantiates a post process render effect.
  56025. * A post process can be used to apply a shader to a texture after it is rendered.
  56026. * @param engine The engine the effect is tied to
  56027. * @param name The name of the effect
  56028. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56029. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56030. */
  56031. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56032. /**
  56033. * Checks if all the post processes in the effect are supported.
  56034. */
  56035. readonly isSupported: boolean;
  56036. /**
  56037. * Updates the current state of the effect
  56038. * @hidden
  56039. */
  56040. _update(): void;
  56041. /**
  56042. * Attaches the effect on cameras
  56043. * @param cameras The camera to attach to.
  56044. * @hidden
  56045. */
  56046. _attachCameras(cameras: Camera): void;
  56047. /**
  56048. * Attaches the effect on cameras
  56049. * @param cameras The camera to attach to.
  56050. * @hidden
  56051. */
  56052. _attachCameras(cameras: Camera[]): void;
  56053. /**
  56054. * Detaches the effect on cameras
  56055. * @param cameras The camera to detatch from.
  56056. * @hidden
  56057. */
  56058. _detachCameras(cameras: Camera): void;
  56059. /**
  56060. * Detatches the effect on cameras
  56061. * @param cameras The camera to detatch from.
  56062. * @hidden
  56063. */
  56064. _detachCameras(cameras: Camera[]): void;
  56065. /**
  56066. * Enables the effect on given cameras
  56067. * @param cameras The camera to enable.
  56068. * @hidden
  56069. */
  56070. _enable(cameras: Camera): void;
  56071. /**
  56072. * Enables the effect on given cameras
  56073. * @param cameras The camera to enable.
  56074. * @hidden
  56075. */
  56076. _enable(cameras: Nullable<Camera[]>): void;
  56077. /**
  56078. * Disables the effect on the given cameras
  56079. * @param cameras The camera to disable.
  56080. * @hidden
  56081. */
  56082. _disable(cameras: Camera): void;
  56083. /**
  56084. * Disables the effect on the given cameras
  56085. * @param cameras The camera to disable.
  56086. * @hidden
  56087. */
  56088. _disable(cameras: Nullable<Camera[]>): void;
  56089. /**
  56090. * Gets a list of the post processes contained in the effect.
  56091. * @param camera The camera to get the post processes on.
  56092. * @returns The list of the post processes in the effect.
  56093. */
  56094. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56095. }
  56096. }
  56097. declare module BABYLON {
  56098. /** @hidden */
  56099. export var extractHighlightsPixelShader: {
  56100. name: string;
  56101. shader: string;
  56102. };
  56103. }
  56104. declare module BABYLON {
  56105. /**
  56106. * 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.
  56107. */
  56108. export class ExtractHighlightsPostProcess extends PostProcess {
  56109. /**
  56110. * The luminance threshold, pixels below this value will be set to black.
  56111. */
  56112. threshold: number;
  56113. /** @hidden */
  56114. _exposure: number;
  56115. /**
  56116. * Post process which has the input texture to be used when performing highlight extraction
  56117. * @hidden
  56118. */
  56119. _inputPostProcess: Nullable<PostProcess>;
  56120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56121. }
  56122. }
  56123. declare module BABYLON {
  56124. /** @hidden */
  56125. export var bloomMergePixelShader: {
  56126. name: string;
  56127. shader: string;
  56128. };
  56129. }
  56130. declare module BABYLON {
  56131. /**
  56132. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56133. */
  56134. export class BloomMergePostProcess extends PostProcess {
  56135. /** Weight of the bloom to be added to the original input. */
  56136. weight: number;
  56137. /**
  56138. * Creates a new instance of @see BloomMergePostProcess
  56139. * @param name The name of the effect.
  56140. * @param originalFromInput Post process which's input will be used for the merge.
  56141. * @param blurred Blurred highlights post process which's output will be used.
  56142. * @param weight Weight of the bloom to be added to the original input.
  56143. * @param options The required width/height ratio to downsize to before computing the render pass.
  56144. * @param camera The camera to apply the render pass to.
  56145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56146. * @param engine The engine which the post process will be applied. (default: current engine)
  56147. * @param reusable If the post process can be reused on the same frame. (default: false)
  56148. * @param textureType Type of textures used when performing the post process. (default: 0)
  56149. * @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)
  56150. */
  56151. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56152. /** Weight of the bloom to be added to the original input. */
  56153. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56154. }
  56155. }
  56156. declare module BABYLON {
  56157. /**
  56158. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56159. */
  56160. export class BloomEffect extends PostProcessRenderEffect {
  56161. private bloomScale;
  56162. /**
  56163. * @hidden Internal
  56164. */
  56165. _effects: Array<PostProcess>;
  56166. /**
  56167. * @hidden Internal
  56168. */
  56169. _downscale: ExtractHighlightsPostProcess;
  56170. private _blurX;
  56171. private _blurY;
  56172. private _merge;
  56173. /**
  56174. * The luminance threshold to find bright areas of the image to bloom.
  56175. */
  56176. threshold: number;
  56177. /**
  56178. * The strength of the bloom.
  56179. */
  56180. weight: number;
  56181. /**
  56182. * Specifies the size of the bloom blur kernel, relative to the final output size
  56183. */
  56184. kernel: number;
  56185. /**
  56186. * Creates a new instance of @see BloomEffect
  56187. * @param scene The scene the effect belongs to.
  56188. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56189. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56190. * @param bloomWeight The the strength of bloom.
  56191. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56192. * @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)
  56193. */
  56194. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56195. /**
  56196. * Disposes each of the internal effects for a given camera.
  56197. * @param camera The camera to dispose the effect on.
  56198. */
  56199. disposeEffects(camera: Camera): void;
  56200. /**
  56201. * @hidden Internal
  56202. */
  56203. _updateEffects(): void;
  56204. /**
  56205. * Internal
  56206. * @returns if all the contained post processes are ready.
  56207. * @hidden
  56208. */
  56209. _isReady(): boolean;
  56210. }
  56211. }
  56212. declare module BABYLON {
  56213. /** @hidden */
  56214. export var chromaticAberrationPixelShader: {
  56215. name: string;
  56216. shader: string;
  56217. };
  56218. }
  56219. declare module BABYLON {
  56220. /**
  56221. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56222. */
  56223. export class ChromaticAberrationPostProcess extends PostProcess {
  56224. /**
  56225. * The amount of seperation of rgb channels (default: 30)
  56226. */
  56227. aberrationAmount: number;
  56228. /**
  56229. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56230. */
  56231. radialIntensity: number;
  56232. /**
  56233. * 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))
  56234. */
  56235. direction: Vector2;
  56236. /**
  56237. * 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))
  56238. */
  56239. centerPosition: Vector2;
  56240. /**
  56241. * Creates a new instance ChromaticAberrationPostProcess
  56242. * @param name The name of the effect.
  56243. * @param screenWidth The width of the screen to apply the effect on.
  56244. * @param screenHeight The height of the screen to apply the effect on.
  56245. * @param options The required width/height ratio to downsize to before computing the render pass.
  56246. * @param camera The camera to apply the render pass to.
  56247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56248. * @param engine The engine which the post process will be applied. (default: current engine)
  56249. * @param reusable If the post process can be reused on the same frame. (default: false)
  56250. * @param textureType Type of textures used when performing the post process. (default: 0)
  56251. * @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)
  56252. */
  56253. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56254. }
  56255. }
  56256. declare module BABYLON {
  56257. /** @hidden */
  56258. export var circleOfConfusionPixelShader: {
  56259. name: string;
  56260. shader: string;
  56261. };
  56262. }
  56263. declare module BABYLON {
  56264. /**
  56265. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56266. */
  56267. export class CircleOfConfusionPostProcess extends PostProcess {
  56268. /**
  56269. * 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.
  56270. */
  56271. lensSize: number;
  56272. /**
  56273. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56274. */
  56275. fStop: number;
  56276. /**
  56277. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56278. */
  56279. focusDistance: number;
  56280. /**
  56281. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56282. */
  56283. focalLength: number;
  56284. private _depthTexture;
  56285. /**
  56286. * Creates a new instance CircleOfConfusionPostProcess
  56287. * @param name The name of the effect.
  56288. * @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.
  56289. * @param options The required width/height ratio to downsize to before computing the render pass.
  56290. * @param camera The camera to apply the render pass to.
  56291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56292. * @param engine The engine which the post process will be applied. (default: current engine)
  56293. * @param reusable If the post process can be reused on the same frame. (default: false)
  56294. * @param textureType Type of textures used when performing the post process. (default: 0)
  56295. * @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)
  56296. */
  56297. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56298. /**
  56299. * 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.
  56300. */
  56301. depthTexture: RenderTargetTexture;
  56302. }
  56303. }
  56304. declare module BABYLON {
  56305. /** @hidden */
  56306. export var colorCorrectionPixelShader: {
  56307. name: string;
  56308. shader: string;
  56309. };
  56310. }
  56311. declare module BABYLON {
  56312. /**
  56313. *
  56314. * This post-process allows the modification of rendered colors by using
  56315. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56316. *
  56317. * The object needs to be provided an url to a texture containing the color
  56318. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56319. * Use an image editing software to tweak the LUT to match your needs.
  56320. *
  56321. * For an example of a color LUT, see here:
  56322. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56323. * For explanations on color grading, see here:
  56324. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56325. *
  56326. */
  56327. export class ColorCorrectionPostProcess extends PostProcess {
  56328. private _colorTableTexture;
  56329. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56330. }
  56331. }
  56332. declare module BABYLON {
  56333. /** @hidden */
  56334. export var convolutionPixelShader: {
  56335. name: string;
  56336. shader: string;
  56337. };
  56338. }
  56339. declare module BABYLON {
  56340. /**
  56341. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56342. * input texture to perform effects such as edge detection or sharpening
  56343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56344. */
  56345. export class ConvolutionPostProcess extends PostProcess {
  56346. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56347. kernel: number[];
  56348. /**
  56349. * Creates a new instance ConvolutionPostProcess
  56350. * @param name The name of the effect.
  56351. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56352. * @param options The required width/height ratio to downsize to before computing the render pass.
  56353. * @param camera The camera to apply the render pass to.
  56354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56355. * @param engine The engine which the post process will be applied. (default: current engine)
  56356. * @param reusable If the post process can be reused on the same frame. (default: false)
  56357. * @param textureType Type of textures used when performing the post process. (default: 0)
  56358. */
  56359. constructor(name: string,
  56360. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56361. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56362. /**
  56363. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56364. */
  56365. static EdgeDetect0Kernel: number[];
  56366. /**
  56367. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56368. */
  56369. static EdgeDetect1Kernel: number[];
  56370. /**
  56371. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56372. */
  56373. static EdgeDetect2Kernel: number[];
  56374. /**
  56375. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56376. */
  56377. static SharpenKernel: number[];
  56378. /**
  56379. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56380. */
  56381. static EmbossKernel: number[];
  56382. /**
  56383. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56384. */
  56385. static GaussianKernel: number[];
  56386. }
  56387. }
  56388. declare module BABYLON {
  56389. /**
  56390. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56391. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56392. * based on samples that have a large difference in distance than the center pixel.
  56393. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56394. */
  56395. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56396. direction: Vector2;
  56397. /**
  56398. * Creates a new instance CircleOfConfusionPostProcess
  56399. * @param name The name of the effect.
  56400. * @param scene The scene the effect belongs to.
  56401. * @param direction The direction the blur should be applied.
  56402. * @param kernel The size of the kernel used to blur.
  56403. * @param options The required width/height ratio to downsize to before computing the render pass.
  56404. * @param camera The camera to apply the render pass to.
  56405. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56406. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56408. * @param engine The engine which the post process will be applied. (default: current engine)
  56409. * @param reusable If the post process can be reused on the same frame. (default: false)
  56410. * @param textureType Type of textures used when performing the post process. (default: 0)
  56411. * @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)
  56412. */
  56413. 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);
  56414. }
  56415. }
  56416. declare module BABYLON {
  56417. /** @hidden */
  56418. export var depthOfFieldMergePixelShader: {
  56419. name: string;
  56420. shader: string;
  56421. };
  56422. }
  56423. declare module BABYLON {
  56424. /**
  56425. * Options to be set when merging outputs from the default pipeline.
  56426. */
  56427. export class DepthOfFieldMergePostProcessOptions {
  56428. /**
  56429. * The original image to merge on top of
  56430. */
  56431. originalFromInput: PostProcess;
  56432. /**
  56433. * Parameters to perform the merge of the depth of field effect
  56434. */
  56435. depthOfField?: {
  56436. circleOfConfusion: PostProcess;
  56437. blurSteps: Array<PostProcess>;
  56438. };
  56439. /**
  56440. * Parameters to perform the merge of bloom effect
  56441. */
  56442. bloom?: {
  56443. blurred: PostProcess;
  56444. weight: number;
  56445. };
  56446. }
  56447. /**
  56448. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56449. */
  56450. export class DepthOfFieldMergePostProcess extends PostProcess {
  56451. private blurSteps;
  56452. /**
  56453. * Creates a new instance of DepthOfFieldMergePostProcess
  56454. * @param name The name of the effect.
  56455. * @param originalFromInput Post process which's input will be used for the merge.
  56456. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56457. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56458. * @param options The required width/height ratio to downsize to before computing the render pass.
  56459. * @param camera The camera to apply the render pass to.
  56460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56461. * @param engine The engine which the post process will be applied. (default: current engine)
  56462. * @param reusable If the post process can be reused on the same frame. (default: false)
  56463. * @param textureType Type of textures used when performing the post process. (default: 0)
  56464. * @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)
  56465. */
  56466. 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);
  56467. /**
  56468. * Updates the effect with the current post process compile time values and recompiles the shader.
  56469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56472. * @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
  56473. * @param onCompiled Called when the shader has been compiled.
  56474. * @param onError Called if there is an error when compiling a shader.
  56475. */
  56476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56477. }
  56478. }
  56479. declare module BABYLON {
  56480. /**
  56481. * Specifies the level of max blur that should be applied when using the depth of field effect
  56482. */
  56483. export enum DepthOfFieldEffectBlurLevel {
  56484. /**
  56485. * Subtle blur
  56486. */
  56487. Low = 0,
  56488. /**
  56489. * Medium blur
  56490. */
  56491. Medium = 1,
  56492. /**
  56493. * Large blur
  56494. */
  56495. High = 2
  56496. }
  56497. /**
  56498. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56499. */
  56500. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56501. private _circleOfConfusion;
  56502. /**
  56503. * @hidden Internal, blurs from high to low
  56504. */
  56505. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56506. private _depthOfFieldBlurY;
  56507. private _dofMerge;
  56508. /**
  56509. * @hidden Internal post processes in depth of field effect
  56510. */
  56511. _effects: Array<PostProcess>;
  56512. /**
  56513. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56514. */
  56515. focalLength: number;
  56516. /**
  56517. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56518. */
  56519. fStop: number;
  56520. /**
  56521. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56522. */
  56523. focusDistance: number;
  56524. /**
  56525. * 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.
  56526. */
  56527. lensSize: number;
  56528. /**
  56529. * Creates a new instance DepthOfFieldEffect
  56530. * @param scene The scene the effect belongs to.
  56531. * @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.
  56532. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56533. * @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)
  56534. */
  56535. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56536. /**
  56537. * Get the current class name of the current effet
  56538. * @returns "DepthOfFieldEffect"
  56539. */
  56540. getClassName(): string;
  56541. /**
  56542. * 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.
  56543. */
  56544. depthTexture: RenderTargetTexture;
  56545. /**
  56546. * Disposes each of the internal effects for a given camera.
  56547. * @param camera The camera to dispose the effect on.
  56548. */
  56549. disposeEffects(camera: Camera): void;
  56550. /**
  56551. * @hidden Internal
  56552. */
  56553. _updateEffects(): void;
  56554. /**
  56555. * Internal
  56556. * @returns if all the contained post processes are ready.
  56557. * @hidden
  56558. */
  56559. _isReady(): boolean;
  56560. }
  56561. }
  56562. declare module BABYLON {
  56563. /** @hidden */
  56564. export var displayPassPixelShader: {
  56565. name: string;
  56566. shader: string;
  56567. };
  56568. }
  56569. declare module BABYLON {
  56570. /**
  56571. * DisplayPassPostProcess which produces an output the same as it's input
  56572. */
  56573. export class DisplayPassPostProcess extends PostProcess {
  56574. /**
  56575. * Creates the DisplayPassPostProcess
  56576. * @param name The name of the effect.
  56577. * @param options The required width/height ratio to downsize to before computing the render pass.
  56578. * @param camera The camera to apply the render pass to.
  56579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56580. * @param engine The engine which the post process will be applied. (default: current engine)
  56581. * @param reusable If the post process can be reused on the same frame. (default: false)
  56582. */
  56583. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /** @hidden */
  56588. export var filterPixelShader: {
  56589. name: string;
  56590. shader: string;
  56591. };
  56592. }
  56593. declare module BABYLON {
  56594. /**
  56595. * Applies a kernel filter to the image
  56596. */
  56597. export class FilterPostProcess extends PostProcess {
  56598. /** The matrix to be applied to the image */
  56599. kernelMatrix: Matrix;
  56600. /**
  56601. *
  56602. * @param name The name of the effect.
  56603. * @param kernelMatrix The matrix to be applied to the image
  56604. * @param options The required width/height ratio to downsize to before computing the render pass.
  56605. * @param camera The camera to apply the render pass to.
  56606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56607. * @param engine The engine which the post process will be applied. (default: current engine)
  56608. * @param reusable If the post process can be reused on the same frame. (default: false)
  56609. */
  56610. constructor(name: string,
  56611. /** The matrix to be applied to the image */
  56612. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /** @hidden */
  56617. export var fxaaPixelShader: {
  56618. name: string;
  56619. shader: string;
  56620. };
  56621. }
  56622. declare module BABYLON {
  56623. /** @hidden */
  56624. export var fxaaVertexShader: {
  56625. name: string;
  56626. shader: string;
  56627. };
  56628. }
  56629. declare module BABYLON {
  56630. /**
  56631. * Fxaa post process
  56632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56633. */
  56634. export class FxaaPostProcess extends PostProcess {
  56635. /** @hidden */
  56636. texelWidth: number;
  56637. /** @hidden */
  56638. texelHeight: number;
  56639. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56640. private _getDefines;
  56641. }
  56642. }
  56643. declare module BABYLON {
  56644. /** @hidden */
  56645. export var grainPixelShader: {
  56646. name: string;
  56647. shader: string;
  56648. };
  56649. }
  56650. declare module BABYLON {
  56651. /**
  56652. * The GrainPostProcess adds noise to the image at mid luminance levels
  56653. */
  56654. export class GrainPostProcess extends PostProcess {
  56655. /**
  56656. * The intensity of the grain added (default: 30)
  56657. */
  56658. intensity: number;
  56659. /**
  56660. * If the grain should be randomized on every frame
  56661. */
  56662. animated: boolean;
  56663. /**
  56664. * Creates a new instance of @see GrainPostProcess
  56665. * @param name The name of the effect.
  56666. * @param options The required width/height ratio to downsize to before computing the render pass.
  56667. * @param camera The camera to apply the render pass to.
  56668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56669. * @param engine The engine which the post process will be applied. (default: current engine)
  56670. * @param reusable If the post process can be reused on the same frame. (default: false)
  56671. * @param textureType Type of textures used when performing the post process. (default: 0)
  56672. * @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)
  56673. */
  56674. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56675. }
  56676. }
  56677. declare module BABYLON {
  56678. /** @hidden */
  56679. export var highlightsPixelShader: {
  56680. name: string;
  56681. shader: string;
  56682. };
  56683. }
  56684. declare module BABYLON {
  56685. /**
  56686. * Extracts highlights from the image
  56687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56688. */
  56689. export class HighlightsPostProcess extends PostProcess {
  56690. /**
  56691. * Extracts highlights from the image
  56692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56693. * @param name The name of the effect.
  56694. * @param options The required width/height ratio to downsize to before computing the render pass.
  56695. * @param camera The camera to apply the render pass to.
  56696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56697. * @param engine The engine which the post process will be applied. (default: current engine)
  56698. * @param reusable If the post process can be reused on the same frame. (default: false)
  56699. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56700. */
  56701. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56702. }
  56703. }
  56704. declare module BABYLON {
  56705. /** @hidden */
  56706. export var mrtFragmentDeclaration: {
  56707. name: string;
  56708. shader: string;
  56709. };
  56710. }
  56711. declare module BABYLON {
  56712. /** @hidden */
  56713. export var geometryPixelShader: {
  56714. name: string;
  56715. shader: string;
  56716. };
  56717. }
  56718. declare module BABYLON {
  56719. /** @hidden */
  56720. export var geometryVertexShader: {
  56721. name: string;
  56722. shader: string;
  56723. };
  56724. }
  56725. declare module BABYLON {
  56726. /** @hidden */
  56727. interface ISavedTransformationMatrix {
  56728. world: Matrix;
  56729. viewProjection: Matrix;
  56730. }
  56731. /**
  56732. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56733. */
  56734. export class GeometryBufferRenderer {
  56735. /**
  56736. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56737. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56738. */
  56739. static readonly POSITION_TEXTURE_TYPE: number;
  56740. /**
  56741. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56742. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56743. */
  56744. static readonly VELOCITY_TEXTURE_TYPE: number;
  56745. /**
  56746. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56747. * in order to compute objects velocities when enableVelocity is set to "true"
  56748. * @hidden
  56749. */
  56750. _previousTransformationMatrices: {
  56751. [index: number]: ISavedTransformationMatrix;
  56752. };
  56753. /**
  56754. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56755. * in order to compute objects velocities when enableVelocity is set to "true"
  56756. * @hidden
  56757. */
  56758. _previousBonesTransformationMatrices: {
  56759. [index: number]: Float32Array;
  56760. };
  56761. /**
  56762. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56763. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56764. */
  56765. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56766. private _scene;
  56767. private _multiRenderTarget;
  56768. private _ratio;
  56769. private _enablePosition;
  56770. private _enableVelocity;
  56771. private _positionIndex;
  56772. private _velocityIndex;
  56773. protected _effect: Effect;
  56774. protected _cachedDefines: string;
  56775. /**
  56776. * Set the render list (meshes to be rendered) used in the G buffer.
  56777. */
  56778. renderList: Mesh[];
  56779. /**
  56780. * Gets wether or not G buffer are supported by the running hardware.
  56781. * This requires draw buffer supports
  56782. */
  56783. readonly isSupported: boolean;
  56784. /**
  56785. * Returns the index of the given texture type in the G-Buffer textures array
  56786. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56787. * @returns the index of the given texture type in the G-Buffer textures array
  56788. */
  56789. getTextureIndex(textureType: number): number;
  56790. /**
  56791. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56792. */
  56793. /**
  56794. * Sets whether or not objects positions are enabled for the G buffer.
  56795. */
  56796. enablePosition: boolean;
  56797. /**
  56798. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56799. */
  56800. /**
  56801. * Sets wether or not objects velocities are enabled for the G buffer.
  56802. */
  56803. enableVelocity: boolean;
  56804. /**
  56805. * Gets the scene associated with the buffer.
  56806. */
  56807. readonly scene: Scene;
  56808. /**
  56809. * Gets the ratio used by the buffer during its creation.
  56810. * How big is the buffer related to the main canvas.
  56811. */
  56812. readonly ratio: number;
  56813. /** @hidden */
  56814. static _SceneComponentInitialization: (scene: Scene) => void;
  56815. /**
  56816. * Creates a new G Buffer for the scene
  56817. * @param scene The scene the buffer belongs to
  56818. * @param ratio How big is the buffer related to the main canvas.
  56819. */
  56820. constructor(scene: Scene, ratio?: number);
  56821. /**
  56822. * Checks wether everything is ready to render a submesh to the G buffer.
  56823. * @param subMesh the submesh to check readiness for
  56824. * @param useInstances is the mesh drawn using instance or not
  56825. * @returns true if ready otherwise false
  56826. */
  56827. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56828. /**
  56829. * Gets the current underlying G Buffer.
  56830. * @returns the buffer
  56831. */
  56832. getGBuffer(): MultiRenderTarget;
  56833. /**
  56834. * Gets the number of samples used to render the buffer (anti aliasing).
  56835. */
  56836. /**
  56837. * Sets the number of samples used to render the buffer (anti aliasing).
  56838. */
  56839. samples: number;
  56840. /**
  56841. * Disposes the renderer and frees up associated resources.
  56842. */
  56843. dispose(): void;
  56844. protected _createRenderTargets(): void;
  56845. private _copyBonesTransformationMatrices;
  56846. }
  56847. }
  56848. declare module BABYLON {
  56849. interface Scene {
  56850. /** @hidden (Backing field) */
  56851. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56852. /**
  56853. * Gets or Sets the current geometry buffer associated to the scene.
  56854. */
  56855. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56856. /**
  56857. * Enables a GeometryBufferRender and associates it with the scene
  56858. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56859. * @returns the GeometryBufferRenderer
  56860. */
  56861. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56862. /**
  56863. * Disables the GeometryBufferRender associated with the scene
  56864. */
  56865. disableGeometryBufferRenderer(): void;
  56866. }
  56867. /**
  56868. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56869. * in several rendering techniques.
  56870. */
  56871. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56872. /**
  56873. * The component name helpful to identify the component in the list of scene components.
  56874. */
  56875. readonly name: string;
  56876. /**
  56877. * The scene the component belongs to.
  56878. */
  56879. scene: Scene;
  56880. /**
  56881. * Creates a new instance of the component for the given scene
  56882. * @param scene Defines the scene to register the component in
  56883. */
  56884. constructor(scene: Scene);
  56885. /**
  56886. * Registers the component in a given scene
  56887. */
  56888. register(): void;
  56889. /**
  56890. * Rebuilds the elements related to this component in case of
  56891. * context lost for instance.
  56892. */
  56893. rebuild(): void;
  56894. /**
  56895. * Disposes the component and the associated ressources
  56896. */
  56897. dispose(): void;
  56898. private _gatherRenderTargets;
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /** @hidden */
  56903. export var motionBlurPixelShader: {
  56904. name: string;
  56905. shader: string;
  56906. };
  56907. }
  56908. declare module BABYLON {
  56909. /**
  56910. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56911. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56912. * As an example, all you have to do is to create the post-process:
  56913. * var mb = new BABYLON.MotionBlurPostProcess(
  56914. * 'mb', // The name of the effect.
  56915. * scene, // The scene containing the objects to blur according to their velocity.
  56916. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56917. * camera // The camera to apply the render pass to.
  56918. * );
  56919. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56920. */
  56921. export class MotionBlurPostProcess extends PostProcess {
  56922. /**
  56923. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56924. */
  56925. motionStrength: number;
  56926. /**
  56927. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56928. */
  56929. /**
  56930. * Sets the number of iterations to be used for motion blur quality
  56931. */
  56932. motionBlurSamples: number;
  56933. private _motionBlurSamples;
  56934. private _geometryBufferRenderer;
  56935. /**
  56936. * Creates a new instance MotionBlurPostProcess
  56937. * @param name The name of the effect.
  56938. * @param scene The scene containing the objects to blur according to their velocity.
  56939. * @param options The required width/height ratio to downsize to before computing the render pass.
  56940. * @param camera The camera to apply the render pass to.
  56941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56942. * @param engine The engine which the post process will be applied. (default: current engine)
  56943. * @param reusable If the post process can be reused on the same frame. (default: false)
  56944. * @param textureType Type of textures used when performing the post process. (default: 0)
  56945. * @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)
  56946. */
  56947. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56948. /**
  56949. * Excludes the given skinned mesh from computing bones velocities.
  56950. * 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.
  56951. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56952. */
  56953. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56954. /**
  56955. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56956. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56957. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56958. */
  56959. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56960. /**
  56961. * Disposes the post process.
  56962. * @param camera The camera to dispose the post process on.
  56963. */
  56964. dispose(camera?: Camera): void;
  56965. }
  56966. }
  56967. declare module BABYLON {
  56968. /** @hidden */
  56969. export var refractionPixelShader: {
  56970. name: string;
  56971. shader: string;
  56972. };
  56973. }
  56974. declare module BABYLON {
  56975. /**
  56976. * Post process which applies a refractin texture
  56977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56978. */
  56979. export class RefractionPostProcess extends PostProcess {
  56980. /** the base color of the refraction (used to taint the rendering) */
  56981. color: Color3;
  56982. /** simulated refraction depth */
  56983. depth: number;
  56984. /** the coefficient of the base color (0 to remove base color tainting) */
  56985. colorLevel: number;
  56986. private _refTexture;
  56987. private _ownRefractionTexture;
  56988. /**
  56989. * Gets or sets the refraction texture
  56990. * Please note that you are responsible for disposing the texture if you set it manually
  56991. */
  56992. refractionTexture: Texture;
  56993. /**
  56994. * Initializes the RefractionPostProcess
  56995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56996. * @param name The name of the effect.
  56997. * @param refractionTextureUrl Url of the refraction texture to use
  56998. * @param color the base color of the refraction (used to taint the rendering)
  56999. * @param depth simulated refraction depth
  57000. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57001. * @param camera The camera to apply the render pass to.
  57002. * @param options The required width/height ratio to downsize to before computing the render pass.
  57003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57004. * @param engine The engine which the post process will be applied. (default: current engine)
  57005. * @param reusable If the post process can be reused on the same frame. (default: false)
  57006. */
  57007. constructor(name: string, refractionTextureUrl: string,
  57008. /** the base color of the refraction (used to taint the rendering) */
  57009. color: Color3,
  57010. /** simulated refraction depth */
  57011. depth: number,
  57012. /** the coefficient of the base color (0 to remove base color tainting) */
  57013. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57014. /**
  57015. * Disposes of the post process
  57016. * @param camera Camera to dispose post process on
  57017. */
  57018. dispose(camera: Camera): void;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /** @hidden */
  57023. export var sharpenPixelShader: {
  57024. name: string;
  57025. shader: string;
  57026. };
  57027. }
  57028. declare module BABYLON {
  57029. /**
  57030. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57031. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57032. */
  57033. export class SharpenPostProcess extends PostProcess {
  57034. /**
  57035. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57036. */
  57037. colorAmount: number;
  57038. /**
  57039. * How much sharpness should be applied (default: 0.3)
  57040. */
  57041. edgeAmount: number;
  57042. /**
  57043. * Creates a new instance ConvolutionPostProcess
  57044. * @param name The name of the effect.
  57045. * @param options The required width/height ratio to downsize to before computing the render pass.
  57046. * @param camera The camera to apply the render pass to.
  57047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57048. * @param engine The engine which the post process will be applied. (default: current engine)
  57049. * @param reusable If the post process can be reused on the same frame. (default: false)
  57050. * @param textureType Type of textures used when performing the post process. (default: 0)
  57051. * @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)
  57052. */
  57053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57054. }
  57055. }
  57056. declare module BABYLON {
  57057. /**
  57058. * PostProcessRenderPipeline
  57059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57060. */
  57061. export class PostProcessRenderPipeline {
  57062. private engine;
  57063. private _renderEffects;
  57064. private _renderEffectsForIsolatedPass;
  57065. /**
  57066. * List of inspectable custom properties (used by the Inspector)
  57067. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57068. */
  57069. inspectableCustomProperties: IInspectable[];
  57070. /**
  57071. * @hidden
  57072. */
  57073. protected _cameras: Camera[];
  57074. /** @hidden */
  57075. _name: string;
  57076. /**
  57077. * Gets pipeline name
  57078. */
  57079. readonly name: string;
  57080. /**
  57081. * Initializes a PostProcessRenderPipeline
  57082. * @param engine engine to add the pipeline to
  57083. * @param name name of the pipeline
  57084. */
  57085. constructor(engine: Engine, name: string);
  57086. /**
  57087. * Gets the class name
  57088. * @returns "PostProcessRenderPipeline"
  57089. */
  57090. getClassName(): string;
  57091. /**
  57092. * If all the render effects in the pipeline are supported
  57093. */
  57094. readonly isSupported: boolean;
  57095. /**
  57096. * Adds an effect to the pipeline
  57097. * @param renderEffect the effect to add
  57098. */
  57099. addEffect(renderEffect: PostProcessRenderEffect): void;
  57100. /** @hidden */
  57101. _rebuild(): void;
  57102. /** @hidden */
  57103. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57104. /** @hidden */
  57105. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57106. /** @hidden */
  57107. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57108. /** @hidden */
  57109. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57110. /** @hidden */
  57111. _attachCameras(cameras: Camera, unique: boolean): void;
  57112. /** @hidden */
  57113. _attachCameras(cameras: Camera[], unique: boolean): void;
  57114. /** @hidden */
  57115. _detachCameras(cameras: Camera): void;
  57116. /** @hidden */
  57117. _detachCameras(cameras: Nullable<Camera[]>): void;
  57118. /** @hidden */
  57119. _update(): void;
  57120. /** @hidden */
  57121. _reset(): void;
  57122. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57123. /**
  57124. * Disposes of the pipeline
  57125. */
  57126. dispose(): void;
  57127. }
  57128. }
  57129. declare module BABYLON {
  57130. /**
  57131. * PostProcessRenderPipelineManager class
  57132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57133. */
  57134. export class PostProcessRenderPipelineManager {
  57135. private _renderPipelines;
  57136. /**
  57137. * Initializes a PostProcessRenderPipelineManager
  57138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57139. */
  57140. constructor();
  57141. /**
  57142. * Gets the list of supported render pipelines
  57143. */
  57144. readonly supportedPipelines: PostProcessRenderPipeline[];
  57145. /**
  57146. * Adds a pipeline to the manager
  57147. * @param renderPipeline The pipeline to add
  57148. */
  57149. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57150. /**
  57151. * Attaches a camera to the pipeline
  57152. * @param renderPipelineName The name of the pipeline to attach to
  57153. * @param cameras the camera to attach
  57154. * @param unique if the camera can be attached multiple times to the pipeline
  57155. */
  57156. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57157. /**
  57158. * Detaches a camera from the pipeline
  57159. * @param renderPipelineName The name of the pipeline to detach from
  57160. * @param cameras the camera to detach
  57161. */
  57162. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57163. /**
  57164. * Enables an effect by name on a pipeline
  57165. * @param renderPipelineName the name of the pipeline to enable the effect in
  57166. * @param renderEffectName the name of the effect to enable
  57167. * @param cameras the cameras that the effect should be enabled on
  57168. */
  57169. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57170. /**
  57171. * Disables an effect by name on a pipeline
  57172. * @param renderPipelineName the name of the pipeline to disable the effect in
  57173. * @param renderEffectName the name of the effect to disable
  57174. * @param cameras the cameras that the effect should be disabled on
  57175. */
  57176. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57177. /**
  57178. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57179. */
  57180. update(): void;
  57181. /** @hidden */
  57182. _rebuild(): void;
  57183. /**
  57184. * Disposes of the manager and pipelines
  57185. */
  57186. dispose(): void;
  57187. }
  57188. }
  57189. declare module BABYLON {
  57190. interface Scene {
  57191. /** @hidden (Backing field) */
  57192. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57193. /**
  57194. * Gets the postprocess render pipeline manager
  57195. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57196. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57197. */
  57198. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57199. }
  57200. /**
  57201. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57202. */
  57203. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57204. /**
  57205. * The component name helpfull to identify the component in the list of scene components.
  57206. */
  57207. readonly name: string;
  57208. /**
  57209. * The scene the component belongs to.
  57210. */
  57211. scene: Scene;
  57212. /**
  57213. * Creates a new instance of the component for the given scene
  57214. * @param scene Defines the scene to register the component in
  57215. */
  57216. constructor(scene: Scene);
  57217. /**
  57218. * Registers the component in a given scene
  57219. */
  57220. register(): void;
  57221. /**
  57222. * Rebuilds the elements related to this component in case of
  57223. * context lost for instance.
  57224. */
  57225. rebuild(): void;
  57226. /**
  57227. * Disposes the component and the associated ressources
  57228. */
  57229. dispose(): void;
  57230. private _gatherRenderTargets;
  57231. }
  57232. }
  57233. declare module BABYLON {
  57234. /**
  57235. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57236. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57237. */
  57238. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57239. private _scene;
  57240. private _camerasToBeAttached;
  57241. /**
  57242. * ID of the sharpen post process,
  57243. */
  57244. private readonly SharpenPostProcessId;
  57245. /**
  57246. * @ignore
  57247. * ID of the image processing post process;
  57248. */
  57249. readonly ImageProcessingPostProcessId: string;
  57250. /**
  57251. * @ignore
  57252. * ID of the Fast Approximate Anti-Aliasing post process;
  57253. */
  57254. readonly FxaaPostProcessId: string;
  57255. /**
  57256. * ID of the chromatic aberration post process,
  57257. */
  57258. private readonly ChromaticAberrationPostProcessId;
  57259. /**
  57260. * ID of the grain post process
  57261. */
  57262. private readonly GrainPostProcessId;
  57263. /**
  57264. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57265. */
  57266. sharpen: SharpenPostProcess;
  57267. private _sharpenEffect;
  57268. private bloom;
  57269. /**
  57270. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57271. */
  57272. depthOfField: DepthOfFieldEffect;
  57273. /**
  57274. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57275. */
  57276. fxaa: FxaaPostProcess;
  57277. /**
  57278. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57279. */
  57280. imageProcessing: ImageProcessingPostProcess;
  57281. /**
  57282. * Chromatic aberration post process which will shift rgb colors in the image
  57283. */
  57284. chromaticAberration: ChromaticAberrationPostProcess;
  57285. private _chromaticAberrationEffect;
  57286. /**
  57287. * Grain post process which add noise to the image
  57288. */
  57289. grain: GrainPostProcess;
  57290. private _grainEffect;
  57291. /**
  57292. * Glow post process which adds a glow to emissive areas of the image
  57293. */
  57294. private _glowLayer;
  57295. /**
  57296. * Animations which can be used to tweak settings over a period of time
  57297. */
  57298. animations: Animation[];
  57299. private _imageProcessingConfigurationObserver;
  57300. private _sharpenEnabled;
  57301. private _bloomEnabled;
  57302. private _depthOfFieldEnabled;
  57303. private _depthOfFieldBlurLevel;
  57304. private _fxaaEnabled;
  57305. private _imageProcessingEnabled;
  57306. private _defaultPipelineTextureType;
  57307. private _bloomScale;
  57308. private _chromaticAberrationEnabled;
  57309. private _grainEnabled;
  57310. private _buildAllowed;
  57311. /**
  57312. * Gets active scene
  57313. */
  57314. readonly scene: Scene;
  57315. /**
  57316. * Enable or disable the sharpen process from the pipeline
  57317. */
  57318. sharpenEnabled: boolean;
  57319. private _resizeObserver;
  57320. private _hardwareScaleLevel;
  57321. private _bloomKernel;
  57322. /**
  57323. * Specifies the size of the bloom blur kernel, relative to the final output size
  57324. */
  57325. bloomKernel: number;
  57326. /**
  57327. * Specifies the weight of the bloom in the final rendering
  57328. */
  57329. private _bloomWeight;
  57330. /**
  57331. * Specifies the luma threshold for the area that will be blurred by the bloom
  57332. */
  57333. private _bloomThreshold;
  57334. private _hdr;
  57335. /**
  57336. * The strength of the bloom.
  57337. */
  57338. bloomWeight: number;
  57339. /**
  57340. * The strength of the bloom.
  57341. */
  57342. bloomThreshold: number;
  57343. /**
  57344. * The scale of the bloom, lower value will provide better performance.
  57345. */
  57346. bloomScale: number;
  57347. /**
  57348. * Enable or disable the bloom from the pipeline
  57349. */
  57350. bloomEnabled: boolean;
  57351. private _rebuildBloom;
  57352. /**
  57353. * If the depth of field is enabled.
  57354. */
  57355. depthOfFieldEnabled: boolean;
  57356. /**
  57357. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57358. */
  57359. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57360. /**
  57361. * If the anti aliasing is enabled.
  57362. */
  57363. fxaaEnabled: boolean;
  57364. private _samples;
  57365. /**
  57366. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57367. */
  57368. samples: number;
  57369. /**
  57370. * If image processing is enabled.
  57371. */
  57372. imageProcessingEnabled: boolean;
  57373. /**
  57374. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57375. */
  57376. glowLayerEnabled: boolean;
  57377. /**
  57378. * Gets the glow layer (or null if not defined)
  57379. */
  57380. readonly glowLayer: Nullable<GlowLayer>;
  57381. /**
  57382. * Enable or disable the chromaticAberration process from the pipeline
  57383. */
  57384. chromaticAberrationEnabled: boolean;
  57385. /**
  57386. * Enable or disable the grain process from the pipeline
  57387. */
  57388. grainEnabled: boolean;
  57389. /**
  57390. * @constructor
  57391. * @param name - The rendering pipeline name (default: "")
  57392. * @param hdr - If high dynamic range textures should be used (default: true)
  57393. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57394. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57395. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57396. */
  57397. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57398. /**
  57399. * Get the class name
  57400. * @returns "DefaultRenderingPipeline"
  57401. */
  57402. getClassName(): string;
  57403. /**
  57404. * Force the compilation of the entire pipeline.
  57405. */
  57406. prepare(): void;
  57407. private _hasCleared;
  57408. private _prevPostProcess;
  57409. private _prevPrevPostProcess;
  57410. private _setAutoClearAndTextureSharing;
  57411. private _depthOfFieldSceneObserver;
  57412. private _buildPipeline;
  57413. private _disposePostProcesses;
  57414. /**
  57415. * Adds a camera to the pipeline
  57416. * @param camera the camera to be added
  57417. */
  57418. addCamera(camera: Camera): void;
  57419. /**
  57420. * Removes a camera from the pipeline
  57421. * @param camera the camera to remove
  57422. */
  57423. removeCamera(camera: Camera): void;
  57424. /**
  57425. * Dispose of the pipeline and stop all post processes
  57426. */
  57427. dispose(): void;
  57428. /**
  57429. * Serialize the rendering pipeline (Used when exporting)
  57430. * @returns the serialized object
  57431. */
  57432. serialize(): any;
  57433. /**
  57434. * Parse the serialized pipeline
  57435. * @param source Source pipeline.
  57436. * @param scene The scene to load the pipeline to.
  57437. * @param rootUrl The URL of the serialized pipeline.
  57438. * @returns An instantiated pipeline from the serialized object.
  57439. */
  57440. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57441. }
  57442. }
  57443. declare module BABYLON {
  57444. /** @hidden */
  57445. export var lensHighlightsPixelShader: {
  57446. name: string;
  57447. shader: string;
  57448. };
  57449. }
  57450. declare module BABYLON {
  57451. /** @hidden */
  57452. export var depthOfFieldPixelShader: {
  57453. name: string;
  57454. shader: string;
  57455. };
  57456. }
  57457. declare module BABYLON {
  57458. /**
  57459. * BABYLON.JS Chromatic Aberration GLSL Shader
  57460. * Author: Olivier Guyot
  57461. * Separates very slightly R, G and B colors on the edges of the screen
  57462. * Inspired by Francois Tarlier & Martins Upitis
  57463. */
  57464. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57465. /**
  57466. * @ignore
  57467. * The chromatic aberration PostProcess id in the pipeline
  57468. */
  57469. LensChromaticAberrationEffect: string;
  57470. /**
  57471. * @ignore
  57472. * The highlights enhancing PostProcess id in the pipeline
  57473. */
  57474. HighlightsEnhancingEffect: string;
  57475. /**
  57476. * @ignore
  57477. * The depth-of-field PostProcess id in the pipeline
  57478. */
  57479. LensDepthOfFieldEffect: string;
  57480. private _scene;
  57481. private _depthTexture;
  57482. private _grainTexture;
  57483. private _chromaticAberrationPostProcess;
  57484. private _highlightsPostProcess;
  57485. private _depthOfFieldPostProcess;
  57486. private _edgeBlur;
  57487. private _grainAmount;
  57488. private _chromaticAberration;
  57489. private _distortion;
  57490. private _highlightsGain;
  57491. private _highlightsThreshold;
  57492. private _dofDistance;
  57493. private _dofAperture;
  57494. private _dofDarken;
  57495. private _dofPentagon;
  57496. private _blurNoise;
  57497. /**
  57498. * @constructor
  57499. *
  57500. * Effect parameters are as follow:
  57501. * {
  57502. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57503. * edge_blur: number; // from 0 to x (1 for realism)
  57504. * distortion: number; // from 0 to x (1 for realism)
  57505. * grain_amount: number; // from 0 to 1
  57506. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57507. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57508. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57509. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57510. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57511. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57512. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57513. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57514. * }
  57515. * Note: if an effect parameter is unset, effect is disabled
  57516. *
  57517. * @param name The rendering pipeline name
  57518. * @param parameters - An object containing all parameters (see above)
  57519. * @param scene The scene linked to this pipeline
  57520. * @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)
  57521. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57522. */
  57523. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57524. /**
  57525. * Get the class name
  57526. * @returns "LensRenderingPipeline"
  57527. */
  57528. getClassName(): string;
  57529. /**
  57530. * Gets associated scene
  57531. */
  57532. readonly scene: Scene;
  57533. /**
  57534. * Gets or sets the edge blur
  57535. */
  57536. edgeBlur: number;
  57537. /**
  57538. * Gets or sets the grain amount
  57539. */
  57540. grainAmount: number;
  57541. /**
  57542. * Gets or sets the chromatic aberration amount
  57543. */
  57544. chromaticAberration: number;
  57545. /**
  57546. * Gets or sets the depth of field aperture
  57547. */
  57548. dofAperture: number;
  57549. /**
  57550. * Gets or sets the edge distortion
  57551. */
  57552. edgeDistortion: number;
  57553. /**
  57554. * Gets or sets the depth of field distortion
  57555. */
  57556. dofDistortion: number;
  57557. /**
  57558. * Gets or sets the darken out of focus amount
  57559. */
  57560. darkenOutOfFocus: number;
  57561. /**
  57562. * Gets or sets a boolean indicating if blur noise is enabled
  57563. */
  57564. blurNoise: boolean;
  57565. /**
  57566. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57567. */
  57568. pentagonBokeh: boolean;
  57569. /**
  57570. * Gets or sets the highlight grain amount
  57571. */
  57572. highlightsGain: number;
  57573. /**
  57574. * Gets or sets the highlight threshold
  57575. */
  57576. highlightsThreshold: number;
  57577. /**
  57578. * Sets the amount of blur at the edges
  57579. * @param amount blur amount
  57580. */
  57581. setEdgeBlur(amount: number): void;
  57582. /**
  57583. * Sets edge blur to 0
  57584. */
  57585. disableEdgeBlur(): void;
  57586. /**
  57587. * Sets the amout of grain
  57588. * @param amount Amount of grain
  57589. */
  57590. setGrainAmount(amount: number): void;
  57591. /**
  57592. * Set grain amount to 0
  57593. */
  57594. disableGrain(): void;
  57595. /**
  57596. * Sets the chromatic aberration amount
  57597. * @param amount amount of chromatic aberration
  57598. */
  57599. setChromaticAberration(amount: number): void;
  57600. /**
  57601. * Sets chromatic aberration amount to 0
  57602. */
  57603. disableChromaticAberration(): void;
  57604. /**
  57605. * Sets the EdgeDistortion amount
  57606. * @param amount amount of EdgeDistortion
  57607. */
  57608. setEdgeDistortion(amount: number): void;
  57609. /**
  57610. * Sets edge distortion to 0
  57611. */
  57612. disableEdgeDistortion(): void;
  57613. /**
  57614. * Sets the FocusDistance amount
  57615. * @param amount amount of FocusDistance
  57616. */
  57617. setFocusDistance(amount: number): void;
  57618. /**
  57619. * Disables depth of field
  57620. */
  57621. disableDepthOfField(): void;
  57622. /**
  57623. * Sets the Aperture amount
  57624. * @param amount amount of Aperture
  57625. */
  57626. setAperture(amount: number): void;
  57627. /**
  57628. * Sets the DarkenOutOfFocus amount
  57629. * @param amount amount of DarkenOutOfFocus
  57630. */
  57631. setDarkenOutOfFocus(amount: number): void;
  57632. private _pentagonBokehIsEnabled;
  57633. /**
  57634. * Creates a pentagon bokeh effect
  57635. */
  57636. enablePentagonBokeh(): void;
  57637. /**
  57638. * Disables the pentagon bokeh effect
  57639. */
  57640. disablePentagonBokeh(): void;
  57641. /**
  57642. * Enables noise blur
  57643. */
  57644. enableNoiseBlur(): void;
  57645. /**
  57646. * Disables noise blur
  57647. */
  57648. disableNoiseBlur(): void;
  57649. /**
  57650. * Sets the HighlightsGain amount
  57651. * @param amount amount of HighlightsGain
  57652. */
  57653. setHighlightsGain(amount: number): void;
  57654. /**
  57655. * Sets the HighlightsThreshold amount
  57656. * @param amount amount of HighlightsThreshold
  57657. */
  57658. setHighlightsThreshold(amount: number): void;
  57659. /**
  57660. * Disables highlights
  57661. */
  57662. disableHighlights(): void;
  57663. /**
  57664. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57665. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57666. */
  57667. dispose(disableDepthRender?: boolean): void;
  57668. private _createChromaticAberrationPostProcess;
  57669. private _createHighlightsPostProcess;
  57670. private _createDepthOfFieldPostProcess;
  57671. private _createGrainTexture;
  57672. }
  57673. }
  57674. declare module BABYLON {
  57675. /** @hidden */
  57676. export var ssao2PixelShader: {
  57677. name: string;
  57678. shader: string;
  57679. };
  57680. }
  57681. declare module BABYLON {
  57682. /** @hidden */
  57683. export var ssaoCombinePixelShader: {
  57684. name: string;
  57685. shader: string;
  57686. };
  57687. }
  57688. declare module BABYLON {
  57689. /**
  57690. * Render pipeline to produce ssao effect
  57691. */
  57692. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57693. /**
  57694. * @ignore
  57695. * The PassPostProcess id in the pipeline that contains the original scene color
  57696. */
  57697. SSAOOriginalSceneColorEffect: string;
  57698. /**
  57699. * @ignore
  57700. * The SSAO PostProcess id in the pipeline
  57701. */
  57702. SSAORenderEffect: string;
  57703. /**
  57704. * @ignore
  57705. * The horizontal blur PostProcess id in the pipeline
  57706. */
  57707. SSAOBlurHRenderEffect: string;
  57708. /**
  57709. * @ignore
  57710. * The vertical blur PostProcess id in the pipeline
  57711. */
  57712. SSAOBlurVRenderEffect: string;
  57713. /**
  57714. * @ignore
  57715. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57716. */
  57717. SSAOCombineRenderEffect: string;
  57718. /**
  57719. * The output strength of the SSAO post-process. Default value is 1.0.
  57720. */
  57721. totalStrength: number;
  57722. /**
  57723. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57724. */
  57725. maxZ: number;
  57726. /**
  57727. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57728. */
  57729. minZAspect: number;
  57730. private _samples;
  57731. /**
  57732. * Number of samples used for the SSAO calculations. Default value is 8
  57733. */
  57734. samples: number;
  57735. private _textureSamples;
  57736. /**
  57737. * Number of samples to use for antialiasing
  57738. */
  57739. textureSamples: number;
  57740. /**
  57741. * Ratio object used for SSAO ratio and blur ratio
  57742. */
  57743. private _ratio;
  57744. /**
  57745. * Dynamically generated sphere sampler.
  57746. */
  57747. private _sampleSphere;
  57748. /**
  57749. * Blur filter offsets
  57750. */
  57751. private _samplerOffsets;
  57752. private _expensiveBlur;
  57753. /**
  57754. * If bilateral blur should be used
  57755. */
  57756. expensiveBlur: boolean;
  57757. /**
  57758. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57759. */
  57760. radius: number;
  57761. /**
  57762. * The base color of the SSAO post-process
  57763. * The final result is "base + ssao" between [0, 1]
  57764. */
  57765. base: number;
  57766. /**
  57767. * Support test.
  57768. */
  57769. static readonly IsSupported: boolean;
  57770. private _scene;
  57771. private _depthTexture;
  57772. private _normalTexture;
  57773. private _randomTexture;
  57774. private _originalColorPostProcess;
  57775. private _ssaoPostProcess;
  57776. private _blurHPostProcess;
  57777. private _blurVPostProcess;
  57778. private _ssaoCombinePostProcess;
  57779. private _firstUpdate;
  57780. /**
  57781. * Gets active scene
  57782. */
  57783. readonly scene: Scene;
  57784. /**
  57785. * @constructor
  57786. * @param name The rendering pipeline name
  57787. * @param scene The scene linked to this pipeline
  57788. * @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 }
  57789. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57790. */
  57791. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57792. /**
  57793. * Get the class name
  57794. * @returns "SSAO2RenderingPipeline"
  57795. */
  57796. getClassName(): string;
  57797. /**
  57798. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57799. */
  57800. dispose(disableGeometryBufferRenderer?: boolean): void;
  57801. private _createBlurPostProcess;
  57802. /** @hidden */
  57803. _rebuild(): void;
  57804. private _bits;
  57805. private _radicalInverse_VdC;
  57806. private _hammersley;
  57807. private _hemisphereSample_uniform;
  57808. private _generateHemisphere;
  57809. private _createSSAOPostProcess;
  57810. private _createSSAOCombinePostProcess;
  57811. private _createRandomTexture;
  57812. /**
  57813. * Serialize the rendering pipeline (Used when exporting)
  57814. * @returns the serialized object
  57815. */
  57816. serialize(): any;
  57817. /**
  57818. * Parse the serialized pipeline
  57819. * @param source Source pipeline.
  57820. * @param scene The scene to load the pipeline to.
  57821. * @param rootUrl The URL of the serialized pipeline.
  57822. * @returns An instantiated pipeline from the serialized object.
  57823. */
  57824. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57825. }
  57826. }
  57827. declare module BABYLON {
  57828. /** @hidden */
  57829. export var ssaoPixelShader: {
  57830. name: string;
  57831. shader: string;
  57832. };
  57833. }
  57834. declare module BABYLON {
  57835. /**
  57836. * Render pipeline to produce ssao effect
  57837. */
  57838. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57839. /**
  57840. * @ignore
  57841. * The PassPostProcess id in the pipeline that contains the original scene color
  57842. */
  57843. SSAOOriginalSceneColorEffect: string;
  57844. /**
  57845. * @ignore
  57846. * The SSAO PostProcess id in the pipeline
  57847. */
  57848. SSAORenderEffect: string;
  57849. /**
  57850. * @ignore
  57851. * The horizontal blur PostProcess id in the pipeline
  57852. */
  57853. SSAOBlurHRenderEffect: string;
  57854. /**
  57855. * @ignore
  57856. * The vertical blur PostProcess id in the pipeline
  57857. */
  57858. SSAOBlurVRenderEffect: string;
  57859. /**
  57860. * @ignore
  57861. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57862. */
  57863. SSAOCombineRenderEffect: string;
  57864. /**
  57865. * The output strength of the SSAO post-process. Default value is 1.0.
  57866. */
  57867. totalStrength: number;
  57868. /**
  57869. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57870. */
  57871. radius: number;
  57872. /**
  57873. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57874. * Must not be equal to fallOff and superior to fallOff.
  57875. * Default value is 0.0075
  57876. */
  57877. area: number;
  57878. /**
  57879. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57880. * Must not be equal to area and inferior to area.
  57881. * Default value is 0.000001
  57882. */
  57883. fallOff: number;
  57884. /**
  57885. * The base color of the SSAO post-process
  57886. * The final result is "base + ssao" between [0, 1]
  57887. */
  57888. base: number;
  57889. private _scene;
  57890. private _depthTexture;
  57891. private _randomTexture;
  57892. private _originalColorPostProcess;
  57893. private _ssaoPostProcess;
  57894. private _blurHPostProcess;
  57895. private _blurVPostProcess;
  57896. private _ssaoCombinePostProcess;
  57897. private _firstUpdate;
  57898. /**
  57899. * Gets active scene
  57900. */
  57901. readonly scene: Scene;
  57902. /**
  57903. * @constructor
  57904. * @param name - The rendering pipeline name
  57905. * @param scene - The scene linked to this pipeline
  57906. * @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 }
  57907. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57908. */
  57909. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57910. /**
  57911. * Get the class name
  57912. * @returns "SSAORenderingPipeline"
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57917. */
  57918. dispose(disableDepthRender?: boolean): void;
  57919. private _createBlurPostProcess;
  57920. /** @hidden */
  57921. _rebuild(): void;
  57922. private _createSSAOPostProcess;
  57923. private _createSSAOCombinePostProcess;
  57924. private _createRandomTexture;
  57925. }
  57926. }
  57927. declare module BABYLON {
  57928. /** @hidden */
  57929. export var standardPixelShader: {
  57930. name: string;
  57931. shader: string;
  57932. };
  57933. }
  57934. declare module BABYLON {
  57935. /**
  57936. * Standard rendering pipeline
  57937. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57938. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57939. */
  57940. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57941. /**
  57942. * Public members
  57943. */
  57944. /**
  57945. * Post-process which contains the original scene color before the pipeline applies all the effects
  57946. */
  57947. originalPostProcess: Nullable<PostProcess>;
  57948. /**
  57949. * Post-process used to down scale an image x4
  57950. */
  57951. downSampleX4PostProcess: Nullable<PostProcess>;
  57952. /**
  57953. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57954. */
  57955. brightPassPostProcess: Nullable<PostProcess>;
  57956. /**
  57957. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57958. */
  57959. blurHPostProcesses: PostProcess[];
  57960. /**
  57961. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57962. */
  57963. blurVPostProcesses: PostProcess[];
  57964. /**
  57965. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57966. */
  57967. textureAdderPostProcess: Nullable<PostProcess>;
  57968. /**
  57969. * Post-process used to create volumetric lighting effect
  57970. */
  57971. volumetricLightPostProcess: Nullable<PostProcess>;
  57972. /**
  57973. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57974. */
  57975. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57976. /**
  57977. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57978. */
  57979. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57980. /**
  57981. * Post-process used to merge the volumetric light effect and the real scene color
  57982. */
  57983. volumetricLightMergePostProces: Nullable<PostProcess>;
  57984. /**
  57985. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57986. */
  57987. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57988. /**
  57989. * Base post-process used to calculate the average luminance of the final image for HDR
  57990. */
  57991. luminancePostProcess: Nullable<PostProcess>;
  57992. /**
  57993. * Post-processes used to create down sample post-processes in order to get
  57994. * the average luminance of the final image for HDR
  57995. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57996. */
  57997. luminanceDownSamplePostProcesses: PostProcess[];
  57998. /**
  57999. * Post-process used to create a HDR effect (light adaptation)
  58000. */
  58001. hdrPostProcess: Nullable<PostProcess>;
  58002. /**
  58003. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58004. */
  58005. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58006. /**
  58007. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58008. */
  58009. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58010. /**
  58011. * Post-process used to merge the final HDR post-process and the real scene color
  58012. */
  58013. hdrFinalPostProcess: Nullable<PostProcess>;
  58014. /**
  58015. * Post-process used to create a lens flare effect
  58016. */
  58017. lensFlarePostProcess: Nullable<PostProcess>;
  58018. /**
  58019. * Post-process that merges the result of the lens flare post-process and the real scene color
  58020. */
  58021. lensFlareComposePostProcess: Nullable<PostProcess>;
  58022. /**
  58023. * Post-process used to create a motion blur effect
  58024. */
  58025. motionBlurPostProcess: Nullable<PostProcess>;
  58026. /**
  58027. * Post-process used to create a depth of field effect
  58028. */
  58029. depthOfFieldPostProcess: Nullable<PostProcess>;
  58030. /**
  58031. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58032. */
  58033. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58034. /**
  58035. * Represents the brightness threshold in order to configure the illuminated surfaces
  58036. */
  58037. brightThreshold: number;
  58038. /**
  58039. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58040. */
  58041. blurWidth: number;
  58042. /**
  58043. * Sets if the blur for highlighted surfaces must be only horizontal
  58044. */
  58045. horizontalBlur: boolean;
  58046. /**
  58047. * Gets the overall exposure used by the pipeline
  58048. */
  58049. /**
  58050. * Sets the overall exposure used by the pipeline
  58051. */
  58052. exposure: number;
  58053. /**
  58054. * Texture used typically to simulate "dirty" on camera lens
  58055. */
  58056. lensTexture: Nullable<Texture>;
  58057. /**
  58058. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58059. */
  58060. volumetricLightCoefficient: number;
  58061. /**
  58062. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58063. */
  58064. volumetricLightPower: number;
  58065. /**
  58066. * Used the set the blur intensity to smooth the volumetric lights
  58067. */
  58068. volumetricLightBlurScale: number;
  58069. /**
  58070. * Light (spot or directional) used to generate the volumetric lights rays
  58071. * The source light must have a shadow generate so the pipeline can get its
  58072. * depth map
  58073. */
  58074. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58075. /**
  58076. * For eye adaptation, represents the minimum luminance the eye can see
  58077. */
  58078. hdrMinimumLuminance: number;
  58079. /**
  58080. * For eye adaptation, represents the decrease luminance speed
  58081. */
  58082. hdrDecreaseRate: number;
  58083. /**
  58084. * For eye adaptation, represents the increase luminance speed
  58085. */
  58086. hdrIncreaseRate: number;
  58087. /**
  58088. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58089. */
  58090. /**
  58091. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58092. */
  58093. hdrAutoExposure: boolean;
  58094. /**
  58095. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58096. */
  58097. lensColorTexture: Nullable<Texture>;
  58098. /**
  58099. * The overall strengh for the lens flare effect
  58100. */
  58101. lensFlareStrength: number;
  58102. /**
  58103. * Dispersion coefficient for lens flare ghosts
  58104. */
  58105. lensFlareGhostDispersal: number;
  58106. /**
  58107. * Main lens flare halo width
  58108. */
  58109. lensFlareHaloWidth: number;
  58110. /**
  58111. * Based on the lens distortion effect, defines how much the lens flare result
  58112. * is distorted
  58113. */
  58114. lensFlareDistortionStrength: number;
  58115. /**
  58116. * Lens star texture must be used to simulate rays on the flares and is available
  58117. * in the documentation
  58118. */
  58119. lensStarTexture: Nullable<Texture>;
  58120. /**
  58121. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58122. * flare effect by taking account of the dirt texture
  58123. */
  58124. lensFlareDirtTexture: Nullable<Texture>;
  58125. /**
  58126. * Represents the focal length for the depth of field effect
  58127. */
  58128. depthOfFieldDistance: number;
  58129. /**
  58130. * Represents the blur intensity for the blurred part of the depth of field effect
  58131. */
  58132. depthOfFieldBlurWidth: number;
  58133. /**
  58134. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58135. */
  58136. /**
  58137. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58138. */
  58139. motionStrength: number;
  58140. /**
  58141. * Gets wether or not the motion blur post-process is object based or screen based.
  58142. */
  58143. /**
  58144. * Sets wether or not the motion blur post-process should be object based or screen based
  58145. */
  58146. objectBasedMotionBlur: boolean;
  58147. /**
  58148. * List of animations for the pipeline (IAnimatable implementation)
  58149. */
  58150. animations: Animation[];
  58151. /**
  58152. * Private members
  58153. */
  58154. private _scene;
  58155. private _currentDepthOfFieldSource;
  58156. private _basePostProcess;
  58157. private _fixedExposure;
  58158. private _currentExposure;
  58159. private _hdrAutoExposure;
  58160. private _hdrCurrentLuminance;
  58161. private _motionStrength;
  58162. private _isObjectBasedMotionBlur;
  58163. private _floatTextureType;
  58164. private _ratio;
  58165. private _bloomEnabled;
  58166. private _depthOfFieldEnabled;
  58167. private _vlsEnabled;
  58168. private _lensFlareEnabled;
  58169. private _hdrEnabled;
  58170. private _motionBlurEnabled;
  58171. private _fxaaEnabled;
  58172. private _motionBlurSamples;
  58173. private _volumetricLightStepsCount;
  58174. private _samples;
  58175. /**
  58176. * @ignore
  58177. * Specifies if the bloom pipeline is enabled
  58178. */
  58179. BloomEnabled: boolean;
  58180. /**
  58181. * @ignore
  58182. * Specifies if the depth of field pipeline is enabed
  58183. */
  58184. DepthOfFieldEnabled: boolean;
  58185. /**
  58186. * @ignore
  58187. * Specifies if the lens flare pipeline is enabed
  58188. */
  58189. LensFlareEnabled: boolean;
  58190. /**
  58191. * @ignore
  58192. * Specifies if the HDR pipeline is enabled
  58193. */
  58194. HDREnabled: boolean;
  58195. /**
  58196. * @ignore
  58197. * Specifies if the volumetric lights scattering effect is enabled
  58198. */
  58199. VLSEnabled: boolean;
  58200. /**
  58201. * @ignore
  58202. * Specifies if the motion blur effect is enabled
  58203. */
  58204. MotionBlurEnabled: boolean;
  58205. /**
  58206. * Specifies if anti-aliasing is enabled
  58207. */
  58208. fxaaEnabled: boolean;
  58209. /**
  58210. * Specifies the number of steps used to calculate the volumetric lights
  58211. * Typically in interval [50, 200]
  58212. */
  58213. volumetricLightStepsCount: number;
  58214. /**
  58215. * Specifies the number of samples used for the motion blur effect
  58216. * Typically in interval [16, 64]
  58217. */
  58218. motionBlurSamples: number;
  58219. /**
  58220. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58221. */
  58222. samples: number;
  58223. /**
  58224. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58225. * @constructor
  58226. * @param name The rendering pipeline name
  58227. * @param scene The scene linked to this pipeline
  58228. * @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)
  58229. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58230. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58231. */
  58232. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58233. private _buildPipeline;
  58234. private _createDownSampleX4PostProcess;
  58235. private _createBrightPassPostProcess;
  58236. private _createBlurPostProcesses;
  58237. private _createTextureAdderPostProcess;
  58238. private _createVolumetricLightPostProcess;
  58239. private _createLuminancePostProcesses;
  58240. private _createHdrPostProcess;
  58241. private _createLensFlarePostProcess;
  58242. private _createDepthOfFieldPostProcess;
  58243. private _createMotionBlurPostProcess;
  58244. private _getDepthTexture;
  58245. private _disposePostProcesses;
  58246. /**
  58247. * Dispose of the pipeline and stop all post processes
  58248. */
  58249. dispose(): void;
  58250. /**
  58251. * Serialize the rendering pipeline (Used when exporting)
  58252. * @returns the serialized object
  58253. */
  58254. serialize(): any;
  58255. /**
  58256. * Parse the serialized pipeline
  58257. * @param source Source pipeline.
  58258. * @param scene The scene to load the pipeline to.
  58259. * @param rootUrl The URL of the serialized pipeline.
  58260. * @returns An instantiated pipeline from the serialized object.
  58261. */
  58262. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58263. /**
  58264. * Luminance steps
  58265. */
  58266. static LuminanceSteps: number;
  58267. }
  58268. }
  58269. declare module BABYLON {
  58270. /** @hidden */
  58271. export var tonemapPixelShader: {
  58272. name: string;
  58273. shader: string;
  58274. };
  58275. }
  58276. declare module BABYLON {
  58277. /** Defines operator used for tonemapping */
  58278. export enum TonemappingOperator {
  58279. /** Hable */
  58280. Hable = 0,
  58281. /** Reinhard */
  58282. Reinhard = 1,
  58283. /** HejiDawson */
  58284. HejiDawson = 2,
  58285. /** Photographic */
  58286. Photographic = 3
  58287. }
  58288. /**
  58289. * Defines a post process to apply tone mapping
  58290. */
  58291. export class TonemapPostProcess extends PostProcess {
  58292. private _operator;
  58293. /** Defines the required exposure adjustement */
  58294. exposureAdjustment: number;
  58295. /**
  58296. * Creates a new TonemapPostProcess
  58297. * @param name defines the name of the postprocess
  58298. * @param _operator defines the operator to use
  58299. * @param exposureAdjustment defines the required exposure adjustement
  58300. * @param camera defines the camera to use (can be null)
  58301. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58302. * @param engine defines the hosting engine (can be ignore if camera is set)
  58303. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58304. */
  58305. constructor(name: string, _operator: TonemappingOperator,
  58306. /** Defines the required exposure adjustement */
  58307. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58308. }
  58309. }
  58310. declare module BABYLON {
  58311. /** @hidden */
  58312. export var depthVertexShader: {
  58313. name: string;
  58314. shader: string;
  58315. };
  58316. }
  58317. declare module BABYLON {
  58318. /** @hidden */
  58319. export var volumetricLightScatteringPixelShader: {
  58320. name: string;
  58321. shader: string;
  58322. };
  58323. }
  58324. declare module BABYLON {
  58325. /** @hidden */
  58326. export var volumetricLightScatteringPassPixelShader: {
  58327. name: string;
  58328. shader: string;
  58329. };
  58330. }
  58331. declare module BABYLON {
  58332. /**
  58333. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58334. */
  58335. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58336. private _volumetricLightScatteringPass;
  58337. private _volumetricLightScatteringRTT;
  58338. private _viewPort;
  58339. private _screenCoordinates;
  58340. private _cachedDefines;
  58341. /**
  58342. * If not undefined, the mesh position is computed from the attached node position
  58343. */
  58344. attachedNode: {
  58345. position: Vector3;
  58346. };
  58347. /**
  58348. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58349. */
  58350. customMeshPosition: Vector3;
  58351. /**
  58352. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58353. */
  58354. useCustomMeshPosition: boolean;
  58355. /**
  58356. * If the post-process should inverse the light scattering direction
  58357. */
  58358. invert: boolean;
  58359. /**
  58360. * The internal mesh used by the post-process
  58361. */
  58362. mesh: Mesh;
  58363. /**
  58364. * @hidden
  58365. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58366. */
  58367. useDiffuseColor: boolean;
  58368. /**
  58369. * Array containing the excluded meshes not rendered in the internal pass
  58370. */
  58371. excludedMeshes: AbstractMesh[];
  58372. /**
  58373. * Controls the overall intensity of the post-process
  58374. */
  58375. exposure: number;
  58376. /**
  58377. * Dissipates each sample's contribution in range [0, 1]
  58378. */
  58379. decay: number;
  58380. /**
  58381. * Controls the overall intensity of each sample
  58382. */
  58383. weight: number;
  58384. /**
  58385. * Controls the density of each sample
  58386. */
  58387. density: number;
  58388. /**
  58389. * @constructor
  58390. * @param name The post-process name
  58391. * @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)
  58392. * @param camera The camera that the post-process will be attached to
  58393. * @param mesh The mesh used to create the light scattering
  58394. * @param samples The post-process quality, default 100
  58395. * @param samplingModeThe post-process filtering mode
  58396. * @param engine The babylon engine
  58397. * @param reusable If the post-process is reusable
  58398. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58399. */
  58400. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58401. /**
  58402. * Returns the string "VolumetricLightScatteringPostProcess"
  58403. * @returns "VolumetricLightScatteringPostProcess"
  58404. */
  58405. getClassName(): string;
  58406. private _isReady;
  58407. /**
  58408. * Sets the new light position for light scattering effect
  58409. * @param position The new custom light position
  58410. */
  58411. setCustomMeshPosition(position: Vector3): void;
  58412. /**
  58413. * Returns the light position for light scattering effect
  58414. * @return Vector3 The custom light position
  58415. */
  58416. getCustomMeshPosition(): Vector3;
  58417. /**
  58418. * Disposes the internal assets and detaches the post-process from the camera
  58419. */
  58420. dispose(camera: Camera): void;
  58421. /**
  58422. * Returns the render target texture used by the post-process
  58423. * @return the render target texture used by the post-process
  58424. */
  58425. getPass(): RenderTargetTexture;
  58426. private _meshExcluded;
  58427. private _createPass;
  58428. private _updateMeshScreenCoordinates;
  58429. /**
  58430. * Creates a default mesh for the Volumeric Light Scattering post-process
  58431. * @param name The mesh name
  58432. * @param scene The scene where to create the mesh
  58433. * @return the default mesh
  58434. */
  58435. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58436. }
  58437. }
  58438. declare module BABYLON {
  58439. interface Scene {
  58440. /** @hidden (Backing field) */
  58441. _boundingBoxRenderer: BoundingBoxRenderer;
  58442. /** @hidden (Backing field) */
  58443. _forceShowBoundingBoxes: boolean;
  58444. /**
  58445. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58446. */
  58447. forceShowBoundingBoxes: boolean;
  58448. /**
  58449. * Gets the bounding box renderer associated with the scene
  58450. * @returns a BoundingBoxRenderer
  58451. */
  58452. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58453. }
  58454. interface AbstractMesh {
  58455. /** @hidden (Backing field) */
  58456. _showBoundingBox: boolean;
  58457. /**
  58458. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58459. */
  58460. showBoundingBox: boolean;
  58461. }
  58462. /**
  58463. * Component responsible of rendering the bounding box of the meshes in a scene.
  58464. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58465. */
  58466. export class BoundingBoxRenderer implements ISceneComponent {
  58467. /**
  58468. * The component name helpfull to identify the component in the list of scene components.
  58469. */
  58470. readonly name: string;
  58471. /**
  58472. * The scene the component belongs to.
  58473. */
  58474. scene: Scene;
  58475. /**
  58476. * Color of the bounding box lines placed in front of an object
  58477. */
  58478. frontColor: Color3;
  58479. /**
  58480. * Color of the bounding box lines placed behind an object
  58481. */
  58482. backColor: Color3;
  58483. /**
  58484. * Defines if the renderer should show the back lines or not
  58485. */
  58486. showBackLines: boolean;
  58487. /**
  58488. * @hidden
  58489. */
  58490. renderList: SmartArray<BoundingBox>;
  58491. private _colorShader;
  58492. private _vertexBuffers;
  58493. private _indexBuffer;
  58494. private _fillIndexBuffer;
  58495. private _fillIndexData;
  58496. /**
  58497. * Instantiates a new bounding box renderer in a scene.
  58498. * @param scene the scene the renderer renders in
  58499. */
  58500. constructor(scene: Scene);
  58501. /**
  58502. * Registers the component in a given scene
  58503. */
  58504. register(): void;
  58505. private _evaluateSubMesh;
  58506. private _activeMesh;
  58507. private _prepareRessources;
  58508. private _createIndexBuffer;
  58509. /**
  58510. * Rebuilds the elements related to this component in case of
  58511. * context lost for instance.
  58512. */
  58513. rebuild(): void;
  58514. /**
  58515. * @hidden
  58516. */
  58517. reset(): void;
  58518. /**
  58519. * Render the bounding boxes of a specific rendering group
  58520. * @param renderingGroupId defines the rendering group to render
  58521. */
  58522. render(renderingGroupId: number): void;
  58523. /**
  58524. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58525. * @param mesh Define the mesh to render the occlusion bounding box for
  58526. */
  58527. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58528. /**
  58529. * Dispose and release the resources attached to this renderer.
  58530. */
  58531. dispose(): void;
  58532. }
  58533. }
  58534. declare module BABYLON {
  58535. /** @hidden */
  58536. export var depthPixelShader: {
  58537. name: string;
  58538. shader: string;
  58539. };
  58540. }
  58541. declare module BABYLON {
  58542. /**
  58543. * This represents a depth renderer in Babylon.
  58544. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58545. */
  58546. export class DepthRenderer {
  58547. private _scene;
  58548. private _depthMap;
  58549. private _effect;
  58550. private readonly _storeNonLinearDepth;
  58551. private readonly _clearColor;
  58552. /** Get if the depth renderer is using packed depth or not */
  58553. readonly isPacked: boolean;
  58554. private _cachedDefines;
  58555. private _camera;
  58556. /**
  58557. * Specifiess that the depth renderer will only be used within
  58558. * the camera it is created for.
  58559. * This can help forcing its rendering during the camera processing.
  58560. */
  58561. useOnlyInActiveCamera: boolean;
  58562. /** @hidden */
  58563. static _SceneComponentInitialization: (scene: Scene) => void;
  58564. /**
  58565. * Instantiates a depth renderer
  58566. * @param scene The scene the renderer belongs to
  58567. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58568. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58569. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58570. */
  58571. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58572. /**
  58573. * Creates the depth rendering effect and checks if the effect is ready.
  58574. * @param subMesh The submesh to be used to render the depth map of
  58575. * @param useInstances If multiple world instances should be used
  58576. * @returns if the depth renderer is ready to render the depth map
  58577. */
  58578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58579. /**
  58580. * Gets the texture which the depth map will be written to.
  58581. * @returns The depth map texture
  58582. */
  58583. getDepthMap(): RenderTargetTexture;
  58584. /**
  58585. * Disposes of the depth renderer.
  58586. */
  58587. dispose(): void;
  58588. }
  58589. }
  58590. declare module BABYLON {
  58591. interface Scene {
  58592. /** @hidden (Backing field) */
  58593. _depthRenderer: {
  58594. [id: string]: DepthRenderer;
  58595. };
  58596. /**
  58597. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58598. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58599. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58600. * @returns the created depth renderer
  58601. */
  58602. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58603. /**
  58604. * Disables a depth renderer for a given camera
  58605. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58606. */
  58607. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58608. }
  58609. /**
  58610. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58611. * in several rendering techniques.
  58612. */
  58613. export class DepthRendererSceneComponent implements ISceneComponent {
  58614. /**
  58615. * The component name helpfull to identify the component in the list of scene components.
  58616. */
  58617. readonly name: string;
  58618. /**
  58619. * The scene the component belongs to.
  58620. */
  58621. scene: Scene;
  58622. /**
  58623. * Creates a new instance of the component for the given scene
  58624. * @param scene Defines the scene to register the component in
  58625. */
  58626. constructor(scene: Scene);
  58627. /**
  58628. * Registers the component in a given scene
  58629. */
  58630. register(): void;
  58631. /**
  58632. * Rebuilds the elements related to this component in case of
  58633. * context lost for instance.
  58634. */
  58635. rebuild(): void;
  58636. /**
  58637. * Disposes the component and the associated ressources
  58638. */
  58639. dispose(): void;
  58640. private _gatherRenderTargets;
  58641. private _gatherActiveCameraRenderTargets;
  58642. }
  58643. }
  58644. declare module BABYLON {
  58645. /** @hidden */
  58646. export var outlinePixelShader: {
  58647. name: string;
  58648. shader: string;
  58649. };
  58650. }
  58651. declare module BABYLON {
  58652. /** @hidden */
  58653. export var outlineVertexShader: {
  58654. name: string;
  58655. shader: string;
  58656. };
  58657. }
  58658. declare module BABYLON {
  58659. interface Scene {
  58660. /** @hidden */
  58661. _outlineRenderer: OutlineRenderer;
  58662. /**
  58663. * Gets the outline renderer associated with the scene
  58664. * @returns a OutlineRenderer
  58665. */
  58666. getOutlineRenderer(): OutlineRenderer;
  58667. }
  58668. interface AbstractMesh {
  58669. /** @hidden (Backing field) */
  58670. _renderOutline: boolean;
  58671. /**
  58672. * Gets or sets a boolean indicating if the outline must be rendered as well
  58673. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58674. */
  58675. renderOutline: boolean;
  58676. /** @hidden (Backing field) */
  58677. _renderOverlay: boolean;
  58678. /**
  58679. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58680. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58681. */
  58682. renderOverlay: boolean;
  58683. }
  58684. /**
  58685. * This class is responsible to draw bothe outline/overlay of meshes.
  58686. * It should not be used directly but through the available method on mesh.
  58687. */
  58688. export class OutlineRenderer implements ISceneComponent {
  58689. /**
  58690. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58691. */
  58692. private static _StencilReference;
  58693. /**
  58694. * The name of the component. Each component must have a unique name.
  58695. */
  58696. name: string;
  58697. /**
  58698. * The scene the component belongs to.
  58699. */
  58700. scene: Scene;
  58701. /**
  58702. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58703. */
  58704. zOffset: number;
  58705. private _engine;
  58706. private _effect;
  58707. private _cachedDefines;
  58708. private _savedDepthWrite;
  58709. /**
  58710. * Instantiates a new outline renderer. (There could be only one per scene).
  58711. * @param scene Defines the scene it belongs to
  58712. */
  58713. constructor(scene: Scene);
  58714. /**
  58715. * Register the component to one instance of a scene.
  58716. */
  58717. register(): void;
  58718. /**
  58719. * Rebuilds the elements related to this component in case of
  58720. * context lost for instance.
  58721. */
  58722. rebuild(): void;
  58723. /**
  58724. * Disposes the component and the associated ressources.
  58725. */
  58726. dispose(): void;
  58727. /**
  58728. * Renders the outline in the canvas.
  58729. * @param subMesh Defines the sumesh to render
  58730. * @param batch Defines the batch of meshes in case of instances
  58731. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58732. */
  58733. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58734. /**
  58735. * Returns whether or not the outline renderer is ready for a given submesh.
  58736. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58737. * @param subMesh Defines the submesh to check readyness for
  58738. * @param useInstances Defines wheter wee are trying to render instances or not
  58739. * @returns true if ready otherwise false
  58740. */
  58741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58742. private _beforeRenderingMesh;
  58743. private _afterRenderingMesh;
  58744. }
  58745. }
  58746. declare module BABYLON {
  58747. /**
  58748. * Defines the list of states available for a task inside a AssetsManager
  58749. */
  58750. export enum AssetTaskState {
  58751. /**
  58752. * Initialization
  58753. */
  58754. INIT = 0,
  58755. /**
  58756. * Running
  58757. */
  58758. RUNNING = 1,
  58759. /**
  58760. * Done
  58761. */
  58762. DONE = 2,
  58763. /**
  58764. * Error
  58765. */
  58766. ERROR = 3
  58767. }
  58768. /**
  58769. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58770. */
  58771. export abstract class AbstractAssetTask {
  58772. /**
  58773. * Task name
  58774. */ name: string;
  58775. /**
  58776. * Callback called when the task is successful
  58777. */
  58778. onSuccess: (task: any) => void;
  58779. /**
  58780. * Callback called when the task is not successful
  58781. */
  58782. onError: (task: any, message?: string, exception?: any) => void;
  58783. /**
  58784. * Creates a new AssetsManager
  58785. * @param name defines the name of the task
  58786. */
  58787. constructor(
  58788. /**
  58789. * Task name
  58790. */ name: string);
  58791. private _isCompleted;
  58792. private _taskState;
  58793. private _errorObject;
  58794. /**
  58795. * Get if the task is completed
  58796. */
  58797. readonly isCompleted: boolean;
  58798. /**
  58799. * Gets the current state of the task
  58800. */
  58801. readonly taskState: AssetTaskState;
  58802. /**
  58803. * Gets the current error object (if task is in error)
  58804. */
  58805. readonly errorObject: {
  58806. message?: string;
  58807. exception?: any;
  58808. };
  58809. /**
  58810. * Internal only
  58811. * @hidden
  58812. */
  58813. _setErrorObject(message?: string, exception?: any): void;
  58814. /**
  58815. * Execute the current task
  58816. * @param scene defines the scene where you want your assets to be loaded
  58817. * @param onSuccess is a callback called when the task is successfully executed
  58818. * @param onError is a callback called if an error occurs
  58819. */
  58820. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58821. /**
  58822. * Execute the current task
  58823. * @param scene defines the scene where you want your assets to be loaded
  58824. * @param onSuccess is a callback called when the task is successfully executed
  58825. * @param onError is a callback called if an error occurs
  58826. */
  58827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58828. /**
  58829. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58830. * This can be used with failed tasks that have the reason for failure fixed.
  58831. */
  58832. reset(): void;
  58833. private onErrorCallback;
  58834. private onDoneCallback;
  58835. }
  58836. /**
  58837. * Define the interface used by progress events raised during assets loading
  58838. */
  58839. export interface IAssetsProgressEvent {
  58840. /**
  58841. * Defines the number of remaining tasks to process
  58842. */
  58843. remainingCount: number;
  58844. /**
  58845. * Defines the total number of tasks
  58846. */
  58847. totalCount: number;
  58848. /**
  58849. * Defines the task that was just processed
  58850. */
  58851. task: AbstractAssetTask;
  58852. }
  58853. /**
  58854. * Class used to share progress information about assets loading
  58855. */
  58856. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58857. /**
  58858. * Defines the number of remaining tasks to process
  58859. */
  58860. remainingCount: number;
  58861. /**
  58862. * Defines the total number of tasks
  58863. */
  58864. totalCount: number;
  58865. /**
  58866. * Defines the task that was just processed
  58867. */
  58868. task: AbstractAssetTask;
  58869. /**
  58870. * Creates a AssetsProgressEvent
  58871. * @param remainingCount defines the number of remaining tasks to process
  58872. * @param totalCount defines the total number of tasks
  58873. * @param task defines the task that was just processed
  58874. */
  58875. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58876. }
  58877. /**
  58878. * Define a task used by AssetsManager to load meshes
  58879. */
  58880. export class MeshAssetTask extends AbstractAssetTask {
  58881. /**
  58882. * Defines the name of the task
  58883. */
  58884. name: string;
  58885. /**
  58886. * Defines the list of mesh's names you want to load
  58887. */
  58888. meshesNames: any;
  58889. /**
  58890. * Defines the root url to use as a base to load your meshes and associated resources
  58891. */
  58892. rootUrl: string;
  58893. /**
  58894. * Defines the filename of the scene to load from
  58895. */
  58896. sceneFilename: string;
  58897. /**
  58898. * Gets the list of loaded meshes
  58899. */
  58900. loadedMeshes: Array<AbstractMesh>;
  58901. /**
  58902. * Gets the list of loaded particle systems
  58903. */
  58904. loadedParticleSystems: Array<IParticleSystem>;
  58905. /**
  58906. * Gets the list of loaded skeletons
  58907. */
  58908. loadedSkeletons: Array<Skeleton>;
  58909. /**
  58910. * Gets the list of loaded animation groups
  58911. */
  58912. loadedAnimationGroups: Array<AnimationGroup>;
  58913. /**
  58914. * Callback called when the task is successful
  58915. */
  58916. onSuccess: (task: MeshAssetTask) => void;
  58917. /**
  58918. * Callback called when the task is successful
  58919. */
  58920. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58921. /**
  58922. * Creates a new MeshAssetTask
  58923. * @param name defines the name of the task
  58924. * @param meshesNames defines the list of mesh's names you want to load
  58925. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58926. * @param sceneFilename defines the filename of the scene to load from
  58927. */
  58928. constructor(
  58929. /**
  58930. * Defines the name of the task
  58931. */
  58932. name: string,
  58933. /**
  58934. * Defines the list of mesh's names you want to load
  58935. */
  58936. meshesNames: any,
  58937. /**
  58938. * Defines the root url to use as a base to load your meshes and associated resources
  58939. */
  58940. rootUrl: string,
  58941. /**
  58942. * Defines the filename of the scene to load from
  58943. */
  58944. sceneFilename: string);
  58945. /**
  58946. * Execute the current task
  58947. * @param scene defines the scene where you want your assets to be loaded
  58948. * @param onSuccess is a callback called when the task is successfully executed
  58949. * @param onError is a callback called if an error occurs
  58950. */
  58951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58952. }
  58953. /**
  58954. * Define a task used by AssetsManager to load text content
  58955. */
  58956. export class TextFileAssetTask extends AbstractAssetTask {
  58957. /**
  58958. * Defines the name of the task
  58959. */
  58960. name: string;
  58961. /**
  58962. * Defines the location of the file to load
  58963. */
  58964. url: string;
  58965. /**
  58966. * Gets the loaded text string
  58967. */
  58968. text: string;
  58969. /**
  58970. * Callback called when the task is successful
  58971. */
  58972. onSuccess: (task: TextFileAssetTask) => void;
  58973. /**
  58974. * Callback called when the task is successful
  58975. */
  58976. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58977. /**
  58978. * Creates a new TextFileAssetTask object
  58979. * @param name defines the name of the task
  58980. * @param url defines the location of the file to load
  58981. */
  58982. constructor(
  58983. /**
  58984. * Defines the name of the task
  58985. */
  58986. name: string,
  58987. /**
  58988. * Defines the location of the file to load
  58989. */
  58990. url: string);
  58991. /**
  58992. * Execute the current task
  58993. * @param scene defines the scene where you want your assets to be loaded
  58994. * @param onSuccess is a callback called when the task is successfully executed
  58995. * @param onError is a callback called if an error occurs
  58996. */
  58997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58998. }
  58999. /**
  59000. * Define a task used by AssetsManager to load binary data
  59001. */
  59002. export class BinaryFileAssetTask extends AbstractAssetTask {
  59003. /**
  59004. * Defines the name of the task
  59005. */
  59006. name: string;
  59007. /**
  59008. * Defines the location of the file to load
  59009. */
  59010. url: string;
  59011. /**
  59012. * Gets the lodaded data (as an array buffer)
  59013. */
  59014. data: ArrayBuffer;
  59015. /**
  59016. * Callback called when the task is successful
  59017. */
  59018. onSuccess: (task: BinaryFileAssetTask) => void;
  59019. /**
  59020. * Callback called when the task is successful
  59021. */
  59022. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59023. /**
  59024. * Creates a new BinaryFileAssetTask object
  59025. * @param name defines the name of the new task
  59026. * @param url defines the location of the file to load
  59027. */
  59028. constructor(
  59029. /**
  59030. * Defines the name of the task
  59031. */
  59032. name: string,
  59033. /**
  59034. * Defines the location of the file to load
  59035. */
  59036. url: string);
  59037. /**
  59038. * Execute the current task
  59039. * @param scene defines the scene where you want your assets to be loaded
  59040. * @param onSuccess is a callback called when the task is successfully executed
  59041. * @param onError is a callback called if an error occurs
  59042. */
  59043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59044. }
  59045. /**
  59046. * Define a task used by AssetsManager to load images
  59047. */
  59048. export class ImageAssetTask extends AbstractAssetTask {
  59049. /**
  59050. * Defines the name of the task
  59051. */
  59052. name: string;
  59053. /**
  59054. * Defines the location of the image to load
  59055. */
  59056. url: string;
  59057. /**
  59058. * Gets the loaded images
  59059. */
  59060. image: HTMLImageElement;
  59061. /**
  59062. * Callback called when the task is successful
  59063. */
  59064. onSuccess: (task: ImageAssetTask) => void;
  59065. /**
  59066. * Callback called when the task is successful
  59067. */
  59068. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59069. /**
  59070. * Creates a new ImageAssetTask
  59071. * @param name defines the name of the task
  59072. * @param url defines the location of the image to load
  59073. */
  59074. constructor(
  59075. /**
  59076. * Defines the name of the task
  59077. */
  59078. name: string,
  59079. /**
  59080. * Defines the location of the image to load
  59081. */
  59082. url: string);
  59083. /**
  59084. * Execute the current task
  59085. * @param scene defines the scene where you want your assets to be loaded
  59086. * @param onSuccess is a callback called when the task is successfully executed
  59087. * @param onError is a callback called if an error occurs
  59088. */
  59089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59090. }
  59091. /**
  59092. * Defines the interface used by texture loading tasks
  59093. */
  59094. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59095. /**
  59096. * Gets the loaded texture
  59097. */
  59098. texture: TEX;
  59099. }
  59100. /**
  59101. * Define a task used by AssetsManager to load 2D textures
  59102. */
  59103. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59104. /**
  59105. * Defines the name of the task
  59106. */
  59107. name: string;
  59108. /**
  59109. * Defines the location of the file to load
  59110. */
  59111. url: string;
  59112. /**
  59113. * Defines if mipmap should not be generated (default is false)
  59114. */
  59115. noMipmap?: boolean | undefined;
  59116. /**
  59117. * Defines if texture must be inverted on Y axis (default is false)
  59118. */
  59119. invertY?: boolean | undefined;
  59120. /**
  59121. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59122. */
  59123. samplingMode: number;
  59124. /**
  59125. * Gets the loaded texture
  59126. */
  59127. texture: Texture;
  59128. /**
  59129. * Callback called when the task is successful
  59130. */
  59131. onSuccess: (task: TextureAssetTask) => void;
  59132. /**
  59133. * Callback called when the task is successful
  59134. */
  59135. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59136. /**
  59137. * Creates a new TextureAssetTask object
  59138. * @param name defines the name of the task
  59139. * @param url defines the location of the file to load
  59140. * @param noMipmap defines if mipmap should not be generated (default is false)
  59141. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59142. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59143. */
  59144. constructor(
  59145. /**
  59146. * Defines the name of the task
  59147. */
  59148. name: string,
  59149. /**
  59150. * Defines the location of the file to load
  59151. */
  59152. url: string,
  59153. /**
  59154. * Defines if mipmap should not be generated (default is false)
  59155. */
  59156. noMipmap?: boolean | undefined,
  59157. /**
  59158. * Defines if texture must be inverted on Y axis (default is false)
  59159. */
  59160. invertY?: boolean | undefined,
  59161. /**
  59162. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59163. */
  59164. samplingMode?: number);
  59165. /**
  59166. * Execute the current task
  59167. * @param scene defines the scene where you want your assets to be loaded
  59168. * @param onSuccess is a callback called when the task is successfully executed
  59169. * @param onError is a callback called if an error occurs
  59170. */
  59171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59172. }
  59173. /**
  59174. * Define a task used by AssetsManager to load cube textures
  59175. */
  59176. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59177. /**
  59178. * Defines the name of the task
  59179. */
  59180. name: string;
  59181. /**
  59182. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59183. */
  59184. url: string;
  59185. /**
  59186. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59187. */
  59188. extensions?: string[] | undefined;
  59189. /**
  59190. * Defines if mipmaps should not be generated (default is false)
  59191. */
  59192. noMipmap?: boolean | undefined;
  59193. /**
  59194. * Defines the explicit list of files (undefined by default)
  59195. */
  59196. files?: string[] | undefined;
  59197. /**
  59198. * Gets the loaded texture
  59199. */
  59200. texture: CubeTexture;
  59201. /**
  59202. * Callback called when the task is successful
  59203. */
  59204. onSuccess: (task: CubeTextureAssetTask) => void;
  59205. /**
  59206. * Callback called when the task is successful
  59207. */
  59208. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59209. /**
  59210. * Creates a new CubeTextureAssetTask
  59211. * @param name defines the name of the task
  59212. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59213. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59214. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59215. * @param files defines the explicit list of files (undefined by default)
  59216. */
  59217. constructor(
  59218. /**
  59219. * Defines the name of the task
  59220. */
  59221. name: string,
  59222. /**
  59223. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59224. */
  59225. url: string,
  59226. /**
  59227. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59228. */
  59229. extensions?: string[] | undefined,
  59230. /**
  59231. * Defines if mipmaps should not be generated (default is false)
  59232. */
  59233. noMipmap?: boolean | undefined,
  59234. /**
  59235. * Defines the explicit list of files (undefined by default)
  59236. */
  59237. files?: string[] | undefined);
  59238. /**
  59239. * Execute the current task
  59240. * @param scene defines the scene where you want your assets to be loaded
  59241. * @param onSuccess is a callback called when the task is successfully executed
  59242. * @param onError is a callback called if an error occurs
  59243. */
  59244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59245. }
  59246. /**
  59247. * Define a task used by AssetsManager to load HDR cube textures
  59248. */
  59249. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59250. /**
  59251. * Defines the name of the task
  59252. */
  59253. name: string;
  59254. /**
  59255. * Defines the location of the file to load
  59256. */
  59257. url: string;
  59258. /**
  59259. * Defines the desired size (the more it increases the longer the generation will be)
  59260. */
  59261. size: number;
  59262. /**
  59263. * Defines if mipmaps should not be generated (default is false)
  59264. */
  59265. noMipmap: boolean;
  59266. /**
  59267. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59268. */
  59269. generateHarmonics: boolean;
  59270. /**
  59271. * 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)
  59272. */
  59273. gammaSpace: boolean;
  59274. /**
  59275. * Internal Use Only
  59276. */
  59277. reserved: boolean;
  59278. /**
  59279. * Gets the loaded texture
  59280. */
  59281. texture: HDRCubeTexture;
  59282. /**
  59283. * Callback called when the task is successful
  59284. */
  59285. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59286. /**
  59287. * Callback called when the task is successful
  59288. */
  59289. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59290. /**
  59291. * Creates a new HDRCubeTextureAssetTask object
  59292. * @param name defines the name of the task
  59293. * @param url defines the location of the file to load
  59294. * @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.
  59295. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59296. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59297. * @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)
  59298. * @param reserved Internal use only
  59299. */
  59300. constructor(
  59301. /**
  59302. * Defines the name of the task
  59303. */
  59304. name: string,
  59305. /**
  59306. * Defines the location of the file to load
  59307. */
  59308. url: string,
  59309. /**
  59310. * Defines the desired size (the more it increases the longer the generation will be)
  59311. */
  59312. size: number,
  59313. /**
  59314. * Defines if mipmaps should not be generated (default is false)
  59315. */
  59316. noMipmap?: boolean,
  59317. /**
  59318. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59319. */
  59320. generateHarmonics?: boolean,
  59321. /**
  59322. * 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)
  59323. */
  59324. gammaSpace?: boolean,
  59325. /**
  59326. * Internal Use Only
  59327. */
  59328. reserved?: boolean);
  59329. /**
  59330. * Execute the current task
  59331. * @param scene defines the scene where you want your assets to be loaded
  59332. * @param onSuccess is a callback called when the task is successfully executed
  59333. * @param onError is a callback called if an error occurs
  59334. */
  59335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59336. }
  59337. /**
  59338. * Define a task used by AssetsManager to load Equirectangular cube textures
  59339. */
  59340. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59341. /**
  59342. * Defines the name of the task
  59343. */
  59344. name: string;
  59345. /**
  59346. * Defines the location of the file to load
  59347. */
  59348. url: string;
  59349. /**
  59350. * Defines the desired size (the more it increases the longer the generation will be)
  59351. */
  59352. size: number;
  59353. /**
  59354. * Defines if mipmaps should not be generated (default is false)
  59355. */
  59356. noMipmap: boolean;
  59357. /**
  59358. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59359. * but the standard material would require them in Gamma space) (default is true)
  59360. */
  59361. gammaSpace: boolean;
  59362. /**
  59363. * Gets the loaded texture
  59364. */
  59365. texture: EquiRectangularCubeTexture;
  59366. /**
  59367. * Callback called when the task is successful
  59368. */
  59369. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59370. /**
  59371. * Callback called when the task is successful
  59372. */
  59373. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59374. /**
  59375. * Creates a new EquiRectangularCubeTextureAssetTask object
  59376. * @param name defines the name of the task
  59377. * @param url defines the location of the file to load
  59378. * @param size defines the desired size (the more it increases the longer the generation will be)
  59379. * If the size is omitted this implies you are using a preprocessed cubemap.
  59380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59381. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59382. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59383. * (default is true)
  59384. */
  59385. constructor(
  59386. /**
  59387. * Defines the name of the task
  59388. */
  59389. name: string,
  59390. /**
  59391. * Defines the location of the file to load
  59392. */
  59393. url: string,
  59394. /**
  59395. * Defines the desired size (the more it increases the longer the generation will be)
  59396. */
  59397. size: number,
  59398. /**
  59399. * Defines if mipmaps should not be generated (default is false)
  59400. */
  59401. noMipmap?: boolean,
  59402. /**
  59403. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59404. * but the standard material would require them in Gamma space) (default is true)
  59405. */
  59406. gammaSpace?: boolean);
  59407. /**
  59408. * Execute the current task
  59409. * @param scene defines the scene where you want your assets to be loaded
  59410. * @param onSuccess is a callback called when the task is successfully executed
  59411. * @param onError is a callback called if an error occurs
  59412. */
  59413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59414. }
  59415. /**
  59416. * This class can be used to easily import assets into a scene
  59417. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59418. */
  59419. export class AssetsManager {
  59420. private _scene;
  59421. private _isLoading;
  59422. protected _tasks: AbstractAssetTask[];
  59423. protected _waitingTasksCount: number;
  59424. protected _totalTasksCount: number;
  59425. /**
  59426. * Callback called when all tasks are processed
  59427. */
  59428. onFinish: (tasks: AbstractAssetTask[]) => void;
  59429. /**
  59430. * Callback called when a task is successful
  59431. */
  59432. onTaskSuccess: (task: AbstractAssetTask) => void;
  59433. /**
  59434. * Callback called when a task had an error
  59435. */
  59436. onTaskError: (task: AbstractAssetTask) => void;
  59437. /**
  59438. * Callback called when a task is done (whatever the result is)
  59439. */
  59440. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59441. /**
  59442. * Observable called when all tasks are processed
  59443. */
  59444. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59445. /**
  59446. * Observable called when a task had an error
  59447. */
  59448. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59449. /**
  59450. * Observable called when all tasks were executed
  59451. */
  59452. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59453. /**
  59454. * Observable called when a task is done (whatever the result is)
  59455. */
  59456. onProgressObservable: Observable<IAssetsProgressEvent>;
  59457. /**
  59458. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59459. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59460. */
  59461. useDefaultLoadingScreen: boolean;
  59462. /**
  59463. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59464. * when all assets have been downloaded.
  59465. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59466. */
  59467. autoHideLoadingUI: boolean;
  59468. /**
  59469. * Creates a new AssetsManager
  59470. * @param scene defines the scene to work on
  59471. */
  59472. constructor(scene: Scene);
  59473. /**
  59474. * Add a MeshAssetTask to the list of active tasks
  59475. * @param taskName defines the name of the new task
  59476. * @param meshesNames defines the name of meshes to load
  59477. * @param rootUrl defines the root url to use to locate files
  59478. * @param sceneFilename defines the filename of the scene file
  59479. * @returns a new MeshAssetTask object
  59480. */
  59481. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59482. /**
  59483. * Add a TextFileAssetTask to the list of active tasks
  59484. * @param taskName defines the name of the new task
  59485. * @param url defines the url of the file to load
  59486. * @returns a new TextFileAssetTask object
  59487. */
  59488. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59489. /**
  59490. * Add a BinaryFileAssetTask to the list of active tasks
  59491. * @param taskName defines the name of the new task
  59492. * @param url defines the url of the file to load
  59493. * @returns a new BinaryFileAssetTask object
  59494. */
  59495. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59496. /**
  59497. * Add a ImageAssetTask to the list of active tasks
  59498. * @param taskName defines the name of the new task
  59499. * @param url defines the url of the file to load
  59500. * @returns a new ImageAssetTask object
  59501. */
  59502. addImageTask(taskName: string, url: string): ImageAssetTask;
  59503. /**
  59504. * Add a TextureAssetTask to the list of active tasks
  59505. * @param taskName defines the name of the new task
  59506. * @param url defines the url of the file to load
  59507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59508. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59509. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59510. * @returns a new TextureAssetTask object
  59511. */
  59512. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59513. /**
  59514. * Add a CubeTextureAssetTask to the list of active tasks
  59515. * @param taskName defines the name of the new task
  59516. * @param url defines the url of the file to load
  59517. * @param extensions defines the extension to use to load the cube map (can be null)
  59518. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59519. * @param files defines the list of files to load (can be null)
  59520. * @returns a new CubeTextureAssetTask object
  59521. */
  59522. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59523. /**
  59524. *
  59525. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59526. * @param taskName defines the name of the new task
  59527. * @param url defines the url of the file to load
  59528. * @param size defines the size you want for the cubemap (can be null)
  59529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59530. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59531. * @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)
  59532. * @param reserved Internal use only
  59533. * @returns a new HDRCubeTextureAssetTask object
  59534. */
  59535. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59536. /**
  59537. *
  59538. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59539. * @param taskName defines the name of the new task
  59540. * @param url defines the url of the file to load
  59541. * @param size defines the size you want for the cubemap (can be null)
  59542. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59543. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59544. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59545. * @returns a new EquiRectangularCubeTextureAssetTask object
  59546. */
  59547. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59548. /**
  59549. * Remove a task from the assets manager.
  59550. * @param task the task to remove
  59551. */
  59552. removeTask(task: AbstractAssetTask): void;
  59553. private _decreaseWaitingTasksCount;
  59554. private _runTask;
  59555. /**
  59556. * Reset the AssetsManager and remove all tasks
  59557. * @return the current instance of the AssetsManager
  59558. */
  59559. reset(): AssetsManager;
  59560. /**
  59561. * Start the loading process
  59562. * @return the current instance of the AssetsManager
  59563. */
  59564. load(): AssetsManager;
  59565. /**
  59566. * Start the loading process as an async operation
  59567. * @return a promise returning the list of failed tasks
  59568. */
  59569. loadAsync(): Promise<void>;
  59570. }
  59571. }
  59572. declare module BABYLON {
  59573. /**
  59574. * Wrapper class for promise with external resolve and reject.
  59575. */
  59576. export class Deferred<T> {
  59577. /**
  59578. * The promise associated with this deferred object.
  59579. */
  59580. readonly promise: Promise<T>;
  59581. private _resolve;
  59582. private _reject;
  59583. /**
  59584. * The resolve method of the promise associated with this deferred object.
  59585. */
  59586. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59587. /**
  59588. * The reject method of the promise associated with this deferred object.
  59589. */
  59590. readonly reject: (reason?: any) => void;
  59591. /**
  59592. * Constructor for this deferred object.
  59593. */
  59594. constructor();
  59595. }
  59596. }
  59597. declare module BABYLON {
  59598. /**
  59599. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59600. */
  59601. export class MeshExploder {
  59602. private _centerMesh;
  59603. private _meshes;
  59604. private _meshesOrigins;
  59605. private _toCenterVectors;
  59606. private _scaledDirection;
  59607. private _newPosition;
  59608. private _centerPosition;
  59609. /**
  59610. * Explodes meshes from a center mesh.
  59611. * @param meshes The meshes to explode.
  59612. * @param centerMesh The mesh to be center of explosion.
  59613. */
  59614. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59615. private _setCenterMesh;
  59616. /**
  59617. * Get class name
  59618. * @returns "MeshExploder"
  59619. */
  59620. getClassName(): string;
  59621. /**
  59622. * "Exploded meshes"
  59623. * @returns Array of meshes with the centerMesh at index 0.
  59624. */
  59625. getMeshes(): Array<Mesh>;
  59626. /**
  59627. * Explodes meshes giving a specific direction
  59628. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59629. */
  59630. explode(direction?: number): void;
  59631. }
  59632. }
  59633. declare module BABYLON {
  59634. /**
  59635. * Class used to help managing file picking and drag'n'drop
  59636. */
  59637. export class FilesInput {
  59638. /**
  59639. * List of files ready to be loaded
  59640. */
  59641. static readonly FilesToLoad: {
  59642. [key: string]: File;
  59643. };
  59644. /**
  59645. * Callback called when a file is processed
  59646. */
  59647. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59648. private _engine;
  59649. private _currentScene;
  59650. private _sceneLoadedCallback;
  59651. private _progressCallback;
  59652. private _additionalRenderLoopLogicCallback;
  59653. private _textureLoadingCallback;
  59654. private _startingProcessingFilesCallback;
  59655. private _onReloadCallback;
  59656. private _errorCallback;
  59657. private _elementToMonitor;
  59658. private _sceneFileToLoad;
  59659. private _filesToLoad;
  59660. /**
  59661. * Creates a new FilesInput
  59662. * @param engine defines the rendering engine
  59663. * @param scene defines the hosting scene
  59664. * @param sceneLoadedCallback callback called when scene is loaded
  59665. * @param progressCallback callback called to track progress
  59666. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59667. * @param textureLoadingCallback callback called when a texture is loading
  59668. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59669. * @param onReloadCallback callback called when a reload is requested
  59670. * @param errorCallback callback call if an error occurs
  59671. */
  59672. 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);
  59673. private _dragEnterHandler;
  59674. private _dragOverHandler;
  59675. private _dropHandler;
  59676. /**
  59677. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59678. * @param elementToMonitor defines the DOM element to track
  59679. */
  59680. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59681. /**
  59682. * Release all associated resources
  59683. */
  59684. dispose(): void;
  59685. private renderFunction;
  59686. private drag;
  59687. private drop;
  59688. private _traverseFolder;
  59689. private _processFiles;
  59690. /**
  59691. * Load files from a drop event
  59692. * @param event defines the drop event to use as source
  59693. */
  59694. loadFiles(event: any): void;
  59695. private _processReload;
  59696. /**
  59697. * Reload the current scene from the loaded files
  59698. */
  59699. reload(): void;
  59700. }
  59701. }
  59702. declare module BABYLON {
  59703. /**
  59704. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59706. */
  59707. export class SceneOptimization {
  59708. /**
  59709. * Defines the priority of this optimization (0 by default which means first in the list)
  59710. */
  59711. priority: number;
  59712. /**
  59713. * Gets a string describing the action executed by the current optimization
  59714. * @returns description string
  59715. */
  59716. getDescription(): string;
  59717. /**
  59718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59719. * @param scene defines the current scene where to apply this optimization
  59720. * @param optimizer defines the current optimizer
  59721. * @returns true if everything that can be done was applied
  59722. */
  59723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59724. /**
  59725. * Creates the SceneOptimization object
  59726. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59727. * @param desc defines the description associated with the optimization
  59728. */
  59729. constructor(
  59730. /**
  59731. * Defines the priority of this optimization (0 by default which means first in the list)
  59732. */
  59733. priority?: number);
  59734. }
  59735. /**
  59736. * Defines an optimization used to reduce the size of render target textures
  59737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59738. */
  59739. export class TextureOptimization extends SceneOptimization {
  59740. /**
  59741. * Defines the priority of this optimization (0 by default which means first in the list)
  59742. */
  59743. priority: number;
  59744. /**
  59745. * 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
  59746. */
  59747. maximumSize: number;
  59748. /**
  59749. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59750. */
  59751. step: number;
  59752. /**
  59753. * Gets a string describing the action executed by the current optimization
  59754. * @returns description string
  59755. */
  59756. getDescription(): string;
  59757. /**
  59758. * Creates the TextureOptimization object
  59759. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59760. * @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
  59761. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59762. */
  59763. constructor(
  59764. /**
  59765. * Defines the priority of this optimization (0 by default which means first in the list)
  59766. */
  59767. priority?: number,
  59768. /**
  59769. * 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
  59770. */
  59771. maximumSize?: number,
  59772. /**
  59773. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59774. */
  59775. step?: number);
  59776. /**
  59777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59778. * @param scene defines the current scene where to apply this optimization
  59779. * @param optimizer defines the current optimizer
  59780. * @returns true if everything that can be done was applied
  59781. */
  59782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59783. }
  59784. /**
  59785. * Defines an optimization used to increase or decrease the rendering resolution
  59786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59787. */
  59788. export class HardwareScalingOptimization extends SceneOptimization {
  59789. /**
  59790. * Defines the priority of this optimization (0 by default which means first in the list)
  59791. */
  59792. priority: number;
  59793. /**
  59794. * Defines the maximum scale to use (2 by default)
  59795. */
  59796. maximumScale: number;
  59797. /**
  59798. * Defines the step to use between two passes (0.5 by default)
  59799. */
  59800. step: number;
  59801. private _currentScale;
  59802. private _directionOffset;
  59803. /**
  59804. * Gets a string describing the action executed by the current optimization
  59805. * @return description string
  59806. */
  59807. getDescription(): string;
  59808. /**
  59809. * Creates the HardwareScalingOptimization object
  59810. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59811. * @param maximumScale defines the maximum scale to use (2 by default)
  59812. * @param step defines the step to use between two passes (0.5 by default)
  59813. */
  59814. constructor(
  59815. /**
  59816. * Defines the priority of this optimization (0 by default which means first in the list)
  59817. */
  59818. priority?: number,
  59819. /**
  59820. * Defines the maximum scale to use (2 by default)
  59821. */
  59822. maximumScale?: number,
  59823. /**
  59824. * Defines the step to use between two passes (0.5 by default)
  59825. */
  59826. step?: number);
  59827. /**
  59828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59829. * @param scene defines the current scene where to apply this optimization
  59830. * @param optimizer defines the current optimizer
  59831. * @returns true if everything that can be done was applied
  59832. */
  59833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59834. }
  59835. /**
  59836. * Defines an optimization used to remove shadows
  59837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59838. */
  59839. export class ShadowsOptimization extends SceneOptimization {
  59840. /**
  59841. * Gets a string describing the action executed by the current optimization
  59842. * @return description string
  59843. */
  59844. getDescription(): string;
  59845. /**
  59846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59847. * @param scene defines the current scene where to apply this optimization
  59848. * @param optimizer defines the current optimizer
  59849. * @returns true if everything that can be done was applied
  59850. */
  59851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59852. }
  59853. /**
  59854. * Defines an optimization used to turn post-processes off
  59855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59856. */
  59857. export class PostProcessesOptimization extends SceneOptimization {
  59858. /**
  59859. * Gets a string describing the action executed by the current optimization
  59860. * @return description string
  59861. */
  59862. getDescription(): string;
  59863. /**
  59864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59865. * @param scene defines the current scene where to apply this optimization
  59866. * @param optimizer defines the current optimizer
  59867. * @returns true if everything that can be done was applied
  59868. */
  59869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59870. }
  59871. /**
  59872. * Defines an optimization used to turn lens flares off
  59873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59874. */
  59875. export class LensFlaresOptimization extends SceneOptimization {
  59876. /**
  59877. * Gets a string describing the action executed by the current optimization
  59878. * @return description string
  59879. */
  59880. getDescription(): string;
  59881. /**
  59882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59883. * @param scene defines the current scene where to apply this optimization
  59884. * @param optimizer defines the current optimizer
  59885. * @returns true if everything that can be done was applied
  59886. */
  59887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59888. }
  59889. /**
  59890. * Defines an optimization based on user defined callback.
  59891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59892. */
  59893. export class CustomOptimization extends SceneOptimization {
  59894. /**
  59895. * Callback called to apply the custom optimization.
  59896. */
  59897. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59898. /**
  59899. * Callback called to get custom description
  59900. */
  59901. onGetDescription: () => string;
  59902. /**
  59903. * Gets a string describing the action executed by the current optimization
  59904. * @returns description string
  59905. */
  59906. getDescription(): string;
  59907. /**
  59908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59909. * @param scene defines the current scene where to apply this optimization
  59910. * @param optimizer defines the current optimizer
  59911. * @returns true if everything that can be done was applied
  59912. */
  59913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59914. }
  59915. /**
  59916. * Defines an optimization used to turn particles off
  59917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59918. */
  59919. export class ParticlesOptimization extends SceneOptimization {
  59920. /**
  59921. * Gets a string describing the action executed by the current optimization
  59922. * @return description string
  59923. */
  59924. getDescription(): string;
  59925. /**
  59926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59927. * @param scene defines the current scene where to apply this optimization
  59928. * @param optimizer defines the current optimizer
  59929. * @returns true if everything that can be done was applied
  59930. */
  59931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59932. }
  59933. /**
  59934. * Defines an optimization used to turn render targets off
  59935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59936. */
  59937. export class RenderTargetsOptimization extends SceneOptimization {
  59938. /**
  59939. * Gets a string describing the action executed by the current optimization
  59940. * @return description string
  59941. */
  59942. getDescription(): string;
  59943. /**
  59944. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59945. * @param scene defines the current scene where to apply this optimization
  59946. * @param optimizer defines the current optimizer
  59947. * @returns true if everything that can be done was applied
  59948. */
  59949. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59950. }
  59951. /**
  59952. * Defines an optimization used to merge meshes with compatible materials
  59953. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59954. */
  59955. export class MergeMeshesOptimization extends SceneOptimization {
  59956. private static _UpdateSelectionTree;
  59957. /**
  59958. * Gets or sets a boolean which defines if optimization octree has to be updated
  59959. */
  59960. /**
  59961. * Gets or sets a boolean which defines if optimization octree has to be updated
  59962. */
  59963. static UpdateSelectionTree: boolean;
  59964. /**
  59965. * Gets a string describing the action executed by the current optimization
  59966. * @return description string
  59967. */
  59968. getDescription(): string;
  59969. private _canBeMerged;
  59970. /**
  59971. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59972. * @param scene defines the current scene where to apply this optimization
  59973. * @param optimizer defines the current optimizer
  59974. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59975. * @returns true if everything that can be done was applied
  59976. */
  59977. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59978. }
  59979. /**
  59980. * Defines a list of options used by SceneOptimizer
  59981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59982. */
  59983. export class SceneOptimizerOptions {
  59984. /**
  59985. * Defines the target frame rate to reach (60 by default)
  59986. */
  59987. targetFrameRate: number;
  59988. /**
  59989. * Defines the interval between two checkes (2000ms by default)
  59990. */
  59991. trackerDuration: number;
  59992. /**
  59993. * Gets the list of optimizations to apply
  59994. */
  59995. optimizations: SceneOptimization[];
  59996. /**
  59997. * Creates a new list of options used by SceneOptimizer
  59998. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59999. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60000. */
  60001. constructor(
  60002. /**
  60003. * Defines the target frame rate to reach (60 by default)
  60004. */
  60005. targetFrameRate?: number,
  60006. /**
  60007. * Defines the interval between two checkes (2000ms by default)
  60008. */
  60009. trackerDuration?: number);
  60010. /**
  60011. * Add a new optimization
  60012. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60013. * @returns the current SceneOptimizerOptions
  60014. */
  60015. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60016. /**
  60017. * Add a new custom optimization
  60018. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60019. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60020. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60021. * @returns the current SceneOptimizerOptions
  60022. */
  60023. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60024. /**
  60025. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60026. * @param targetFrameRate defines the target frame rate (60 by default)
  60027. * @returns a SceneOptimizerOptions object
  60028. */
  60029. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60030. /**
  60031. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60032. * @param targetFrameRate defines the target frame rate (60 by default)
  60033. * @returns a SceneOptimizerOptions object
  60034. */
  60035. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60036. /**
  60037. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60038. * @param targetFrameRate defines the target frame rate (60 by default)
  60039. * @returns a SceneOptimizerOptions object
  60040. */
  60041. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60042. }
  60043. /**
  60044. * Class used to run optimizations in order to reach a target frame rate
  60045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60046. */
  60047. export class SceneOptimizer implements IDisposable {
  60048. private _isRunning;
  60049. private _options;
  60050. private _scene;
  60051. private _currentPriorityLevel;
  60052. private _targetFrameRate;
  60053. private _trackerDuration;
  60054. private _currentFrameRate;
  60055. private _sceneDisposeObserver;
  60056. private _improvementMode;
  60057. /**
  60058. * Defines an observable called when the optimizer reaches the target frame rate
  60059. */
  60060. onSuccessObservable: Observable<SceneOptimizer>;
  60061. /**
  60062. * Defines an observable called when the optimizer enables an optimization
  60063. */
  60064. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60065. /**
  60066. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60067. */
  60068. onFailureObservable: Observable<SceneOptimizer>;
  60069. /**
  60070. * Gets a boolean indicating if the optimizer is in improvement mode
  60071. */
  60072. readonly isInImprovementMode: boolean;
  60073. /**
  60074. * Gets the current priority level (0 at start)
  60075. */
  60076. readonly currentPriorityLevel: number;
  60077. /**
  60078. * Gets the current frame rate checked by the SceneOptimizer
  60079. */
  60080. readonly currentFrameRate: number;
  60081. /**
  60082. * Gets or sets the current target frame rate (60 by default)
  60083. */
  60084. /**
  60085. * Gets or sets the current target frame rate (60 by default)
  60086. */
  60087. targetFrameRate: number;
  60088. /**
  60089. * Gets or sets the current interval between two checks (every 2000ms by default)
  60090. */
  60091. /**
  60092. * Gets or sets the current interval between two checks (every 2000ms by default)
  60093. */
  60094. trackerDuration: number;
  60095. /**
  60096. * Gets the list of active optimizations
  60097. */
  60098. readonly optimizations: SceneOptimization[];
  60099. /**
  60100. * Creates a new SceneOptimizer
  60101. * @param scene defines the scene to work on
  60102. * @param options defines the options to use with the SceneOptimizer
  60103. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60104. * @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)
  60105. */
  60106. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60107. /**
  60108. * Stops the current optimizer
  60109. */
  60110. stop(): void;
  60111. /**
  60112. * Reset the optimizer to initial step (current priority level = 0)
  60113. */
  60114. reset(): void;
  60115. /**
  60116. * Start the optimizer. By default it will try to reach a specific framerate
  60117. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60118. */
  60119. start(): void;
  60120. private _checkCurrentState;
  60121. /**
  60122. * Release all resources
  60123. */
  60124. dispose(): void;
  60125. /**
  60126. * Helper function to create a SceneOptimizer with one single line of code
  60127. * @param scene defines the scene to work on
  60128. * @param options defines the options to use with the SceneOptimizer
  60129. * @param onSuccess defines a callback to call on success
  60130. * @param onFailure defines a callback to call on failure
  60131. * @returns the new SceneOptimizer object
  60132. */
  60133. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60134. }
  60135. }
  60136. declare module BABYLON {
  60137. /**
  60138. * Class used to serialize a scene into a string
  60139. */
  60140. export class SceneSerializer {
  60141. /**
  60142. * Clear cache used by a previous serialization
  60143. */
  60144. static ClearCache(): void;
  60145. /**
  60146. * Serialize a scene into a JSON compatible object
  60147. * @param scene defines the scene to serialize
  60148. * @returns a JSON compatible object
  60149. */
  60150. static Serialize(scene: Scene): any;
  60151. /**
  60152. * Serialize a mesh into a JSON compatible object
  60153. * @param toSerialize defines the mesh to serialize
  60154. * @param withParents defines if parents must be serialized as well
  60155. * @param withChildren defines if children must be serialized as well
  60156. * @returns a JSON compatible object
  60157. */
  60158. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60159. }
  60160. }
  60161. declare module BABYLON {
  60162. /**
  60163. * Class used to host texture specific utilities
  60164. */
  60165. export class TextureTools {
  60166. /**
  60167. * Uses the GPU to create a copy texture rescaled at a given size
  60168. * @param texture Texture to copy from
  60169. * @param width defines the desired width
  60170. * @param height defines the desired height
  60171. * @param useBilinearMode defines if bilinear mode has to be used
  60172. * @return the generated texture
  60173. */
  60174. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60175. }
  60176. }
  60177. declare module BABYLON {
  60178. /**
  60179. * This represents the different options available for the video capture.
  60180. */
  60181. export interface VideoRecorderOptions {
  60182. /** Defines the mime type of the video. */
  60183. mimeType: string;
  60184. /** Defines the FPS the video should be recorded at. */
  60185. fps: number;
  60186. /** Defines the chunk size for the recording data. */
  60187. recordChunckSize: number;
  60188. /** The audio tracks to attach to the recording. */
  60189. audioTracks?: MediaStreamTrack[];
  60190. }
  60191. /**
  60192. * This can help with recording videos from BabylonJS.
  60193. * This is based on the available WebRTC functionalities of the browser.
  60194. *
  60195. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60196. */
  60197. export class VideoRecorder {
  60198. private static readonly _defaultOptions;
  60199. /**
  60200. * Returns whether or not the VideoRecorder is available in your browser.
  60201. * @param engine Defines the Babylon Engine.
  60202. * @returns true if supported otherwise false.
  60203. */
  60204. static IsSupported(engine: Engine): boolean;
  60205. private readonly _options;
  60206. private _canvas;
  60207. private _mediaRecorder;
  60208. private _recordedChunks;
  60209. private _fileName;
  60210. private _resolve;
  60211. private _reject;
  60212. /**
  60213. * True when a recording is already in progress.
  60214. */
  60215. readonly isRecording: boolean;
  60216. /**
  60217. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60218. * @param engine Defines the BabylonJS Engine you wish to record.
  60219. * @param options Defines options that can be used to customize the capture.
  60220. */
  60221. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60222. /**
  60223. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60224. */
  60225. stopRecording(): void;
  60226. /**
  60227. * Starts recording the canvas for a max duration specified in parameters.
  60228. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60229. * If null no automatic download will start and you can rely on the promise to get the data back.
  60230. * @param maxDuration Defines the maximum recording time in seconds.
  60231. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60232. * @return A promise callback at the end of the recording with the video data in Blob.
  60233. */
  60234. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60235. /**
  60236. * Releases internal resources used during the recording.
  60237. */
  60238. dispose(): void;
  60239. private _handleDataAvailable;
  60240. private _handleError;
  60241. private _handleStop;
  60242. }
  60243. }
  60244. declare module BABYLON {
  60245. /**
  60246. * Class containing a set of static utilities functions for screenshots
  60247. */
  60248. export class ScreenshotTools {
  60249. /**
  60250. * Captures a screenshot of the current rendering
  60251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60252. * @param engine defines the rendering engine
  60253. * @param camera defines the source camera
  60254. * @param size This parameter can be set to a single number or to an object with the
  60255. * following (optional) properties: precision, width, height. If a single number is passed,
  60256. * it will be used for both width and height. If an object is passed, the screenshot size
  60257. * will be derived from the parameters. The precision property is a multiplier allowing
  60258. * rendering at a higher or lower resolution
  60259. * @param successCallback defines the callback receives a single parameter which contains the
  60260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60261. * src parameter of an <img> to display it
  60262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60263. * Check your browser for supported MIME types
  60264. */
  60265. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  60266. /**
  60267. * Generates an image screenshot from the specified camera.
  60268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60269. * @param engine The engine to use for rendering
  60270. * @param camera The camera to use for rendering
  60271. * @param size This parameter can be set to a single number or to an object with the
  60272. * following (optional) properties: precision, width, height. If a single number is passed,
  60273. * it will be used for both width and height. If an object is passed, the screenshot size
  60274. * will be derived from the parameters. The precision property is a multiplier allowing
  60275. * rendering at a higher or lower resolution
  60276. * @param successCallback The callback receives a single parameter which contains the
  60277. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60278. * src parameter of an <img> to display it
  60279. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60280. * Check your browser for supported MIME types
  60281. * @param samples Texture samples (default: 1)
  60282. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60283. * @param fileName A name for for the downloaded file.
  60284. */
  60285. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * A cursor which tracks a point on a path
  60291. */
  60292. export class PathCursor {
  60293. private path;
  60294. /**
  60295. * Stores path cursor callbacks for when an onchange event is triggered
  60296. */
  60297. private _onchange;
  60298. /**
  60299. * The value of the path cursor
  60300. */
  60301. value: number;
  60302. /**
  60303. * The animation array of the path cursor
  60304. */
  60305. animations: Animation[];
  60306. /**
  60307. * Initializes the path cursor
  60308. * @param path The path to track
  60309. */
  60310. constructor(path: Path2);
  60311. /**
  60312. * Gets the cursor point on the path
  60313. * @returns A point on the path cursor at the cursor location
  60314. */
  60315. getPoint(): Vector3;
  60316. /**
  60317. * Moves the cursor ahead by the step amount
  60318. * @param step The amount to move the cursor forward
  60319. * @returns This path cursor
  60320. */
  60321. moveAhead(step?: number): PathCursor;
  60322. /**
  60323. * Moves the cursor behind by the step amount
  60324. * @param step The amount to move the cursor back
  60325. * @returns This path cursor
  60326. */
  60327. moveBack(step?: number): PathCursor;
  60328. /**
  60329. * Moves the cursor by the step amount
  60330. * If the step amount is greater than one, an exception is thrown
  60331. * @param step The amount to move the cursor
  60332. * @returns This path cursor
  60333. */
  60334. move(step: number): PathCursor;
  60335. /**
  60336. * Ensures that the value is limited between zero and one
  60337. * @returns This path cursor
  60338. */
  60339. private ensureLimits;
  60340. /**
  60341. * Runs onchange callbacks on change (used by the animation engine)
  60342. * @returns This path cursor
  60343. */
  60344. private raiseOnChange;
  60345. /**
  60346. * Executes a function on change
  60347. * @param f A path cursor onchange callback
  60348. * @returns This path cursor
  60349. */
  60350. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /** @hidden */
  60355. export var blurPixelShader: {
  60356. name: string;
  60357. shader: string;
  60358. };
  60359. }
  60360. declare module BABYLON {
  60361. /** @hidden */
  60362. export var pointCloudVertexDeclaration: {
  60363. name: string;
  60364. shader: string;
  60365. };
  60366. }
  60367. // Mixins
  60368. interface Window {
  60369. mozIndexedDB: IDBFactory;
  60370. webkitIndexedDB: IDBFactory;
  60371. msIndexedDB: IDBFactory;
  60372. webkitURL: typeof URL;
  60373. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60374. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60375. WebGLRenderingContext: WebGLRenderingContext;
  60376. MSGesture: MSGesture;
  60377. CANNON: any;
  60378. AudioContext: AudioContext;
  60379. webkitAudioContext: AudioContext;
  60380. PointerEvent: any;
  60381. Math: Math;
  60382. Uint8Array: Uint8ArrayConstructor;
  60383. Float32Array: Float32ArrayConstructor;
  60384. mozURL: typeof URL;
  60385. msURL: typeof URL;
  60386. VRFrameData: any; // WebVR, from specs 1.1
  60387. DracoDecoderModule: any;
  60388. setImmediate(handler: (...args: any[]) => void): number;
  60389. }
  60390. interface HTMLCanvasElement {
  60391. requestPointerLock(): void;
  60392. msRequestPointerLock?(): void;
  60393. mozRequestPointerLock?(): void;
  60394. webkitRequestPointerLock?(): void;
  60395. /** Track wether a record is in progress */
  60396. isRecording: boolean;
  60397. /** Capture Stream method defined by some browsers */
  60398. captureStream(fps?: number): MediaStream;
  60399. }
  60400. interface CanvasRenderingContext2D {
  60401. msImageSmoothingEnabled: boolean;
  60402. }
  60403. interface MouseEvent {
  60404. mozMovementX: number;
  60405. mozMovementY: number;
  60406. webkitMovementX: number;
  60407. webkitMovementY: number;
  60408. msMovementX: number;
  60409. msMovementY: number;
  60410. }
  60411. interface Navigator {
  60412. mozGetVRDevices: (any: any) => any;
  60413. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60414. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60415. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60416. webkitGetGamepads(): Gamepad[];
  60417. msGetGamepads(): Gamepad[];
  60418. webkitGamepads(): Gamepad[];
  60419. }
  60420. interface HTMLVideoElement {
  60421. mozSrcObject: any;
  60422. }
  60423. interface Math {
  60424. fround(x: number): number;
  60425. imul(a: number, b: number): number;
  60426. }
  60427. interface WebGLRenderingContext {
  60428. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60429. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60430. vertexAttribDivisor(index: number, divisor: number): void;
  60431. createVertexArray(): any;
  60432. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60433. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60434. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60435. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60436. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60437. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60438. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60439. // Queries
  60440. createQuery(): WebGLQuery;
  60441. deleteQuery(query: WebGLQuery): void;
  60442. beginQuery(target: number, query: WebGLQuery): void;
  60443. endQuery(target: number): void;
  60444. getQueryParameter(query: WebGLQuery, pname: number): any;
  60445. getQuery(target: number, pname: number): any;
  60446. MAX_SAMPLES: number;
  60447. RGBA8: number;
  60448. READ_FRAMEBUFFER: number;
  60449. DRAW_FRAMEBUFFER: number;
  60450. UNIFORM_BUFFER: number;
  60451. HALF_FLOAT_OES: number;
  60452. RGBA16F: number;
  60453. RGBA32F: number;
  60454. R32F: number;
  60455. RG32F: number;
  60456. RGB32F: number;
  60457. R16F: number;
  60458. RG16F: number;
  60459. RGB16F: number;
  60460. RED: number;
  60461. RG: number;
  60462. R8: number;
  60463. RG8: number;
  60464. UNSIGNED_INT_24_8: number;
  60465. DEPTH24_STENCIL8: number;
  60466. /* Multiple Render Targets */
  60467. drawBuffers(buffers: number[]): void;
  60468. readBuffer(src: number): void;
  60469. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  60470. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  60471. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  60472. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  60473. // Occlusion Query
  60474. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  60475. ANY_SAMPLES_PASSED: number;
  60476. QUERY_RESULT_AVAILABLE: number;
  60477. QUERY_RESULT: number;
  60478. }
  60479. interface WebGLProgram {
  60480. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60481. }
  60482. interface EXT_disjoint_timer_query {
  60483. QUERY_COUNTER_BITS_EXT: number;
  60484. TIME_ELAPSED_EXT: number;
  60485. TIMESTAMP_EXT: number;
  60486. GPU_DISJOINT_EXT: number;
  60487. QUERY_RESULT_EXT: number;
  60488. QUERY_RESULT_AVAILABLE_EXT: number;
  60489. queryCounterEXT(query: WebGLQuery, target: number): void;
  60490. createQueryEXT(): WebGLQuery;
  60491. beginQueryEXT(target: number, query: WebGLQuery): void;
  60492. endQueryEXT(target: number): void;
  60493. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60494. deleteQueryEXT(query: WebGLQuery): void;
  60495. }
  60496. interface WebGLUniformLocation {
  60497. _currentState: any;
  60498. }
  60499. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60500. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60501. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60502. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60503. interface WebGLRenderingContext {
  60504. readonly RASTERIZER_DISCARD: number;
  60505. readonly DEPTH_COMPONENT24: number;
  60506. readonly TEXTURE_3D: number;
  60507. readonly TEXTURE_2D_ARRAY: number;
  60508. readonly TEXTURE_COMPARE_FUNC: number;
  60509. readonly TEXTURE_COMPARE_MODE: number;
  60510. readonly COMPARE_REF_TO_TEXTURE: number;
  60511. readonly TEXTURE_WRAP_R: number;
  60512. readonly HALF_FLOAT: number;
  60513. readonly RGB8: number;
  60514. readonly RED_INTEGER: number;
  60515. readonly RG_INTEGER: number;
  60516. readonly RGB_INTEGER: number;
  60517. readonly RGBA_INTEGER: number;
  60518. readonly R8_SNORM: number;
  60519. readonly RG8_SNORM: number;
  60520. readonly RGB8_SNORM: number;
  60521. readonly RGBA8_SNORM: number;
  60522. readonly R8I: number;
  60523. readonly RG8I: number;
  60524. readonly RGB8I: number;
  60525. readonly RGBA8I: number;
  60526. readonly R8UI: number;
  60527. readonly RG8UI: number;
  60528. readonly RGB8UI: number;
  60529. readonly RGBA8UI: number;
  60530. readonly R16I: number;
  60531. readonly RG16I: number;
  60532. readonly RGB16I: number;
  60533. readonly RGBA16I: number;
  60534. readonly R16UI: number;
  60535. readonly RG16UI: number;
  60536. readonly RGB16UI: number;
  60537. readonly RGBA16UI: number;
  60538. readonly R32I: number;
  60539. readonly RG32I: number;
  60540. readonly RGB32I: number;
  60541. readonly RGBA32I: number;
  60542. readonly R32UI: number;
  60543. readonly RG32UI: number;
  60544. readonly RGB32UI: number;
  60545. readonly RGBA32UI: number;
  60546. readonly RGB10_A2UI: number;
  60547. readonly R11F_G11F_B10F: number;
  60548. readonly RGB9_E5: number;
  60549. readonly RGB10_A2: number;
  60550. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60551. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60552. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60553. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60554. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60555. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60556. 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;
  60557. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60558. readonly TRANSFORM_FEEDBACK: number;
  60559. readonly INTERLEAVED_ATTRIBS: number;
  60560. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60561. createTransformFeedback(): WebGLTransformFeedback;
  60562. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60563. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60564. beginTransformFeedback(primitiveMode: number): void;
  60565. endTransformFeedback(): void;
  60566. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60567. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60568. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60569. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60570. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60571. }
  60572. interface ImageBitmap {
  60573. readonly width: number;
  60574. readonly height: number;
  60575. close(): void;
  60576. }
  60577. interface WebGLQuery extends WebGLObject {
  60578. }
  60579. declare var WebGLQuery: {
  60580. prototype: WebGLQuery;
  60581. new(): WebGLQuery;
  60582. };
  60583. interface WebGLSampler extends WebGLObject {
  60584. }
  60585. declare var WebGLSampler: {
  60586. prototype: WebGLSampler;
  60587. new(): WebGLSampler;
  60588. };
  60589. interface WebGLSync extends WebGLObject {
  60590. }
  60591. declare var WebGLSync: {
  60592. prototype: WebGLSync;
  60593. new(): WebGLSync;
  60594. };
  60595. interface WebGLTransformFeedback extends WebGLObject {
  60596. }
  60597. declare var WebGLTransformFeedback: {
  60598. prototype: WebGLTransformFeedback;
  60599. new(): WebGLTransformFeedback;
  60600. };
  60601. interface WebGLVertexArrayObject extends WebGLObject {
  60602. }
  60603. declare var WebGLVertexArrayObject: {
  60604. prototype: WebGLVertexArrayObject;
  60605. new(): WebGLVertexArrayObject;
  60606. };
  60607. // Type definitions for WebVR API
  60608. // Project: https://w3c.github.io/webvr/
  60609. // Definitions by: six a <https://github.com/lostfictions>
  60610. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60611. interface VRDisplay extends EventTarget {
  60612. /**
  60613. * Dictionary of capabilities describing the VRDisplay.
  60614. */
  60615. readonly capabilities: VRDisplayCapabilities;
  60616. /**
  60617. * z-depth defining the far plane of the eye view frustum
  60618. * enables mapping of values in the render target depth
  60619. * attachment to scene coordinates. Initially set to 10000.0.
  60620. */
  60621. depthFar: number;
  60622. /**
  60623. * z-depth defining the near plane of the eye view frustum
  60624. * enables mapping of values in the render target depth
  60625. * attachment to scene coordinates. Initially set to 0.01.
  60626. */
  60627. depthNear: number;
  60628. /**
  60629. * An identifier for this distinct VRDisplay. Used as an
  60630. * association point in the Gamepad API.
  60631. */
  60632. readonly displayId: number;
  60633. /**
  60634. * A display name, a user-readable name identifying it.
  60635. */
  60636. readonly displayName: string;
  60637. readonly isConnected: boolean;
  60638. readonly isPresenting: boolean;
  60639. /**
  60640. * If this VRDisplay supports room-scale experiences, the optional
  60641. * stage attribute contains details on the room-scale parameters.
  60642. */
  60643. readonly stageParameters: VRStageParameters | null;
  60644. /**
  60645. * Passing the value returned by `requestAnimationFrame` to
  60646. * `cancelAnimationFrame` will unregister the callback.
  60647. * @param handle Define the hanle of the request to cancel
  60648. */
  60649. cancelAnimationFrame(handle: number): void;
  60650. /**
  60651. * Stops presenting to the VRDisplay.
  60652. * @returns a promise to know when it stopped
  60653. */
  60654. exitPresent(): Promise<void>;
  60655. /**
  60656. * Return the current VREyeParameters for the given eye.
  60657. * @param whichEye Define the eye we want the parameter for
  60658. * @returns the eye parameters
  60659. */
  60660. getEyeParameters(whichEye: string): VREyeParameters;
  60661. /**
  60662. * Populates the passed VRFrameData with the information required to render
  60663. * the current frame.
  60664. * @param frameData Define the data structure to populate
  60665. * @returns true if ok otherwise false
  60666. */
  60667. getFrameData(frameData: VRFrameData): boolean;
  60668. /**
  60669. * Get the layers currently being presented.
  60670. * @returns the list of VR layers
  60671. */
  60672. getLayers(): VRLayer[];
  60673. /**
  60674. * Return a VRPose containing the future predicted pose of the VRDisplay
  60675. * when the current frame will be presented. The value returned will not
  60676. * change until JavaScript has returned control to the browser.
  60677. *
  60678. * The VRPose will contain the position, orientation, velocity,
  60679. * and acceleration of each of these properties.
  60680. * @returns the pose object
  60681. */
  60682. getPose(): VRPose;
  60683. /**
  60684. * Return the current instantaneous pose of the VRDisplay, with no
  60685. * prediction applied.
  60686. * @returns the current instantaneous pose
  60687. */
  60688. getImmediatePose(): VRPose;
  60689. /**
  60690. * The callback passed to `requestAnimationFrame` will be called
  60691. * any time a new frame should be rendered. When the VRDisplay is
  60692. * presenting the callback will be called at the native refresh
  60693. * rate of the HMD. When not presenting this function acts
  60694. * identically to how window.requestAnimationFrame acts. Content should
  60695. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60696. * asynchronously from other displays and at differing refresh rates.
  60697. * @param callback Define the eaction to run next frame
  60698. * @returns the request handle it
  60699. */
  60700. requestAnimationFrame(callback: FrameRequestCallback): number;
  60701. /**
  60702. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60703. * Repeat calls while already presenting will update the VRLayers being displayed.
  60704. * @param layers Define the list of layer to present
  60705. * @returns a promise to know when the request has been fulfilled
  60706. */
  60707. requestPresent(layers: VRLayer[]): Promise<void>;
  60708. /**
  60709. * Reset the pose for this display, treating its current position and
  60710. * orientation as the "origin/zero" values. VRPose.position,
  60711. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60712. * updated when calling resetPose(). This should be called in only
  60713. * sitting-space experiences.
  60714. */
  60715. resetPose(): void;
  60716. /**
  60717. * The VRLayer provided to the VRDisplay will be captured and presented
  60718. * in the HMD. Calling this function has the same effect on the source
  60719. * canvas as any other operation that uses its source image, and canvases
  60720. * created without preserveDrawingBuffer set to true will be cleared.
  60721. * @param pose Define the pose to submit
  60722. */
  60723. submitFrame(pose?: VRPose): void;
  60724. }
  60725. declare var VRDisplay: {
  60726. prototype: VRDisplay;
  60727. new(): VRDisplay;
  60728. };
  60729. interface VRLayer {
  60730. leftBounds?: number[] | Float32Array | null;
  60731. rightBounds?: number[] | Float32Array | null;
  60732. source?: HTMLCanvasElement | null;
  60733. }
  60734. interface VRDisplayCapabilities {
  60735. readonly canPresent: boolean;
  60736. readonly hasExternalDisplay: boolean;
  60737. readonly hasOrientation: boolean;
  60738. readonly hasPosition: boolean;
  60739. readonly maxLayers: number;
  60740. }
  60741. interface VREyeParameters {
  60742. /** @deprecated */
  60743. readonly fieldOfView: VRFieldOfView;
  60744. readonly offset: Float32Array;
  60745. readonly renderHeight: number;
  60746. readonly renderWidth: number;
  60747. }
  60748. interface VRFieldOfView {
  60749. readonly downDegrees: number;
  60750. readonly leftDegrees: number;
  60751. readonly rightDegrees: number;
  60752. readonly upDegrees: number;
  60753. }
  60754. interface VRFrameData {
  60755. readonly leftProjectionMatrix: Float32Array;
  60756. readonly leftViewMatrix: Float32Array;
  60757. readonly pose: VRPose;
  60758. readonly rightProjectionMatrix: Float32Array;
  60759. readonly rightViewMatrix: Float32Array;
  60760. readonly timestamp: number;
  60761. }
  60762. interface VRPose {
  60763. readonly angularAcceleration: Float32Array | null;
  60764. readonly angularVelocity: Float32Array | null;
  60765. readonly linearAcceleration: Float32Array | null;
  60766. readonly linearVelocity: Float32Array | null;
  60767. readonly orientation: Float32Array | null;
  60768. readonly position: Float32Array | null;
  60769. readonly timestamp: number;
  60770. }
  60771. interface VRStageParameters {
  60772. sittingToStandingTransform?: Float32Array;
  60773. sizeX?: number;
  60774. sizeY?: number;
  60775. }
  60776. interface Navigator {
  60777. getVRDisplays(): Promise<VRDisplay[]>;
  60778. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60779. }
  60780. interface Window {
  60781. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60782. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60783. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60784. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60785. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60786. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60787. }
  60788. interface Gamepad {
  60789. readonly displayId: number;
  60790. }
  60791. type XRSessionMode =
  60792. | "inline"
  60793. | "immersive-vr"
  60794. | "immersive-ar";
  60795. type XRReferenceSpaceType =
  60796. | "viewer"
  60797. | "local"
  60798. | "local-floor"
  60799. | "bounded-floor"
  60800. | "unbounded";
  60801. type XREnvironmentBlendMode =
  60802. | "opaque"
  60803. | "additive"
  60804. | "alpha-blend";
  60805. type XRVisibilityState =
  60806. | "visible"
  60807. | "visible-blurred"
  60808. | "hidden";
  60809. type XRHandedness =
  60810. | "none"
  60811. | "left"
  60812. | "right";
  60813. type XRTargetRayMode =
  60814. | "gaze"
  60815. | "tracked-pointer"
  60816. | "screen";
  60817. type XREye =
  60818. | "none"
  60819. | "left"
  60820. | "right";
  60821. interface XRSpace extends EventTarget {
  60822. }
  60823. interface XRRenderState {
  60824. depthNear?: number;
  60825. depthFar?: number;
  60826. inlineVerticalFieldOfView?: number;
  60827. baseLayer?: XRWebGLLayer;
  60828. }
  60829. interface XRInputSource {
  60830. handedness: XRHandedness;
  60831. targetRayMode: XRTargetRayMode;
  60832. targetRaySpace: XRSpace;
  60833. gripSpace: XRSpace | undefined;
  60834. gamepad: Gamepad | undefined;
  60835. profiles: Array<string>;
  60836. }
  60837. interface XRSession {
  60838. addEventListener: Function;
  60839. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60840. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60841. requestAnimationFrame: Function;
  60842. end(): Promise<void>;
  60843. renderState: XRRenderState;
  60844. inputSources: Array<XRInputSource>;
  60845. }
  60846. interface XRReferenceSpace extends XRSpace {
  60847. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60848. onreset: any;
  60849. }
  60850. interface XRFrame {
  60851. session: XRSession;
  60852. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60853. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60854. }
  60855. interface XRViewerPose extends XRPose {
  60856. views: Array<XRView>;
  60857. }
  60858. interface XRPose {
  60859. transform: XRRigidTransform;
  60860. emulatedPosition: boolean;
  60861. }
  60862. declare var XRWebGLLayer: {
  60863. prototype: XRWebGLLayer;
  60864. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60865. };
  60866. interface XRWebGLLayer {
  60867. framebuffer: WebGLFramebuffer;
  60868. framebufferWidth: number;
  60869. framebufferHeight: number;
  60870. getViewport: Function;
  60871. }
  60872. interface XRRigidTransform {
  60873. position: DOMPointReadOnly;
  60874. orientation: DOMPointReadOnly;
  60875. matrix: Float32Array;
  60876. inverse: XRRigidTransform;
  60877. }
  60878. interface XRView {
  60879. eye: XREye;
  60880. projectionMatrix: Float32Array;
  60881. transform: XRRigidTransform;
  60882. }
  60883. interface XRInputSourceChangeEvent {
  60884. session: XRSession;
  60885. removed: Array<XRInputSource>;
  60886. added: Array<XRInputSource>;
  60887. }
  60888. declare module BABYLON.GUI {
  60889. /**
  60890. * Class used to specific a value and its associated unit
  60891. */
  60892. export class ValueAndUnit {
  60893. /** defines the unit to store */
  60894. unit: number;
  60895. /** defines a boolean indicating if the value can be negative */
  60896. negativeValueAllowed: boolean;
  60897. private _value;
  60898. private _originalUnit;
  60899. /**
  60900. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60901. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60902. */
  60903. ignoreAdaptiveScaling: boolean;
  60904. /**
  60905. * Creates a new ValueAndUnit
  60906. * @param value defines the value to store
  60907. * @param unit defines the unit to store
  60908. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60909. */
  60910. constructor(value: number,
  60911. /** defines the unit to store */
  60912. unit?: number,
  60913. /** defines a boolean indicating if the value can be negative */
  60914. negativeValueAllowed?: boolean);
  60915. /** Gets a boolean indicating if the value is a percentage */
  60916. readonly isPercentage: boolean;
  60917. /** Gets a boolean indicating if the value is store as pixel */
  60918. readonly isPixel: boolean;
  60919. /** Gets direct internal value */
  60920. readonly internalValue: number;
  60921. /**
  60922. * Gets value as pixel
  60923. * @param host defines the root host
  60924. * @param refValue defines the reference value for percentages
  60925. * @returns the value as pixel
  60926. */
  60927. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60928. /**
  60929. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60930. * @param value defines the value to store
  60931. * @param unit defines the unit to store
  60932. * @returns the current ValueAndUnit
  60933. */
  60934. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60935. /**
  60936. * Gets the value accordingly to its unit
  60937. * @param host defines the root host
  60938. * @returns the value
  60939. */
  60940. getValue(host: AdvancedDynamicTexture): number;
  60941. /**
  60942. * Gets a string representation of the value
  60943. * @param host defines the root host
  60944. * @param decimals defines an optional number of decimals to display
  60945. * @returns a string
  60946. */
  60947. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60948. /**
  60949. * Store a value parsed from a string
  60950. * @param source defines the source string
  60951. * @returns true if the value was successfully parsed
  60952. */
  60953. fromString(source: string | number): boolean;
  60954. private static _Regex;
  60955. private static _UNITMODE_PERCENTAGE;
  60956. private static _UNITMODE_PIXEL;
  60957. /** UNITMODE_PERCENTAGE */
  60958. static readonly UNITMODE_PERCENTAGE: number;
  60959. /** UNITMODE_PIXEL */
  60960. static readonly UNITMODE_PIXEL: number;
  60961. }
  60962. }
  60963. declare module BABYLON.GUI {
  60964. /**
  60965. * Define a style used by control to automatically setup properties based on a template.
  60966. * Only support font related properties so far
  60967. */
  60968. export class Style implements BABYLON.IDisposable {
  60969. private _fontFamily;
  60970. private _fontStyle;
  60971. private _fontWeight;
  60972. /** @hidden */
  60973. _host: AdvancedDynamicTexture;
  60974. /** @hidden */
  60975. _fontSize: ValueAndUnit;
  60976. /**
  60977. * BABYLON.Observable raised when the style values are changed
  60978. */
  60979. onChangedObservable: BABYLON.Observable<Style>;
  60980. /**
  60981. * Creates a new style object
  60982. * @param host defines the AdvancedDynamicTexture which hosts this style
  60983. */
  60984. constructor(host: AdvancedDynamicTexture);
  60985. /**
  60986. * Gets or sets the font size
  60987. */
  60988. fontSize: string | number;
  60989. /**
  60990. * Gets or sets the font family
  60991. */
  60992. fontFamily: string;
  60993. /**
  60994. * Gets or sets the font style
  60995. */
  60996. fontStyle: string;
  60997. /** Gets or sets font weight */
  60998. fontWeight: string;
  60999. /** Dispose all associated resources */
  61000. dispose(): void;
  61001. }
  61002. }
  61003. declare module BABYLON.GUI {
  61004. /**
  61005. * Class used to transport BABYLON.Vector2 information for pointer events
  61006. */
  61007. export class Vector2WithInfo extends BABYLON.Vector2 {
  61008. /** defines the current mouse button index */
  61009. buttonIndex: number;
  61010. /**
  61011. * Creates a new Vector2WithInfo
  61012. * @param source defines the vector2 data to transport
  61013. * @param buttonIndex defines the current mouse button index
  61014. */
  61015. constructor(source: BABYLON.Vector2,
  61016. /** defines the current mouse button index */
  61017. buttonIndex?: number);
  61018. }
  61019. /** Class used to provide 2D matrix features */
  61020. export class Matrix2D {
  61021. /** Gets the internal array of 6 floats used to store matrix data */
  61022. m: Float32Array;
  61023. /**
  61024. * Creates a new matrix
  61025. * @param m00 defines value for (0, 0)
  61026. * @param m01 defines value for (0, 1)
  61027. * @param m10 defines value for (1, 0)
  61028. * @param m11 defines value for (1, 1)
  61029. * @param m20 defines value for (2, 0)
  61030. * @param m21 defines value for (2, 1)
  61031. */
  61032. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61033. /**
  61034. * Fills the matrix from direct values
  61035. * @param m00 defines value for (0, 0)
  61036. * @param m01 defines value for (0, 1)
  61037. * @param m10 defines value for (1, 0)
  61038. * @param m11 defines value for (1, 1)
  61039. * @param m20 defines value for (2, 0)
  61040. * @param m21 defines value for (2, 1)
  61041. * @returns the current modified matrix
  61042. */
  61043. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61044. /**
  61045. * Gets matrix determinant
  61046. * @returns the determinant
  61047. */
  61048. determinant(): number;
  61049. /**
  61050. * Inverses the matrix and stores it in a target matrix
  61051. * @param result defines the target matrix
  61052. * @returns the current matrix
  61053. */
  61054. invertToRef(result: Matrix2D): Matrix2D;
  61055. /**
  61056. * Multiplies the current matrix with another one
  61057. * @param other defines the second operand
  61058. * @param result defines the target matrix
  61059. * @returns the current matrix
  61060. */
  61061. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61062. /**
  61063. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61064. * @param x defines the x coordinate to transform
  61065. * @param y defines the x coordinate to transform
  61066. * @param result defines the target vector2
  61067. * @returns the current matrix
  61068. */
  61069. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61070. /**
  61071. * Creates an identity matrix
  61072. * @returns a new matrix
  61073. */
  61074. static Identity(): Matrix2D;
  61075. /**
  61076. * Creates a translation matrix and stores it in a target matrix
  61077. * @param x defines the x coordinate of the translation
  61078. * @param y defines the y coordinate of the translation
  61079. * @param result defines the target matrix
  61080. */
  61081. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61082. /**
  61083. * Creates a scaling matrix and stores it in a target matrix
  61084. * @param x defines the x coordinate of the scaling
  61085. * @param y defines the y coordinate of the scaling
  61086. * @param result defines the target matrix
  61087. */
  61088. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61089. /**
  61090. * Creates a rotation matrix and stores it in a target matrix
  61091. * @param angle defines the rotation angle
  61092. * @param result defines the target matrix
  61093. */
  61094. static RotationToRef(angle: number, result: Matrix2D): void;
  61095. private static _TempPreTranslationMatrix;
  61096. private static _TempPostTranslationMatrix;
  61097. private static _TempRotationMatrix;
  61098. private static _TempScalingMatrix;
  61099. private static _TempCompose0;
  61100. private static _TempCompose1;
  61101. private static _TempCompose2;
  61102. /**
  61103. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61104. * @param tx defines the x coordinate of the translation
  61105. * @param ty defines the y coordinate of the translation
  61106. * @param angle defines the rotation angle
  61107. * @param scaleX defines the x coordinate of the scaling
  61108. * @param scaleY defines the y coordinate of the scaling
  61109. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61110. * @param result defines the target matrix
  61111. */
  61112. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61113. }
  61114. }
  61115. declare module BABYLON.GUI {
  61116. /**
  61117. * Class used to store 2D control sizes
  61118. */
  61119. export class Measure {
  61120. /** defines left coordinate */
  61121. left: number;
  61122. /** defines top coordinate */
  61123. top: number;
  61124. /** defines width dimension */
  61125. width: number;
  61126. /** defines height dimension */
  61127. height: number;
  61128. /**
  61129. * Creates a new measure
  61130. * @param left defines left coordinate
  61131. * @param top defines top coordinate
  61132. * @param width defines width dimension
  61133. * @param height defines height dimension
  61134. */
  61135. constructor(
  61136. /** defines left coordinate */
  61137. left: number,
  61138. /** defines top coordinate */
  61139. top: number,
  61140. /** defines width dimension */
  61141. width: number,
  61142. /** defines height dimension */
  61143. height: number);
  61144. /**
  61145. * Copy from another measure
  61146. * @param other defines the other measure to copy from
  61147. */
  61148. copyFrom(other: Measure): void;
  61149. /**
  61150. * Copy from a group of 4 floats
  61151. * @param left defines left coordinate
  61152. * @param top defines top coordinate
  61153. * @param width defines width dimension
  61154. * @param height defines height dimension
  61155. */
  61156. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61157. /**
  61158. * Computes the axis aligned bounding box measure for two given measures
  61159. * @param a Input measure
  61160. * @param b Input measure
  61161. * @param result the resulting bounding measure
  61162. */
  61163. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61164. /**
  61165. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61166. * @param transform the matrix to transform the measure before computing the AABB
  61167. * @param result the resulting AABB
  61168. */
  61169. transformToRef(transform: Matrix2D, result: Measure): void;
  61170. /**
  61171. * Check equality between this measure and another one
  61172. * @param other defines the other measures
  61173. * @returns true if both measures are equals
  61174. */
  61175. isEqualsTo(other: Measure): boolean;
  61176. /**
  61177. * Creates an empty measure
  61178. * @returns a new measure
  61179. */
  61180. static Empty(): Measure;
  61181. }
  61182. }
  61183. declare module BABYLON.GUI {
  61184. /**
  61185. * Interface used to define a control that can receive focus
  61186. */
  61187. export interface IFocusableControl {
  61188. /**
  61189. * Function called when the control receives the focus
  61190. */
  61191. onFocus(): void;
  61192. /**
  61193. * Function called when the control loses the focus
  61194. */
  61195. onBlur(): void;
  61196. /**
  61197. * Function called to let the control handle keyboard events
  61198. * @param evt defines the current keyboard event
  61199. */
  61200. processKeyboard(evt: KeyboardEvent): void;
  61201. /**
  61202. * Function called to get the list of controls that should not steal the focus from this control
  61203. * @returns an array of controls
  61204. */
  61205. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61206. }
  61207. /**
  61208. * Class used to create texture to support 2D GUI elements
  61209. * @see http://doc.babylonjs.com/how_to/gui
  61210. */
  61211. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61212. private _isDirty;
  61213. private _renderObserver;
  61214. private _resizeObserver;
  61215. private _preKeyboardObserver;
  61216. private _pointerMoveObserver;
  61217. private _pointerObserver;
  61218. private _canvasPointerOutObserver;
  61219. private _background;
  61220. /** @hidden */
  61221. _rootContainer: Container;
  61222. /** @hidden */
  61223. _lastPickedControl: Control;
  61224. /** @hidden */
  61225. _lastControlOver: {
  61226. [pointerId: number]: Control;
  61227. };
  61228. /** @hidden */
  61229. _lastControlDown: {
  61230. [pointerId: number]: Control;
  61231. };
  61232. /** @hidden */
  61233. _capturingControl: {
  61234. [pointerId: number]: Control;
  61235. };
  61236. /** @hidden */
  61237. _shouldBlockPointer: boolean;
  61238. /** @hidden */
  61239. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61240. /** @hidden */
  61241. _linkedControls: Control[];
  61242. private _isFullscreen;
  61243. private _fullscreenViewport;
  61244. private _idealWidth;
  61245. private _idealHeight;
  61246. private _useSmallestIdeal;
  61247. private _renderAtIdealSize;
  61248. private _focusedControl;
  61249. private _blockNextFocusCheck;
  61250. private _renderScale;
  61251. private _rootCanvas;
  61252. private _cursorChanged;
  61253. /**
  61254. * Define type to string to ensure compatibility across browsers
  61255. * Safari doesn't support DataTransfer constructor
  61256. */
  61257. private _clipboardData;
  61258. /**
  61259. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61260. */
  61261. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61262. /**
  61263. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61264. */
  61265. onControlPickedObservable: BABYLON.Observable<Control>;
  61266. /**
  61267. * BABYLON.Observable event triggered before layout is evaluated
  61268. */
  61269. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61270. /**
  61271. * BABYLON.Observable event triggered after the layout was evaluated
  61272. */
  61273. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61274. /**
  61275. * BABYLON.Observable event triggered before the texture is rendered
  61276. */
  61277. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61278. /**
  61279. * BABYLON.Observable event triggered after the texture was rendered
  61280. */
  61281. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61282. /**
  61283. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61284. */
  61285. premulAlpha: boolean;
  61286. /**
  61287. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61288. * Useful when you want more antialiasing
  61289. */
  61290. renderScale: number;
  61291. /** Gets or sets the background color */
  61292. background: string;
  61293. /**
  61294. * Gets or sets the ideal width used to design controls.
  61295. * The GUI will then rescale everything accordingly
  61296. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61297. */
  61298. idealWidth: number;
  61299. /**
  61300. * Gets or sets the ideal height used to design controls.
  61301. * The GUI will then rescale everything accordingly
  61302. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61303. */
  61304. idealHeight: number;
  61305. /**
  61306. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61307. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61308. */
  61309. useSmallestIdeal: boolean;
  61310. /**
  61311. * Gets or sets a boolean indicating if adaptive scaling must be used
  61312. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61313. */
  61314. renderAtIdealSize: boolean;
  61315. /**
  61316. * Gets the underlying layer used to render the texture when in fullscreen mode
  61317. */
  61318. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61319. /**
  61320. * Gets the root container control
  61321. */
  61322. readonly rootContainer: Container;
  61323. /**
  61324. * Returns an array containing the root container.
  61325. * This is mostly used to let the Inspector introspects the ADT
  61326. * @returns an array containing the rootContainer
  61327. */
  61328. getChildren(): Array<Container>;
  61329. /**
  61330. * Will return all controls that are inside this texture
  61331. * @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
  61332. * @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
  61333. * @return all child controls
  61334. */
  61335. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61336. /**
  61337. * Gets or sets the current focused control
  61338. */
  61339. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61340. /**
  61341. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61342. */
  61343. isForeground: boolean;
  61344. /**
  61345. * Gets or set information about clipboardData
  61346. */
  61347. clipboardData: string;
  61348. /**
  61349. * Creates a new AdvancedDynamicTexture
  61350. * @param name defines the name of the texture
  61351. * @param width defines the width of the texture
  61352. * @param height defines the height of the texture
  61353. * @param scene defines the hosting scene
  61354. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61355. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61356. */
  61357. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61358. /**
  61359. * Get the current class name of the texture useful for serialization or dynamic coding.
  61360. * @returns "AdvancedDynamicTexture"
  61361. */
  61362. getClassName(): string;
  61363. /**
  61364. * Function used to execute a function on all controls
  61365. * @param func defines the function to execute
  61366. * @param container defines the container where controls belong. If null the root container will be used
  61367. */
  61368. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61369. private _useInvalidateRectOptimization;
  61370. /**
  61371. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61372. */
  61373. useInvalidateRectOptimization: boolean;
  61374. private _invalidatedRectangle;
  61375. /**
  61376. * Invalidates a rectangle area on the gui texture
  61377. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61378. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61379. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61380. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61381. */
  61382. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61383. /**
  61384. * Marks the texture as dirty forcing a complete update
  61385. */
  61386. markAsDirty(): void;
  61387. /**
  61388. * Helper function used to create a new style
  61389. * @returns a new style
  61390. * @see http://doc.babylonjs.com/how_to/gui#styles
  61391. */
  61392. createStyle(): Style;
  61393. /**
  61394. * Adds a new control to the root container
  61395. * @param control defines the control to add
  61396. * @returns the current texture
  61397. */
  61398. addControl(control: Control): AdvancedDynamicTexture;
  61399. /**
  61400. * Removes a control from the root container
  61401. * @param control defines the control to remove
  61402. * @returns the current texture
  61403. */
  61404. removeControl(control: Control): AdvancedDynamicTexture;
  61405. /**
  61406. * Release all resources
  61407. */
  61408. dispose(): void;
  61409. private _onResize;
  61410. /** @hidden */
  61411. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61412. /**
  61413. * Get screen coordinates for a vector3
  61414. * @param position defines the position to project
  61415. * @param worldMatrix defines the world matrix to use
  61416. * @returns the projected position
  61417. */
  61418. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61419. private _checkUpdate;
  61420. private _clearMeasure;
  61421. private _render;
  61422. /** @hidden */
  61423. _changeCursor(cursor: string): void;
  61424. /** @hidden */
  61425. _registerLastControlDown(control: Control, pointerId: number): void;
  61426. private _doPicking;
  61427. /** @hidden */
  61428. _cleanControlAfterRemovalFromList(list: {
  61429. [pointerId: number]: Control;
  61430. }, control: Control): void;
  61431. /** @hidden */
  61432. _cleanControlAfterRemoval(control: Control): void;
  61433. /** Attach to all scene events required to support pointer events */
  61434. attach(): void;
  61435. /** @hidden */
  61436. private onClipboardCopy;
  61437. /** @hidden */
  61438. private onClipboardCut;
  61439. /** @hidden */
  61440. private onClipboardPaste;
  61441. /**
  61442. * Register the clipboard Events onto the canvas
  61443. */
  61444. registerClipboardEvents(): void;
  61445. /**
  61446. * Unregister the clipboard Events from the canvas
  61447. */
  61448. unRegisterClipboardEvents(): void;
  61449. /**
  61450. * Connect the texture to a hosting mesh to enable interactions
  61451. * @param mesh defines the mesh to attach to
  61452. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  61453. */
  61454. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  61455. /**
  61456. * Move the focus to a specific control
  61457. * @param control defines the control which will receive the focus
  61458. */
  61459. moveFocusToControl(control: IFocusableControl): void;
  61460. private _manageFocus;
  61461. private _attachToOnPointerOut;
  61462. /**
  61463. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  61464. * @param mesh defines the mesh which will receive the texture
  61465. * @param width defines the texture width (1024 by default)
  61466. * @param height defines the texture height (1024 by default)
  61467. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  61468. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  61469. * @returns a new AdvancedDynamicTexture
  61470. */
  61471. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  61472. /**
  61473. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  61474. * In this mode the texture will rely on a layer for its rendering.
  61475. * This allows it to be treated like any other layer.
  61476. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  61477. * LayerMask is set through advancedTexture.layer.layerMask
  61478. * @param name defines name for the texture
  61479. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61480. * @param scene defines the hsoting scene
  61481. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61482. * @returns a new AdvancedDynamicTexture
  61483. */
  61484. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61485. }
  61486. }
  61487. declare module BABYLON.GUI {
  61488. /**
  61489. * Root class used for all 2D controls
  61490. * @see http://doc.babylonjs.com/how_to/gui#controls
  61491. */
  61492. export class Control {
  61493. /** defines the name of the control */
  61494. name?: string | undefined;
  61495. /**
  61496. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61497. */
  61498. static AllowAlphaInheritance: boolean;
  61499. private _alpha;
  61500. private _alphaSet;
  61501. private _zIndex;
  61502. /** @hidden */
  61503. _host: AdvancedDynamicTexture;
  61504. /** Gets or sets the control parent */
  61505. parent: BABYLON.Nullable<Container>;
  61506. /** @hidden */
  61507. _currentMeasure: Measure;
  61508. private _fontFamily;
  61509. private _fontStyle;
  61510. private _fontWeight;
  61511. private _fontSize;
  61512. private _font;
  61513. /** @hidden */
  61514. _width: ValueAndUnit;
  61515. /** @hidden */
  61516. _height: ValueAndUnit;
  61517. /** @hidden */
  61518. protected _fontOffset: {
  61519. ascent: number;
  61520. height: number;
  61521. descent: number;
  61522. };
  61523. private _color;
  61524. private _style;
  61525. private _styleObserver;
  61526. /** @hidden */
  61527. protected _horizontalAlignment: number;
  61528. /** @hidden */
  61529. protected _verticalAlignment: number;
  61530. /** @hidden */
  61531. protected _isDirty: boolean;
  61532. /** @hidden */
  61533. protected _wasDirty: boolean;
  61534. /** @hidden */
  61535. _tempParentMeasure: Measure;
  61536. /** @hidden */
  61537. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61538. /** @hidden */
  61539. protected _cachedParentMeasure: Measure;
  61540. private _paddingLeft;
  61541. private _paddingRight;
  61542. private _paddingTop;
  61543. private _paddingBottom;
  61544. /** @hidden */
  61545. _left: ValueAndUnit;
  61546. /** @hidden */
  61547. _top: ValueAndUnit;
  61548. private _scaleX;
  61549. private _scaleY;
  61550. private _rotation;
  61551. private _transformCenterX;
  61552. private _transformCenterY;
  61553. /** @hidden */
  61554. _transformMatrix: Matrix2D;
  61555. /** @hidden */
  61556. protected _invertTransformMatrix: Matrix2D;
  61557. /** @hidden */
  61558. protected _transformedPosition: BABYLON.Vector2;
  61559. private _isMatrixDirty;
  61560. private _cachedOffsetX;
  61561. private _cachedOffsetY;
  61562. private _isVisible;
  61563. private _isHighlighted;
  61564. /** @hidden */
  61565. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61566. private _fontSet;
  61567. private _dummyVector2;
  61568. private _downCount;
  61569. private _enterCount;
  61570. private _doNotRender;
  61571. private _downPointerIds;
  61572. protected _isEnabled: boolean;
  61573. protected _disabledColor: string;
  61574. /** @hidden */
  61575. protected _rebuildLayout: boolean;
  61576. /** @hidden */
  61577. _isClipped: boolean;
  61578. /** @hidden */
  61579. _tag: any;
  61580. /**
  61581. * 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
  61582. */
  61583. uniqueId: number;
  61584. /**
  61585. * Gets or sets an object used to store user defined information for the node
  61586. */
  61587. metadata: any;
  61588. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61589. isHitTestVisible: boolean;
  61590. /** Gets or sets a boolean indicating if the control can block pointer events */
  61591. isPointerBlocker: boolean;
  61592. /** Gets or sets a boolean indicating if the control can be focusable */
  61593. isFocusInvisible: boolean;
  61594. /**
  61595. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61596. * 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
  61597. */
  61598. clipChildren: boolean;
  61599. /**
  61600. * Gets or sets a boolean indicating that control content must be clipped
  61601. * 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
  61602. */
  61603. clipContent: boolean;
  61604. /**
  61605. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61606. */
  61607. useBitmapCache: boolean;
  61608. private _cacheData;
  61609. private _shadowOffsetX;
  61610. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61611. shadowOffsetX: number;
  61612. private _shadowOffsetY;
  61613. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61614. shadowOffsetY: number;
  61615. private _shadowBlur;
  61616. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61617. shadowBlur: number;
  61618. private _shadowColor;
  61619. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61620. shadowColor: string;
  61621. /** Gets or sets the cursor to use when the control is hovered */
  61622. hoverCursor: string;
  61623. /** @hidden */
  61624. protected _linkOffsetX: ValueAndUnit;
  61625. /** @hidden */
  61626. protected _linkOffsetY: ValueAndUnit;
  61627. /** Gets the control type name */
  61628. readonly typeName: string;
  61629. /**
  61630. * Get the current class name of the control.
  61631. * @returns current class name
  61632. */
  61633. getClassName(): string;
  61634. /**
  61635. * An event triggered when the pointer move over the control.
  61636. */
  61637. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61638. /**
  61639. * An event triggered when the pointer move out of the control.
  61640. */
  61641. onPointerOutObservable: BABYLON.Observable<Control>;
  61642. /**
  61643. * An event triggered when the pointer taps the control
  61644. */
  61645. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61646. /**
  61647. * An event triggered when pointer up
  61648. */
  61649. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61650. /**
  61651. * An event triggered when a control is clicked on
  61652. */
  61653. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61654. /**
  61655. * An event triggered when pointer enters the control
  61656. */
  61657. onPointerEnterObservable: BABYLON.Observable<Control>;
  61658. /**
  61659. * An event triggered when the control is marked as dirty
  61660. */
  61661. onDirtyObservable: BABYLON.Observable<Control>;
  61662. /**
  61663. * An event triggered before drawing the control
  61664. */
  61665. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61666. /**
  61667. * An event triggered after the control was drawn
  61668. */
  61669. onAfterDrawObservable: BABYLON.Observable<Control>;
  61670. /**
  61671. * Get the hosting AdvancedDynamicTexture
  61672. */
  61673. readonly host: AdvancedDynamicTexture;
  61674. /** Gets or set information about font offsets (used to render and align text) */
  61675. fontOffset: {
  61676. ascent: number;
  61677. height: number;
  61678. descent: number;
  61679. };
  61680. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61681. alpha: number;
  61682. /**
  61683. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61684. */
  61685. isHighlighted: boolean;
  61686. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61687. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61688. */
  61689. scaleX: number;
  61690. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61691. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61692. */
  61693. scaleY: number;
  61694. /** Gets or sets the rotation angle (0 by default)
  61695. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61696. */
  61697. rotation: number;
  61698. /** Gets or sets the transformation center on Y axis (0 by default)
  61699. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61700. */
  61701. transformCenterY: number;
  61702. /** Gets or sets the transformation center on X axis (0 by default)
  61703. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61704. */
  61705. transformCenterX: number;
  61706. /**
  61707. * Gets or sets the horizontal alignment
  61708. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61709. */
  61710. horizontalAlignment: number;
  61711. /**
  61712. * Gets or sets the vertical alignment
  61713. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61714. */
  61715. verticalAlignment: number;
  61716. /**
  61717. * Gets or sets control width
  61718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61719. */
  61720. width: string | number;
  61721. /**
  61722. * Gets or sets the control width in pixel
  61723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61724. */
  61725. widthInPixels: number;
  61726. /**
  61727. * Gets or sets control height
  61728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61729. */
  61730. height: string | number;
  61731. /**
  61732. * Gets or sets control height in pixel
  61733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61734. */
  61735. heightInPixels: number;
  61736. /** Gets or set font family */
  61737. fontFamily: string;
  61738. /** Gets or sets font style */
  61739. fontStyle: string;
  61740. /** Gets or sets font weight */
  61741. fontWeight: string;
  61742. /**
  61743. * Gets or sets style
  61744. * @see http://doc.babylonjs.com/how_to/gui#styles
  61745. */
  61746. style: BABYLON.Nullable<Style>;
  61747. /** @hidden */
  61748. readonly _isFontSizeInPercentage: boolean;
  61749. /** Gets or sets font size in pixels */
  61750. fontSizeInPixels: number;
  61751. /** Gets or sets font size */
  61752. fontSize: string | number;
  61753. /** Gets or sets foreground color */
  61754. color: string;
  61755. /** Gets or sets z index which is used to reorder controls on the z axis */
  61756. zIndex: number;
  61757. /** Gets or sets a boolean indicating if the control can be rendered */
  61758. notRenderable: boolean;
  61759. /** Gets or sets a boolean indicating if the control is visible */
  61760. isVisible: boolean;
  61761. /** Gets a boolean indicating that the control needs to update its rendering */
  61762. readonly isDirty: boolean;
  61763. /**
  61764. * Gets the current linked mesh (or null if none)
  61765. */
  61766. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61767. /**
  61768. * Gets or sets a value indicating the padding to use on the left of the control
  61769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61770. */
  61771. paddingLeft: string | number;
  61772. /**
  61773. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61775. */
  61776. paddingLeftInPixels: number;
  61777. /**
  61778. * Gets or sets a value indicating the padding to use on the right of the control
  61779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61780. */
  61781. paddingRight: string | number;
  61782. /**
  61783. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61785. */
  61786. paddingRightInPixels: number;
  61787. /**
  61788. * Gets or sets a value indicating the padding to use on the top of the control
  61789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61790. */
  61791. paddingTop: string | number;
  61792. /**
  61793. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61795. */
  61796. paddingTopInPixels: number;
  61797. /**
  61798. * Gets or sets a value indicating the padding to use on the bottom of the control
  61799. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61800. */
  61801. paddingBottom: string | number;
  61802. /**
  61803. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61804. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61805. */
  61806. paddingBottomInPixels: number;
  61807. /**
  61808. * Gets or sets a value indicating the left coordinate of the control
  61809. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61810. */
  61811. left: string | number;
  61812. /**
  61813. * Gets or sets a value indicating the left coordinate in pixels of the control
  61814. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61815. */
  61816. leftInPixels: number;
  61817. /**
  61818. * Gets or sets a value indicating the top coordinate of the control
  61819. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61820. */
  61821. top: string | number;
  61822. /**
  61823. * Gets or sets a value indicating the top coordinate in pixels of the control
  61824. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61825. */
  61826. topInPixels: number;
  61827. /**
  61828. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61829. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61830. */
  61831. linkOffsetX: string | number;
  61832. /**
  61833. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61834. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61835. */
  61836. linkOffsetXInPixels: number;
  61837. /**
  61838. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61839. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61840. */
  61841. linkOffsetY: string | number;
  61842. /**
  61843. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61844. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61845. */
  61846. linkOffsetYInPixels: number;
  61847. /** Gets the center coordinate on X axis */
  61848. readonly centerX: number;
  61849. /** Gets the center coordinate on Y axis */
  61850. readonly centerY: number;
  61851. /** Gets or sets if control is Enabled*/
  61852. isEnabled: boolean;
  61853. /** Gets or sets background color of control if it's disabled*/
  61854. disabledColor: string;
  61855. /**
  61856. * Creates a new control
  61857. * @param name defines the name of the control
  61858. */
  61859. constructor(
  61860. /** defines the name of the control */
  61861. name?: string | undefined);
  61862. /** @hidden */
  61863. protected _getTypeName(): string;
  61864. /**
  61865. * Gets the first ascendant in the hierarchy of the given type
  61866. * @param className defines the required type
  61867. * @returns the ascendant or null if not found
  61868. */
  61869. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61870. /** @hidden */
  61871. _resetFontCache(): void;
  61872. /**
  61873. * Determines if a container is an ascendant of the current control
  61874. * @param container defines the container to look for
  61875. * @returns true if the container is one of the ascendant of the control
  61876. */
  61877. isAscendant(container: Control): boolean;
  61878. /**
  61879. * Gets coordinates in local control space
  61880. * @param globalCoordinates defines the coordinates to transform
  61881. * @returns the new coordinates in local space
  61882. */
  61883. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61884. /**
  61885. * Gets coordinates in local control space
  61886. * @param globalCoordinates defines the coordinates to transform
  61887. * @param result defines the target vector2 where to store the result
  61888. * @returns the current control
  61889. */
  61890. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61891. /**
  61892. * Gets coordinates in parent local control space
  61893. * @param globalCoordinates defines the coordinates to transform
  61894. * @returns the new coordinates in parent local space
  61895. */
  61896. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61897. /**
  61898. * Move the current control to a vector3 position projected onto the screen.
  61899. * @param position defines the target position
  61900. * @param scene defines the hosting scene
  61901. */
  61902. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61903. /** @hidden */
  61904. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61905. /**
  61906. * Will return all controls that have this control as ascendant
  61907. * @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
  61908. * @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
  61909. * @return all child controls
  61910. */
  61911. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61912. /**
  61913. * Link current control with a target mesh
  61914. * @param mesh defines the mesh to link with
  61915. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61916. */
  61917. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61918. /** @hidden */
  61919. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61920. /** @hidden */
  61921. _offsetLeft(offset: number): void;
  61922. /** @hidden */
  61923. _offsetTop(offset: number): void;
  61924. /** @hidden */
  61925. _markMatrixAsDirty(): void;
  61926. /** @hidden */
  61927. _flagDescendantsAsMatrixDirty(): void;
  61928. /** @hidden */
  61929. _intersectsRect(rect: Measure): boolean;
  61930. /** @hidden */
  61931. protected invalidateRect(): void;
  61932. /** @hidden */
  61933. _markAsDirty(force?: boolean): void;
  61934. /** @hidden */
  61935. _markAllAsDirty(): void;
  61936. /** @hidden */
  61937. _link(host: AdvancedDynamicTexture): void;
  61938. /** @hidden */
  61939. protected _transform(context?: CanvasRenderingContext2D): void;
  61940. /** @hidden */
  61941. _renderHighlight(context: CanvasRenderingContext2D): void;
  61942. /** @hidden */
  61943. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61944. /** @hidden */
  61945. protected _applyStates(context: CanvasRenderingContext2D): void;
  61946. /** @hidden */
  61947. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61948. /** @hidden */
  61949. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61950. protected _evaluateClippingState(parentMeasure: Measure): void;
  61951. /** @hidden */
  61952. _measure(): void;
  61953. /** @hidden */
  61954. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61955. /** @hidden */
  61956. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61957. /** @hidden */
  61958. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61959. /** @hidden */
  61960. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61961. private static _ClipMeasure;
  61962. private _tmpMeasureA;
  61963. private _clip;
  61964. /** @hidden */
  61965. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61966. /** @hidden */
  61967. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61968. /**
  61969. * Tests if a given coordinates belong to the current control
  61970. * @param x defines x coordinate to test
  61971. * @param y defines y coordinate to test
  61972. * @returns true if the coordinates are inside the control
  61973. */
  61974. contains(x: number, y: number): boolean;
  61975. /** @hidden */
  61976. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61977. /** @hidden */
  61978. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61979. /** @hidden */
  61980. _onPointerEnter(target: Control): boolean;
  61981. /** @hidden */
  61982. _onPointerOut(target: Control, force?: boolean): void;
  61983. /** @hidden */
  61984. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61985. /** @hidden */
  61986. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61987. /** @hidden */
  61988. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61989. /** @hidden */
  61990. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61991. private _prepareFont;
  61992. /** Releases associated resources */
  61993. dispose(): void;
  61994. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61995. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61996. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61997. private static _VERTICAL_ALIGNMENT_TOP;
  61998. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61999. private static _VERTICAL_ALIGNMENT_CENTER;
  62000. /** HORIZONTAL_ALIGNMENT_LEFT */
  62001. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62002. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62003. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62004. /** HORIZONTAL_ALIGNMENT_CENTER */
  62005. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62006. /** VERTICAL_ALIGNMENT_TOP */
  62007. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62008. /** VERTICAL_ALIGNMENT_BOTTOM */
  62009. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62010. /** VERTICAL_ALIGNMENT_CENTER */
  62011. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62012. private static _FontHeightSizes;
  62013. /** @hidden */
  62014. static _GetFontOffset(font: string): {
  62015. ascent: number;
  62016. height: number;
  62017. descent: number;
  62018. };
  62019. /**
  62020. * Creates a stack panel that can be used to render headers
  62021. * @param control defines the control to associate with the header
  62022. * @param text defines the text of the header
  62023. * @param size defines the size of the header
  62024. * @param options defines options used to configure the header
  62025. * @returns a new StackPanel
  62026. * @ignore
  62027. * @hidden
  62028. */
  62029. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62030. isHorizontal: boolean;
  62031. controlFirst: boolean;
  62032. }) => any;
  62033. /** @hidden */
  62034. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62035. }
  62036. }
  62037. declare module BABYLON.GUI {
  62038. /**
  62039. * Root class for 2D containers
  62040. * @see http://doc.babylonjs.com/how_to/gui#containers
  62041. */
  62042. export class Container extends Control {
  62043. name?: string | undefined;
  62044. /** @hidden */
  62045. protected _children: Control[];
  62046. /** @hidden */
  62047. protected _measureForChildren: Measure;
  62048. /** @hidden */
  62049. protected _background: string;
  62050. /** @hidden */
  62051. protected _adaptWidthToChildren: boolean;
  62052. /** @hidden */
  62053. protected _adaptHeightToChildren: boolean;
  62054. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62055. adaptHeightToChildren: boolean;
  62056. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62057. adaptWidthToChildren: boolean;
  62058. /** Gets or sets background color */
  62059. background: string;
  62060. /** Gets the list of children */
  62061. readonly children: Control[];
  62062. /**
  62063. * Creates a new Container
  62064. * @param name defines the name of the container
  62065. */
  62066. constructor(name?: string | undefined);
  62067. protected _getTypeName(): string;
  62068. _flagDescendantsAsMatrixDirty(): void;
  62069. /**
  62070. * Gets a child using its name
  62071. * @param name defines the child name to look for
  62072. * @returns the child control if found
  62073. */
  62074. getChildByName(name: string): BABYLON.Nullable<Control>;
  62075. /**
  62076. * Gets a child using its type and its name
  62077. * @param name defines the child name to look for
  62078. * @param type defines the child type to look for
  62079. * @returns the child control if found
  62080. */
  62081. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62082. /**
  62083. * Search for a specific control in children
  62084. * @param control defines the control to look for
  62085. * @returns true if the control is in child list
  62086. */
  62087. containsControl(control: Control): boolean;
  62088. /**
  62089. * Adds a new control to the current container
  62090. * @param control defines the control to add
  62091. * @returns the current container
  62092. */
  62093. addControl(control: BABYLON.Nullable<Control>): Container;
  62094. /**
  62095. * Removes all controls from the current container
  62096. * @returns the current container
  62097. */
  62098. clearControls(): Container;
  62099. /**
  62100. * Removes a control from the current container
  62101. * @param control defines the control to remove
  62102. * @returns the current container
  62103. */
  62104. removeControl(control: Control): Container;
  62105. /** @hidden */
  62106. _reOrderControl(control: Control): void;
  62107. /** @hidden */
  62108. _offsetLeft(offset: number): void;
  62109. /** @hidden */
  62110. _offsetTop(offset: number): void;
  62111. /** @hidden */
  62112. _markAllAsDirty(): void;
  62113. /** @hidden */
  62114. protected _localDraw(context: CanvasRenderingContext2D): void;
  62115. /** @hidden */
  62116. _link(host: AdvancedDynamicTexture): void;
  62117. /** @hidden */
  62118. protected _beforeLayout(): void;
  62119. /** @hidden */
  62120. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62121. /** @hidden */
  62122. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62123. protected _postMeasure(): void;
  62124. /** @hidden */
  62125. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62126. /** @hidden */
  62127. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62128. /** @hidden */
  62129. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62130. /** @hidden */
  62131. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62132. /** Releases associated resources */
  62133. dispose(): void;
  62134. }
  62135. }
  62136. declare module BABYLON.GUI {
  62137. /** Class used to create rectangle container */
  62138. export class Rectangle extends Container {
  62139. name?: string | undefined;
  62140. private _thickness;
  62141. private _cornerRadius;
  62142. /** Gets or sets border thickness */
  62143. thickness: number;
  62144. /** Gets or sets the corner radius angle */
  62145. cornerRadius: number;
  62146. /**
  62147. * Creates a new Rectangle
  62148. * @param name defines the control name
  62149. */
  62150. constructor(name?: string | undefined);
  62151. protected _getTypeName(): string;
  62152. protected _localDraw(context: CanvasRenderingContext2D): void;
  62153. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62154. private _drawRoundedRect;
  62155. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62156. }
  62157. }
  62158. declare module BABYLON.GUI {
  62159. /**
  62160. * Enum that determines the text-wrapping mode to use.
  62161. */
  62162. export enum TextWrapping {
  62163. /**
  62164. * Clip the text when it's larger than Control.width; this is the default mode.
  62165. */
  62166. Clip = 0,
  62167. /**
  62168. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62169. */
  62170. WordWrap = 1,
  62171. /**
  62172. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62173. */
  62174. Ellipsis = 2
  62175. }
  62176. /**
  62177. * Class used to create text block control
  62178. */
  62179. export class TextBlock extends Control {
  62180. /**
  62181. * Defines the name of the control
  62182. */
  62183. name?: string | undefined;
  62184. private _text;
  62185. private _textWrapping;
  62186. private _textHorizontalAlignment;
  62187. private _textVerticalAlignment;
  62188. private _lines;
  62189. private _resizeToFit;
  62190. private _lineSpacing;
  62191. private _outlineWidth;
  62192. private _outlineColor;
  62193. /**
  62194. * An event triggered after the text is changed
  62195. */
  62196. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62197. /**
  62198. * An event triggered after the text was broken up into lines
  62199. */
  62200. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62201. /**
  62202. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62203. */
  62204. readonly lines: any[];
  62205. /**
  62206. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62207. */
  62208. /**
  62209. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62210. */
  62211. resizeToFit: boolean;
  62212. /**
  62213. * Gets or sets a boolean indicating if text must be wrapped
  62214. */
  62215. /**
  62216. * Gets or sets a boolean indicating if text must be wrapped
  62217. */
  62218. textWrapping: TextWrapping | boolean;
  62219. /**
  62220. * Gets or sets text to display
  62221. */
  62222. /**
  62223. * Gets or sets text to display
  62224. */
  62225. text: string;
  62226. /**
  62227. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62228. */
  62229. /**
  62230. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62231. */
  62232. textHorizontalAlignment: number;
  62233. /**
  62234. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62235. */
  62236. /**
  62237. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62238. */
  62239. textVerticalAlignment: number;
  62240. /**
  62241. * Gets or sets line spacing value
  62242. */
  62243. /**
  62244. * Gets or sets line spacing value
  62245. */
  62246. lineSpacing: string | number;
  62247. /**
  62248. * Gets or sets outlineWidth of the text to display
  62249. */
  62250. /**
  62251. * Gets or sets outlineWidth of the text to display
  62252. */
  62253. outlineWidth: number;
  62254. /**
  62255. * Gets or sets outlineColor of the text to display
  62256. */
  62257. /**
  62258. * Gets or sets outlineColor of the text to display
  62259. */
  62260. outlineColor: string;
  62261. /**
  62262. * Creates a new TextBlock object
  62263. * @param name defines the name of the control
  62264. * @param text defines the text to display (emptry string by default)
  62265. */
  62266. constructor(
  62267. /**
  62268. * Defines the name of the control
  62269. */
  62270. name?: string | undefined, text?: string);
  62271. protected _getTypeName(): string;
  62272. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62273. private _drawText;
  62274. /** @hidden */
  62275. _draw(context: CanvasRenderingContext2D): void;
  62276. protected _applyStates(context: CanvasRenderingContext2D): void;
  62277. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62278. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62279. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62280. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62281. protected _renderLines(context: CanvasRenderingContext2D): void;
  62282. /**
  62283. * Given a width constraint applied on the text block, find the expected height
  62284. * @returns expected height
  62285. */
  62286. computeExpectedHeight(): number;
  62287. dispose(): void;
  62288. }
  62289. }
  62290. declare module BABYLON.GUI {
  62291. /**
  62292. * Class used to create 2D images
  62293. */
  62294. export class Image extends Control {
  62295. name?: string | undefined;
  62296. private static _WorkingCanvas;
  62297. private _domImage;
  62298. private _imageWidth;
  62299. private _imageHeight;
  62300. private _loaded;
  62301. private _stretch;
  62302. private _source;
  62303. private _autoScale;
  62304. private _sourceLeft;
  62305. private _sourceTop;
  62306. private _sourceWidth;
  62307. private _sourceHeight;
  62308. private _cellWidth;
  62309. private _cellHeight;
  62310. private _cellId;
  62311. private _populateNinePatchSlicesFromImage;
  62312. private _sliceLeft;
  62313. private _sliceRight;
  62314. private _sliceTop;
  62315. private _sliceBottom;
  62316. private _detectPointerOnOpaqueOnly;
  62317. /**
  62318. * BABYLON.Observable notified when the content is loaded
  62319. */
  62320. onImageLoadedObservable: BABYLON.Observable<Image>;
  62321. /**
  62322. * Gets a boolean indicating that the content is loaded
  62323. */
  62324. readonly isLoaded: boolean;
  62325. /**
  62326. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62327. */
  62328. populateNinePatchSlicesFromImage: boolean;
  62329. /**
  62330. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62331. * Beware using this as this will comsume more memory as the image has to be stored twice
  62332. */
  62333. detectPointerOnOpaqueOnly: boolean;
  62334. /**
  62335. * Gets or sets the left value for slicing (9-patch)
  62336. */
  62337. sliceLeft: number;
  62338. /**
  62339. * Gets or sets the right value for slicing (9-patch)
  62340. */
  62341. sliceRight: number;
  62342. /**
  62343. * Gets or sets the top value for slicing (9-patch)
  62344. */
  62345. sliceTop: number;
  62346. /**
  62347. * Gets or sets the bottom value for slicing (9-patch)
  62348. */
  62349. sliceBottom: number;
  62350. /**
  62351. * Gets or sets the left coordinate in the source image
  62352. */
  62353. sourceLeft: number;
  62354. /**
  62355. * Gets or sets the top coordinate in the source image
  62356. */
  62357. sourceTop: number;
  62358. /**
  62359. * Gets or sets the width to capture in the source image
  62360. */
  62361. sourceWidth: number;
  62362. /**
  62363. * Gets or sets the height to capture in the source image
  62364. */
  62365. sourceHeight: number;
  62366. /**
  62367. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62368. * @see http://doc.babylonjs.com/how_to/gui#image
  62369. */
  62370. autoScale: boolean;
  62371. /** Gets or sets the streching mode used by the image */
  62372. stretch: number;
  62373. /**
  62374. * Gets or sets the internal DOM image used to render the control
  62375. */
  62376. domImage: HTMLImageElement;
  62377. private _onImageLoaded;
  62378. private _extractNinePatchSliceDataFromImage;
  62379. /**
  62380. * Gets or sets image source url
  62381. */
  62382. source: BABYLON.Nullable<string>;
  62383. /**
  62384. * Gets or sets the cell width to use when animation sheet is enabled
  62385. * @see http://doc.babylonjs.com/how_to/gui#image
  62386. */
  62387. cellWidth: number;
  62388. /**
  62389. * Gets or sets the cell height to use when animation sheet is enabled
  62390. * @see http://doc.babylonjs.com/how_to/gui#image
  62391. */
  62392. cellHeight: number;
  62393. /**
  62394. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62395. * @see http://doc.babylonjs.com/how_to/gui#image
  62396. */
  62397. cellId: number;
  62398. /**
  62399. * Creates a new Image
  62400. * @param name defines the control name
  62401. * @param url defines the image url
  62402. */
  62403. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62404. /**
  62405. * Tests if a given coordinates belong to the current control
  62406. * @param x defines x coordinate to test
  62407. * @param y defines y coordinate to test
  62408. * @returns true if the coordinates are inside the control
  62409. */
  62410. contains(x: number, y: number): boolean;
  62411. protected _getTypeName(): string;
  62412. /** Force the control to synchronize with its content */
  62413. synchronizeSizeWithContent(): void;
  62414. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62415. private _prepareWorkingCanvasForOpaqueDetection;
  62416. private _drawImage;
  62417. _draw(context: CanvasRenderingContext2D): void;
  62418. private _renderCornerPatch;
  62419. private _renderNinePatch;
  62420. dispose(): void;
  62421. /** STRETCH_NONE */
  62422. static readonly STRETCH_NONE: number;
  62423. /** STRETCH_FILL */
  62424. static readonly STRETCH_FILL: number;
  62425. /** STRETCH_UNIFORM */
  62426. static readonly STRETCH_UNIFORM: number;
  62427. /** STRETCH_EXTEND */
  62428. static readonly STRETCH_EXTEND: number;
  62429. /** NINE_PATCH */
  62430. static readonly STRETCH_NINE_PATCH: number;
  62431. }
  62432. }
  62433. declare module BABYLON.GUI {
  62434. /**
  62435. * Class used to create 2D buttons
  62436. */
  62437. export class Button extends Rectangle {
  62438. name?: string | undefined;
  62439. /**
  62440. * Function called to generate a pointer enter animation
  62441. */
  62442. pointerEnterAnimation: () => void;
  62443. /**
  62444. * Function called to generate a pointer out animation
  62445. */
  62446. pointerOutAnimation: () => void;
  62447. /**
  62448. * Function called to generate a pointer down animation
  62449. */
  62450. pointerDownAnimation: () => void;
  62451. /**
  62452. * Function called to generate a pointer up animation
  62453. */
  62454. pointerUpAnimation: () => void;
  62455. private _image;
  62456. /**
  62457. * Returns the image part of the button (if any)
  62458. */
  62459. readonly image: BABYLON.Nullable<Image>;
  62460. private _textBlock;
  62461. /**
  62462. * Returns the image part of the button (if any)
  62463. */
  62464. readonly textBlock: BABYLON.Nullable<TextBlock>;
  62465. /**
  62466. * Creates a new Button
  62467. * @param name defines the name of the button
  62468. */
  62469. constructor(name?: string | undefined);
  62470. protected _getTypeName(): string;
  62471. /** @hidden */
  62472. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62473. /** @hidden */
  62474. _onPointerEnter(target: Control): boolean;
  62475. /** @hidden */
  62476. _onPointerOut(target: Control, force?: boolean): void;
  62477. /** @hidden */
  62478. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62479. /** @hidden */
  62480. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62481. /**
  62482. * Creates a new button made with an image and a text
  62483. * @param name defines the name of the button
  62484. * @param text defines the text of the button
  62485. * @param imageUrl defines the url of the image
  62486. * @returns a new Button
  62487. */
  62488. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62489. /**
  62490. * Creates a new button made with an image
  62491. * @param name defines the name of the button
  62492. * @param imageUrl defines the url of the image
  62493. * @returns a new Button
  62494. */
  62495. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62496. /**
  62497. * Creates a new button made with a text
  62498. * @param name defines the name of the button
  62499. * @param text defines the text of the button
  62500. * @returns a new Button
  62501. */
  62502. static CreateSimpleButton(name: string, text: string): Button;
  62503. /**
  62504. * Creates a new button made with an image and a centered text
  62505. * @param name defines the name of the button
  62506. * @param text defines the text of the button
  62507. * @param imageUrl defines the url of the image
  62508. * @returns a new Button
  62509. */
  62510. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62511. }
  62512. }
  62513. declare module BABYLON.GUI {
  62514. /**
  62515. * Class used to create a 2D stack panel container
  62516. */
  62517. export class StackPanel extends Container {
  62518. name?: string | undefined;
  62519. private _isVertical;
  62520. private _manualWidth;
  62521. private _manualHeight;
  62522. private _doNotTrackManualChanges;
  62523. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62524. isVertical: boolean;
  62525. /**
  62526. * Gets or sets panel width.
  62527. * This value should not be set when in horizontal mode as it will be computed automatically
  62528. */
  62529. width: string | number;
  62530. /**
  62531. * Gets or sets panel height.
  62532. * This value should not be set when in vertical mode as it will be computed automatically
  62533. */
  62534. height: string | number;
  62535. /**
  62536. * Creates a new StackPanel
  62537. * @param name defines control name
  62538. */
  62539. constructor(name?: string | undefined);
  62540. protected _getTypeName(): string;
  62541. /** @hidden */
  62542. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62543. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62544. protected _postMeasure(): void;
  62545. }
  62546. }
  62547. declare module BABYLON.GUI {
  62548. /**
  62549. * Class used to represent a 2D checkbox
  62550. */
  62551. export class Checkbox extends Control {
  62552. name?: string | undefined;
  62553. private _isChecked;
  62554. private _background;
  62555. private _checkSizeRatio;
  62556. private _thickness;
  62557. /** Gets or sets border thickness */
  62558. thickness: number;
  62559. /**
  62560. * BABYLON.Observable raised when isChecked property changes
  62561. */
  62562. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62563. /** Gets or sets a value indicating the ratio between overall size and check size */
  62564. checkSizeRatio: number;
  62565. /** Gets or sets background color */
  62566. background: string;
  62567. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62568. isChecked: boolean;
  62569. /**
  62570. * Creates a new CheckBox
  62571. * @param name defines the control name
  62572. */
  62573. constructor(name?: string | undefined);
  62574. protected _getTypeName(): string;
  62575. /** @hidden */
  62576. _draw(context: CanvasRenderingContext2D): void;
  62577. /** @hidden */
  62578. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62579. /**
  62580. * Utility function to easily create a checkbox with a header
  62581. * @param title defines the label to use for the header
  62582. * @param onValueChanged defines the callback to call when value changes
  62583. * @returns a StackPanel containing the checkbox and a textBlock
  62584. */
  62585. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62586. }
  62587. }
  62588. declare module BABYLON.GUI {
  62589. /**
  62590. * Class used to store key control properties
  62591. */
  62592. export class KeyPropertySet {
  62593. /** Width */
  62594. width?: string;
  62595. /** Height */
  62596. height?: string;
  62597. /** Left padding */
  62598. paddingLeft?: string;
  62599. /** Right padding */
  62600. paddingRight?: string;
  62601. /** Top padding */
  62602. paddingTop?: string;
  62603. /** Bottom padding */
  62604. paddingBottom?: string;
  62605. /** Foreground color */
  62606. color?: string;
  62607. /** Background color */
  62608. background?: string;
  62609. }
  62610. /**
  62611. * Class used to create virtual keyboard
  62612. */
  62613. export class VirtualKeyboard extends StackPanel {
  62614. /** BABYLON.Observable raised when a key is pressed */
  62615. onKeyPressObservable: BABYLON.Observable<string>;
  62616. /** Gets or sets default key button width */
  62617. defaultButtonWidth: string;
  62618. /** Gets or sets default key button height */
  62619. defaultButtonHeight: string;
  62620. /** Gets or sets default key button left padding */
  62621. defaultButtonPaddingLeft: string;
  62622. /** Gets or sets default key button right padding */
  62623. defaultButtonPaddingRight: string;
  62624. /** Gets or sets default key button top padding */
  62625. defaultButtonPaddingTop: string;
  62626. /** Gets or sets default key button bottom padding */
  62627. defaultButtonPaddingBottom: string;
  62628. /** Gets or sets default key button foreground color */
  62629. defaultButtonColor: string;
  62630. /** Gets or sets default key button background color */
  62631. defaultButtonBackground: string;
  62632. /** Gets or sets shift button foreground color */
  62633. shiftButtonColor: string;
  62634. /** Gets or sets shift button thickness*/
  62635. selectedShiftThickness: number;
  62636. /** Gets shift key state */
  62637. shiftState: number;
  62638. protected _getTypeName(): string;
  62639. private _createKey;
  62640. /**
  62641. * Adds a new row of keys
  62642. * @param keys defines the list of keys to add
  62643. * @param propertySets defines the associated property sets
  62644. */
  62645. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62646. /**
  62647. * Set the shift key to a specific state
  62648. * @param shiftState defines the new shift state
  62649. */
  62650. applyShiftState(shiftState: number): void;
  62651. private _currentlyConnectedInputText;
  62652. private _connectedInputTexts;
  62653. private _onKeyPressObserver;
  62654. /** Gets the input text control currently attached to the keyboard */
  62655. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62656. /**
  62657. * Connects the keyboard with an input text control
  62658. *
  62659. * @param input defines the target control
  62660. */
  62661. connect(input: InputText): void;
  62662. /**
  62663. * Disconnects the keyboard from connected InputText controls
  62664. *
  62665. * @param input optionally defines a target control, otherwise all are disconnected
  62666. */
  62667. disconnect(input?: InputText): void;
  62668. private _removeConnectedInputObservables;
  62669. /**
  62670. * Release all resources
  62671. */
  62672. dispose(): void;
  62673. /**
  62674. * Creates a new keyboard using a default layout
  62675. *
  62676. * @param name defines control name
  62677. * @returns a new VirtualKeyboard
  62678. */
  62679. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62680. }
  62681. }
  62682. declare module BABYLON.GUI {
  62683. /**
  62684. * Class used to create input text control
  62685. */
  62686. export class InputText extends Control implements IFocusableControl {
  62687. name?: string | undefined;
  62688. private _text;
  62689. private _placeholderText;
  62690. private _background;
  62691. private _focusedBackground;
  62692. private _focusedColor;
  62693. private _placeholderColor;
  62694. private _thickness;
  62695. private _margin;
  62696. private _autoStretchWidth;
  62697. private _maxWidth;
  62698. private _isFocused;
  62699. private _blinkTimeout;
  62700. private _blinkIsEven;
  62701. private _cursorOffset;
  62702. private _scrollLeft;
  62703. private _textWidth;
  62704. private _clickedCoordinate;
  62705. private _deadKey;
  62706. private _addKey;
  62707. private _currentKey;
  62708. private _isTextHighlightOn;
  62709. private _textHighlightColor;
  62710. private _highligherOpacity;
  62711. private _highlightedText;
  62712. private _startHighlightIndex;
  62713. private _endHighlightIndex;
  62714. private _cursorIndex;
  62715. private _onFocusSelectAll;
  62716. private _isPointerDown;
  62717. private _onClipboardObserver;
  62718. private _onPointerDblTapObserver;
  62719. /** @hidden */
  62720. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62721. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62722. promptMessage: string;
  62723. /** Force disable prompt on mobile device */
  62724. disableMobilePrompt: boolean;
  62725. /** BABYLON.Observable raised when the text changes */
  62726. onTextChangedObservable: BABYLON.Observable<InputText>;
  62727. /** BABYLON.Observable raised just before an entered character is to be added */
  62728. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62729. /** BABYLON.Observable raised when the control gets the focus */
  62730. onFocusObservable: BABYLON.Observable<InputText>;
  62731. /** BABYLON.Observable raised when the control loses the focus */
  62732. onBlurObservable: BABYLON.Observable<InputText>;
  62733. /**Observable raised when the text is highlighted */
  62734. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62735. /**Observable raised when copy event is triggered */
  62736. onTextCopyObservable: BABYLON.Observable<InputText>;
  62737. /** BABYLON.Observable raised when cut event is triggered */
  62738. onTextCutObservable: BABYLON.Observable<InputText>;
  62739. /** BABYLON.Observable raised when paste event is triggered */
  62740. onTextPasteObservable: BABYLON.Observable<InputText>;
  62741. /** BABYLON.Observable raised when a key event was processed */
  62742. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62743. /** Gets or sets the maximum width allowed by the control */
  62744. maxWidth: string | number;
  62745. /** Gets the maximum width allowed by the control in pixels */
  62746. readonly maxWidthInPixels: number;
  62747. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62748. highligherOpacity: number;
  62749. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62750. onFocusSelectAll: boolean;
  62751. /** Gets or sets the text hightlight color */
  62752. textHighlightColor: string;
  62753. /** Gets or sets control margin */
  62754. margin: string;
  62755. /** Gets control margin in pixels */
  62756. readonly marginInPixels: number;
  62757. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62758. autoStretchWidth: boolean;
  62759. /** Gets or sets border thickness */
  62760. thickness: number;
  62761. /** Gets or sets the background color when focused */
  62762. focusedBackground: string;
  62763. /** Gets or sets the background color when focused */
  62764. focusedColor: string;
  62765. /** Gets or sets the background color */
  62766. background: string;
  62767. /** Gets or sets the placeholder color */
  62768. placeholderColor: string;
  62769. /** Gets or sets the text displayed when the control is empty */
  62770. placeholderText: string;
  62771. /** Gets or sets the dead key flag */
  62772. deadKey: boolean;
  62773. /** Gets or sets the highlight text */
  62774. highlightedText: string;
  62775. /** Gets or sets if the current key should be added */
  62776. addKey: boolean;
  62777. /** Gets or sets the value of the current key being entered */
  62778. currentKey: string;
  62779. /** Gets or sets the text displayed in the control */
  62780. text: string;
  62781. /** Gets or sets control width */
  62782. width: string | number;
  62783. /**
  62784. * Creates a new InputText
  62785. * @param name defines the control name
  62786. * @param text defines the text of the control
  62787. */
  62788. constructor(name?: string | undefined, text?: string);
  62789. /** @hidden */
  62790. onBlur(): void;
  62791. /** @hidden */
  62792. onFocus(): void;
  62793. protected _getTypeName(): string;
  62794. /**
  62795. * Function called to get the list of controls that should not steal the focus from this control
  62796. * @returns an array of controls
  62797. */
  62798. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62799. /** @hidden */
  62800. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62801. /** @hidden */
  62802. private _updateValueFromCursorIndex;
  62803. /** @hidden */
  62804. private _processDblClick;
  62805. /** @hidden */
  62806. private _selectAllText;
  62807. /**
  62808. * Handles the keyboard event
  62809. * @param evt Defines the KeyboardEvent
  62810. */
  62811. processKeyboard(evt: KeyboardEvent): void;
  62812. /** @hidden */
  62813. private _onCopyText;
  62814. /** @hidden */
  62815. private _onCutText;
  62816. /** @hidden */
  62817. private _onPasteText;
  62818. _draw(context: CanvasRenderingContext2D): void;
  62819. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62820. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62821. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62822. protected _beforeRenderText(text: string): string;
  62823. dispose(): void;
  62824. }
  62825. }
  62826. declare module BABYLON.GUI {
  62827. /**
  62828. * Class used to create a 2D grid container
  62829. */
  62830. export class Grid extends Container {
  62831. name?: string | undefined;
  62832. private _rowDefinitions;
  62833. private _columnDefinitions;
  62834. private _cells;
  62835. private _childControls;
  62836. /**
  62837. * Gets the number of columns
  62838. */
  62839. readonly columnCount: number;
  62840. /**
  62841. * Gets the number of rows
  62842. */
  62843. readonly rowCount: number;
  62844. /** Gets the list of children */
  62845. readonly children: Control[];
  62846. /** Gets the list of cells (e.g. the containers) */
  62847. readonly cells: {
  62848. [key: string]: Container;
  62849. };
  62850. /**
  62851. * Gets the definition of a specific row
  62852. * @param index defines the index of the row
  62853. * @returns the row definition
  62854. */
  62855. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62856. /**
  62857. * Gets the definition of a specific column
  62858. * @param index defines the index of the column
  62859. * @returns the column definition
  62860. */
  62861. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62862. /**
  62863. * Adds a new row to the grid
  62864. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62865. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62866. * @returns the current grid
  62867. */
  62868. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62869. /**
  62870. * Adds a new column to the grid
  62871. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62872. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62873. * @returns the current grid
  62874. */
  62875. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62876. /**
  62877. * Update a row definition
  62878. * @param index defines the index of the row to update
  62879. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62880. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62881. * @returns the current grid
  62882. */
  62883. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62884. /**
  62885. * Update a column definition
  62886. * @param index defines the index of the column to update
  62887. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62888. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62889. * @returns the current grid
  62890. */
  62891. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62892. /**
  62893. * Gets the list of children stored in a specific cell
  62894. * @param row defines the row to check
  62895. * @param column defines the column to check
  62896. * @returns the list of controls
  62897. */
  62898. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62899. /**
  62900. * Gets a string representing the child cell info (row x column)
  62901. * @param child defines the control to get info from
  62902. * @returns a string containing the child cell info (row x column)
  62903. */
  62904. getChildCellInfo(child: Control): string;
  62905. private _removeCell;
  62906. private _offsetCell;
  62907. /**
  62908. * Remove a column definition at specified index
  62909. * @param index defines the index of the column to remove
  62910. * @returns the current grid
  62911. */
  62912. removeColumnDefinition(index: number): Grid;
  62913. /**
  62914. * Remove a row definition at specified index
  62915. * @param index defines the index of the row to remove
  62916. * @returns the current grid
  62917. */
  62918. removeRowDefinition(index: number): Grid;
  62919. /**
  62920. * Adds a new control to the current grid
  62921. * @param control defines the control to add
  62922. * @param row defines the row where to add the control (0 by default)
  62923. * @param column defines the column where to add the control (0 by default)
  62924. * @returns the current grid
  62925. */
  62926. addControl(control: Control, row?: number, column?: number): Grid;
  62927. /**
  62928. * Removes a control from the current container
  62929. * @param control defines the control to remove
  62930. * @returns the current container
  62931. */
  62932. removeControl(control: Control): Container;
  62933. /**
  62934. * Creates a new Grid
  62935. * @param name defines control name
  62936. */
  62937. constructor(name?: string | undefined);
  62938. protected _getTypeName(): string;
  62939. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62940. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62941. _flagDescendantsAsMatrixDirty(): void;
  62942. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62943. /** Releases associated resources */
  62944. dispose(): void;
  62945. }
  62946. }
  62947. declare module BABYLON.GUI {
  62948. /** Class used to create color pickers */
  62949. export class ColorPicker extends Control {
  62950. name?: string | undefined;
  62951. private static _Epsilon;
  62952. private _colorWheelCanvas;
  62953. private _value;
  62954. private _tmpColor;
  62955. private _pointerStartedOnSquare;
  62956. private _pointerStartedOnWheel;
  62957. private _squareLeft;
  62958. private _squareTop;
  62959. private _squareSize;
  62960. private _h;
  62961. private _s;
  62962. private _v;
  62963. private _lastPointerDownID;
  62964. /**
  62965. * BABYLON.Observable raised when the value changes
  62966. */
  62967. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62968. /** Gets or sets the color of the color picker */
  62969. value: BABYLON.Color3;
  62970. /**
  62971. * Gets or sets control width
  62972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62973. */
  62974. width: string | number;
  62975. /**
  62976. * Gets or sets control height
  62977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62978. */
  62979. /** Gets or sets control height */
  62980. height: string | number;
  62981. /** Gets or sets control size */
  62982. size: string | number;
  62983. /**
  62984. * Creates a new ColorPicker
  62985. * @param name defines the control name
  62986. */
  62987. constructor(name?: string | undefined);
  62988. protected _getTypeName(): string;
  62989. /** @hidden */
  62990. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62991. private _updateSquareProps;
  62992. private _drawGradientSquare;
  62993. private _drawCircle;
  62994. private _createColorWheelCanvas;
  62995. /** @hidden */
  62996. _draw(context: CanvasRenderingContext2D): void;
  62997. private _pointerIsDown;
  62998. private _updateValueFromPointer;
  62999. private _isPointOnSquare;
  63000. private _isPointOnWheel;
  63001. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63002. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63003. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63004. /**
  63005. * This function expands the color picker by creating a color picker dialog with manual
  63006. * color value input and the ability to save colors into an array to be used later in
  63007. * subsequent launches of the dialogue.
  63008. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63009. * @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.
  63010. * @returns picked color as a hex string and the saved colors array as hex strings.
  63011. */
  63012. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63013. pickerWidth?: string;
  63014. pickerHeight?: string;
  63015. headerHeight?: string;
  63016. lastColor?: string;
  63017. swatchLimit?: number;
  63018. numSwatchesPerLine?: number;
  63019. savedColors?: Array<string>;
  63020. }): Promise<{
  63021. savedColors?: string[];
  63022. pickedColor: string;
  63023. }>;
  63024. }
  63025. }
  63026. declare module BABYLON.GUI {
  63027. /** Class used to create 2D ellipse containers */
  63028. export class Ellipse extends Container {
  63029. name?: string | undefined;
  63030. private _thickness;
  63031. /** Gets or sets border thickness */
  63032. thickness: number;
  63033. /**
  63034. * Creates a new Ellipse
  63035. * @param name defines the control name
  63036. */
  63037. constructor(name?: string | undefined);
  63038. protected _getTypeName(): string;
  63039. protected _localDraw(context: CanvasRenderingContext2D): void;
  63040. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63041. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63042. }
  63043. }
  63044. declare module BABYLON.GUI {
  63045. /**
  63046. * Class used to create a password control
  63047. */
  63048. export class InputPassword extends InputText {
  63049. protected _beforeRenderText(text: string): string;
  63050. }
  63051. }
  63052. declare module BABYLON.GUI {
  63053. /** Class used to render 2D lines */
  63054. export class Line extends Control {
  63055. name?: string | undefined;
  63056. private _lineWidth;
  63057. private _x1;
  63058. private _y1;
  63059. private _x2;
  63060. private _y2;
  63061. private _dash;
  63062. private _connectedControl;
  63063. private _connectedControlDirtyObserver;
  63064. /** Gets or sets the dash pattern */
  63065. dash: Array<number>;
  63066. /** Gets or sets the control connected with the line end */
  63067. connectedControl: Control;
  63068. /** Gets or sets start coordinates on X axis */
  63069. x1: string | number;
  63070. /** Gets or sets start coordinates on Y axis */
  63071. y1: string | number;
  63072. /** Gets or sets end coordinates on X axis */
  63073. x2: string | number;
  63074. /** Gets or sets end coordinates on Y axis */
  63075. y2: string | number;
  63076. /** Gets or sets line width */
  63077. lineWidth: number;
  63078. /** Gets or sets horizontal alignment */
  63079. horizontalAlignment: number;
  63080. /** Gets or sets vertical alignment */
  63081. verticalAlignment: number;
  63082. private readonly _effectiveX2;
  63083. private readonly _effectiveY2;
  63084. /**
  63085. * Creates a new Line
  63086. * @param name defines the control name
  63087. */
  63088. constructor(name?: string | undefined);
  63089. protected _getTypeName(): string;
  63090. _draw(context: CanvasRenderingContext2D): void;
  63091. _measure(): void;
  63092. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63093. /**
  63094. * Move one end of the line given 3D cartesian coordinates.
  63095. * @param position Targeted world position
  63096. * @param scene BABYLON.Scene
  63097. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63098. */
  63099. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63100. /**
  63101. * Move one end of the line to a position in screen absolute space.
  63102. * @param projectedPosition Position in screen absolute space (X, Y)
  63103. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63104. */
  63105. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63106. }
  63107. }
  63108. declare module BABYLON.GUI {
  63109. /**
  63110. * Class used to store a point for a MultiLine object.
  63111. * The point can be pure 2D coordinates, a mesh or a control
  63112. */
  63113. export class MultiLinePoint {
  63114. private _multiLine;
  63115. private _x;
  63116. private _y;
  63117. private _control;
  63118. private _mesh;
  63119. private _controlObserver;
  63120. private _meshObserver;
  63121. /** @hidden */
  63122. _point: BABYLON.Vector2;
  63123. /**
  63124. * Creates a new MultiLinePoint
  63125. * @param multiLine defines the source MultiLine object
  63126. */
  63127. constructor(multiLine: MultiLine);
  63128. /** Gets or sets x coordinate */
  63129. x: string | number;
  63130. /** Gets or sets y coordinate */
  63131. y: string | number;
  63132. /** Gets or sets the control associated with this point */
  63133. control: BABYLON.Nullable<Control>;
  63134. /** Gets or sets the mesh associated with this point */
  63135. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63136. /** Resets links */
  63137. resetLinks(): void;
  63138. /**
  63139. * Gets a translation vector
  63140. * @returns the translation vector
  63141. */
  63142. translate(): BABYLON.Vector2;
  63143. private _translatePoint;
  63144. /** Release associated resources */
  63145. dispose(): void;
  63146. }
  63147. }
  63148. declare module BABYLON.GUI {
  63149. /**
  63150. * Class used to create multi line control
  63151. */
  63152. export class MultiLine extends Control {
  63153. name?: string | undefined;
  63154. private _lineWidth;
  63155. private _dash;
  63156. private _points;
  63157. private _minX;
  63158. private _minY;
  63159. private _maxX;
  63160. private _maxY;
  63161. /**
  63162. * Creates a new MultiLine
  63163. * @param name defines the control name
  63164. */
  63165. constructor(name?: string | undefined);
  63166. /** Gets or sets dash pattern */
  63167. dash: Array<number>;
  63168. /**
  63169. * Gets point stored at specified index
  63170. * @param index defines the index to look for
  63171. * @returns the requested point if found
  63172. */
  63173. getAt(index: number): MultiLinePoint;
  63174. /** Function called when a point is updated */
  63175. onPointUpdate: () => void;
  63176. /**
  63177. * Adds new points to the point collection
  63178. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63179. * @returns the list of created MultiLinePoint
  63180. */
  63181. add(...items: (AbstractMesh | Control | {
  63182. x: string | number;
  63183. y: string | number;
  63184. })[]): MultiLinePoint[];
  63185. /**
  63186. * Adds a new point to the point collection
  63187. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63188. * @returns the created MultiLinePoint
  63189. */
  63190. push(item?: (AbstractMesh | Control | {
  63191. x: string | number;
  63192. y: string | number;
  63193. })): MultiLinePoint;
  63194. /**
  63195. * Remove a specific value or point from the active point collection
  63196. * @param value defines the value or point to remove
  63197. */
  63198. remove(value: number | MultiLinePoint): void;
  63199. /**
  63200. * Resets this object to initial state (no point)
  63201. */
  63202. reset(): void;
  63203. /**
  63204. * Resets all links
  63205. */
  63206. resetLinks(): void;
  63207. /** Gets or sets line width */
  63208. lineWidth: number;
  63209. horizontalAlignment: number;
  63210. verticalAlignment: number;
  63211. protected _getTypeName(): string;
  63212. _draw(context: CanvasRenderingContext2D): void;
  63213. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63214. _measure(): void;
  63215. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63216. dispose(): void;
  63217. }
  63218. }
  63219. declare module BABYLON.GUI {
  63220. /**
  63221. * Class used to create radio button controls
  63222. */
  63223. export class RadioButton extends Control {
  63224. name?: string | undefined;
  63225. private _isChecked;
  63226. private _background;
  63227. private _checkSizeRatio;
  63228. private _thickness;
  63229. /** Gets or sets border thickness */
  63230. thickness: number;
  63231. /** Gets or sets group name */
  63232. group: string;
  63233. /** BABYLON.Observable raised when isChecked is changed */
  63234. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63235. /** Gets or sets a value indicating the ratio between overall size and check size */
  63236. checkSizeRatio: number;
  63237. /** Gets or sets background color */
  63238. background: string;
  63239. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63240. isChecked: boolean;
  63241. /**
  63242. * Creates a new RadioButton
  63243. * @param name defines the control name
  63244. */
  63245. constructor(name?: string | undefined);
  63246. protected _getTypeName(): string;
  63247. _draw(context: CanvasRenderingContext2D): void;
  63248. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63249. /**
  63250. * Utility function to easily create a radio button with a header
  63251. * @param title defines the label to use for the header
  63252. * @param group defines the group to use for the radio button
  63253. * @param isChecked defines the initial state of the radio button
  63254. * @param onValueChanged defines the callback to call when value changes
  63255. * @returns a StackPanel containing the radio button and a textBlock
  63256. */
  63257. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63258. }
  63259. }
  63260. declare module BABYLON.GUI {
  63261. /**
  63262. * Class used to create slider controls
  63263. */
  63264. export class BaseSlider extends Control {
  63265. name?: string | undefined;
  63266. protected _thumbWidth: ValueAndUnit;
  63267. private _minimum;
  63268. private _maximum;
  63269. private _value;
  63270. private _isVertical;
  63271. protected _barOffset: ValueAndUnit;
  63272. private _isThumbClamped;
  63273. protected _displayThumb: boolean;
  63274. private _step;
  63275. private _lastPointerDownID;
  63276. protected _effectiveBarOffset: number;
  63277. protected _renderLeft: number;
  63278. protected _renderTop: number;
  63279. protected _renderWidth: number;
  63280. protected _renderHeight: number;
  63281. protected _backgroundBoxLength: number;
  63282. protected _backgroundBoxThickness: number;
  63283. protected _effectiveThumbThickness: number;
  63284. /** BABYLON.Observable raised when the sldier value changes */
  63285. onValueChangedObservable: BABYLON.Observable<number>;
  63286. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63287. displayThumb: boolean;
  63288. /** Gets or sets a step to apply to values (0 by default) */
  63289. step: number;
  63290. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63291. barOffset: string | number;
  63292. /** Gets main bar offset in pixels*/
  63293. readonly barOffsetInPixels: number;
  63294. /** Gets or sets thumb width */
  63295. thumbWidth: string | number;
  63296. /** Gets thumb width in pixels */
  63297. readonly thumbWidthInPixels: number;
  63298. /** Gets or sets minimum value */
  63299. minimum: number;
  63300. /** Gets or sets maximum value */
  63301. maximum: number;
  63302. /** Gets or sets current value */
  63303. value: number;
  63304. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63305. isVertical: boolean;
  63306. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63307. isThumbClamped: boolean;
  63308. /**
  63309. * Creates a new BaseSlider
  63310. * @param name defines the control name
  63311. */
  63312. constructor(name?: string | undefined);
  63313. protected _getTypeName(): string;
  63314. protected _getThumbPosition(): number;
  63315. protected _getThumbThickness(type: string): number;
  63316. protected _prepareRenderingData(type: string): void;
  63317. private _pointerIsDown;
  63318. /** @hidden */
  63319. protected _updateValueFromPointer(x: number, y: number): void;
  63320. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63321. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63322. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63323. }
  63324. }
  63325. declare module BABYLON.GUI {
  63326. /**
  63327. * Class used to create slider controls
  63328. */
  63329. export class Slider extends BaseSlider {
  63330. name?: string | undefined;
  63331. private _background;
  63332. private _borderColor;
  63333. private _isThumbCircle;
  63334. protected _displayValueBar: boolean;
  63335. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63336. displayValueBar: boolean;
  63337. /** Gets or sets border color */
  63338. borderColor: string;
  63339. /** Gets or sets background color */
  63340. background: string;
  63341. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63342. isThumbCircle: boolean;
  63343. /**
  63344. * Creates a new Slider
  63345. * @param name defines the control name
  63346. */
  63347. constructor(name?: string | undefined);
  63348. protected _getTypeName(): string;
  63349. _draw(context: CanvasRenderingContext2D): void;
  63350. }
  63351. }
  63352. declare module BABYLON.GUI {
  63353. /** Class used to create a RadioGroup
  63354. * which contains groups of radio buttons
  63355. */
  63356. export class SelectorGroup {
  63357. /** name of SelectorGroup */
  63358. name: string;
  63359. private _groupPanel;
  63360. private _selectors;
  63361. private _groupHeader;
  63362. /**
  63363. * Creates a new SelectorGroup
  63364. * @param name of group, used as a group heading
  63365. */
  63366. constructor(
  63367. /** name of SelectorGroup */
  63368. name: string);
  63369. /** Gets the groupPanel of the SelectorGroup */
  63370. readonly groupPanel: StackPanel;
  63371. /** Gets the selectors array */
  63372. readonly selectors: StackPanel[];
  63373. /** Gets and sets the group header */
  63374. header: string;
  63375. /** @hidden */
  63376. private _addGroupHeader;
  63377. /** @hidden*/
  63378. _getSelector(selectorNb: number): StackPanel | undefined;
  63379. /** Removes the selector at the given position
  63380. * @param selectorNb the position of the selector within the group
  63381. */
  63382. removeSelector(selectorNb: number): void;
  63383. }
  63384. /** Class used to create a CheckboxGroup
  63385. * which contains groups of checkbox buttons
  63386. */
  63387. export class CheckboxGroup extends SelectorGroup {
  63388. /** Adds a checkbox as a control
  63389. * @param text is the label for the selector
  63390. * @param func is the function called when the Selector is checked
  63391. * @param checked is true when Selector is checked
  63392. */
  63393. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63394. /** @hidden */
  63395. _setSelectorLabel(selectorNb: number, label: string): void;
  63396. /** @hidden */
  63397. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63398. /** @hidden */
  63399. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63400. /** @hidden */
  63401. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63402. }
  63403. /** Class used to create a RadioGroup
  63404. * which contains groups of radio buttons
  63405. */
  63406. export class RadioGroup extends SelectorGroup {
  63407. private _selectNb;
  63408. /** Adds a radio button as a control
  63409. * @param label is the label for the selector
  63410. * @param func is the function called when the Selector is checked
  63411. * @param checked is true when Selector is checked
  63412. */
  63413. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63414. /** @hidden */
  63415. _setSelectorLabel(selectorNb: number, label: string): void;
  63416. /** @hidden */
  63417. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63418. /** @hidden */
  63419. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63420. /** @hidden */
  63421. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63422. }
  63423. /** Class used to create a SliderGroup
  63424. * which contains groups of slider buttons
  63425. */
  63426. export class SliderGroup extends SelectorGroup {
  63427. /**
  63428. * Adds a slider to the SelectorGroup
  63429. * @param label is the label for the SliderBar
  63430. * @param func is the function called when the Slider moves
  63431. * @param unit is a string describing the units used, eg degrees or metres
  63432. * @param min is the minimum value for the Slider
  63433. * @param max is the maximum value for the Slider
  63434. * @param value is the start value for the Slider between min and max
  63435. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63436. */
  63437. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  63438. /** @hidden */
  63439. _setSelectorLabel(selectorNb: number, label: string): void;
  63440. /** @hidden */
  63441. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63442. /** @hidden */
  63443. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63444. /** @hidden */
  63445. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63446. }
  63447. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  63448. * @see http://doc.babylonjs.com/how_to/selector
  63449. */
  63450. export class SelectionPanel extends Rectangle {
  63451. /** name of SelectionPanel */
  63452. name: string;
  63453. /** an array of SelectionGroups */
  63454. groups: SelectorGroup[];
  63455. private _panel;
  63456. private _buttonColor;
  63457. private _buttonBackground;
  63458. private _headerColor;
  63459. private _barColor;
  63460. private _barHeight;
  63461. private _spacerHeight;
  63462. private _labelColor;
  63463. private _groups;
  63464. private _bars;
  63465. /**
  63466. * Creates a new SelectionPanel
  63467. * @param name of SelectionPanel
  63468. * @param groups is an array of SelectionGroups
  63469. */
  63470. constructor(
  63471. /** name of SelectionPanel */
  63472. name: string,
  63473. /** an array of SelectionGroups */
  63474. groups?: SelectorGroup[]);
  63475. protected _getTypeName(): string;
  63476. /** Gets or sets the headerColor */
  63477. headerColor: string;
  63478. private _setHeaderColor;
  63479. /** Gets or sets the button color */
  63480. buttonColor: string;
  63481. private _setbuttonColor;
  63482. /** Gets or sets the label color */
  63483. labelColor: string;
  63484. private _setLabelColor;
  63485. /** Gets or sets the button background */
  63486. buttonBackground: string;
  63487. private _setButtonBackground;
  63488. /** Gets or sets the color of separator bar */
  63489. barColor: string;
  63490. private _setBarColor;
  63491. /** Gets or sets the height of separator bar */
  63492. barHeight: string;
  63493. private _setBarHeight;
  63494. /** Gets or sets the height of spacers*/
  63495. spacerHeight: string;
  63496. private _setSpacerHeight;
  63497. /** Adds a bar between groups */
  63498. private _addSpacer;
  63499. /** Add a group to the selection panel
  63500. * @param group is the selector group to add
  63501. */
  63502. addGroup(group: SelectorGroup): void;
  63503. /** Remove the group from the given position
  63504. * @param groupNb is the position of the group in the list
  63505. */
  63506. removeGroup(groupNb: number): void;
  63507. /** Change a group header label
  63508. * @param label is the new group header label
  63509. * @param groupNb is the number of the group to relabel
  63510. * */
  63511. setHeaderName(label: string, groupNb: number): void;
  63512. /** Change selector label to the one given
  63513. * @param label is the new selector label
  63514. * @param groupNb is the number of the groupcontaining the selector
  63515. * @param selectorNb is the number of the selector within a group to relabel
  63516. * */
  63517. relabel(label: string, groupNb: number, selectorNb: number): void;
  63518. /** For a given group position remove the selector at the given position
  63519. * @param groupNb is the number of the group to remove the selector from
  63520. * @param selectorNb is the number of the selector within the group
  63521. */
  63522. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63523. /** For a given group position of correct type add a checkbox button
  63524. * @param groupNb is the number of the group to remove the selector from
  63525. * @param label is the label for the selector
  63526. * @param func is the function called when the Selector is checked
  63527. * @param checked is true when Selector is checked
  63528. */
  63529. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63530. /** For a given group position of correct type add a radio button
  63531. * @param groupNb is the number of the group to remove the selector from
  63532. * @param label is the label for the selector
  63533. * @param func is the function called when the Selector is checked
  63534. * @param checked is true when Selector is checked
  63535. */
  63536. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63537. /**
  63538. * For a given slider group add a slider
  63539. * @param groupNb is the number of the group to add the slider to
  63540. * @param label is the label for the Slider
  63541. * @param func is the function called when the Slider moves
  63542. * @param unit is a string describing the units used, eg degrees or metres
  63543. * @param min is the minimum value for the Slider
  63544. * @param max is the maximum value for the Slider
  63545. * @param value is the start value for the Slider between min and max
  63546. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63547. */
  63548. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63549. }
  63550. }
  63551. declare module BABYLON.GUI {
  63552. /**
  63553. * Class used to hold a the container for ScrollViewer
  63554. * @hidden
  63555. */
  63556. export class _ScrollViewerWindow extends Container {
  63557. parentClientWidth: number;
  63558. parentClientHeight: number;
  63559. /**
  63560. * Creates a new ScrollViewerWindow
  63561. * @param name of ScrollViewerWindow
  63562. */
  63563. constructor(name?: string);
  63564. protected _getTypeName(): string;
  63565. /** @hidden */
  63566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63567. protected _postMeasure(): void;
  63568. }
  63569. }
  63570. declare module BABYLON.GUI {
  63571. /**
  63572. * Class used to create slider controls
  63573. */
  63574. export class ScrollBar extends BaseSlider {
  63575. name?: string | undefined;
  63576. private _background;
  63577. private _borderColor;
  63578. private _thumbMeasure;
  63579. /** Gets or sets border color */
  63580. borderColor: string;
  63581. /** Gets or sets background color */
  63582. background: string;
  63583. /**
  63584. * Creates a new Slider
  63585. * @param name defines the control name
  63586. */
  63587. constructor(name?: string | undefined);
  63588. protected _getTypeName(): string;
  63589. protected _getThumbThickness(): number;
  63590. _draw(context: CanvasRenderingContext2D): void;
  63591. private _first;
  63592. private _originX;
  63593. private _originY;
  63594. /** @hidden */
  63595. protected _updateValueFromPointer(x: number, y: number): void;
  63596. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63597. }
  63598. }
  63599. declare module BABYLON.GUI {
  63600. /**
  63601. * Class used to hold a viewer window and sliders in a grid
  63602. */
  63603. export class ScrollViewer extends Rectangle {
  63604. private _grid;
  63605. private _horizontalBarSpace;
  63606. private _verticalBarSpace;
  63607. private _dragSpace;
  63608. private _horizontalBar;
  63609. private _verticalBar;
  63610. private _barColor;
  63611. private _barBackground;
  63612. private _barSize;
  63613. private _endLeft;
  63614. private _endTop;
  63615. private _window;
  63616. private _pointerIsOver;
  63617. private _wheelPrecision;
  63618. private _onPointerObserver;
  63619. private _clientWidth;
  63620. private _clientHeight;
  63621. /**
  63622. * Gets the horizontal scrollbar
  63623. */
  63624. readonly horizontalBar: ScrollBar;
  63625. /**
  63626. * Gets the vertical scrollbar
  63627. */
  63628. readonly verticalBar: ScrollBar;
  63629. /**
  63630. * Adds a new control to the current container
  63631. * @param control defines the control to add
  63632. * @returns the current container
  63633. */
  63634. addControl(control: BABYLON.Nullable<Control>): Container;
  63635. /**
  63636. * Removes a control from the current container
  63637. * @param control defines the control to remove
  63638. * @returns the current container
  63639. */
  63640. removeControl(control: Control): Container;
  63641. /** Gets the list of children */
  63642. readonly children: Control[];
  63643. _flagDescendantsAsMatrixDirty(): void;
  63644. /**
  63645. * Creates a new ScrollViewer
  63646. * @param name of ScrollViewer
  63647. */
  63648. constructor(name?: string);
  63649. /** Reset the scroll viewer window to initial size */
  63650. resetWindow(): void;
  63651. protected _getTypeName(): string;
  63652. private _buildClientSizes;
  63653. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63654. protected _postMeasure(): void;
  63655. /**
  63656. * Gets or sets the mouse wheel precision
  63657. * from 0 to 1 with a default value of 0.05
  63658. * */
  63659. wheelPrecision: number;
  63660. /** Gets or sets the bar color */
  63661. barColor: string;
  63662. /** Gets or sets the size of the bar */
  63663. barSize: number;
  63664. /** Gets or sets the bar background */
  63665. barBackground: string;
  63666. /** @hidden */
  63667. private _updateScroller;
  63668. _link(host: AdvancedDynamicTexture): void;
  63669. /** @hidden */
  63670. private _attachWheel;
  63671. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63672. /** Releases associated resources */
  63673. dispose(): void;
  63674. }
  63675. }
  63676. declare module BABYLON.GUI {
  63677. /** Class used to render a grid */
  63678. export class DisplayGrid extends Control {
  63679. name?: string | undefined;
  63680. private _cellWidth;
  63681. private _cellHeight;
  63682. private _minorLineTickness;
  63683. private _minorLineColor;
  63684. private _majorLineTickness;
  63685. private _majorLineColor;
  63686. private _majorLineFrequency;
  63687. private _background;
  63688. private _displayMajorLines;
  63689. private _displayMinorLines;
  63690. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63691. displayMinorLines: boolean;
  63692. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63693. displayMajorLines: boolean;
  63694. /** Gets or sets background color (Black by default) */
  63695. background: string;
  63696. /** Gets or sets the width of each cell (20 by default) */
  63697. cellWidth: number;
  63698. /** Gets or sets the height of each cell (20 by default) */
  63699. cellHeight: number;
  63700. /** Gets or sets the tickness of minor lines (1 by default) */
  63701. minorLineTickness: number;
  63702. /** Gets or sets the color of minor lines (DarkGray by default) */
  63703. minorLineColor: string;
  63704. /** Gets or sets the tickness of major lines (2 by default) */
  63705. majorLineTickness: number;
  63706. /** Gets or sets the color of major lines (White by default) */
  63707. majorLineColor: string;
  63708. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63709. majorLineFrequency: number;
  63710. /**
  63711. * Creates a new GridDisplayRectangle
  63712. * @param name defines the control name
  63713. */
  63714. constructor(name?: string | undefined);
  63715. _draw(context: CanvasRenderingContext2D): void;
  63716. protected _getTypeName(): string;
  63717. }
  63718. }
  63719. declare module BABYLON.GUI {
  63720. /**
  63721. * Class used to create slider controls based on images
  63722. */
  63723. export class ImageBasedSlider extends BaseSlider {
  63724. name?: string | undefined;
  63725. private _backgroundImage;
  63726. private _thumbImage;
  63727. private _valueBarImage;
  63728. private _tempMeasure;
  63729. displayThumb: boolean;
  63730. /**
  63731. * Gets or sets the image used to render the background
  63732. */
  63733. backgroundImage: Image;
  63734. /**
  63735. * Gets or sets the image used to render the value bar
  63736. */
  63737. valueBarImage: Image;
  63738. /**
  63739. * Gets or sets the image used to render the thumb
  63740. */
  63741. thumbImage: Image;
  63742. /**
  63743. * Creates a new ImageBasedSlider
  63744. * @param name defines the control name
  63745. */
  63746. constructor(name?: string | undefined);
  63747. protected _getTypeName(): string;
  63748. _draw(context: CanvasRenderingContext2D): void;
  63749. }
  63750. }
  63751. declare module BABYLON.GUI {
  63752. /**
  63753. * Forcing an export so that this code will execute
  63754. * @hidden
  63755. */
  63756. const name = "Statics";
  63757. }
  63758. declare module BABYLON.GUI {
  63759. /**
  63760. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63761. */
  63762. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63763. /**
  63764. * Define the instrumented AdvancedDynamicTexture.
  63765. */
  63766. texture: AdvancedDynamicTexture;
  63767. private _captureRenderTime;
  63768. private _renderTime;
  63769. private _captureLayoutTime;
  63770. private _layoutTime;
  63771. private _onBeginRenderObserver;
  63772. private _onEndRenderObserver;
  63773. private _onBeginLayoutObserver;
  63774. private _onEndLayoutObserver;
  63775. /**
  63776. * Gets the perf counter used to capture render time
  63777. */
  63778. readonly renderTimeCounter: BABYLON.PerfCounter;
  63779. /**
  63780. * Gets the perf counter used to capture layout time
  63781. */
  63782. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63783. /**
  63784. * Enable or disable the render time capture
  63785. */
  63786. captureRenderTime: boolean;
  63787. /**
  63788. * Enable or disable the layout time capture
  63789. */
  63790. captureLayoutTime: boolean;
  63791. /**
  63792. * Instantiates a new advanced dynamic texture instrumentation.
  63793. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63794. * @param texture Defines the AdvancedDynamicTexture to instrument
  63795. */
  63796. constructor(
  63797. /**
  63798. * Define the instrumented AdvancedDynamicTexture.
  63799. */
  63800. texture: AdvancedDynamicTexture);
  63801. /**
  63802. * Dispose and release associated resources.
  63803. */
  63804. dispose(): void;
  63805. }
  63806. }
  63807. declare module BABYLON.GUI {
  63808. /**
  63809. * Class used to create containers for controls
  63810. */
  63811. export class Container3D extends Control3D {
  63812. private _blockLayout;
  63813. /**
  63814. * Gets the list of child controls
  63815. */
  63816. protected _children: Control3D[];
  63817. /**
  63818. * Gets the list of child controls
  63819. */
  63820. readonly children: Array<Control3D>;
  63821. /**
  63822. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63823. * This is helpful to optimize layout operation when adding multiple children in a row
  63824. */
  63825. blockLayout: boolean;
  63826. /**
  63827. * Creates a new container
  63828. * @param name defines the container name
  63829. */
  63830. constructor(name?: string);
  63831. /**
  63832. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63833. * @returns the current container
  63834. */
  63835. updateLayout(): Container3D;
  63836. /**
  63837. * Gets a boolean indicating if the given control is in the children of this control
  63838. * @param control defines the control to check
  63839. * @returns true if the control is in the child list
  63840. */
  63841. containsControl(control: Control3D): boolean;
  63842. /**
  63843. * Adds a control to the children of this control
  63844. * @param control defines the control to add
  63845. * @returns the current container
  63846. */
  63847. addControl(control: Control3D): Container3D;
  63848. /**
  63849. * This function will be called everytime a new control is added
  63850. */
  63851. protected _arrangeChildren(): void;
  63852. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63853. /**
  63854. * Removes a control from the children of this control
  63855. * @param control defines the control to remove
  63856. * @returns the current container
  63857. */
  63858. removeControl(control: Control3D): Container3D;
  63859. protected _getTypeName(): string;
  63860. /**
  63861. * Releases all associated resources
  63862. */
  63863. dispose(): void;
  63864. /** Control rotation will remain unchanged */
  63865. static readonly UNSET_ORIENTATION: number;
  63866. /** Control will rotate to make it look at sphere central axis */
  63867. static readonly FACEORIGIN_ORIENTATION: number;
  63868. /** Control will rotate to make it look back at sphere central axis */
  63869. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63870. /** Control will rotate to look at z axis (0, 0, 1) */
  63871. static readonly FACEFORWARD_ORIENTATION: number;
  63872. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63873. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63874. }
  63875. }
  63876. declare module BABYLON.GUI {
  63877. /**
  63878. * Class used to manage 3D user interface
  63879. * @see http://doc.babylonjs.com/how_to/gui3d
  63880. */
  63881. export class GUI3DManager implements BABYLON.IDisposable {
  63882. private _scene;
  63883. private _sceneDisposeObserver;
  63884. private _utilityLayer;
  63885. private _rootContainer;
  63886. private _pointerObserver;
  63887. private _pointerOutObserver;
  63888. /** @hidden */
  63889. _lastPickedControl: Control3D;
  63890. /** @hidden */
  63891. _lastControlOver: {
  63892. [pointerId: number]: Control3D;
  63893. };
  63894. /** @hidden */
  63895. _lastControlDown: {
  63896. [pointerId: number]: Control3D;
  63897. };
  63898. /**
  63899. * BABYLON.Observable raised when the point picked by the pointer events changed
  63900. */
  63901. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63902. /** @hidden */
  63903. _sharedMaterials: {
  63904. [key: string]: BABYLON.Material;
  63905. };
  63906. /** Gets the hosting scene */
  63907. readonly scene: BABYLON.Scene;
  63908. /** Gets associated utility layer */
  63909. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63910. /**
  63911. * Creates a new GUI3DManager
  63912. * @param scene
  63913. */
  63914. constructor(scene?: BABYLON.Scene);
  63915. private _handlePointerOut;
  63916. private _doPicking;
  63917. /**
  63918. * Gets the root container
  63919. */
  63920. readonly rootContainer: Container3D;
  63921. /**
  63922. * Gets a boolean indicating if the given control is in the root child list
  63923. * @param control defines the control to check
  63924. * @returns true if the control is in the root child list
  63925. */
  63926. containsControl(control: Control3D): boolean;
  63927. /**
  63928. * Adds a control to the root child list
  63929. * @param control defines the control to add
  63930. * @returns the current manager
  63931. */
  63932. addControl(control: Control3D): GUI3DManager;
  63933. /**
  63934. * Removes a control from the root child list
  63935. * @param control defines the control to remove
  63936. * @returns the current container
  63937. */
  63938. removeControl(control: Control3D): GUI3DManager;
  63939. /**
  63940. * Releases all associated resources
  63941. */
  63942. dispose(): void;
  63943. }
  63944. }
  63945. declare module BABYLON.GUI {
  63946. /**
  63947. * Class used to transport BABYLON.Vector3 information for pointer events
  63948. */
  63949. export class Vector3WithInfo extends BABYLON.Vector3 {
  63950. /** defines the current mouse button index */
  63951. buttonIndex: number;
  63952. /**
  63953. * Creates a new Vector3WithInfo
  63954. * @param source defines the vector3 data to transport
  63955. * @param buttonIndex defines the current mouse button index
  63956. */
  63957. constructor(source: BABYLON.Vector3,
  63958. /** defines the current mouse button index */
  63959. buttonIndex?: number);
  63960. }
  63961. }
  63962. declare module BABYLON.GUI {
  63963. /**
  63964. * Class used as base class for controls
  63965. */
  63966. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63967. /** Defines the control name */
  63968. name?: string | undefined;
  63969. /** @hidden */
  63970. _host: GUI3DManager;
  63971. private _node;
  63972. private _downCount;
  63973. private _enterCount;
  63974. private _downPointerIds;
  63975. private _isVisible;
  63976. /** Gets or sets the control position in world space */
  63977. position: BABYLON.Vector3;
  63978. /** Gets or sets the control scaling in world space */
  63979. scaling: BABYLON.Vector3;
  63980. /** Callback used to start pointer enter animation */
  63981. pointerEnterAnimation: () => void;
  63982. /** Callback used to start pointer out animation */
  63983. pointerOutAnimation: () => void;
  63984. /** Callback used to start pointer down animation */
  63985. pointerDownAnimation: () => void;
  63986. /** Callback used to start pointer up animation */
  63987. pointerUpAnimation: () => void;
  63988. /**
  63989. * An event triggered when the pointer move over the control
  63990. */
  63991. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63992. /**
  63993. * An event triggered when the pointer move out of the control
  63994. */
  63995. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63996. /**
  63997. * An event triggered when the pointer taps the control
  63998. */
  63999. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64000. /**
  64001. * An event triggered when pointer is up
  64002. */
  64003. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64004. /**
  64005. * An event triggered when a control is clicked on (with a mouse)
  64006. */
  64007. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64008. /**
  64009. * An event triggered when pointer enters the control
  64010. */
  64011. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64012. /**
  64013. * Gets or sets the parent container
  64014. */
  64015. parent: BABYLON.Nullable<Container3D>;
  64016. private _behaviors;
  64017. /**
  64018. * Gets the list of attached behaviors
  64019. * @see http://doc.babylonjs.com/features/behaviour
  64020. */
  64021. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64022. /**
  64023. * Attach a behavior to the control
  64024. * @see http://doc.babylonjs.com/features/behaviour
  64025. * @param behavior defines the behavior to attach
  64026. * @returns the current control
  64027. */
  64028. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64029. /**
  64030. * Remove an attached behavior
  64031. * @see http://doc.babylonjs.com/features/behaviour
  64032. * @param behavior defines the behavior to attach
  64033. * @returns the current control
  64034. */
  64035. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64036. /**
  64037. * Gets an attached behavior by name
  64038. * @param name defines the name of the behavior to look for
  64039. * @see http://doc.babylonjs.com/features/behaviour
  64040. * @returns null if behavior was not found else the requested behavior
  64041. */
  64042. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64043. /** Gets or sets a boolean indicating if the control is visible */
  64044. isVisible: boolean;
  64045. /**
  64046. * Creates a new control
  64047. * @param name defines the control name
  64048. */
  64049. constructor(
  64050. /** Defines the control name */
  64051. name?: string | undefined);
  64052. /**
  64053. * Gets a string representing the class name
  64054. */
  64055. readonly typeName: string;
  64056. /**
  64057. * Get the current class name of the control.
  64058. * @returns current class name
  64059. */
  64060. getClassName(): string;
  64061. protected _getTypeName(): string;
  64062. /**
  64063. * Gets the transform node used by this control
  64064. */
  64065. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64066. /**
  64067. * Gets the mesh used to render this control
  64068. */
  64069. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64070. /**
  64071. * Link the control as child of the given node
  64072. * @param node defines the node to link to. Use null to unlink the control
  64073. * @returns the current control
  64074. */
  64075. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64076. /** @hidden **/
  64077. _prepareNode(scene: BABYLON.Scene): void;
  64078. /**
  64079. * Node creation.
  64080. * Can be overriden by children
  64081. * @param scene defines the scene where the node must be attached
  64082. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64083. */
  64084. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64085. /**
  64086. * Affect a material to the given mesh
  64087. * @param mesh defines the mesh which will represent the control
  64088. */
  64089. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64090. /** @hidden */
  64091. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64092. /** @hidden */
  64093. _onPointerEnter(target: Control3D): boolean;
  64094. /** @hidden */
  64095. _onPointerOut(target: Control3D): void;
  64096. /** @hidden */
  64097. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64098. /** @hidden */
  64099. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64100. /** @hidden */
  64101. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64102. /** @hidden */
  64103. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64104. /** @hidden */
  64105. _disposeNode(): void;
  64106. /**
  64107. * Releases all associated resources
  64108. */
  64109. dispose(): void;
  64110. }
  64111. }
  64112. declare module BABYLON.GUI {
  64113. /**
  64114. * Class used as a root to all buttons
  64115. */
  64116. export class AbstractButton3D extends Control3D {
  64117. /**
  64118. * Creates a new button
  64119. * @param name defines the control name
  64120. */
  64121. constructor(name?: string);
  64122. protected _getTypeName(): string;
  64123. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64124. }
  64125. }
  64126. declare module BABYLON.GUI {
  64127. /**
  64128. * Class used to create a button in 3D
  64129. */
  64130. export class Button3D extends AbstractButton3D {
  64131. /** @hidden */
  64132. protected _currentMaterial: BABYLON.Material;
  64133. private _facadeTexture;
  64134. private _content;
  64135. private _contentResolution;
  64136. private _contentScaleRatio;
  64137. /**
  64138. * Gets or sets the texture resolution used to render content (512 by default)
  64139. */
  64140. contentResolution: BABYLON.int;
  64141. /**
  64142. * Gets or sets the texture scale ratio used to render content (2 by default)
  64143. */
  64144. contentScaleRatio: number;
  64145. protected _disposeFacadeTexture(): void;
  64146. protected _resetContent(): void;
  64147. /**
  64148. * Creates a new button
  64149. * @param name defines the control name
  64150. */
  64151. constructor(name?: string);
  64152. /**
  64153. * Gets or sets the GUI 2D content used to display the button's facade
  64154. */
  64155. content: Control;
  64156. /**
  64157. * Apply the facade texture (created from the content property).
  64158. * This function can be overloaded by child classes
  64159. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64160. */
  64161. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64162. protected _getTypeName(): string;
  64163. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64164. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64165. /**
  64166. * Releases all associated resources
  64167. */
  64168. dispose(): void;
  64169. }
  64170. }
  64171. declare module BABYLON.GUI {
  64172. /**
  64173. * Abstract class used to create a container panel deployed on the surface of a volume
  64174. */
  64175. export abstract class VolumeBasedPanel extends Container3D {
  64176. private _columns;
  64177. private _rows;
  64178. private _rowThenColum;
  64179. private _orientation;
  64180. protected _cellWidth: number;
  64181. protected _cellHeight: number;
  64182. /**
  64183. * Gets or sets the distance between elements
  64184. */
  64185. margin: number;
  64186. /**
  64187. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64188. * | Value | Type | Description |
  64189. * | ----- | ----------------------------------- | ----------- |
  64190. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64191. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64192. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64193. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64194. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64195. */
  64196. orientation: number;
  64197. /**
  64198. * Gets or sets the number of columns requested (10 by default).
  64199. * The panel will automatically compute the number of rows based on number of child controls.
  64200. */
  64201. columns: BABYLON.int;
  64202. /**
  64203. * Gets or sets a the number of rows requested.
  64204. * The panel will automatically compute the number of columns based on number of child controls.
  64205. */
  64206. rows: BABYLON.int;
  64207. /**
  64208. * Creates new VolumeBasedPanel
  64209. */
  64210. constructor();
  64211. protected _arrangeChildren(): void;
  64212. /** Child classes must implement this function to provide correct control positioning */
  64213. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64214. /** Child classes can implement this function to provide additional processing */
  64215. protected _finalProcessing(): void;
  64216. }
  64217. }
  64218. declare module BABYLON.GUI {
  64219. /**
  64220. * Class used to create a container panel deployed on the surface of a cylinder
  64221. */
  64222. export class CylinderPanel extends VolumeBasedPanel {
  64223. private _radius;
  64224. /**
  64225. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64226. */
  64227. radius: BABYLON.float;
  64228. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64229. private _cylindricalMapping;
  64230. }
  64231. }
  64232. declare module BABYLON.GUI {
  64233. /** @hidden */
  64234. export var fluentVertexShader: {
  64235. name: string;
  64236. shader: string;
  64237. };
  64238. }
  64239. declare module BABYLON.GUI {
  64240. /** @hidden */
  64241. export var fluentPixelShader: {
  64242. name: string;
  64243. shader: string;
  64244. };
  64245. }
  64246. declare module BABYLON.GUI {
  64247. /** @hidden */
  64248. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64249. INNERGLOW: boolean;
  64250. BORDER: boolean;
  64251. HOVERLIGHT: boolean;
  64252. TEXTURE: boolean;
  64253. constructor();
  64254. }
  64255. /**
  64256. * Class used to render controls with fluent desgin
  64257. */
  64258. export class FluentMaterial extends BABYLON.PushMaterial {
  64259. /**
  64260. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64261. */
  64262. innerGlowColorIntensity: number;
  64263. /**
  64264. * Gets or sets the inner glow color (white by default)
  64265. */
  64266. innerGlowColor: BABYLON.Color3;
  64267. /**
  64268. * Gets or sets alpha value (default is 1.0)
  64269. */
  64270. alpha: number;
  64271. /**
  64272. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64273. */
  64274. albedoColor: BABYLON.Color3;
  64275. /**
  64276. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64277. */
  64278. renderBorders: boolean;
  64279. /**
  64280. * Gets or sets border width (default is 0.5)
  64281. */
  64282. borderWidth: number;
  64283. /**
  64284. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64285. */
  64286. edgeSmoothingValue: number;
  64287. /**
  64288. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64289. */
  64290. borderMinValue: number;
  64291. /**
  64292. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64293. */
  64294. renderHoverLight: boolean;
  64295. /**
  64296. * Gets or sets the radius used to render the hover light (default is 1.0)
  64297. */
  64298. hoverRadius: number;
  64299. /**
  64300. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64301. */
  64302. hoverColor: BABYLON.Color4;
  64303. /**
  64304. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64305. */
  64306. hoverPosition: BABYLON.Vector3;
  64307. private _albedoTexture;
  64308. /** Gets or sets the texture to use for albedo color */
  64309. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64310. /**
  64311. * Creates a new Fluent material
  64312. * @param name defines the name of the material
  64313. * @param scene defines the hosting scene
  64314. */
  64315. constructor(name: string, scene: BABYLON.Scene);
  64316. needAlphaBlending(): boolean;
  64317. needAlphaTesting(): boolean;
  64318. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64321. getActiveTextures(): BABYLON.BaseTexture[];
  64322. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64323. dispose(forceDisposeEffect?: boolean): void;
  64324. clone(name: string): FluentMaterial;
  64325. serialize(): any;
  64326. getClassName(): string;
  64327. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64328. }
  64329. }
  64330. declare module BABYLON.GUI {
  64331. /**
  64332. * Class used to create a holographic button in 3D
  64333. */
  64334. export class HolographicButton extends Button3D {
  64335. private _backPlate;
  64336. private _textPlate;
  64337. private _frontPlate;
  64338. private _text;
  64339. private _imageUrl;
  64340. private _shareMaterials;
  64341. private _frontMaterial;
  64342. private _backMaterial;
  64343. private _plateMaterial;
  64344. private _pickedPointObserver;
  64345. private _tooltipFade;
  64346. private _tooltipTextBlock;
  64347. private _tooltipTexture;
  64348. private _tooltipMesh;
  64349. private _tooltipHoverObserver;
  64350. private _tooltipOutObserver;
  64351. private _disposeTooltip;
  64352. /**
  64353. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64354. */
  64355. tooltipText: BABYLON.Nullable<string>;
  64356. /**
  64357. * Gets or sets text for the button
  64358. */
  64359. text: string;
  64360. /**
  64361. * Gets or sets the image url for the button
  64362. */
  64363. imageUrl: string;
  64364. /**
  64365. * Gets the back material used by this button
  64366. */
  64367. readonly backMaterial: FluentMaterial;
  64368. /**
  64369. * Gets the front material used by this button
  64370. */
  64371. readonly frontMaterial: FluentMaterial;
  64372. /**
  64373. * Gets the plate material used by this button
  64374. */
  64375. readonly plateMaterial: BABYLON.StandardMaterial;
  64376. /**
  64377. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64378. */
  64379. readonly shareMaterials: boolean;
  64380. /**
  64381. * Creates a new button
  64382. * @param name defines the control name
  64383. */
  64384. constructor(name?: string, shareMaterials?: boolean);
  64385. protected _getTypeName(): string;
  64386. private _rebuildContent;
  64387. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64388. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64389. private _createBackMaterial;
  64390. private _createFrontMaterial;
  64391. private _createPlateMaterial;
  64392. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64393. /**
  64394. * Releases all associated resources
  64395. */
  64396. dispose(): void;
  64397. }
  64398. }
  64399. declare module BABYLON.GUI {
  64400. /**
  64401. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64402. */
  64403. export class MeshButton3D extends Button3D {
  64404. /** @hidden */
  64405. protected _currentMesh: BABYLON.Mesh;
  64406. /**
  64407. * Creates a new 3D button based on a mesh
  64408. * @param mesh mesh to become a 3D button
  64409. * @param name defines the control name
  64410. */
  64411. constructor(mesh: BABYLON.Mesh, name?: string);
  64412. protected _getTypeName(): string;
  64413. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64414. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64415. }
  64416. }
  64417. declare module BABYLON.GUI {
  64418. /**
  64419. * Class used to create a container panel deployed on the surface of a plane
  64420. */
  64421. export class PlanePanel extends VolumeBasedPanel {
  64422. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64423. }
  64424. }
  64425. declare module BABYLON.GUI {
  64426. /**
  64427. * Class used to create a container panel where items get randomized planar mapping
  64428. */
  64429. export class ScatterPanel extends VolumeBasedPanel {
  64430. private _iteration;
  64431. /**
  64432. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64433. */
  64434. iteration: BABYLON.float;
  64435. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64436. private _scatterMapping;
  64437. protected _finalProcessing(): void;
  64438. }
  64439. }
  64440. declare module BABYLON.GUI {
  64441. /**
  64442. * Class used to create a container panel deployed on the surface of a sphere
  64443. */
  64444. export class SpherePanel extends VolumeBasedPanel {
  64445. private _radius;
  64446. /**
  64447. * Gets or sets the radius of the sphere where to project controls (5 by default)
  64448. */
  64449. radius: BABYLON.float;
  64450. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64451. private _sphericalMapping;
  64452. }
  64453. }
  64454. declare module BABYLON.GUI {
  64455. /**
  64456. * Class used to create a stack panel in 3D on XY plane
  64457. */
  64458. export class StackPanel3D extends Container3D {
  64459. private _isVertical;
  64460. /**
  64461. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  64462. */
  64463. isVertical: boolean;
  64464. /**
  64465. * Gets or sets the distance between elements
  64466. */
  64467. margin: number;
  64468. /**
  64469. * Creates new StackPanel
  64470. * @param isVertical
  64471. */
  64472. constructor(isVertical?: boolean);
  64473. protected _arrangeChildren(): void;
  64474. }
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * Mode that determines the coordinate system to use.
  64479. */
  64480. export enum GLTFLoaderCoordinateSystemMode {
  64481. /**
  64482. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64483. */
  64484. AUTO = 0,
  64485. /**
  64486. * Sets the useRightHandedSystem flag on the scene.
  64487. */
  64488. FORCE_RIGHT_HANDED = 1
  64489. }
  64490. /**
  64491. * Mode that determines what animations will start.
  64492. */
  64493. export enum GLTFLoaderAnimationStartMode {
  64494. /**
  64495. * No animation will start.
  64496. */
  64497. NONE = 0,
  64498. /**
  64499. * The first animation will start.
  64500. */
  64501. FIRST = 1,
  64502. /**
  64503. * All animations will start.
  64504. */
  64505. ALL = 2
  64506. }
  64507. /**
  64508. * Interface that contains the data for the glTF asset.
  64509. */
  64510. export interface IGLTFLoaderData {
  64511. /**
  64512. * Object that represents the glTF JSON.
  64513. */
  64514. json: Object;
  64515. /**
  64516. * The BIN chunk of a binary glTF.
  64517. */
  64518. bin: Nullable<ArrayBufferView>;
  64519. }
  64520. /**
  64521. * Interface for extending the loader.
  64522. */
  64523. export interface IGLTFLoaderExtension {
  64524. /**
  64525. * The name of this extension.
  64526. */
  64527. readonly name: string;
  64528. /**
  64529. * Defines whether this extension is enabled.
  64530. */
  64531. enabled: boolean;
  64532. }
  64533. /**
  64534. * Loader state.
  64535. */
  64536. export enum GLTFLoaderState {
  64537. /**
  64538. * The asset is loading.
  64539. */
  64540. LOADING = 0,
  64541. /**
  64542. * The asset is ready for rendering.
  64543. */
  64544. READY = 1,
  64545. /**
  64546. * The asset is completely loaded.
  64547. */
  64548. COMPLETE = 2
  64549. }
  64550. /** @hidden */
  64551. export interface IGLTFLoader extends IDisposable {
  64552. readonly state: Nullable<GLTFLoaderState>;
  64553. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64554. meshes: AbstractMesh[];
  64555. particleSystems: IParticleSystem[];
  64556. skeletons: Skeleton[];
  64557. animationGroups: AnimationGroup[];
  64558. }>;
  64559. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64560. }
  64561. /**
  64562. * File loader for loading glTF files into a scene.
  64563. */
  64564. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64565. /** @hidden */
  64566. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64567. /** @hidden */
  64568. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64569. /**
  64570. * Raised when the asset has been parsed
  64571. */
  64572. onParsedObservable: Observable<IGLTFLoaderData>;
  64573. private _onParsedObserver;
  64574. /**
  64575. * Raised when the asset has been parsed
  64576. */
  64577. onParsed: (loaderData: IGLTFLoaderData) => void;
  64578. /**
  64579. * 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.
  64580. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64581. * Defaults to true.
  64582. * @hidden
  64583. */
  64584. static IncrementalLoading: boolean;
  64585. /**
  64586. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64587. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64588. * @hidden
  64589. */
  64590. static HomogeneousCoordinates: boolean;
  64591. /**
  64592. * The coordinate system mode. Defaults to AUTO.
  64593. */
  64594. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64595. /**
  64596. * The animation start mode. Defaults to FIRST.
  64597. */
  64598. animationStartMode: GLTFLoaderAnimationStartMode;
  64599. /**
  64600. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64601. */
  64602. compileMaterials: boolean;
  64603. /**
  64604. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64605. */
  64606. useClipPlane: boolean;
  64607. /**
  64608. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64609. */
  64610. compileShadowGenerators: boolean;
  64611. /**
  64612. * Defines if the Alpha blended materials are only applied as coverage.
  64613. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64614. * If true, no extra effects are applied to transparent pixels.
  64615. */
  64616. transparencyAsCoverage: boolean;
  64617. /**
  64618. * Function called before loading a url referenced by the asset.
  64619. */
  64620. preprocessUrlAsync: (url: string) => Promise<string>;
  64621. /**
  64622. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64623. */
  64624. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64625. private _onMeshLoadedObserver;
  64626. /**
  64627. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64628. */
  64629. onMeshLoaded: (mesh: AbstractMesh) => void;
  64630. /**
  64631. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64632. */
  64633. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64634. private _onTextureLoadedObserver;
  64635. /**
  64636. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64637. */
  64638. onTextureLoaded: (texture: BaseTexture) => void;
  64639. /**
  64640. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64641. */
  64642. readonly onMaterialLoadedObservable: Observable<Material>;
  64643. private _onMaterialLoadedObserver;
  64644. /**
  64645. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64646. */
  64647. onMaterialLoaded: (material: Material) => void;
  64648. /**
  64649. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64650. */
  64651. readonly onCameraLoadedObservable: Observable<Camera>;
  64652. private _onCameraLoadedObserver;
  64653. /**
  64654. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64655. */
  64656. onCameraLoaded: (camera: Camera) => void;
  64657. /**
  64658. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64659. * For assets with LODs, raised when all of the LODs are complete.
  64660. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64661. */
  64662. readonly onCompleteObservable: Observable<void>;
  64663. private _onCompleteObserver;
  64664. /**
  64665. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64666. * For assets with LODs, raised when all of the LODs are complete.
  64667. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64668. */
  64669. onComplete: () => void;
  64670. /**
  64671. * Observable raised when an error occurs.
  64672. */
  64673. readonly onErrorObservable: Observable<any>;
  64674. private _onErrorObserver;
  64675. /**
  64676. * Callback raised when an error occurs.
  64677. */
  64678. onError: (reason: any) => void;
  64679. /**
  64680. * Observable raised after the loader is disposed.
  64681. */
  64682. readonly onDisposeObservable: Observable<void>;
  64683. private _onDisposeObserver;
  64684. /**
  64685. * Callback raised after the loader is disposed.
  64686. */
  64687. onDispose: () => void;
  64688. /**
  64689. * Observable raised after a loader extension is created.
  64690. * Set additional options for a loader extension in this event.
  64691. */
  64692. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64693. private _onExtensionLoadedObserver;
  64694. /**
  64695. * Callback raised after a loader extension is created.
  64696. */
  64697. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64698. /**
  64699. * Defines if the loader logging is enabled.
  64700. */
  64701. loggingEnabled: boolean;
  64702. /**
  64703. * Defines if the loader should capture performance counters.
  64704. */
  64705. capturePerformanceCounters: boolean;
  64706. /**
  64707. * Defines if the loader should validate the asset.
  64708. */
  64709. validate: boolean;
  64710. /**
  64711. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64712. */
  64713. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64714. private _onValidatedObserver;
  64715. /**
  64716. * Callback raised after a loader extension is created.
  64717. */
  64718. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64719. private _loader;
  64720. /**
  64721. * Name of the loader ("gltf")
  64722. */
  64723. name: string;
  64724. /**
  64725. * Supported file extensions of the loader (.gltf, .glb)
  64726. */
  64727. extensions: ISceneLoaderPluginExtensions;
  64728. /**
  64729. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64730. */
  64731. dispose(): void;
  64732. /** @hidden */
  64733. _clear(): void;
  64734. /**
  64735. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64736. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64737. * @param scene the scene the meshes should be added to
  64738. * @param data the glTF data to load
  64739. * @param rootUrl root url to load from
  64740. * @param onProgress event that fires when loading progress has occured
  64741. * @param fileName Defines the name of the file to load
  64742. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64743. */
  64744. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64745. meshes: AbstractMesh[];
  64746. particleSystems: IParticleSystem[];
  64747. skeletons: Skeleton[];
  64748. animationGroups: AnimationGroup[];
  64749. }>;
  64750. /**
  64751. * Imports all objects from the loaded glTF data and adds them to the scene
  64752. * @param scene the scene the objects should be added to
  64753. * @param data the glTF data to load
  64754. * @param rootUrl root url to load from
  64755. * @param onProgress event that fires when loading progress has occured
  64756. * @param fileName Defines the name of the file to load
  64757. * @returns a promise which completes when objects have been loaded to the scene
  64758. */
  64759. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64760. /**
  64761. * Load into an asset container.
  64762. * @param scene The scene to load into
  64763. * @param data The data to import
  64764. * @param rootUrl The root url for scene and resources
  64765. * @param onProgress The callback when the load progresses
  64766. * @param fileName Defines the name of the file to load
  64767. * @returns The loaded asset container
  64768. */
  64769. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64770. /**
  64771. * If the data string can be loaded directly.
  64772. * @param data string contianing the file data
  64773. * @returns if the data can be loaded directly
  64774. */
  64775. canDirectLoad(data: string): boolean;
  64776. /**
  64777. * Rewrites a url by combining a root url and response url.
  64778. */
  64779. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64780. /**
  64781. * Instantiates a glTF file loader plugin.
  64782. * @returns the created plugin
  64783. */
  64784. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64785. /**
  64786. * The loader state or null if the loader is not active.
  64787. */
  64788. readonly loaderState: Nullable<GLTFLoaderState>;
  64789. /**
  64790. * Returns a promise that resolves when the asset is completely loaded.
  64791. * @returns a promise that resolves when the asset is completely loaded.
  64792. */
  64793. whenCompleteAsync(): Promise<void>;
  64794. private _parseAsync;
  64795. private _validateAsync;
  64796. private _getLoader;
  64797. private _unpackBinary;
  64798. private _unpackBinaryV1;
  64799. private _unpackBinaryV2;
  64800. private static _parseVersion;
  64801. private static _compareVersion;
  64802. private static _decodeBufferToText;
  64803. private static readonly _logSpaces;
  64804. private _logIndentLevel;
  64805. private _loggingEnabled;
  64806. /** @hidden */
  64807. _log: (message: string) => void;
  64808. /** @hidden */
  64809. _logOpen(message: string): void;
  64810. /** @hidden */
  64811. _logClose(): void;
  64812. private _logEnabled;
  64813. private _logDisabled;
  64814. private _capturePerformanceCounters;
  64815. /** @hidden */
  64816. _startPerformanceCounter: (counterName: string) => void;
  64817. /** @hidden */
  64818. _endPerformanceCounter: (counterName: string) => void;
  64819. private _startPerformanceCounterEnabled;
  64820. private _startPerformanceCounterDisabled;
  64821. private _endPerformanceCounterEnabled;
  64822. private _endPerformanceCounterDisabled;
  64823. }
  64824. }
  64825. declare module BABYLON.GLTF1 {
  64826. /**
  64827. * Enums
  64828. * @hidden
  64829. */
  64830. export enum EComponentType {
  64831. BYTE = 5120,
  64832. UNSIGNED_BYTE = 5121,
  64833. SHORT = 5122,
  64834. UNSIGNED_SHORT = 5123,
  64835. FLOAT = 5126
  64836. }
  64837. /** @hidden */
  64838. export enum EShaderType {
  64839. FRAGMENT = 35632,
  64840. VERTEX = 35633
  64841. }
  64842. /** @hidden */
  64843. export enum EParameterType {
  64844. BYTE = 5120,
  64845. UNSIGNED_BYTE = 5121,
  64846. SHORT = 5122,
  64847. UNSIGNED_SHORT = 5123,
  64848. INT = 5124,
  64849. UNSIGNED_INT = 5125,
  64850. FLOAT = 5126,
  64851. FLOAT_VEC2 = 35664,
  64852. FLOAT_VEC3 = 35665,
  64853. FLOAT_VEC4 = 35666,
  64854. INT_VEC2 = 35667,
  64855. INT_VEC3 = 35668,
  64856. INT_VEC4 = 35669,
  64857. BOOL = 35670,
  64858. BOOL_VEC2 = 35671,
  64859. BOOL_VEC3 = 35672,
  64860. BOOL_VEC4 = 35673,
  64861. FLOAT_MAT2 = 35674,
  64862. FLOAT_MAT3 = 35675,
  64863. FLOAT_MAT4 = 35676,
  64864. SAMPLER_2D = 35678
  64865. }
  64866. /** @hidden */
  64867. export enum ETextureWrapMode {
  64868. CLAMP_TO_EDGE = 33071,
  64869. MIRRORED_REPEAT = 33648,
  64870. REPEAT = 10497
  64871. }
  64872. /** @hidden */
  64873. export enum ETextureFilterType {
  64874. NEAREST = 9728,
  64875. LINEAR = 9728,
  64876. NEAREST_MIPMAP_NEAREST = 9984,
  64877. LINEAR_MIPMAP_NEAREST = 9985,
  64878. NEAREST_MIPMAP_LINEAR = 9986,
  64879. LINEAR_MIPMAP_LINEAR = 9987
  64880. }
  64881. /** @hidden */
  64882. export enum ETextureFormat {
  64883. ALPHA = 6406,
  64884. RGB = 6407,
  64885. RGBA = 6408,
  64886. LUMINANCE = 6409,
  64887. LUMINANCE_ALPHA = 6410
  64888. }
  64889. /** @hidden */
  64890. export enum ECullingType {
  64891. FRONT = 1028,
  64892. BACK = 1029,
  64893. FRONT_AND_BACK = 1032
  64894. }
  64895. /** @hidden */
  64896. export enum EBlendingFunction {
  64897. ZERO = 0,
  64898. ONE = 1,
  64899. SRC_COLOR = 768,
  64900. ONE_MINUS_SRC_COLOR = 769,
  64901. DST_COLOR = 774,
  64902. ONE_MINUS_DST_COLOR = 775,
  64903. SRC_ALPHA = 770,
  64904. ONE_MINUS_SRC_ALPHA = 771,
  64905. DST_ALPHA = 772,
  64906. ONE_MINUS_DST_ALPHA = 773,
  64907. CONSTANT_COLOR = 32769,
  64908. ONE_MINUS_CONSTANT_COLOR = 32770,
  64909. CONSTANT_ALPHA = 32771,
  64910. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64911. SRC_ALPHA_SATURATE = 776
  64912. }
  64913. /** @hidden */
  64914. export interface IGLTFProperty {
  64915. extensions?: {
  64916. [key: string]: any;
  64917. };
  64918. extras?: Object;
  64919. }
  64920. /** @hidden */
  64921. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64922. name?: string;
  64923. }
  64924. /** @hidden */
  64925. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64926. bufferView: string;
  64927. byteOffset: number;
  64928. byteStride: number;
  64929. count: number;
  64930. type: string;
  64931. componentType: EComponentType;
  64932. max?: number[];
  64933. min?: number[];
  64934. name?: string;
  64935. }
  64936. /** @hidden */
  64937. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64938. buffer: string;
  64939. byteOffset: number;
  64940. byteLength: number;
  64941. byteStride: number;
  64942. target?: number;
  64943. }
  64944. /** @hidden */
  64945. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64946. uri: string;
  64947. byteLength?: number;
  64948. type?: string;
  64949. }
  64950. /** @hidden */
  64951. export interface IGLTFShader extends IGLTFChildRootProperty {
  64952. uri: string;
  64953. type: EShaderType;
  64954. }
  64955. /** @hidden */
  64956. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64957. attributes: string[];
  64958. fragmentShader: string;
  64959. vertexShader: string;
  64960. }
  64961. /** @hidden */
  64962. export interface IGLTFTechniqueParameter {
  64963. type: number;
  64964. count?: number;
  64965. semantic?: string;
  64966. node?: string;
  64967. value?: number | boolean | string | Array<any>;
  64968. source?: string;
  64969. babylonValue?: any;
  64970. }
  64971. /** @hidden */
  64972. export interface IGLTFTechniqueCommonProfile {
  64973. lightingModel: string;
  64974. texcoordBindings: Object;
  64975. parameters?: Array<any>;
  64976. }
  64977. /** @hidden */
  64978. export interface IGLTFTechniqueStatesFunctions {
  64979. blendColor?: number[];
  64980. blendEquationSeparate?: number[];
  64981. blendFuncSeparate?: number[];
  64982. colorMask: boolean[];
  64983. cullFace: number[];
  64984. }
  64985. /** @hidden */
  64986. export interface IGLTFTechniqueStates {
  64987. enable: number[];
  64988. functions: IGLTFTechniqueStatesFunctions;
  64989. }
  64990. /** @hidden */
  64991. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64992. parameters: {
  64993. [key: string]: IGLTFTechniqueParameter;
  64994. };
  64995. program: string;
  64996. attributes: {
  64997. [key: string]: string;
  64998. };
  64999. uniforms: {
  65000. [key: string]: string;
  65001. };
  65002. states: IGLTFTechniqueStates;
  65003. }
  65004. /** @hidden */
  65005. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65006. technique?: string;
  65007. values: string[];
  65008. }
  65009. /** @hidden */
  65010. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65011. attributes: {
  65012. [key: string]: string;
  65013. };
  65014. indices: string;
  65015. material: string;
  65016. mode?: number;
  65017. }
  65018. /** @hidden */
  65019. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65020. primitives: IGLTFMeshPrimitive[];
  65021. }
  65022. /** @hidden */
  65023. export interface IGLTFImage extends IGLTFChildRootProperty {
  65024. uri: string;
  65025. }
  65026. /** @hidden */
  65027. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65028. magFilter?: number;
  65029. minFilter?: number;
  65030. wrapS?: number;
  65031. wrapT?: number;
  65032. }
  65033. /** @hidden */
  65034. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65035. sampler: string;
  65036. source: string;
  65037. format?: ETextureFormat;
  65038. internalFormat?: ETextureFormat;
  65039. target?: number;
  65040. type?: number;
  65041. babylonTexture?: Texture;
  65042. }
  65043. /** @hidden */
  65044. export interface IGLTFAmbienLight {
  65045. color?: number[];
  65046. }
  65047. /** @hidden */
  65048. export interface IGLTFDirectionalLight {
  65049. color?: number[];
  65050. }
  65051. /** @hidden */
  65052. export interface IGLTFPointLight {
  65053. color?: number[];
  65054. constantAttenuation?: number;
  65055. linearAttenuation?: number;
  65056. quadraticAttenuation?: number;
  65057. }
  65058. /** @hidden */
  65059. export interface IGLTFSpotLight {
  65060. color?: number[];
  65061. constantAttenuation?: number;
  65062. fallOfAngle?: number;
  65063. fallOffExponent?: number;
  65064. linearAttenuation?: number;
  65065. quadraticAttenuation?: number;
  65066. }
  65067. /** @hidden */
  65068. export interface IGLTFLight extends IGLTFChildRootProperty {
  65069. type: string;
  65070. }
  65071. /** @hidden */
  65072. export interface IGLTFCameraOrthographic {
  65073. xmag: number;
  65074. ymag: number;
  65075. zfar: number;
  65076. znear: number;
  65077. }
  65078. /** @hidden */
  65079. export interface IGLTFCameraPerspective {
  65080. aspectRatio: number;
  65081. yfov: number;
  65082. zfar: number;
  65083. znear: number;
  65084. }
  65085. /** @hidden */
  65086. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65087. type: string;
  65088. }
  65089. /** @hidden */
  65090. export interface IGLTFAnimationChannelTarget {
  65091. id: string;
  65092. path: string;
  65093. }
  65094. /** @hidden */
  65095. export interface IGLTFAnimationChannel {
  65096. sampler: string;
  65097. target: IGLTFAnimationChannelTarget;
  65098. }
  65099. /** @hidden */
  65100. export interface IGLTFAnimationSampler {
  65101. input: string;
  65102. output: string;
  65103. interpolation?: string;
  65104. }
  65105. /** @hidden */
  65106. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65107. channels?: IGLTFAnimationChannel[];
  65108. parameters?: {
  65109. [key: string]: string;
  65110. };
  65111. samplers?: {
  65112. [key: string]: IGLTFAnimationSampler;
  65113. };
  65114. }
  65115. /** @hidden */
  65116. export interface IGLTFNodeInstanceSkin {
  65117. skeletons: string[];
  65118. skin: string;
  65119. meshes: string[];
  65120. }
  65121. /** @hidden */
  65122. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65123. bindShapeMatrix: number[];
  65124. inverseBindMatrices: string;
  65125. jointNames: string[];
  65126. babylonSkeleton?: Skeleton;
  65127. }
  65128. /** @hidden */
  65129. export interface IGLTFNode extends IGLTFChildRootProperty {
  65130. camera?: string;
  65131. children: string[];
  65132. skin?: string;
  65133. jointName?: string;
  65134. light?: string;
  65135. matrix: number[];
  65136. mesh?: string;
  65137. meshes?: string[];
  65138. rotation?: number[];
  65139. scale?: number[];
  65140. translation?: number[];
  65141. babylonNode?: Node;
  65142. }
  65143. /** @hidden */
  65144. export interface IGLTFScene extends IGLTFChildRootProperty {
  65145. nodes: string[];
  65146. }
  65147. /** @hidden */
  65148. export interface IGLTFRuntime {
  65149. extensions: {
  65150. [key: string]: any;
  65151. };
  65152. accessors: {
  65153. [key: string]: IGLTFAccessor;
  65154. };
  65155. buffers: {
  65156. [key: string]: IGLTFBuffer;
  65157. };
  65158. bufferViews: {
  65159. [key: string]: IGLTFBufferView;
  65160. };
  65161. meshes: {
  65162. [key: string]: IGLTFMesh;
  65163. };
  65164. lights: {
  65165. [key: string]: IGLTFLight;
  65166. };
  65167. cameras: {
  65168. [key: string]: IGLTFCamera;
  65169. };
  65170. nodes: {
  65171. [key: string]: IGLTFNode;
  65172. };
  65173. images: {
  65174. [key: string]: IGLTFImage;
  65175. };
  65176. textures: {
  65177. [key: string]: IGLTFTexture;
  65178. };
  65179. shaders: {
  65180. [key: string]: IGLTFShader;
  65181. };
  65182. programs: {
  65183. [key: string]: IGLTFProgram;
  65184. };
  65185. samplers: {
  65186. [key: string]: IGLTFSampler;
  65187. };
  65188. techniques: {
  65189. [key: string]: IGLTFTechnique;
  65190. };
  65191. materials: {
  65192. [key: string]: IGLTFMaterial;
  65193. };
  65194. animations: {
  65195. [key: string]: IGLTFAnimation;
  65196. };
  65197. skins: {
  65198. [key: string]: IGLTFSkins;
  65199. };
  65200. currentScene?: Object;
  65201. scenes: {
  65202. [key: string]: IGLTFScene;
  65203. };
  65204. extensionsUsed: string[];
  65205. extensionsRequired?: string[];
  65206. buffersCount: number;
  65207. shaderscount: number;
  65208. scene: Scene;
  65209. rootUrl: string;
  65210. loadedBufferCount: number;
  65211. loadedBufferViews: {
  65212. [name: string]: ArrayBufferView;
  65213. };
  65214. loadedShaderCount: number;
  65215. importOnlyMeshes: boolean;
  65216. importMeshesNames?: string[];
  65217. dummyNodes: Node[];
  65218. }
  65219. /** @hidden */
  65220. export interface INodeToRoot {
  65221. bone: Bone;
  65222. node: IGLTFNode;
  65223. id: string;
  65224. }
  65225. /** @hidden */
  65226. export interface IJointNode {
  65227. node: IGLTFNode;
  65228. id: string;
  65229. }
  65230. }
  65231. declare module BABYLON.GLTF1 {
  65232. /**
  65233. * Utils functions for GLTF
  65234. * @hidden
  65235. */
  65236. export class GLTFUtils {
  65237. /**
  65238. * Sets the given "parameter" matrix
  65239. * @param scene: the Scene object
  65240. * @param source: the source node where to pick the matrix
  65241. * @param parameter: the GLTF technique parameter
  65242. * @param uniformName: the name of the shader's uniform
  65243. * @param shaderMaterial: the shader material
  65244. */
  65245. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65246. /**
  65247. * Sets the given "parameter" matrix
  65248. * @param shaderMaterial: the shader material
  65249. * @param uniform: the name of the shader's uniform
  65250. * @param value: the value of the uniform
  65251. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65252. */
  65253. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65254. /**
  65255. * Returns the wrap mode of the texture
  65256. * @param mode: the mode value
  65257. */
  65258. static GetWrapMode(mode: number): number;
  65259. /**
  65260. * Returns the byte stride giving an accessor
  65261. * @param accessor: the GLTF accessor objet
  65262. */
  65263. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65264. /**
  65265. * Returns the texture filter mode giving a mode value
  65266. * @param mode: the filter mode value
  65267. */
  65268. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65269. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65270. /**
  65271. * Returns a buffer from its accessor
  65272. * @param gltfRuntime: the GLTF runtime
  65273. * @param accessor: the GLTF accessor
  65274. */
  65275. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65276. /**
  65277. * Decodes a buffer view into a string
  65278. * @param view: the buffer view
  65279. */
  65280. static DecodeBufferToText(view: ArrayBufferView): string;
  65281. /**
  65282. * Returns the default material of gltf. Related to
  65283. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65284. * @param scene: the Babylon.js scene
  65285. */
  65286. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65287. private static _DefaultMaterial;
  65288. }
  65289. }
  65290. declare module BABYLON.GLTF1 {
  65291. /**
  65292. * Implementation of the base glTF spec
  65293. * @hidden
  65294. */
  65295. export class GLTFLoaderBase {
  65296. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65297. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65298. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65299. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65300. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65301. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65302. }
  65303. /**
  65304. * glTF V1 Loader
  65305. * @hidden
  65306. */
  65307. export class GLTFLoader implements IGLTFLoader {
  65308. static Extensions: {
  65309. [name: string]: GLTFLoaderExtension;
  65310. };
  65311. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65312. state: Nullable<GLTFLoaderState>;
  65313. dispose(): void;
  65314. private _importMeshAsync;
  65315. /**
  65316. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65317. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65318. * @param scene the scene the meshes should be added to
  65319. * @param data gltf data containing information of the meshes in a loaded file
  65320. * @param rootUrl root url to load from
  65321. * @param onProgress event that fires when loading progress has occured
  65322. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65323. */
  65324. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65325. meshes: AbstractMesh[];
  65326. particleSystems: IParticleSystem[];
  65327. skeletons: Skeleton[];
  65328. animationGroups: AnimationGroup[];
  65329. }>;
  65330. private _loadAsync;
  65331. /**
  65332. * Imports all objects from a loaded gltf file and adds them to the scene
  65333. * @param scene the scene the objects should be added to
  65334. * @param data gltf data containing information of the meshes in a loaded file
  65335. * @param rootUrl root url to load from
  65336. * @param onProgress event that fires when loading progress has occured
  65337. * @returns a promise which completes when objects have been loaded to the scene
  65338. */
  65339. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65340. private _loadShadersAsync;
  65341. private _loadBuffersAsync;
  65342. private _createNodes;
  65343. }
  65344. /** @hidden */
  65345. export abstract class GLTFLoaderExtension {
  65346. private _name;
  65347. constructor(name: string);
  65348. readonly name: string;
  65349. /**
  65350. * Defines an override for loading the runtime
  65351. * Return true to stop further extensions from loading the runtime
  65352. */
  65353. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65354. /**
  65355. * Defines an onverride for creating gltf runtime
  65356. * Return true to stop further extensions from creating the runtime
  65357. */
  65358. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65359. /**
  65360. * Defines an override for loading buffers
  65361. * Return true to stop further extensions from loading this buffer
  65362. */
  65363. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65364. /**
  65365. * Defines an override for loading texture buffers
  65366. * Return true to stop further extensions from loading this texture data
  65367. */
  65368. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65369. /**
  65370. * Defines an override for creating textures
  65371. * Return true to stop further extensions from loading this texture
  65372. */
  65373. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65374. /**
  65375. * Defines an override for loading shader strings
  65376. * Return true to stop further extensions from loading this shader data
  65377. */
  65378. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65379. /**
  65380. * Defines an override for loading materials
  65381. * Return true to stop further extensions from loading this material
  65382. */
  65383. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65384. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65385. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65386. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65387. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65388. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65389. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65390. private static LoadTextureBufferAsync;
  65391. private static CreateTextureAsync;
  65392. private static ApplyExtensions;
  65393. }
  65394. }
  65395. declare module BABYLON.GLTF1 {
  65396. /** @hidden */
  65397. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65398. private _bin;
  65399. constructor();
  65400. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65401. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65402. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65403. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65404. }
  65405. }
  65406. declare module BABYLON.GLTF1 {
  65407. /** @hidden */
  65408. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65409. constructor();
  65410. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65411. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65412. private _loadTexture;
  65413. }
  65414. }
  65415. declare module BABYLON.GLTF2.Loader {
  65416. /**
  65417. * Loader interface with an index field.
  65418. */
  65419. export interface IArrayItem {
  65420. /**
  65421. * The index of this item in the array.
  65422. */
  65423. index: number;
  65424. }
  65425. /**
  65426. * Loader interface with additional members.
  65427. */
  65428. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65429. /** @hidden */
  65430. _data?: Promise<ArrayBufferView>;
  65431. /** @hidden */
  65432. _babylonVertexBuffer?: Promise<VertexBuffer>;
  65433. }
  65434. /**
  65435. * Loader interface with additional members.
  65436. */
  65437. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  65438. }
  65439. /** @hidden */
  65440. export interface _IAnimationSamplerData {
  65441. input: Float32Array;
  65442. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  65443. output: Float32Array;
  65444. }
  65445. /**
  65446. * Loader interface with additional members.
  65447. */
  65448. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  65449. /** @hidden */
  65450. _data?: Promise<_IAnimationSamplerData>;
  65451. }
  65452. /**
  65453. * Loader interface with additional members.
  65454. */
  65455. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  65456. channels: IAnimationChannel[];
  65457. samplers: IAnimationSampler[];
  65458. /** @hidden */
  65459. _babylonAnimationGroup?: AnimationGroup;
  65460. }
  65461. /**
  65462. * Loader interface with additional members.
  65463. */
  65464. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  65465. /** @hidden */
  65466. _data?: Promise<ArrayBufferView>;
  65467. }
  65468. /**
  65469. * Loader interface with additional members.
  65470. */
  65471. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  65472. /** @hidden */
  65473. _data?: Promise<ArrayBufferView>;
  65474. /** @hidden */
  65475. _babylonBuffer?: Promise<Buffer>;
  65476. }
  65477. /**
  65478. * Loader interface with additional members.
  65479. */
  65480. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65481. }
  65482. /**
  65483. * Loader interface with additional members.
  65484. */
  65485. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65486. /** @hidden */
  65487. _data?: Promise<ArrayBufferView>;
  65488. }
  65489. /**
  65490. * Loader interface with additional members.
  65491. */
  65492. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65493. }
  65494. /**
  65495. * Loader interface with additional members.
  65496. */
  65497. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65498. }
  65499. /**
  65500. * Loader interface with additional members.
  65501. */
  65502. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65503. baseColorTexture?: ITextureInfo;
  65504. metallicRoughnessTexture?: ITextureInfo;
  65505. }
  65506. /**
  65507. * Loader interface with additional members.
  65508. */
  65509. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65510. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65511. normalTexture?: IMaterialNormalTextureInfo;
  65512. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65513. emissiveTexture?: ITextureInfo;
  65514. /** @hidden */
  65515. _data?: {
  65516. [babylonDrawMode: number]: {
  65517. babylonMaterial: Material;
  65518. babylonMeshes: AbstractMesh[];
  65519. promise: Promise<void>;
  65520. };
  65521. };
  65522. }
  65523. /**
  65524. * Loader interface with additional members.
  65525. */
  65526. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65527. primitives: IMeshPrimitive[];
  65528. }
  65529. /**
  65530. * Loader interface with additional members.
  65531. */
  65532. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65533. /** @hidden */
  65534. _instanceData?: {
  65535. babylonSourceMesh: Mesh;
  65536. promise: Promise<any>;
  65537. };
  65538. }
  65539. /**
  65540. * Loader interface with additional members.
  65541. */
  65542. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65543. /**
  65544. * The parent glTF node.
  65545. */
  65546. parent?: INode;
  65547. /** @hidden */
  65548. _babylonTransformNode?: TransformNode;
  65549. /** @hidden */
  65550. _primitiveBabylonMeshes?: AbstractMesh[];
  65551. /** @hidden */
  65552. _babylonBones?: Bone[];
  65553. /** @hidden */
  65554. _numMorphTargets?: number;
  65555. }
  65556. /** @hidden */
  65557. export interface _ISamplerData {
  65558. noMipMaps: boolean;
  65559. samplingMode: number;
  65560. wrapU: number;
  65561. wrapV: number;
  65562. }
  65563. /**
  65564. * Loader interface with additional members.
  65565. */
  65566. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65567. /** @hidden */
  65568. _data?: _ISamplerData;
  65569. }
  65570. /**
  65571. * Loader interface with additional members.
  65572. */
  65573. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65574. }
  65575. /**
  65576. * Loader interface with additional members.
  65577. */
  65578. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65579. /** @hidden */
  65580. _data?: {
  65581. babylonSkeleton: Skeleton;
  65582. promise: Promise<void>;
  65583. };
  65584. }
  65585. /**
  65586. * Loader interface with additional members.
  65587. */
  65588. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65589. }
  65590. /**
  65591. * Loader interface with additional members.
  65592. */
  65593. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65594. }
  65595. /**
  65596. * Loader interface with additional members.
  65597. */
  65598. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65599. accessors?: IAccessor[];
  65600. animations?: IAnimation[];
  65601. buffers?: IBuffer[];
  65602. bufferViews?: IBufferView[];
  65603. cameras?: ICamera[];
  65604. images?: IImage[];
  65605. materials?: IMaterial[];
  65606. meshes?: IMesh[];
  65607. nodes?: INode[];
  65608. samplers?: ISampler[];
  65609. scenes?: IScene[];
  65610. skins?: ISkin[];
  65611. textures?: ITexture[];
  65612. }
  65613. }
  65614. declare module BABYLON.GLTF2 {
  65615. /**
  65616. * Interface for a glTF loader extension.
  65617. */
  65618. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65619. /**
  65620. * Called after the loader state changes to LOADING.
  65621. */
  65622. onLoading?(): void;
  65623. /**
  65624. * Called after the loader state changes to READY.
  65625. */
  65626. onReady?(): void;
  65627. /**
  65628. * Define this method to modify the default behavior when loading scenes.
  65629. * @param context The context when loading the asset
  65630. * @param scene The glTF scene property
  65631. * @returns A promise that resolves when the load is complete or null if not handled
  65632. */
  65633. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65634. /**
  65635. * Define this method to modify the default behavior when loading nodes.
  65636. * @param context The context when loading the asset
  65637. * @param node The glTF node property
  65638. * @param assign A function called synchronously after parsing the glTF properties
  65639. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65640. */
  65641. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65642. /**
  65643. * Define this method to modify the default behavior when loading cameras.
  65644. * @param context The context when loading the asset
  65645. * @param camera The glTF camera property
  65646. * @param assign A function called synchronously after parsing the glTF properties
  65647. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65648. */
  65649. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65650. /**
  65651. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65652. * @param context The context when loading the asset
  65653. * @param primitive The glTF mesh primitive property
  65654. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65655. */
  65656. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65657. /**
  65658. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65659. * @param context The context when loading the asset
  65660. * @param name The mesh name when loading the asset
  65661. * @param node The glTF node when loading the asset
  65662. * @param mesh The glTF mesh when loading the asset
  65663. * @param primitive The glTF mesh primitive property
  65664. * @param assign A function called synchronously after parsing the glTF properties
  65665. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65666. */
  65667. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65668. /**
  65669. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65670. * @param context The context when loading the asset
  65671. * @param material The glTF material property
  65672. * @param assign A function called synchronously after parsing the glTF properties
  65673. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65674. */
  65675. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65676. /**
  65677. * Define this method to modify the default behavior when creating materials.
  65678. * @param context The context when loading the asset
  65679. * @param material The glTF material property
  65680. * @param babylonDrawMode The draw mode for the Babylon material
  65681. * @returns The Babylon material or null if not handled
  65682. */
  65683. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65684. /**
  65685. * Define this method to modify the default behavior when loading material properties.
  65686. * @param context The context when loading the asset
  65687. * @param material The glTF material property
  65688. * @param babylonMaterial The Babylon material
  65689. * @returns A promise that resolves when the load is complete or null if not handled
  65690. */
  65691. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65692. /**
  65693. * Define this method to modify the default behavior when loading texture infos.
  65694. * @param context The context when loading the asset
  65695. * @param textureInfo The glTF texture info property
  65696. * @param assign A function called synchronously after parsing the glTF properties
  65697. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65698. */
  65699. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65700. /**
  65701. * Define this method to modify the default behavior when loading animations.
  65702. * @param context The context when loading the asset
  65703. * @param animation The glTF animation property
  65704. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65705. */
  65706. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65707. /**
  65708. * @hidden Define this method to modify the default behavior when loading skins.
  65709. * @param context The context when loading the asset
  65710. * @param node The glTF node property
  65711. * @param skin The glTF skin property
  65712. * @returns A promise that resolves when the load is complete or null if not handled
  65713. */
  65714. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65715. /**
  65716. * @hidden Define this method to modify the default behavior when loading uris.
  65717. * @param context The context when loading the asset
  65718. * @param property The glTF property associated with the uri
  65719. * @param uri The uri to load
  65720. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65721. */
  65722. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65723. }
  65724. }
  65725. declare module BABYLON.GLTF2 {
  65726. /**
  65727. * Helper class for working with arrays when loading the glTF asset
  65728. */
  65729. export class ArrayItem {
  65730. /**
  65731. * Gets an item from the given array.
  65732. * @param context The context when loading the asset
  65733. * @param array The array to get the item from
  65734. * @param index The index to the array
  65735. * @returns The array item
  65736. */
  65737. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65738. /**
  65739. * Assign an `index` field to each item of the given array.
  65740. * @param array The array of items
  65741. */
  65742. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65743. }
  65744. /**
  65745. * The glTF 2.0 loader
  65746. */
  65747. export class GLTFLoader implements IGLTFLoader {
  65748. /** @hidden */
  65749. _completePromises: Promise<any>[];
  65750. private _disposed;
  65751. private _parent;
  65752. private _state;
  65753. private _extensions;
  65754. private _rootUrl;
  65755. private _fileName;
  65756. private _uniqueRootUrl;
  65757. private _gltf;
  65758. private _babylonScene;
  65759. private _rootBabylonMesh;
  65760. private _defaultBabylonMaterialData;
  65761. private _progressCallback?;
  65762. private _requests;
  65763. private static readonly _DefaultSampler;
  65764. private static _ExtensionNames;
  65765. private static _ExtensionFactories;
  65766. /**
  65767. * Registers a loader extension.
  65768. * @param name The name of the loader extension.
  65769. * @param factory The factory function that creates the loader extension.
  65770. */
  65771. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65772. /**
  65773. * Unregisters a loader extension.
  65774. * @param name The name of the loader extenion.
  65775. * @returns A boolean indicating whether the extension has been unregistered
  65776. */
  65777. static UnregisterExtension(name: string): boolean;
  65778. /**
  65779. * Gets the loader state.
  65780. */
  65781. readonly state: Nullable<GLTFLoaderState>;
  65782. /**
  65783. * The glTF object parsed from the JSON.
  65784. */
  65785. readonly gltf: IGLTF;
  65786. /**
  65787. * The Babylon scene when loading the asset.
  65788. */
  65789. readonly babylonScene: Scene;
  65790. /**
  65791. * The root Babylon mesh when loading the asset.
  65792. */
  65793. readonly rootBabylonMesh: Mesh;
  65794. /** @hidden */
  65795. constructor(parent: GLTFFileLoader);
  65796. /** @hidden */
  65797. dispose(): void;
  65798. /** @hidden */
  65799. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65800. meshes: AbstractMesh[];
  65801. particleSystems: IParticleSystem[];
  65802. skeletons: Skeleton[];
  65803. animationGroups: AnimationGroup[];
  65804. }>;
  65805. /** @hidden */
  65806. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65807. private _loadAsync;
  65808. private _loadData;
  65809. private _setupData;
  65810. private _loadExtensions;
  65811. private _checkExtensions;
  65812. private _setState;
  65813. private _createRootNode;
  65814. /**
  65815. * Loads a glTF scene.
  65816. * @param context The context when loading the asset
  65817. * @param scene The glTF scene property
  65818. * @returns A promise that resolves when the load is complete
  65819. */
  65820. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65821. private _forEachPrimitive;
  65822. private _getMeshes;
  65823. private _getSkeletons;
  65824. private _getAnimationGroups;
  65825. private _startAnimations;
  65826. /**
  65827. * Loads a glTF node.
  65828. * @param context The context when loading the asset
  65829. * @param node The glTF node property
  65830. * @param assign A function called synchronously after parsing the glTF properties
  65831. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65832. */
  65833. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65834. private _loadMeshAsync;
  65835. /**
  65836. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65837. * @param context The context when loading the asset
  65838. * @param name The mesh name when loading the asset
  65839. * @param node The glTF node when loading the asset
  65840. * @param mesh The glTF mesh when loading the asset
  65841. * @param primitive The glTF mesh primitive property
  65842. * @param assign A function called synchronously after parsing the glTF properties
  65843. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65844. */
  65845. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65846. private _loadVertexDataAsync;
  65847. private _createMorphTargets;
  65848. private _loadMorphTargetsAsync;
  65849. private _loadMorphTargetVertexDataAsync;
  65850. private static _LoadTransform;
  65851. private _loadSkinAsync;
  65852. private _loadBones;
  65853. private _loadBone;
  65854. private _loadSkinInverseBindMatricesDataAsync;
  65855. private _updateBoneMatrices;
  65856. private _getNodeMatrix;
  65857. /**
  65858. * Loads a glTF camera.
  65859. * @param context The context when loading the asset
  65860. * @param camera The glTF camera property
  65861. * @param assign A function called synchronously after parsing the glTF properties
  65862. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65863. */
  65864. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65865. private _loadAnimationsAsync;
  65866. /**
  65867. * Loads a glTF animation.
  65868. * @param context The context when loading the asset
  65869. * @param animation The glTF animation property
  65870. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65871. */
  65872. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65873. /**
  65874. * @hidden Loads a glTF animation channel.
  65875. * @param context The context when loading the asset
  65876. * @param animationContext The context of the animation when loading the asset
  65877. * @param animation The glTF animation property
  65878. * @param channel The glTF animation channel property
  65879. * @param babylonAnimationGroup The babylon animation group property
  65880. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65881. * @returns A void promise when the channel load is complete
  65882. */
  65883. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65884. private _loadAnimationSamplerAsync;
  65885. private _loadBufferAsync;
  65886. /**
  65887. * Loads a glTF buffer view.
  65888. * @param context The context when loading the asset
  65889. * @param bufferView The glTF buffer view property
  65890. * @returns A promise that resolves with the loaded data when the load is complete
  65891. */
  65892. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65893. private _loadAccessorAsync;
  65894. private _loadFloatAccessorAsync;
  65895. private _loadIndicesAccessorAsync;
  65896. private _loadVertexBufferViewAsync;
  65897. private _loadVertexAccessorAsync;
  65898. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65899. /** @hidden */
  65900. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65901. private _createDefaultMaterial;
  65902. /**
  65903. * Creates a Babylon material from a glTF material.
  65904. * @param context The context when loading the asset
  65905. * @param material The glTF material property
  65906. * @param babylonDrawMode The draw mode for the Babylon material
  65907. * @returns The Babylon material
  65908. */
  65909. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65910. /**
  65911. * Loads properties from a glTF material into a Babylon material.
  65912. * @param context The context when loading the asset
  65913. * @param material The glTF material property
  65914. * @param babylonMaterial The Babylon material
  65915. * @returns A promise that resolves when the load is complete
  65916. */
  65917. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65918. /**
  65919. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65920. * @param context The context when loading the asset
  65921. * @param material The glTF material property
  65922. * @param babylonMaterial The Babylon material
  65923. * @returns A promise that resolves when the load is complete
  65924. */
  65925. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65926. /**
  65927. * Loads the alpha properties from a glTF material into a Babylon material.
  65928. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65929. * @param context The context when loading the asset
  65930. * @param material The glTF material property
  65931. * @param babylonMaterial The Babylon material
  65932. */
  65933. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65934. /**
  65935. * Loads a glTF texture info.
  65936. * @param context The context when loading the asset
  65937. * @param textureInfo The glTF texture info property
  65938. * @param assign A function called synchronously after parsing the glTF properties
  65939. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65940. */
  65941. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65942. private _loadTextureAsync;
  65943. private _loadSampler;
  65944. /**
  65945. * Loads a glTF image.
  65946. * @param context The context when loading the asset
  65947. * @param image The glTF image property
  65948. * @returns A promise that resolves with the loaded data when the load is complete
  65949. */
  65950. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65951. /**
  65952. * Loads a glTF uri.
  65953. * @param context The context when loading the asset
  65954. * @param property The glTF property associated with the uri
  65955. * @param uri The base64 or relative uri
  65956. * @returns A promise that resolves with the loaded data when the load is complete
  65957. */
  65958. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65959. private _onProgress;
  65960. /**
  65961. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65962. * @param babylonObject the Babylon object with metadata
  65963. * @param pointer the JSON pointer
  65964. */
  65965. static AddPointerMetadata(babylonObject: {
  65966. metadata: any;
  65967. }, pointer: string): void;
  65968. private static _GetTextureWrapMode;
  65969. private static _GetTextureSamplingMode;
  65970. private static _GetTypedArrayConstructor;
  65971. private static _GetTypedArray;
  65972. private static _GetNumComponents;
  65973. private static _ValidateUri;
  65974. private static _GetDrawMode;
  65975. private _compileMaterialsAsync;
  65976. private _compileShadowGeneratorsAsync;
  65977. private _forEachExtensions;
  65978. private _applyExtensions;
  65979. private _extensionsOnLoading;
  65980. private _extensionsOnReady;
  65981. private _extensionsLoadSceneAsync;
  65982. private _extensionsLoadNodeAsync;
  65983. private _extensionsLoadCameraAsync;
  65984. private _extensionsLoadVertexDataAsync;
  65985. private _extensionsLoadMeshPrimitiveAsync;
  65986. private _extensionsLoadMaterialAsync;
  65987. private _extensionsCreateMaterial;
  65988. private _extensionsLoadMaterialPropertiesAsync;
  65989. private _extensionsLoadTextureInfoAsync;
  65990. private _extensionsLoadAnimationAsync;
  65991. private _extensionsLoadSkinAsync;
  65992. private _extensionsLoadUriAsync;
  65993. /**
  65994. * Helper method called by a loader extension to load an glTF extension.
  65995. * @param context The context when loading the asset
  65996. * @param property The glTF property to load the extension from
  65997. * @param extensionName The name of the extension to load
  65998. * @param actionAsync The action to run
  65999. * @returns The promise returned by actionAsync or null if the extension does not exist
  66000. */
  66001. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66002. /**
  66003. * Helper method called by a loader extension to load a glTF extra.
  66004. * @param context The context when loading the asset
  66005. * @param property The glTF property to load the extra from
  66006. * @param extensionName The name of the extension to load
  66007. * @param actionAsync The action to run
  66008. * @returns The promise returned by actionAsync or null if the extra does not exist
  66009. */
  66010. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66011. /**
  66012. * Increments the indentation level and logs a message.
  66013. * @param message The message to log
  66014. */
  66015. logOpen(message: string): void;
  66016. /**
  66017. * Decrements the indentation level.
  66018. */
  66019. logClose(): void;
  66020. /**
  66021. * Logs a message
  66022. * @param message The message to log
  66023. */
  66024. log(message: string): void;
  66025. /**
  66026. * Starts a performance counter.
  66027. * @param counterName The name of the performance counter
  66028. */
  66029. startPerformanceCounter(counterName: string): void;
  66030. /**
  66031. * Ends a performance counter.
  66032. * @param counterName The name of the performance counter
  66033. */
  66034. endPerformanceCounter(counterName: string): void;
  66035. }
  66036. }
  66037. declare module BABYLON.GLTF2.Loader.Extensions {
  66038. /**
  66039. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66040. */
  66041. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66042. /** The name of this extension. */
  66043. readonly name: string;
  66044. /** Defines whether this extension is enabled. */
  66045. enabled: boolean;
  66046. private _loader;
  66047. private _lights?;
  66048. /** @hidden */
  66049. constructor(loader: GLTFLoader);
  66050. /** @hidden */
  66051. dispose(): void;
  66052. /** @hidden */
  66053. onLoading(): void;
  66054. /** @hidden */
  66055. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66056. private _loadLightAsync;
  66057. }
  66058. }
  66059. declare module BABYLON.GLTF2.Loader.Extensions {
  66060. /**
  66061. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66062. */
  66063. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66064. /** The name of this extension. */
  66065. readonly name: string;
  66066. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66067. dracoCompression?: DracoCompression;
  66068. /** Defines whether this extension is enabled. */
  66069. enabled: boolean;
  66070. private _loader;
  66071. /** @hidden */
  66072. constructor(loader: GLTFLoader);
  66073. /** @hidden */
  66074. dispose(): void;
  66075. /** @hidden */
  66076. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66077. }
  66078. }
  66079. declare module BABYLON.GLTF2.Loader.Extensions {
  66080. /**
  66081. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66082. */
  66083. export class KHR_lights implements IGLTFLoaderExtension {
  66084. /** The name of this extension. */
  66085. readonly name: string;
  66086. /** Defines whether this extension is enabled. */
  66087. enabled: boolean;
  66088. private _loader;
  66089. private _lights?;
  66090. /** @hidden */
  66091. constructor(loader: GLTFLoader);
  66092. /** @hidden */
  66093. dispose(): void;
  66094. /** @hidden */
  66095. onLoading(): void;
  66096. /** @hidden */
  66097. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66098. }
  66099. }
  66100. declare module BABYLON.GLTF2.Loader.Extensions {
  66101. /**
  66102. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66103. */
  66104. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66105. /** The name of this extension. */
  66106. readonly name: string;
  66107. /** Defines whether this extension is enabled. */
  66108. enabled: boolean;
  66109. private _loader;
  66110. /** @hidden */
  66111. constructor(loader: GLTFLoader);
  66112. /** @hidden */
  66113. dispose(): void;
  66114. /** @hidden */
  66115. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66116. private _loadSpecularGlossinessPropertiesAsync;
  66117. }
  66118. }
  66119. declare module BABYLON.GLTF2.Loader.Extensions {
  66120. /**
  66121. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66122. */
  66123. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66124. /** The name of this extension. */
  66125. readonly name: string;
  66126. /** Defines whether this extension is enabled. */
  66127. enabled: boolean;
  66128. private _loader;
  66129. /** @hidden */
  66130. constructor(loader: GLTFLoader);
  66131. /** @hidden */
  66132. dispose(): void;
  66133. /** @hidden */
  66134. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66135. private _loadUnlitPropertiesAsync;
  66136. }
  66137. }
  66138. declare module BABYLON.GLTF2.Loader.Extensions {
  66139. /**
  66140. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66141. */
  66142. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66143. /** The name of this extension. */
  66144. readonly name: string;
  66145. /** Defines whether this extension is enabled. */
  66146. enabled: boolean;
  66147. private _loader;
  66148. /** @hidden */
  66149. constructor(loader: GLTFLoader);
  66150. /** @hidden */
  66151. dispose(): void;
  66152. /** @hidden */
  66153. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66154. }
  66155. }
  66156. declare module BABYLON.GLTF2.Loader.Extensions {
  66157. /**
  66158. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66159. */
  66160. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66161. /** The name of this extension. */
  66162. readonly name: string;
  66163. /** Defines whether this extension is enabled. */
  66164. enabled: boolean;
  66165. private _loader;
  66166. private _clips;
  66167. private _emitters;
  66168. /** @hidden */
  66169. constructor(loader: GLTFLoader);
  66170. /** @hidden */
  66171. dispose(): void;
  66172. /** @hidden */
  66173. onLoading(): void;
  66174. /** @hidden */
  66175. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66176. /** @hidden */
  66177. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66178. /** @hidden */
  66179. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66180. private _loadClipAsync;
  66181. private _loadEmitterAsync;
  66182. private _getEventAction;
  66183. private _loadAnimationEventAsync;
  66184. }
  66185. }
  66186. declare module BABYLON.GLTF2.Loader.Extensions {
  66187. /**
  66188. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66189. */
  66190. export class MSFT_lod implements IGLTFLoaderExtension {
  66191. /** The name of this extension. */
  66192. readonly name: string;
  66193. /** Defines whether this extension is enabled. */
  66194. enabled: boolean;
  66195. /**
  66196. * Maximum number of LODs to load, starting from the lowest LOD.
  66197. */
  66198. maxLODsToLoad: number;
  66199. /**
  66200. * Observable raised when all node LODs of one level are loaded.
  66201. * The event data is the index of the loaded LOD starting from zero.
  66202. * Dispose the loader to cancel the loading of the next level of LODs.
  66203. */
  66204. onNodeLODsLoadedObservable: Observable<number>;
  66205. /**
  66206. * Observable raised when all material LODs of one level are loaded.
  66207. * The event data is the index of the loaded LOD starting from zero.
  66208. * Dispose the loader to cancel the loading of the next level of LODs.
  66209. */
  66210. onMaterialLODsLoadedObservable: Observable<number>;
  66211. private _loader;
  66212. private _nodeIndexLOD;
  66213. private _nodeSignalLODs;
  66214. private _nodePromiseLODs;
  66215. private _materialIndexLOD;
  66216. private _materialSignalLODs;
  66217. private _materialPromiseLODs;
  66218. /** @hidden */
  66219. constructor(loader: GLTFLoader);
  66220. /** @hidden */
  66221. dispose(): void;
  66222. /** @hidden */
  66223. onReady(): void;
  66224. /** @hidden */
  66225. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66226. /** @hidden */
  66227. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66228. /** @hidden */
  66229. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66230. /**
  66231. * Gets an array of LOD properties from lowest to highest.
  66232. */
  66233. private _getLODs;
  66234. private _disposeUnusedMaterials;
  66235. }
  66236. }
  66237. declare module BABYLON.GLTF2.Loader.Extensions {
  66238. /** @hidden */
  66239. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66240. readonly name: string;
  66241. enabled: boolean;
  66242. private _loader;
  66243. constructor(loader: GLTFLoader);
  66244. dispose(): void;
  66245. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66246. }
  66247. }
  66248. declare module BABYLON.GLTF2.Loader.Extensions {
  66249. /** @hidden */
  66250. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66251. readonly name: string;
  66252. enabled: boolean;
  66253. private _loader;
  66254. constructor(loader: GLTFLoader);
  66255. dispose(): void;
  66256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66257. }
  66258. }
  66259. declare module BABYLON.GLTF2.Loader.Extensions {
  66260. /**
  66261. * Store glTF extras (if present) in BJS objects' metadata
  66262. */
  66263. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66264. /** The name of this extension. */
  66265. readonly name: string;
  66266. /** Defines whether this extension is enabled. */
  66267. enabled: boolean;
  66268. private _loader;
  66269. private _assignExtras;
  66270. /** @hidden */
  66271. constructor(loader: GLTFLoader);
  66272. /** @hidden */
  66273. dispose(): void;
  66274. /** @hidden */
  66275. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66276. /** @hidden */
  66277. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66278. /** @hidden */
  66279. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66280. }
  66281. }
  66282. declare module BABYLON {
  66283. /**
  66284. * Class reading and parsing the MTL file bundled with the obj file.
  66285. */
  66286. export class MTLFileLoader {
  66287. /**
  66288. * All material loaded from the mtl will be set here
  66289. */
  66290. materials: StandardMaterial[];
  66291. /**
  66292. * This function will read the mtl file and create each material described inside
  66293. * This function could be improve by adding :
  66294. * -some component missing (Ni, Tf...)
  66295. * -including the specific options available
  66296. *
  66297. * @param scene defines the scene the material will be created in
  66298. * @param data defines the mtl data to parse
  66299. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66300. */
  66301. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66302. /**
  66303. * Gets the texture for the material.
  66304. *
  66305. * If the material is imported from input file,
  66306. * We sanitize the url to ensure it takes the textre from aside the material.
  66307. *
  66308. * @param rootUrl The root url to load from
  66309. * @param value The value stored in the mtl
  66310. * @return The Texture
  66311. */
  66312. private static _getTexture;
  66313. }
  66314. /**
  66315. * Options for loading OBJ/MTL files
  66316. */
  66317. type MeshLoadOptions = {
  66318. /**
  66319. * Defines if UVs are optimized by default during load.
  66320. */
  66321. OptimizeWithUV: boolean;
  66322. /**
  66323. * Defines custom scaling of UV coordinates of loaded meshes.
  66324. */
  66325. UVScaling: Vector2;
  66326. /**
  66327. * Invert model on y-axis (does a model scaling inversion)
  66328. */
  66329. InvertY: boolean;
  66330. /**
  66331. * Invert Y-Axis of referenced textures on load
  66332. */
  66333. InvertTextureY: boolean;
  66334. /**
  66335. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66336. */
  66337. ImportVertexColors: boolean;
  66338. /**
  66339. * Compute the normals for the model, even if normals are present in the file.
  66340. */
  66341. ComputeNormals: boolean;
  66342. /**
  66343. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66344. */
  66345. SkipMaterials: boolean;
  66346. /**
  66347. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66348. */
  66349. MaterialLoadingFailsSilently: boolean;
  66350. };
  66351. /**
  66352. * OBJ file type loader.
  66353. * This is a babylon scene loader plugin.
  66354. */
  66355. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66356. /**
  66357. * Defines if UVs are optimized by default during load.
  66358. */
  66359. static OPTIMIZE_WITH_UV: boolean;
  66360. /**
  66361. * Invert model on y-axis (does a model scaling inversion)
  66362. */
  66363. static INVERT_Y: boolean;
  66364. /**
  66365. * Invert Y-Axis of referenced textures on load
  66366. */
  66367. static INVERT_TEXTURE_Y: boolean;
  66368. /**
  66369. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66370. */
  66371. static IMPORT_VERTEX_COLORS: boolean;
  66372. /**
  66373. * Compute the normals for the model, even if normals are present in the file.
  66374. */
  66375. static COMPUTE_NORMALS: boolean;
  66376. /**
  66377. * Defines custom scaling of UV coordinates of loaded meshes.
  66378. */
  66379. static UV_SCALING: Vector2;
  66380. /**
  66381. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66382. */
  66383. static SKIP_MATERIALS: boolean;
  66384. /**
  66385. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66386. *
  66387. * Defaults to true for backwards compatibility.
  66388. */
  66389. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66390. /**
  66391. * Defines the name of the plugin.
  66392. */
  66393. name: string;
  66394. /**
  66395. * Defines the extension the plugin is able to load.
  66396. */
  66397. extensions: string;
  66398. /** @hidden */
  66399. obj: RegExp;
  66400. /** @hidden */
  66401. group: RegExp;
  66402. /** @hidden */
  66403. mtllib: RegExp;
  66404. /** @hidden */
  66405. usemtl: RegExp;
  66406. /** @hidden */
  66407. smooth: RegExp;
  66408. /** @hidden */
  66409. vertexPattern: RegExp;
  66410. /** @hidden */
  66411. normalPattern: RegExp;
  66412. /** @hidden */
  66413. uvPattern: RegExp;
  66414. /** @hidden */
  66415. facePattern1: RegExp;
  66416. /** @hidden */
  66417. facePattern2: RegExp;
  66418. /** @hidden */
  66419. facePattern3: RegExp;
  66420. /** @hidden */
  66421. facePattern4: RegExp;
  66422. /** @hidden */
  66423. facePattern5: RegExp;
  66424. private _meshLoadOptions;
  66425. /**
  66426. * Creates loader for .OBJ files
  66427. *
  66428. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66429. */
  66430. constructor(meshLoadOptions?: MeshLoadOptions);
  66431. private static readonly currentMeshLoadOptions;
  66432. /**
  66433. * Calls synchronously the MTL file attached to this obj.
  66434. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66435. * Without this function materials are not displayed in the first frame (but displayed after).
  66436. * In consequence it is impossible to get material information in your HTML file
  66437. *
  66438. * @param url The URL of the MTL file
  66439. * @param rootUrl
  66440. * @param onSuccess Callback function to be called when the MTL file is loaded
  66441. * @private
  66442. */
  66443. private _loadMTL;
  66444. /**
  66445. * Instantiates a OBJ file loader plugin.
  66446. * @returns the created plugin
  66447. */
  66448. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  66449. /**
  66450. * If the data string can be loaded directly.
  66451. *
  66452. * @param data string containing the file data
  66453. * @returns if the data can be loaded directly
  66454. */
  66455. canDirectLoad(data: string): boolean;
  66456. /**
  66457. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  66458. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66459. * @param scene the scene the meshes should be added to
  66460. * @param data the OBJ data to load
  66461. * @param rootUrl root url to load from
  66462. * @param onProgress event that fires when loading progress has occured
  66463. * @param fileName Defines the name of the file to load
  66464. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66465. */
  66466. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66467. meshes: AbstractMesh[];
  66468. particleSystems: IParticleSystem[];
  66469. skeletons: Skeleton[];
  66470. animationGroups: AnimationGroup[];
  66471. }>;
  66472. /**
  66473. * Imports all objects from the loaded OBJ data and adds them to the scene
  66474. * @param scene the scene the objects should be added to
  66475. * @param data the OBJ data to load
  66476. * @param rootUrl root url to load from
  66477. * @param onProgress event that fires when loading progress has occured
  66478. * @param fileName Defines the name of the file to load
  66479. * @returns a promise which completes when objects have been loaded to the scene
  66480. */
  66481. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66482. /**
  66483. * Load into an asset container.
  66484. * @param scene The scene to load into
  66485. * @param data The data to import
  66486. * @param rootUrl The root url for scene and resources
  66487. * @param onProgress The callback when the load progresses
  66488. * @param fileName Defines the name of the file to load
  66489. * @returns The loaded asset container
  66490. */
  66491. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66492. /**
  66493. * Read the OBJ file and create an Array of meshes.
  66494. * Each mesh contains all information given by the OBJ and the MTL file.
  66495. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66496. *
  66497. * @param meshesNames
  66498. * @param scene Scene The scene where are displayed the data
  66499. * @param data String The content of the obj file
  66500. * @param rootUrl String The path to the folder
  66501. * @returns Array<AbstractMesh>
  66502. * @private
  66503. */
  66504. private _parseSolid;
  66505. }
  66506. }
  66507. declare module BABYLON {
  66508. /**
  66509. * STL file type loader.
  66510. * This is a babylon scene loader plugin.
  66511. */
  66512. export class STLFileLoader implements ISceneLoaderPlugin {
  66513. /** @hidden */
  66514. solidPattern: RegExp;
  66515. /** @hidden */
  66516. facetsPattern: RegExp;
  66517. /** @hidden */
  66518. normalPattern: RegExp;
  66519. /** @hidden */
  66520. vertexPattern: RegExp;
  66521. /**
  66522. * Defines the name of the plugin.
  66523. */
  66524. name: string;
  66525. /**
  66526. * Defines the extensions the stl loader is able to load.
  66527. * force data to come in as an ArrayBuffer
  66528. * we'll convert to string if it looks like it's an ASCII .stl
  66529. */
  66530. extensions: ISceneLoaderPluginExtensions;
  66531. /**
  66532. * Import meshes into a scene.
  66533. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66534. * @param scene The scene to import into
  66535. * @param data The data to import
  66536. * @param rootUrl The root url for scene and resources
  66537. * @param meshes The meshes array to import into
  66538. * @param particleSystems The particle systems array to import into
  66539. * @param skeletons The skeletons array to import into
  66540. * @param onError The callback when import fails
  66541. * @returns True if successful or false otherwise
  66542. */
  66543. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66544. /**
  66545. * Load into a scene.
  66546. * @param scene The scene to load into
  66547. * @param data The data to import
  66548. * @param rootUrl The root url for scene and resources
  66549. * @param onError The callback when import fails
  66550. * @returns true if successful or false otherwise
  66551. */
  66552. load(scene: Scene, data: any, rootUrl: string): boolean;
  66553. /**
  66554. * Load into an asset container.
  66555. * @param scene The scene to load into
  66556. * @param data The data to import
  66557. * @param rootUrl The root url for scene and resources
  66558. * @param onError The callback when import fails
  66559. * @returns The loaded asset container
  66560. */
  66561. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66562. private _isBinary;
  66563. private _parseBinary;
  66564. private _parseASCII;
  66565. }
  66566. }
  66567. declare module BABYLON {
  66568. /**
  66569. * Class for generating OBJ data from a Babylon scene.
  66570. */
  66571. export class OBJExport {
  66572. /**
  66573. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66574. * @param mesh defines the list of meshes to serialize
  66575. * @param materials defines if materials should be exported
  66576. * @param matlibname defines the name of the associated mtl file
  66577. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66578. * @returns the OBJ content
  66579. */
  66580. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66581. /**
  66582. * Exports the material(s) of a mesh in .MTL file format (text)
  66583. * @param mesh defines the mesh to extract the material from
  66584. * @returns the mtl content
  66585. */
  66586. static MTL(mesh: Mesh): string;
  66587. }
  66588. }
  66589. declare module BABYLON {
  66590. /** @hidden */
  66591. export var __IGLTFExporterExtension: number;
  66592. /**
  66593. * Interface for extending the exporter
  66594. * @hidden
  66595. */
  66596. export interface IGLTFExporterExtension {
  66597. /**
  66598. * The name of this extension
  66599. */
  66600. readonly name: string;
  66601. /**
  66602. * Defines whether this extension is enabled
  66603. */
  66604. enabled: boolean;
  66605. /**
  66606. * Defines whether this extension is required
  66607. */
  66608. required: boolean;
  66609. }
  66610. }
  66611. declare module BABYLON.GLTF2.Exporter {
  66612. /** @hidden */
  66613. export var __IGLTFExporterExtensionV2: number;
  66614. /**
  66615. * Interface for a glTF exporter extension
  66616. * @hidden
  66617. */
  66618. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66619. /**
  66620. * Define this method to modify the default behavior before exporting a texture
  66621. * @param context The context when loading the asset
  66622. * @param babylonTexture The glTF texture info property
  66623. * @param mimeType The mime-type of the generated image
  66624. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66625. */
  66626. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66627. /**
  66628. * Define this method to modify the default behavior when exporting texture info
  66629. * @param context The context when loading the asset
  66630. * @param meshPrimitive glTF mesh primitive
  66631. * @param babylonSubMesh Babylon submesh
  66632. * @param binaryWriter glTF serializer binary writer instance
  66633. * @returns nullable IMeshPrimitive promise
  66634. */
  66635. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66636. /**
  66637. * Define this method to modify the default behavior when exporting a node
  66638. * @param context The context when exporting the node
  66639. * @param node glTF node
  66640. * @param babylonNode BabylonJS node
  66641. * @returns nullable INode promise
  66642. */
  66643. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66644. /**
  66645. * Called after the exporter state changes to EXPORTING
  66646. */
  66647. onExporting?(): void;
  66648. }
  66649. }
  66650. declare module BABYLON.GLTF2.Exporter {
  66651. /**
  66652. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66653. * @hidden
  66654. */
  66655. export class _GLTFMaterialExporter {
  66656. /**
  66657. * Represents the dielectric specular values for R, G and B
  66658. */
  66659. private static readonly _DielectricSpecular;
  66660. /**
  66661. * Allows the maximum specular power to be defined for material calculations
  66662. */
  66663. private static readonly _MaxSpecularPower;
  66664. /**
  66665. * Mapping to store textures
  66666. */
  66667. private _textureMap;
  66668. /**
  66669. * Numeric tolerance value
  66670. */
  66671. private static readonly _Epsilon;
  66672. /**
  66673. * Reference to the glTF Exporter
  66674. */
  66675. private _exporter;
  66676. constructor(exporter: _Exporter);
  66677. /**
  66678. * Specifies if two colors are approximately equal in value
  66679. * @param color1 first color to compare to
  66680. * @param color2 second color to compare to
  66681. * @param epsilon threshold value
  66682. */
  66683. private static FuzzyEquals;
  66684. /**
  66685. * Gets the materials from a Babylon scene and converts them to glTF materials
  66686. * @param scene babylonjs scene
  66687. * @param mimeType texture mime type
  66688. * @param images array of images
  66689. * @param textures array of textures
  66690. * @param materials array of materials
  66691. * @param imageData mapping of texture names to base64 textures
  66692. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66693. */
  66694. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66695. /**
  66696. * Makes a copy of the glTF material without the texture parameters
  66697. * @param originalMaterial original glTF material
  66698. * @returns glTF material without texture parameters
  66699. */
  66700. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66701. /**
  66702. * Specifies if the material has any texture parameters present
  66703. * @param material glTF Material
  66704. * @returns boolean specifying if texture parameters are present
  66705. */
  66706. _hasTexturesPresent(material: IMaterial): boolean;
  66707. /**
  66708. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66709. * @param babylonStandardMaterial
  66710. * @returns glTF Metallic Roughness Material representation
  66711. */
  66712. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66713. /**
  66714. * Computes the metallic factor
  66715. * @param diffuse diffused value
  66716. * @param specular specular value
  66717. * @param oneMinusSpecularStrength one minus the specular strength
  66718. * @returns metallic value
  66719. */
  66720. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66721. /**
  66722. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66723. * @param glTFMaterial glTF material
  66724. * @param babylonMaterial Babylon material
  66725. */
  66726. private static _SetAlphaMode;
  66727. /**
  66728. * Converts a Babylon Standard Material to a glTF Material
  66729. * @param babylonStandardMaterial BJS Standard Material
  66730. * @param mimeType mime type to use for the textures
  66731. * @param images array of glTF image interfaces
  66732. * @param textures array of glTF texture interfaces
  66733. * @param materials array of glTF material interfaces
  66734. * @param imageData map of image file name to data
  66735. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66736. */
  66737. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66738. /**
  66739. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66740. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66741. * @param mimeType mime type to use for the textures
  66742. * @param images array of glTF image interfaces
  66743. * @param textures array of glTF texture interfaces
  66744. * @param materials array of glTF material interfaces
  66745. * @param imageData map of image file name to data
  66746. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66747. */
  66748. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66749. /**
  66750. * Converts an image typed array buffer to a base64 image
  66751. * @param buffer typed array buffer
  66752. * @param width width of the image
  66753. * @param height height of the image
  66754. * @param mimeType mimetype of the image
  66755. * @returns base64 image string
  66756. */
  66757. private _createBase64FromCanvasAsync;
  66758. /**
  66759. * Generates a white texture based on the specified width and height
  66760. * @param width width of the texture in pixels
  66761. * @param height height of the texture in pixels
  66762. * @param scene babylonjs scene
  66763. * @returns white texture
  66764. */
  66765. private _createWhiteTexture;
  66766. /**
  66767. * 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
  66768. * @param texture1 first texture to resize
  66769. * @param texture2 second texture to resize
  66770. * @param scene babylonjs scene
  66771. * @returns resized textures or null
  66772. */
  66773. private _resizeTexturesToSameDimensions;
  66774. /**
  66775. * Converts an array of pixels to a Float32Array
  66776. * Throws an error if the pixel format is not supported
  66777. * @param pixels - array buffer containing pixel values
  66778. * @returns Float32 of pixels
  66779. */
  66780. private _convertPixelArrayToFloat32;
  66781. /**
  66782. * Convert Specular Glossiness Textures to Metallic Roughness
  66783. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66784. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66785. * @param diffuseTexture texture used to store diffuse information
  66786. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66787. * @param factors specular glossiness material factors
  66788. * @param mimeType the mime type to use for the texture
  66789. * @returns pbr metallic roughness interface or null
  66790. */
  66791. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66792. /**
  66793. * Converts specular glossiness material properties to metallic roughness
  66794. * @param specularGlossiness interface with specular glossiness material properties
  66795. * @returns interface with metallic roughness material properties
  66796. */
  66797. private _convertSpecularGlossinessToMetallicRoughness;
  66798. /**
  66799. * Calculates the surface reflectance, independent of lighting conditions
  66800. * @param color Color source to calculate brightness from
  66801. * @returns number representing the perceived brightness, or zero if color is undefined
  66802. */
  66803. private _getPerceivedBrightness;
  66804. /**
  66805. * Returns the maximum color component value
  66806. * @param color
  66807. * @returns maximum color component value, or zero if color is null or undefined
  66808. */
  66809. private _getMaxComponent;
  66810. /**
  66811. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66812. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66813. * @param mimeType mime type to use for the textures
  66814. * @param images array of glTF image interfaces
  66815. * @param textures array of glTF texture interfaces
  66816. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66817. * @param imageData map of image file name to data
  66818. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66819. * @returns glTF PBR Metallic Roughness factors
  66820. */
  66821. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66822. private _getGLTFTextureSampler;
  66823. private _getGLTFTextureWrapMode;
  66824. private _getGLTFTextureWrapModesSampler;
  66825. /**
  66826. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66827. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66828. * @param mimeType mime type to use for the textures
  66829. * @param images array of glTF image interfaces
  66830. * @param textures array of glTF texture interfaces
  66831. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66832. * @param imageData map of image file name to data
  66833. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66834. * @returns glTF PBR Metallic Roughness factors
  66835. */
  66836. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66837. /**
  66838. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66839. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66840. * @param mimeType mime type to use for the textures
  66841. * @param images array of glTF image interfaces
  66842. * @param textures array of glTF texture interfaces
  66843. * @param materials array of glTF material interfaces
  66844. * @param imageData map of image file name to data
  66845. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66846. */
  66847. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66848. private setMetallicRoughnessPbrMaterial;
  66849. private getPixelsFromTexture;
  66850. /**
  66851. * Extracts a texture from a Babylon texture into file data and glTF data
  66852. * @param babylonTexture Babylon texture to extract
  66853. * @param mimeType Mime Type of the babylonTexture
  66854. * @return glTF texture info, or null if the texture format is not supported
  66855. */
  66856. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66857. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66858. /**
  66859. * Builds a texture from base64 string
  66860. * @param base64Texture base64 texture string
  66861. * @param baseTextureName Name to use for the texture
  66862. * @param mimeType image mime type for the texture
  66863. * @param images array of images
  66864. * @param textures array of textures
  66865. * @param imageData map of image data
  66866. * @returns glTF texture info, or null if the texture format is not supported
  66867. */
  66868. private _getTextureInfoFromBase64;
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /**
  66873. * Class for holding and downloading glTF file data
  66874. */
  66875. export class GLTFData {
  66876. /**
  66877. * Object which contains the file name as the key and its data as the value
  66878. */
  66879. glTFFiles: {
  66880. [fileName: string]: string | Blob;
  66881. };
  66882. /**
  66883. * Initializes the glTF file object
  66884. */
  66885. constructor();
  66886. /**
  66887. * Downloads the glTF data as files based on their names and data
  66888. */
  66889. downloadFiles(): void;
  66890. }
  66891. }
  66892. declare module BABYLON {
  66893. /**
  66894. * Holds a collection of exporter options and parameters
  66895. */
  66896. export interface IExportOptions {
  66897. /**
  66898. * Function which indicates whether a babylon node should be exported or not
  66899. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66900. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66901. */
  66902. shouldExportNode?(node: Node): boolean;
  66903. /**
  66904. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66905. * @param metadata source metadata to read from
  66906. * @returns the data to store to glTF node extras
  66907. */
  66908. metadataSelector?(metadata: any): any;
  66909. /**
  66910. * The sample rate to bake animation curves
  66911. */
  66912. animationSampleRate?: number;
  66913. /**
  66914. * Begin serialization without waiting for the scene to be ready
  66915. */
  66916. exportWithoutWaitingForScene?: boolean;
  66917. }
  66918. /**
  66919. * Class for generating glTF data from a Babylon scene.
  66920. */
  66921. export class GLTF2Export {
  66922. /**
  66923. * Exports the geometry of the scene to .gltf file format asynchronously
  66924. * @param scene Babylon scene with scene hierarchy information
  66925. * @param filePrefix File prefix to use when generating the glTF file
  66926. * @param options Exporter options
  66927. * @returns Returns an object with a .gltf file and associates texture names
  66928. * as keys and their data and paths as values
  66929. */
  66930. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66931. private static _PreExportAsync;
  66932. private static _PostExportAsync;
  66933. /**
  66934. * Exports the geometry of the scene to .glb file format asychronously
  66935. * @param scene Babylon scene with scene hierarchy information
  66936. * @param filePrefix File prefix to use when generating glb file
  66937. * @param options Exporter options
  66938. * @returns Returns an object with a .glb filename as key and data as value
  66939. */
  66940. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66941. }
  66942. }
  66943. declare module BABYLON.GLTF2.Exporter {
  66944. /**
  66945. * @hidden
  66946. */
  66947. export class _GLTFUtilities {
  66948. /**
  66949. * Creates a buffer view based on the supplied arguments
  66950. * @param bufferIndex index value of the specified buffer
  66951. * @param byteOffset byte offset value
  66952. * @param byteLength byte length of the bufferView
  66953. * @param byteStride byte distance between conequential elements
  66954. * @param name name of the buffer view
  66955. * @returns bufferView for glTF
  66956. */
  66957. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66958. /**
  66959. * Creates an accessor based on the supplied arguments
  66960. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66961. * @param name The name of the accessor
  66962. * @param type The type of the accessor
  66963. * @param componentType The datatype of components in the attribute
  66964. * @param count The number of attributes referenced by this accessor
  66965. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66966. * @param min Minimum value of each component in this attribute
  66967. * @param max Maximum value of each component in this attribute
  66968. * @returns accessor for glTF
  66969. */
  66970. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66971. /**
  66972. * Calculates the minimum and maximum values of an array of position floats
  66973. * @param positions Positions array of a mesh
  66974. * @param vertexStart Starting vertex offset to calculate min and max values
  66975. * @param vertexCount Number of vertices to check for min and max values
  66976. * @returns min number array and max number array
  66977. */
  66978. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66979. min: number[];
  66980. max: number[];
  66981. };
  66982. /**
  66983. * Converts a new right-handed Vector3
  66984. * @param vector vector3 array
  66985. * @returns right-handed Vector3
  66986. */
  66987. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66988. /**
  66989. * Converts a Vector3 to right-handed
  66990. * @param vector Vector3 to convert to right-handed
  66991. */
  66992. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66993. /**
  66994. * Converts a three element number array to right-handed
  66995. * @param vector number array to convert to right-handed
  66996. */
  66997. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66998. /**
  66999. * Converts a new right-handed Vector3
  67000. * @param vector vector3 array
  67001. * @returns right-handed Vector3
  67002. */
  67003. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67004. /**
  67005. * Converts a Vector3 to right-handed
  67006. * @param vector Vector3 to convert to right-handed
  67007. */
  67008. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67009. /**
  67010. * Converts a three element number array to right-handed
  67011. * @param vector number array to convert to right-handed
  67012. */
  67013. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67014. /**
  67015. * Converts a Vector4 to right-handed
  67016. * @param vector Vector4 to convert to right-handed
  67017. */
  67018. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67019. /**
  67020. * Converts a Vector4 to right-handed
  67021. * @param vector Vector4 to convert to right-handed
  67022. */
  67023. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67024. /**
  67025. * Converts a Quaternion to right-handed
  67026. * @param quaternion Source quaternion to convert to right-handed
  67027. */
  67028. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67029. /**
  67030. * Converts a Quaternion to right-handed
  67031. * @param quaternion Source quaternion to convert to right-handed
  67032. */
  67033. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67034. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67035. }
  67036. }
  67037. declare module BABYLON.GLTF2.Exporter {
  67038. /**
  67039. * Converts Babylon Scene into glTF 2.0.
  67040. * @hidden
  67041. */
  67042. export class _Exporter {
  67043. /**
  67044. * Stores the glTF to export
  67045. */
  67046. _glTF: IGLTF;
  67047. /**
  67048. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67049. */
  67050. _bufferViews: IBufferView[];
  67051. /**
  67052. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67053. */
  67054. _accessors: IAccessor[];
  67055. /**
  67056. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67057. */
  67058. private _nodes;
  67059. /**
  67060. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67061. */
  67062. private _scenes;
  67063. /**
  67064. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67065. */
  67066. private _meshes;
  67067. /**
  67068. * Stores all the generated material information, which represents the appearance of each primitive
  67069. */
  67070. _materials: IMaterial[];
  67071. _materialMap: {
  67072. [materialID: number]: number;
  67073. };
  67074. /**
  67075. * Stores all the generated texture information, which is referenced by glTF materials
  67076. */
  67077. _textures: ITexture[];
  67078. /**
  67079. * Stores all the generated image information, which is referenced by glTF textures
  67080. */
  67081. _images: IImage[];
  67082. /**
  67083. * Stores all the texture samplers
  67084. */
  67085. _samplers: ISampler[];
  67086. /**
  67087. * Stores all the generated animation samplers, which is referenced by glTF animations
  67088. */
  67089. /**
  67090. * Stores the animations for glTF models
  67091. */
  67092. private _animations;
  67093. /**
  67094. * Stores the total amount of bytes stored in the glTF buffer
  67095. */
  67096. private _totalByteLength;
  67097. /**
  67098. * Stores a reference to the Babylon scene containing the source geometry and material information
  67099. */
  67100. _babylonScene: Scene;
  67101. /**
  67102. * Stores a map of the image data, where the key is the file name and the value
  67103. * is the image data
  67104. */
  67105. _imageData: {
  67106. [fileName: string]: {
  67107. data: Uint8Array;
  67108. mimeType: ImageMimeType;
  67109. };
  67110. };
  67111. /**
  67112. * Stores a map of the unique id of a node to its index in the node array
  67113. */
  67114. private _nodeMap;
  67115. /**
  67116. * Specifies if the Babylon scene should be converted to right-handed on export
  67117. */
  67118. _convertToRightHandedSystem: boolean;
  67119. /**
  67120. * Baked animation sample rate
  67121. */
  67122. private _animationSampleRate;
  67123. private _options;
  67124. private _localEngine;
  67125. _glTFMaterialExporter: _GLTFMaterialExporter;
  67126. private _extensions;
  67127. private static _ExtensionNames;
  67128. private static _ExtensionFactories;
  67129. private _applyExtensions;
  67130. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  67131. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67132. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67133. private _forEachExtensions;
  67134. private _extensionsOnExporting;
  67135. /**
  67136. * Load glTF serializer extensions
  67137. */
  67138. private _loadExtensions;
  67139. /**
  67140. * Creates a glTF Exporter instance, which can accept optional exporter options
  67141. * @param babylonScene Babylon scene object
  67142. * @param options Options to modify the behavior of the exporter
  67143. */
  67144. constructor(babylonScene: Scene, options?: IExportOptions);
  67145. /**
  67146. * Registers a glTF exporter extension
  67147. * @param name Name of the extension to export
  67148. * @param factory The factory function that creates the exporter extension
  67149. */
  67150. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67151. /**
  67152. * Un-registers an exporter extension
  67153. * @param name The name fo the exporter extension
  67154. * @returns A boolean indicating whether the extension has been un-registered
  67155. */
  67156. static UnregisterExtension(name: string): boolean;
  67157. /**
  67158. * Lazy load a local engine with premultiplied alpha set to false
  67159. */
  67160. _getLocalEngine(): Engine;
  67161. private reorderIndicesBasedOnPrimitiveMode;
  67162. /**
  67163. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67164. * clock-wise during export to glTF
  67165. * @param submesh BabylonJS submesh
  67166. * @param primitiveMode Primitive mode of the mesh
  67167. * @param sideOrientation the winding order of the submesh
  67168. * @param vertexBufferKind The type of vertex attribute
  67169. * @param meshAttributeArray The vertex attribute data
  67170. * @param byteOffset The offset to the binary data
  67171. * @param binaryWriter The binary data for the glTF file
  67172. */
  67173. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67174. /**
  67175. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67176. * clock-wise during export to glTF
  67177. * @param submesh BabylonJS submesh
  67178. * @param primitiveMode Primitive mode of the mesh
  67179. * @param sideOrientation the winding order of the submesh
  67180. * @param vertexBufferKind The type of vertex attribute
  67181. * @param meshAttributeArray The vertex attribute data
  67182. * @param byteOffset The offset to the binary data
  67183. * @param binaryWriter The binary data for the glTF file
  67184. */
  67185. private reorderTriangleFillMode;
  67186. /**
  67187. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67188. * clock-wise during export to glTF
  67189. * @param submesh BabylonJS submesh
  67190. * @param primitiveMode Primitive mode of the mesh
  67191. * @param sideOrientation the winding order of the submesh
  67192. * @param vertexBufferKind The type of vertex attribute
  67193. * @param meshAttributeArray The vertex attribute data
  67194. * @param byteOffset The offset to the binary data
  67195. * @param binaryWriter The binary data for the glTF file
  67196. */
  67197. private reorderTriangleStripDrawMode;
  67198. /**
  67199. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67200. * clock-wise during export to glTF
  67201. * @param submesh BabylonJS submesh
  67202. * @param primitiveMode Primitive mode of the mesh
  67203. * @param sideOrientation the winding order of the submesh
  67204. * @param vertexBufferKind The type of vertex attribute
  67205. * @param meshAttributeArray The vertex attribute data
  67206. * @param byteOffset The offset to the binary data
  67207. * @param binaryWriter The binary data for the glTF file
  67208. */
  67209. private reorderTriangleFanMode;
  67210. /**
  67211. * Writes the vertex attribute data to binary
  67212. * @param vertices The vertices to write to the binary writer
  67213. * @param byteOffset The offset into the binary writer to overwrite binary data
  67214. * @param vertexAttributeKind The vertex attribute type
  67215. * @param meshAttributeArray The vertex attribute data
  67216. * @param binaryWriter The writer containing the binary data
  67217. */
  67218. private writeVertexAttributeData;
  67219. /**
  67220. * Writes mesh attribute data to a data buffer
  67221. * Returns the bytelength of the data
  67222. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67223. * @param meshAttributeArray Array containing the attribute data
  67224. * @param binaryWriter The buffer to write the binary data to
  67225. * @param indices Used to specify the order of the vertex data
  67226. */
  67227. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67228. /**
  67229. * Generates glTF json data
  67230. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67231. * @param glTFPrefix Text to use when prefixing a glTF file
  67232. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67233. * @returns json data as string
  67234. */
  67235. private generateJSON;
  67236. /**
  67237. * Generates data for .gltf and .bin files based on the glTF prefix string
  67238. * @param glTFPrefix Text to use when prefixing a glTF file
  67239. * @returns GLTFData with glTF file data
  67240. */
  67241. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67242. /**
  67243. * Creates a binary buffer for glTF
  67244. * @returns array buffer for binary data
  67245. */
  67246. private _generateBinaryAsync;
  67247. /**
  67248. * Pads the number to a multiple of 4
  67249. * @param num number to pad
  67250. * @returns padded number
  67251. */
  67252. private _getPadding;
  67253. /**
  67254. * Generates a glb file from the json and binary data
  67255. * Returns an object with the glb file name as the key and data as the value
  67256. * @param glTFPrefix
  67257. * @returns object with glb filename as key and data as value
  67258. */
  67259. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67260. /**
  67261. * Sets the TRS for each node
  67262. * @param node glTF Node for storing the transformation data
  67263. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67264. */
  67265. private setNodeTransformation;
  67266. private getVertexBufferFromMesh;
  67267. /**
  67268. * Creates a bufferview based on the vertices type for the Babylon mesh
  67269. * @param kind Indicates the type of vertices data
  67270. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67271. * @param binaryWriter The buffer to write the bufferview data to
  67272. */
  67273. private createBufferViewKind;
  67274. /**
  67275. * The primitive mode of the Babylon mesh
  67276. * @param babylonMesh The BabylonJS mesh
  67277. */
  67278. private getMeshPrimitiveMode;
  67279. /**
  67280. * Sets the primitive mode of the glTF mesh primitive
  67281. * @param meshPrimitive glTF mesh primitive
  67282. * @param primitiveMode The primitive mode
  67283. */
  67284. private setPrimitiveMode;
  67285. /**
  67286. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67287. * @param meshPrimitive glTF mesh primitive
  67288. * @param attributeKind vertex attribute
  67289. * @returns boolean specifying if uv coordinates are present
  67290. */
  67291. private setAttributeKind;
  67292. /**
  67293. * Sets data for the primitive attributes of each submesh
  67294. * @param mesh glTF Mesh object to store the primitive attribute information
  67295. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67296. * @param binaryWriter Buffer to write the attribute data to
  67297. */
  67298. private setPrimitiveAttributesAsync;
  67299. /**
  67300. * Creates a glTF scene based on the array of meshes
  67301. * Returns the the total byte offset
  67302. * @param babylonScene Babylon scene to get the mesh data from
  67303. * @param binaryWriter Buffer to write binary data to
  67304. */
  67305. private createSceneAsync;
  67306. /**
  67307. * Creates a mapping of Node unique id to node index and handles animations
  67308. * @param babylonScene Babylon Scene
  67309. * @param nodes Babylon transform nodes
  67310. * @param binaryWriter Buffer to write binary data to
  67311. * @returns Node mapping of unique id to index
  67312. */
  67313. private createNodeMapAndAnimationsAsync;
  67314. /**
  67315. * Creates a glTF node from a Babylon mesh
  67316. * @param babylonMesh Source Babylon mesh
  67317. * @param binaryWriter Buffer for storing geometry data
  67318. * @returns glTF node
  67319. */
  67320. private createNodeAsync;
  67321. }
  67322. /**
  67323. * @hidden
  67324. *
  67325. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67326. */
  67327. export class _BinaryWriter {
  67328. /**
  67329. * Array buffer which stores all binary data
  67330. */
  67331. private _arrayBuffer;
  67332. /**
  67333. * View of the array buffer
  67334. */
  67335. private _dataView;
  67336. /**
  67337. * byte offset of data in array buffer
  67338. */
  67339. private _byteOffset;
  67340. /**
  67341. * Initialize binary writer with an initial byte length
  67342. * @param byteLength Initial byte length of the array buffer
  67343. */
  67344. constructor(byteLength: number);
  67345. /**
  67346. * Resize the array buffer to the specified byte length
  67347. * @param byteLength
  67348. */
  67349. private resizeBuffer;
  67350. /**
  67351. * Get an array buffer with the length of the byte offset
  67352. * @returns ArrayBuffer resized to the byte offset
  67353. */
  67354. getArrayBuffer(): ArrayBuffer;
  67355. /**
  67356. * Get the byte offset of the array buffer
  67357. * @returns byte offset
  67358. */
  67359. getByteOffset(): number;
  67360. /**
  67361. * Stores an UInt8 in the array buffer
  67362. * @param entry
  67363. * @param byteOffset If defined, specifies where to set the value as an offset.
  67364. */
  67365. setUInt8(entry: number, byteOffset?: number): void;
  67366. /**
  67367. * Gets an UInt32 in the array buffer
  67368. * @param entry
  67369. * @param byteOffset If defined, specifies where to set the value as an offset.
  67370. */
  67371. getUInt32(byteOffset: number): number;
  67372. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67373. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67374. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67375. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67376. /**
  67377. * Stores a Float32 in the array buffer
  67378. * @param entry
  67379. */
  67380. setFloat32(entry: number, byteOffset?: number): void;
  67381. /**
  67382. * Stores an UInt32 in the array buffer
  67383. * @param entry
  67384. * @param byteOffset If defined, specifies where to set the value as an offset.
  67385. */
  67386. setUInt32(entry: number, byteOffset?: number): void;
  67387. }
  67388. }
  67389. declare module BABYLON.GLTF2.Exporter {
  67390. /**
  67391. * @hidden
  67392. * Interface to store animation data.
  67393. */
  67394. export interface _IAnimationData {
  67395. /**
  67396. * Keyframe data.
  67397. */
  67398. inputs: number[];
  67399. /**
  67400. * Value data.
  67401. */
  67402. outputs: number[][];
  67403. /**
  67404. * Animation interpolation data.
  67405. */
  67406. samplerInterpolation: AnimationSamplerInterpolation;
  67407. /**
  67408. * Minimum keyframe value.
  67409. */
  67410. inputsMin: number;
  67411. /**
  67412. * Maximum keyframe value.
  67413. */
  67414. inputsMax: number;
  67415. }
  67416. /**
  67417. * @hidden
  67418. */
  67419. export interface _IAnimationInfo {
  67420. /**
  67421. * The target channel for the animation
  67422. */
  67423. animationChannelTargetPath: AnimationChannelTargetPath;
  67424. /**
  67425. * The glTF accessor type for the data.
  67426. */
  67427. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67428. /**
  67429. * Specifies if quaternions should be used.
  67430. */
  67431. useQuaternion: boolean;
  67432. }
  67433. /**
  67434. * @hidden
  67435. * Utility class for generating glTF animation data from BabylonJS.
  67436. */
  67437. export class _GLTFAnimation {
  67438. /**
  67439. * @ignore
  67440. *
  67441. * Creates glTF channel animation from BabylonJS animation.
  67442. * @param babylonTransformNode - BabylonJS mesh.
  67443. * @param animation - animation.
  67444. * @param animationChannelTargetPath - The target animation channel.
  67445. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  67446. * @param useQuaternion - Specifies if quaternions are used.
  67447. * @returns nullable IAnimationData
  67448. */
  67449. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  67450. private static _DeduceAnimationInfo;
  67451. /**
  67452. * @ignore
  67453. * Create node animations from the transform node animations
  67454. * @param babylonNode
  67455. * @param runtimeGLTFAnimation
  67456. * @param idleGLTFAnimations
  67457. * @param nodeMap
  67458. * @param nodes
  67459. * @param binaryWriter
  67460. * @param bufferViews
  67461. * @param accessors
  67462. * @param convertToRightHandedSystem
  67463. */
  67464. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  67465. [key: number]: number;
  67466. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67467. /**
  67468. * @ignore
  67469. * Create node animations from the animation groups
  67470. * @param babylonScene
  67471. * @param glTFAnimations
  67472. * @param nodeMap
  67473. * @param nodes
  67474. * @param binaryWriter
  67475. * @param bufferViews
  67476. * @param accessors
  67477. * @param convertToRightHandedSystem
  67478. */
  67479. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67480. [key: number]: number;
  67481. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67482. private static AddAnimation;
  67483. /**
  67484. * Create a baked animation
  67485. * @param babylonTransformNode BabylonJS mesh
  67486. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67487. * @param animationChannelTargetPath animation target channel
  67488. * @param minFrame minimum animation frame
  67489. * @param maxFrame maximum animation frame
  67490. * @param fps frames per second of the animation
  67491. * @param inputs input key frames of the animation
  67492. * @param outputs output key frame data of the animation
  67493. * @param convertToRightHandedSystem converts the values to right-handed
  67494. * @param useQuaternion specifies if quaternions should be used
  67495. */
  67496. private static _CreateBakedAnimation;
  67497. private static _ConvertFactorToVector3OrQuaternion;
  67498. private static _SetInterpolatedValue;
  67499. /**
  67500. * Creates linear animation from the animation key frames
  67501. * @param babylonTransformNode BabylonJS mesh
  67502. * @param animation BabylonJS animation
  67503. * @param animationChannelTargetPath The target animation channel
  67504. * @param frameDelta The difference between the last and first frame of the animation
  67505. * @param inputs Array to store the key frame times
  67506. * @param outputs Array to store the key frame data
  67507. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67508. * @param useQuaternion Specifies if quaternions are used in the animation
  67509. */
  67510. private static _CreateLinearOrStepAnimation;
  67511. /**
  67512. * Creates cubic spline animation from the animation key frames
  67513. * @param babylonTransformNode BabylonJS mesh
  67514. * @param animation BabylonJS animation
  67515. * @param animationChannelTargetPath The target animation channel
  67516. * @param frameDelta The difference between the last and first frame of the animation
  67517. * @param inputs Array to store the key frame times
  67518. * @param outputs Array to store the key frame data
  67519. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67520. * @param useQuaternion Specifies if quaternions are used in the animation
  67521. */
  67522. private static _CreateCubicSplineAnimation;
  67523. private static _GetBasePositionRotationOrScale;
  67524. /**
  67525. * Adds a key frame value
  67526. * @param keyFrame
  67527. * @param animation
  67528. * @param outputs
  67529. * @param animationChannelTargetPath
  67530. * @param basePositionRotationOrScale
  67531. * @param convertToRightHandedSystem
  67532. * @param useQuaternion
  67533. */
  67534. private static _AddKeyframeValue;
  67535. /**
  67536. * Determine the interpolation based on the key frames
  67537. * @param keyFrames
  67538. * @param animationChannelTargetPath
  67539. * @param useQuaternion
  67540. */
  67541. private static _DeduceInterpolation;
  67542. /**
  67543. * Adds an input tangent or output tangent to the output data
  67544. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67545. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67546. * @param outputs The animation data by keyframe
  67547. * @param animationChannelTargetPath The target animation channel
  67548. * @param interpolation The interpolation type
  67549. * @param keyFrame The key frame with the animation data
  67550. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67551. * @param useQuaternion Specifies if quaternions are used
  67552. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67553. */
  67554. private static AddSplineTangent;
  67555. /**
  67556. * Get the minimum and maximum key frames' frame values
  67557. * @param keyFrames animation key frames
  67558. * @returns the minimum and maximum key frame value
  67559. */
  67560. private static calculateMinMaxKeyFrames;
  67561. }
  67562. }
  67563. declare module BABYLON.GLTF2.Exporter {
  67564. /** @hidden */
  67565. export var textureTransformPixelShader: {
  67566. name: string;
  67567. shader: string;
  67568. };
  67569. }
  67570. declare module BABYLON.GLTF2.Exporter.Extensions {
  67571. /**
  67572. * @hidden
  67573. */
  67574. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67575. /** Name of this extension */
  67576. readonly name: string;
  67577. /** Defines whether this extension is enabled */
  67578. enabled: boolean;
  67579. /** Defines whether this extension is required */
  67580. required: boolean;
  67581. /** Reference to the glTF exporter */
  67582. private _exporter;
  67583. constructor(exporter: _Exporter);
  67584. dispose(): void;
  67585. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67586. /**
  67587. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67588. * @param babylonTexture
  67589. * @param offset
  67590. * @param rotation
  67591. * @param scale
  67592. * @param scene
  67593. */
  67594. private _textureTransformTextureAsync;
  67595. }
  67596. }
  67597. declare module BABYLON.GLTF2.Exporter.Extensions {
  67598. /**
  67599. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67600. */
  67601. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67602. /** The name of this extension. */
  67603. readonly name: string;
  67604. /** Defines whether this extension is enabled. */
  67605. enabled: boolean;
  67606. /** Defines whether this extension is required */
  67607. required: boolean;
  67608. /** Reference to the glTF exporter */
  67609. private _exporter;
  67610. private _lights;
  67611. /** @hidden */
  67612. constructor(exporter: _Exporter);
  67613. /** @hidden */
  67614. dispose(): void;
  67615. /** @hidden */
  67616. onExporting(): void;
  67617. /**
  67618. * Define this method to modify the default behavior when exporting a node
  67619. * @param context The context when exporting the node
  67620. * @param node glTF node
  67621. * @param babylonNode BabylonJS node
  67622. * @returns nullable INode promise
  67623. */
  67624. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67625. }
  67626. }
  67627. declare module BABYLON {
  67628. /**
  67629. * Class for generating STL data from a Babylon scene.
  67630. */
  67631. export class STLExport {
  67632. /**
  67633. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67634. * @param meshes list defines the mesh to serialize
  67635. * @param download triggers the automatic download of the file.
  67636. * @param fileName changes the downloads fileName.
  67637. * @param binary changes the STL to a binary type.
  67638. * @param isLittleEndian toggle for binary type exporter.
  67639. * @returns the STL as UTF8 string
  67640. */
  67641. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67642. }
  67643. }
  67644. /**
  67645. * @ignoreChildren
  67646. * @ignore
  67647. */
  67648. declare module "babylonjs-gltf2interface" {
  67649. export = BABYLON.GLTF2;
  67650. }
  67651. /**
  67652. * Module for glTF 2.0 Interface
  67653. * @ignoreChildren
  67654. * @ignore
  67655. */
  67656. declare module BABYLON.GLTF2 {
  67657. /**
  67658. * The datatype of the components in the attribute
  67659. */
  67660. const enum AccessorComponentType {
  67661. /**
  67662. * Byte
  67663. */
  67664. BYTE = 5120,
  67665. /**
  67666. * Unsigned Byte
  67667. */
  67668. UNSIGNED_BYTE = 5121,
  67669. /**
  67670. * Short
  67671. */
  67672. SHORT = 5122,
  67673. /**
  67674. * Unsigned Short
  67675. */
  67676. UNSIGNED_SHORT = 5123,
  67677. /**
  67678. * Unsigned Int
  67679. */
  67680. UNSIGNED_INT = 5125,
  67681. /**
  67682. * Float
  67683. */
  67684. FLOAT = 5126,
  67685. }
  67686. /**
  67687. * Specifies if the attirbute is a scalar, vector, or matrix
  67688. */
  67689. const enum AccessorType {
  67690. /**
  67691. * Scalar
  67692. */
  67693. SCALAR = "SCALAR",
  67694. /**
  67695. * Vector2
  67696. */
  67697. VEC2 = "VEC2",
  67698. /**
  67699. * Vector3
  67700. */
  67701. VEC3 = "VEC3",
  67702. /**
  67703. * Vector4
  67704. */
  67705. VEC4 = "VEC4",
  67706. /**
  67707. * Matrix2x2
  67708. */
  67709. MAT2 = "MAT2",
  67710. /**
  67711. * Matrix3x3
  67712. */
  67713. MAT3 = "MAT3",
  67714. /**
  67715. * Matrix4x4
  67716. */
  67717. MAT4 = "MAT4",
  67718. }
  67719. /**
  67720. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67721. */
  67722. const enum AnimationChannelTargetPath {
  67723. /**
  67724. * Translation
  67725. */
  67726. TRANSLATION = "translation",
  67727. /**
  67728. * Rotation
  67729. */
  67730. ROTATION = "rotation",
  67731. /**
  67732. * Scale
  67733. */
  67734. SCALE = "scale",
  67735. /**
  67736. * Weights
  67737. */
  67738. WEIGHTS = "weights",
  67739. }
  67740. /**
  67741. * Interpolation algorithm
  67742. */
  67743. const enum AnimationSamplerInterpolation {
  67744. /**
  67745. * The animated values are linearly interpolated between keyframes
  67746. */
  67747. LINEAR = "LINEAR",
  67748. /**
  67749. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67750. */
  67751. STEP = "STEP",
  67752. /**
  67753. * The animation's interpolation is computed using a cubic spline with specified tangents
  67754. */
  67755. CUBICSPLINE = "CUBICSPLINE",
  67756. }
  67757. /**
  67758. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67759. */
  67760. const enum CameraType {
  67761. /**
  67762. * A perspective camera containing properties to create a perspective projection matrix
  67763. */
  67764. PERSPECTIVE = "perspective",
  67765. /**
  67766. * An orthographic camera containing properties to create an orthographic projection matrix
  67767. */
  67768. ORTHOGRAPHIC = "orthographic",
  67769. }
  67770. /**
  67771. * The mime-type of the image
  67772. */
  67773. const enum ImageMimeType {
  67774. /**
  67775. * JPEG Mime-type
  67776. */
  67777. JPEG = "image/jpeg",
  67778. /**
  67779. * PNG Mime-type
  67780. */
  67781. PNG = "image/png",
  67782. }
  67783. /**
  67784. * The alpha rendering mode of the material
  67785. */
  67786. const enum MaterialAlphaMode {
  67787. /**
  67788. * The alpha value is ignored and the rendered output is fully opaque
  67789. */
  67790. OPAQUE = "OPAQUE",
  67791. /**
  67792. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67793. */
  67794. MASK = "MASK",
  67795. /**
  67796. * 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)
  67797. */
  67798. BLEND = "BLEND",
  67799. }
  67800. /**
  67801. * The type of the primitives to render
  67802. */
  67803. const enum MeshPrimitiveMode {
  67804. /**
  67805. * Points
  67806. */
  67807. POINTS = 0,
  67808. /**
  67809. * Lines
  67810. */
  67811. LINES = 1,
  67812. /**
  67813. * Line Loop
  67814. */
  67815. LINE_LOOP = 2,
  67816. /**
  67817. * Line Strip
  67818. */
  67819. LINE_STRIP = 3,
  67820. /**
  67821. * Triangles
  67822. */
  67823. TRIANGLES = 4,
  67824. /**
  67825. * Triangle Strip
  67826. */
  67827. TRIANGLE_STRIP = 5,
  67828. /**
  67829. * Triangle Fan
  67830. */
  67831. TRIANGLE_FAN = 6,
  67832. }
  67833. /**
  67834. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67835. */
  67836. const enum TextureMagFilter {
  67837. /**
  67838. * Nearest
  67839. */
  67840. NEAREST = 9728,
  67841. /**
  67842. * Linear
  67843. */
  67844. LINEAR = 9729,
  67845. }
  67846. /**
  67847. * Minification filter. All valid values correspond to WebGL enums
  67848. */
  67849. const enum TextureMinFilter {
  67850. /**
  67851. * Nearest
  67852. */
  67853. NEAREST = 9728,
  67854. /**
  67855. * Linear
  67856. */
  67857. LINEAR = 9729,
  67858. /**
  67859. * Nearest Mip-Map Nearest
  67860. */
  67861. NEAREST_MIPMAP_NEAREST = 9984,
  67862. /**
  67863. * Linear Mipmap Nearest
  67864. */
  67865. LINEAR_MIPMAP_NEAREST = 9985,
  67866. /**
  67867. * Nearest Mipmap Linear
  67868. */
  67869. NEAREST_MIPMAP_LINEAR = 9986,
  67870. /**
  67871. * Linear Mipmap Linear
  67872. */
  67873. LINEAR_MIPMAP_LINEAR = 9987,
  67874. }
  67875. /**
  67876. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67877. */
  67878. const enum TextureWrapMode {
  67879. /**
  67880. * Clamp to Edge
  67881. */
  67882. CLAMP_TO_EDGE = 33071,
  67883. /**
  67884. * Mirrored Repeat
  67885. */
  67886. MIRRORED_REPEAT = 33648,
  67887. /**
  67888. * Repeat
  67889. */
  67890. REPEAT = 10497,
  67891. }
  67892. /**
  67893. * glTF Property
  67894. */
  67895. interface IProperty {
  67896. /**
  67897. * Dictionary object with extension-specific objects
  67898. */
  67899. extensions?: {
  67900. [key: string]: any;
  67901. };
  67902. /**
  67903. * Application-Specific data
  67904. */
  67905. extras?: any;
  67906. }
  67907. /**
  67908. * glTF Child of Root Property
  67909. */
  67910. interface IChildRootProperty extends IProperty {
  67911. /**
  67912. * The user-defined name of this object
  67913. */
  67914. name?: string;
  67915. }
  67916. /**
  67917. * Indices of those attributes that deviate from their initialization value
  67918. */
  67919. interface IAccessorSparseIndices extends IProperty {
  67920. /**
  67921. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67922. */
  67923. bufferView: number;
  67924. /**
  67925. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67926. */
  67927. byteOffset?: number;
  67928. /**
  67929. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67930. */
  67931. componentType: AccessorComponentType;
  67932. }
  67933. /**
  67934. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67935. */
  67936. interface IAccessorSparseValues extends IProperty {
  67937. /**
  67938. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67939. */
  67940. bufferView: number;
  67941. /**
  67942. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67943. */
  67944. byteOffset?: number;
  67945. }
  67946. /**
  67947. * Sparse storage of attributes that deviate from their initialization value
  67948. */
  67949. interface IAccessorSparse extends IProperty {
  67950. /**
  67951. * The number of attributes encoded in this sparse accessor
  67952. */
  67953. count: number;
  67954. /**
  67955. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67956. */
  67957. indices: IAccessorSparseIndices;
  67958. /**
  67959. * 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
  67960. */
  67961. values: IAccessorSparseValues;
  67962. }
  67963. /**
  67964. * 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
  67965. */
  67966. interface IAccessor extends IChildRootProperty {
  67967. /**
  67968. * The index of the bufferview
  67969. */
  67970. bufferView?: number;
  67971. /**
  67972. * The offset relative to the start of the bufferView in bytes
  67973. */
  67974. byteOffset?: number;
  67975. /**
  67976. * The datatype of components in the attribute
  67977. */
  67978. componentType: AccessorComponentType;
  67979. /**
  67980. * Specifies whether integer data values should be normalized
  67981. */
  67982. normalized?: boolean;
  67983. /**
  67984. * The number of attributes referenced by this accessor
  67985. */
  67986. count: number;
  67987. /**
  67988. * Specifies if the attribute is a scalar, vector, or matrix
  67989. */
  67990. type: AccessorType;
  67991. /**
  67992. * Maximum value of each component in this attribute
  67993. */
  67994. max?: number[];
  67995. /**
  67996. * Minimum value of each component in this attribute
  67997. */
  67998. min?: number[];
  67999. /**
  68000. * Sparse storage of attributes that deviate from their initialization value
  68001. */
  68002. sparse?: IAccessorSparse;
  68003. }
  68004. /**
  68005. * Targets an animation's sampler at a node's property
  68006. */
  68007. interface IAnimationChannel extends IProperty {
  68008. /**
  68009. * The index of a sampler in this animation used to compute the value for the target
  68010. */
  68011. sampler: number;
  68012. /**
  68013. * The index of the node and TRS property to target
  68014. */
  68015. target: IAnimationChannelTarget;
  68016. }
  68017. /**
  68018. * The index of the node and TRS property that an animation channel targets
  68019. */
  68020. interface IAnimationChannelTarget extends IProperty {
  68021. /**
  68022. * The index of the node to target
  68023. */
  68024. node: number;
  68025. /**
  68026. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68027. */
  68028. path: AnimationChannelTargetPath;
  68029. }
  68030. /**
  68031. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68032. */
  68033. interface IAnimationSampler extends IProperty {
  68034. /**
  68035. * The index of an accessor containing keyframe input values, e.g., time
  68036. */
  68037. input: number;
  68038. /**
  68039. * Interpolation algorithm
  68040. */
  68041. interpolation?: AnimationSamplerInterpolation;
  68042. /**
  68043. * The index of an accessor, containing keyframe output values
  68044. */
  68045. output: number;
  68046. }
  68047. /**
  68048. * A keyframe animation
  68049. */
  68050. interface IAnimation extends IChildRootProperty {
  68051. /**
  68052. * An array of channels, each of which targets an animation's sampler at a node's property
  68053. */
  68054. channels: IAnimationChannel[];
  68055. /**
  68056. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68057. */
  68058. samplers: IAnimationSampler[];
  68059. }
  68060. /**
  68061. * Metadata about the glTF asset
  68062. */
  68063. interface IAsset extends IChildRootProperty {
  68064. /**
  68065. * A copyright message suitable for display to credit the content creator
  68066. */
  68067. copyright?: string;
  68068. /**
  68069. * Tool that generated this glTF model. Useful for debugging
  68070. */
  68071. generator?: string;
  68072. /**
  68073. * The glTF version that this asset targets
  68074. */
  68075. version: string;
  68076. /**
  68077. * The minimum glTF version that this asset targets
  68078. */
  68079. minVersion?: string;
  68080. }
  68081. /**
  68082. * A buffer points to binary geometry, animation, or skins
  68083. */
  68084. interface IBuffer extends IChildRootProperty {
  68085. /**
  68086. * 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
  68087. */
  68088. uri?: string;
  68089. /**
  68090. * The length of the buffer in bytes
  68091. */
  68092. byteLength: number;
  68093. }
  68094. /**
  68095. * A view into a buffer generally representing a subset of the buffer
  68096. */
  68097. interface IBufferView extends IChildRootProperty {
  68098. /**
  68099. * The index of the buffer
  68100. */
  68101. buffer: number;
  68102. /**
  68103. * The offset into the buffer in bytes
  68104. */
  68105. byteOffset?: number;
  68106. /**
  68107. * The lenth of the bufferView in bytes
  68108. */
  68109. byteLength: number;
  68110. /**
  68111. * The stride, in bytes
  68112. */
  68113. byteStride?: number;
  68114. }
  68115. /**
  68116. * An orthographic camera containing properties to create an orthographic projection matrix
  68117. */
  68118. interface ICameraOrthographic extends IProperty {
  68119. /**
  68120. * The floating-point horizontal magnification of the view. Must not be zero
  68121. */
  68122. xmag: number;
  68123. /**
  68124. * The floating-point vertical magnification of the view. Must not be zero
  68125. */
  68126. ymag: number;
  68127. /**
  68128. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68129. */
  68130. zfar: number;
  68131. /**
  68132. * The floating-point distance to the near clipping plane
  68133. */
  68134. znear: number;
  68135. }
  68136. /**
  68137. * A perspective camera containing properties to create a perspective projection matrix
  68138. */
  68139. interface ICameraPerspective extends IProperty {
  68140. /**
  68141. * The floating-point aspect ratio of the field of view
  68142. */
  68143. aspectRatio?: number;
  68144. /**
  68145. * The floating-point vertical field of view in radians
  68146. */
  68147. yfov: number;
  68148. /**
  68149. * The floating-point distance to the far clipping plane
  68150. */
  68151. zfar?: number;
  68152. /**
  68153. * The floating-point distance to the near clipping plane
  68154. */
  68155. znear: number;
  68156. }
  68157. /**
  68158. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68159. */
  68160. interface ICamera extends IChildRootProperty {
  68161. /**
  68162. * An orthographic camera containing properties to create an orthographic projection matrix
  68163. */
  68164. orthographic?: ICameraOrthographic;
  68165. /**
  68166. * A perspective camera containing properties to create a perspective projection matrix
  68167. */
  68168. perspective?: ICameraPerspective;
  68169. /**
  68170. * Specifies if the camera uses a perspective or orthographic projection
  68171. */
  68172. type: CameraType;
  68173. }
  68174. /**
  68175. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68176. */
  68177. interface IImage extends IChildRootProperty {
  68178. /**
  68179. * 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
  68180. */
  68181. uri?: string;
  68182. /**
  68183. * The image's MIME type
  68184. */
  68185. mimeType?: ImageMimeType;
  68186. /**
  68187. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68188. */
  68189. bufferView?: number;
  68190. }
  68191. /**
  68192. * Material Normal Texture Info
  68193. */
  68194. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68195. /**
  68196. * The scalar multiplier applied to each normal vector of the normal texture
  68197. */
  68198. scale?: number;
  68199. }
  68200. /**
  68201. * Material Occlusion Texture Info
  68202. */
  68203. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68204. /**
  68205. * A scalar multiplier controlling the amount of occlusion applied
  68206. */
  68207. strength?: number;
  68208. }
  68209. /**
  68210. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68211. */
  68212. interface IMaterialPbrMetallicRoughness {
  68213. /**
  68214. * The material's base color factor
  68215. */
  68216. baseColorFactor?: number[];
  68217. /**
  68218. * The base color texture
  68219. */
  68220. baseColorTexture?: ITextureInfo;
  68221. /**
  68222. * The metalness of the material
  68223. */
  68224. metallicFactor?: number;
  68225. /**
  68226. * The roughness of the material
  68227. */
  68228. roughnessFactor?: number;
  68229. /**
  68230. * The metallic-roughness texture
  68231. */
  68232. metallicRoughnessTexture?: ITextureInfo;
  68233. }
  68234. /**
  68235. * The material appearance of a primitive
  68236. */
  68237. interface IMaterial extends IChildRootProperty {
  68238. /**
  68239. * 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
  68240. */
  68241. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68242. /**
  68243. * The normal map texture
  68244. */
  68245. normalTexture?: IMaterialNormalTextureInfo;
  68246. /**
  68247. * The occlusion map texture
  68248. */
  68249. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68250. /**
  68251. * The emissive map texture
  68252. */
  68253. emissiveTexture?: ITextureInfo;
  68254. /**
  68255. * 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
  68256. */
  68257. emissiveFactor?: number[];
  68258. /**
  68259. * The alpha rendering mode of the material
  68260. */
  68261. alphaMode?: MaterialAlphaMode;
  68262. /**
  68263. * The alpha cutoff value of the material
  68264. */
  68265. alphaCutoff?: number;
  68266. /**
  68267. * Specifies whether the material is double sided
  68268. */
  68269. doubleSided?: boolean;
  68270. }
  68271. /**
  68272. * Geometry to be rendered with the given material
  68273. */
  68274. interface IMeshPrimitive extends IProperty {
  68275. /**
  68276. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68277. */
  68278. attributes: {
  68279. [name: string]: number;
  68280. };
  68281. /**
  68282. * The index of the accessor that contains the indices
  68283. */
  68284. indices?: number;
  68285. /**
  68286. * The index of the material to apply to this primitive when rendering
  68287. */
  68288. material?: number;
  68289. /**
  68290. * The type of primitives to render. All valid values correspond to WebGL enums
  68291. */
  68292. mode?: MeshPrimitiveMode;
  68293. /**
  68294. * 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
  68295. */
  68296. targets?: {
  68297. [name: string]: number;
  68298. }[];
  68299. }
  68300. /**
  68301. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68302. */
  68303. interface IMesh extends IChildRootProperty {
  68304. /**
  68305. * An array of primitives, each defining geometry to be rendered with a material
  68306. */
  68307. primitives: IMeshPrimitive[];
  68308. /**
  68309. * Array of weights to be applied to the Morph Targets
  68310. */
  68311. weights?: number[];
  68312. }
  68313. /**
  68314. * A node in the node hierarchy
  68315. */
  68316. interface INode extends IChildRootProperty {
  68317. /**
  68318. * The index of the camera referenced by this node
  68319. */
  68320. camera?: number;
  68321. /**
  68322. * The indices of this node's children
  68323. */
  68324. children?: number[];
  68325. /**
  68326. * The index of the skin referenced by this node
  68327. */
  68328. skin?: number;
  68329. /**
  68330. * A floating-point 4x4 transformation matrix stored in column-major order
  68331. */
  68332. matrix?: number[];
  68333. /**
  68334. * The index of the mesh in this node
  68335. */
  68336. mesh?: number;
  68337. /**
  68338. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68339. */
  68340. rotation?: number[];
  68341. /**
  68342. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68343. */
  68344. scale?: number[];
  68345. /**
  68346. * The node's translation along the x, y, and z axes
  68347. */
  68348. translation?: number[];
  68349. /**
  68350. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68351. */
  68352. weights?: number[];
  68353. }
  68354. /**
  68355. * Texture sampler properties for filtering and wrapping modes
  68356. */
  68357. interface ISampler extends IChildRootProperty {
  68358. /**
  68359. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68360. */
  68361. magFilter?: TextureMagFilter;
  68362. /**
  68363. * Minification filter. All valid values correspond to WebGL enums
  68364. */
  68365. minFilter?: TextureMinFilter;
  68366. /**
  68367. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68368. */
  68369. wrapS?: TextureWrapMode;
  68370. /**
  68371. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68372. */
  68373. wrapT?: TextureWrapMode;
  68374. }
  68375. /**
  68376. * The root nodes of a scene
  68377. */
  68378. interface IScene extends IChildRootProperty {
  68379. /**
  68380. * The indices of each root node
  68381. */
  68382. nodes: number[];
  68383. }
  68384. /**
  68385. * Joints and matrices defining a skin
  68386. */
  68387. interface ISkin extends IChildRootProperty {
  68388. /**
  68389. * 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
  68390. */
  68391. inverseBindMatrices?: number;
  68392. /**
  68393. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68394. */
  68395. skeleton?: number;
  68396. /**
  68397. * 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)
  68398. */
  68399. joints: number[];
  68400. }
  68401. /**
  68402. * A texture and its sampler
  68403. */
  68404. interface ITexture extends IChildRootProperty {
  68405. /**
  68406. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68407. */
  68408. sampler?: number;
  68409. /**
  68410. * The index of the image used by this texture
  68411. */
  68412. source: number;
  68413. }
  68414. /**
  68415. * Reference to a texture
  68416. */
  68417. interface ITextureInfo extends IProperty {
  68418. /**
  68419. * The index of the texture
  68420. */
  68421. index: number;
  68422. /**
  68423. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68424. */
  68425. texCoord?: number;
  68426. }
  68427. /**
  68428. * The root object for a glTF asset
  68429. */
  68430. interface IGLTF extends IProperty {
  68431. /**
  68432. * An array of accessors. An accessor is a typed view into a bufferView
  68433. */
  68434. accessors?: IAccessor[];
  68435. /**
  68436. * An array of keyframe animations
  68437. */
  68438. animations?: IAnimation[];
  68439. /**
  68440. * Metadata about the glTF asset
  68441. */
  68442. asset: IAsset;
  68443. /**
  68444. * An array of buffers. A buffer points to binary geometry, animation, or skins
  68445. */
  68446. buffers?: IBuffer[];
  68447. /**
  68448. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  68449. */
  68450. bufferViews?: IBufferView[];
  68451. /**
  68452. * An array of cameras
  68453. */
  68454. cameras?: ICamera[];
  68455. /**
  68456. * Names of glTF extensions used somewhere in this asset
  68457. */
  68458. extensionsUsed?: string[];
  68459. /**
  68460. * Names of glTF extensions required to properly load this asset
  68461. */
  68462. extensionsRequired?: string[];
  68463. /**
  68464. * An array of images. An image defines data used to create a texture
  68465. */
  68466. images?: IImage[];
  68467. /**
  68468. * An array of materials. A material defines the appearance of a primitive
  68469. */
  68470. materials?: IMaterial[];
  68471. /**
  68472. * An array of meshes. A mesh is a set of primitives to be rendered
  68473. */
  68474. meshes?: IMesh[];
  68475. /**
  68476. * An array of nodes
  68477. */
  68478. nodes?: INode[];
  68479. /**
  68480. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68481. */
  68482. samplers?: ISampler[];
  68483. /**
  68484. * The index of the default scene
  68485. */
  68486. scene?: number;
  68487. /**
  68488. * An array of scenes
  68489. */
  68490. scenes?: IScene[];
  68491. /**
  68492. * An array of skins. A skin is defined by joints and matrices
  68493. */
  68494. skins?: ISkin[];
  68495. /**
  68496. * An array of textures
  68497. */
  68498. textures?: ITexture[];
  68499. }
  68500. /**
  68501. * The glTF validation results
  68502. */
  68503. interface IGLTFValidationResults {
  68504. info: {
  68505. generator: string;
  68506. hasAnimations: boolean;
  68507. hasDefaultScene: boolean;
  68508. hasMaterials: boolean;
  68509. hasMorphTargets: boolean;
  68510. hasSkins: boolean;
  68511. hasTextures: boolean;
  68512. maxAttributesUsed: number;
  68513. primitivesCount: number
  68514. };
  68515. issues: {
  68516. messages: Array<string>;
  68517. numErrors: number;
  68518. numHints: number;
  68519. numInfos: number;
  68520. numWarnings: number;
  68521. truncated: boolean
  68522. };
  68523. mimeType: string;
  68524. uri: string;
  68525. validatedAt: string;
  68526. validatorVersion: string;
  68527. }
  68528. /**
  68529. * The glTF validation options
  68530. */
  68531. interface IGLTFValidationOptions {
  68532. uri?: string;
  68533. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68534. validateAccessorData?: boolean;
  68535. maxIssues?: number;
  68536. ignoredIssues?: Array<string>;
  68537. severityOverrides?: Object;
  68538. }
  68539. /**
  68540. * The glTF validator object
  68541. */
  68542. interface IGLTFValidator {
  68543. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68544. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68545. }
  68546. }
  68547. declare module BABYLON {
  68548. /** @hidden */
  68549. export var cellPixelShader: {
  68550. name: string;
  68551. shader: string;
  68552. };
  68553. }
  68554. declare module BABYLON {
  68555. /** @hidden */
  68556. export var cellVertexShader: {
  68557. name: string;
  68558. shader: string;
  68559. };
  68560. }
  68561. declare module BABYLON {
  68562. export class CellMaterial extends BABYLON.PushMaterial {
  68563. private _diffuseTexture;
  68564. diffuseTexture: BABYLON.BaseTexture;
  68565. diffuseColor: BABYLON.Color3;
  68566. _computeHighLevel: boolean;
  68567. computeHighLevel: boolean;
  68568. private _disableLighting;
  68569. disableLighting: boolean;
  68570. private _maxSimultaneousLights;
  68571. maxSimultaneousLights: number;
  68572. private _renderId;
  68573. constructor(name: string, scene: BABYLON.Scene);
  68574. needAlphaBlending(): boolean;
  68575. needAlphaTesting(): boolean;
  68576. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68577. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68578. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68579. getAnimatables(): BABYLON.IAnimatable[];
  68580. getActiveTextures(): BABYLON.BaseTexture[];
  68581. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68582. dispose(forceDisposeEffect?: boolean): void;
  68583. getClassName(): string;
  68584. clone(name: string): CellMaterial;
  68585. serialize(): any;
  68586. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68587. }
  68588. }
  68589. declare module BABYLON {
  68590. export class CustomShaderStructure {
  68591. FragmentStore: string;
  68592. VertexStore: string;
  68593. constructor();
  68594. }
  68595. export class ShaderSpecialParts {
  68596. constructor();
  68597. Fragment_Begin: string;
  68598. Fragment_Definitions: string;
  68599. Fragment_MainBegin: string;
  68600. Fragment_Custom_Diffuse: string;
  68601. Fragment_Before_Lights: string;
  68602. Fragment_Before_Fog: string;
  68603. Fragment_Custom_Alpha: string;
  68604. Fragment_Before_FragColor: string;
  68605. Vertex_Begin: string;
  68606. Vertex_Definitions: string;
  68607. Vertex_MainBegin: string;
  68608. Vertex_Before_PositionUpdated: string;
  68609. Vertex_Before_NormalUpdated: string;
  68610. Vertex_MainEnd: string;
  68611. }
  68612. export class CustomMaterial extends BABYLON.StandardMaterial {
  68613. static ShaderIndexer: number;
  68614. CustomParts: ShaderSpecialParts;
  68615. _isCreatedShader: boolean;
  68616. _createdShaderName: string;
  68617. _customUniform: string[];
  68618. _newUniforms: string[];
  68619. _newUniformInstances: any[];
  68620. _newSamplerInstances: BABYLON.Texture[];
  68621. FragmentShader: string;
  68622. VertexShader: string;
  68623. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68624. ReviewUniform(name: string, arr: string[]): string[];
  68625. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68626. constructor(name: string, scene: BABYLON.Scene);
  68627. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68628. Fragment_Begin(shaderPart: string): CustomMaterial;
  68629. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68630. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68631. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68632. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68633. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68634. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68635. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68636. Vertex_Begin(shaderPart: string): CustomMaterial;
  68637. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68638. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68639. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68640. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68641. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68642. }
  68643. }
  68644. declare module BABYLON {
  68645. export class ShaderAlebdoParts {
  68646. constructor();
  68647. Fragment_Begin: string;
  68648. Fragment_Definitions: string;
  68649. Fragment_MainBegin: string;
  68650. Fragment_Custom_Albedo: string;
  68651. Fragment_Before_Lights: string;
  68652. Fragment_Custom_MetallicRoughness: string;
  68653. Fragment_Custom_MicroSurface: string;
  68654. Fragment_Before_Fog: string;
  68655. Fragment_Custom_Alpha: string;
  68656. Fragment_Before_FragColor: string;
  68657. Vertex_Begin: string;
  68658. Vertex_Definitions: string;
  68659. Vertex_MainBegin: string;
  68660. Vertex_Before_PositionUpdated: string;
  68661. Vertex_Before_NormalUpdated: string;
  68662. Vertex_MainEnd: string;
  68663. }
  68664. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68665. static ShaderIndexer: number;
  68666. CustomParts: ShaderAlebdoParts;
  68667. _isCreatedShader: boolean;
  68668. _createdShaderName: string;
  68669. _customUniform: string[];
  68670. _newUniforms: string[];
  68671. _newUniformInstances: any[];
  68672. _newSamplerInstances: BABYLON.Texture[];
  68673. FragmentShader: string;
  68674. VertexShader: string;
  68675. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68676. ReviewUniform(name: string, arr: string[]): string[];
  68677. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68678. constructor(name: string, scene: BABYLON.Scene);
  68679. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68680. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68681. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68682. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68683. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68684. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68685. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68686. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68687. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68688. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68689. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68690. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68691. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68692. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68693. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68694. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68695. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68696. }
  68697. }
  68698. declare module BABYLON {
  68699. /** @hidden */
  68700. export var firePixelShader: {
  68701. name: string;
  68702. shader: string;
  68703. };
  68704. }
  68705. declare module BABYLON {
  68706. /** @hidden */
  68707. export var fireVertexShader: {
  68708. name: string;
  68709. shader: string;
  68710. };
  68711. }
  68712. declare module BABYLON {
  68713. export class FireMaterial extends BABYLON.PushMaterial {
  68714. private _diffuseTexture;
  68715. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68716. private _distortionTexture;
  68717. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68718. private _opacityTexture;
  68719. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68720. diffuseColor: BABYLON.Color3;
  68721. speed: number;
  68722. private _scaledDiffuse;
  68723. private _renderId;
  68724. private _lastTime;
  68725. constructor(name: string, scene: BABYLON.Scene);
  68726. needAlphaBlending(): boolean;
  68727. needAlphaTesting(): boolean;
  68728. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68729. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68730. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68731. getAnimatables(): BABYLON.IAnimatable[];
  68732. getActiveTextures(): BABYLON.BaseTexture[];
  68733. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68734. getClassName(): string;
  68735. dispose(forceDisposeEffect?: boolean): void;
  68736. clone(name: string): FireMaterial;
  68737. serialize(): any;
  68738. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68739. }
  68740. }
  68741. declare module BABYLON {
  68742. /** @hidden */
  68743. export var furPixelShader: {
  68744. name: string;
  68745. shader: string;
  68746. };
  68747. }
  68748. declare module BABYLON {
  68749. /** @hidden */
  68750. export var furVertexShader: {
  68751. name: string;
  68752. shader: string;
  68753. };
  68754. }
  68755. declare module BABYLON {
  68756. export class FurMaterial extends BABYLON.PushMaterial {
  68757. private _diffuseTexture;
  68758. diffuseTexture: BABYLON.BaseTexture;
  68759. private _heightTexture;
  68760. heightTexture: BABYLON.BaseTexture;
  68761. diffuseColor: BABYLON.Color3;
  68762. furLength: number;
  68763. furAngle: number;
  68764. furColor: BABYLON.Color3;
  68765. furOffset: number;
  68766. furSpacing: number;
  68767. furGravity: BABYLON.Vector3;
  68768. furSpeed: number;
  68769. furDensity: number;
  68770. furOcclusion: number;
  68771. furTexture: BABYLON.DynamicTexture;
  68772. private _disableLighting;
  68773. disableLighting: boolean;
  68774. private _maxSimultaneousLights;
  68775. maxSimultaneousLights: number;
  68776. highLevelFur: boolean;
  68777. _meshes: BABYLON.AbstractMesh[];
  68778. private _renderId;
  68779. private _furTime;
  68780. constructor(name: string, scene: BABYLON.Scene);
  68781. furTime: number;
  68782. needAlphaBlending(): boolean;
  68783. needAlphaTesting(): boolean;
  68784. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68785. updateFur(): void;
  68786. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68787. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68788. getAnimatables(): BABYLON.IAnimatable[];
  68789. getActiveTextures(): BABYLON.BaseTexture[];
  68790. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68791. dispose(forceDisposeEffect?: boolean): void;
  68792. clone(name: string): FurMaterial;
  68793. serialize(): any;
  68794. getClassName(): string;
  68795. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68796. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68797. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68798. }
  68799. }
  68800. declare module BABYLON {
  68801. /** @hidden */
  68802. export var gradientPixelShader: {
  68803. name: string;
  68804. shader: string;
  68805. };
  68806. }
  68807. declare module BABYLON {
  68808. /** @hidden */
  68809. export var gradientVertexShader: {
  68810. name: string;
  68811. shader: string;
  68812. };
  68813. }
  68814. declare module BABYLON {
  68815. export class GradientMaterial extends BABYLON.PushMaterial {
  68816. private _maxSimultaneousLights;
  68817. maxSimultaneousLights: number;
  68818. topColor: BABYLON.Color3;
  68819. topColorAlpha: number;
  68820. bottomColor: BABYLON.Color3;
  68821. bottomColorAlpha: number;
  68822. offset: number;
  68823. scale: number;
  68824. smoothness: number;
  68825. private _disableLighting;
  68826. disableLighting: boolean;
  68827. private _renderId;
  68828. constructor(name: string, scene: BABYLON.Scene);
  68829. needAlphaBlending(): boolean;
  68830. needAlphaTesting(): boolean;
  68831. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68832. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68833. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68834. getAnimatables(): BABYLON.IAnimatable[];
  68835. dispose(forceDisposeEffect?: boolean): void;
  68836. clone(name: string): GradientMaterial;
  68837. serialize(): any;
  68838. getClassName(): string;
  68839. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68840. }
  68841. }
  68842. declare module BABYLON {
  68843. /** @hidden */
  68844. export var gridPixelShader: {
  68845. name: string;
  68846. shader: string;
  68847. };
  68848. }
  68849. declare module BABYLON {
  68850. /** @hidden */
  68851. export var gridVertexShader: {
  68852. name: string;
  68853. shader: string;
  68854. };
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * The grid materials allows you to wrap any shape with a grid.
  68859. * Colors are customizable.
  68860. */
  68861. export class GridMaterial extends BABYLON.PushMaterial {
  68862. /**
  68863. * Main color of the grid (e.g. between lines)
  68864. */
  68865. mainColor: BABYLON.Color3;
  68866. /**
  68867. * Color of the grid lines.
  68868. */
  68869. lineColor: BABYLON.Color3;
  68870. /**
  68871. * The scale of the grid compared to unit.
  68872. */
  68873. gridRatio: number;
  68874. /**
  68875. * Allows setting an offset for the grid lines.
  68876. */
  68877. gridOffset: BABYLON.Vector3;
  68878. /**
  68879. * The frequency of thicker lines.
  68880. */
  68881. majorUnitFrequency: number;
  68882. /**
  68883. * The visibility of minor units in the grid.
  68884. */
  68885. minorUnitVisibility: number;
  68886. /**
  68887. * The grid opacity outside of the lines.
  68888. */
  68889. opacity: number;
  68890. /**
  68891. * Determine RBG output is premultiplied by alpha value.
  68892. */
  68893. preMultiplyAlpha: boolean;
  68894. private _opacityTexture;
  68895. opacityTexture: BABYLON.BaseTexture;
  68896. private _gridControl;
  68897. private _renderId;
  68898. /**
  68899. * constructor
  68900. * @param name The name given to the material in order to identify it afterwards.
  68901. * @param scene The scene the material is used in.
  68902. */
  68903. constructor(name: string, scene: BABYLON.Scene);
  68904. /**
  68905. * Returns wehter or not the grid requires alpha blending.
  68906. */
  68907. needAlphaBlending(): boolean;
  68908. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68909. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68910. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68911. /**
  68912. * Dispose the material and its associated resources.
  68913. * @param forceDisposeEffect will also dispose the used effect when true
  68914. */
  68915. dispose(forceDisposeEffect?: boolean): void;
  68916. clone(name: string): GridMaterial;
  68917. serialize(): any;
  68918. getClassName(): string;
  68919. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68920. }
  68921. }
  68922. declare module BABYLON {
  68923. /** @hidden */
  68924. export var lavaPixelShader: {
  68925. name: string;
  68926. shader: string;
  68927. };
  68928. }
  68929. declare module BABYLON {
  68930. /** @hidden */
  68931. export var lavaVertexShader: {
  68932. name: string;
  68933. shader: string;
  68934. };
  68935. }
  68936. declare module BABYLON {
  68937. export class LavaMaterial extends BABYLON.PushMaterial {
  68938. private _diffuseTexture;
  68939. diffuseTexture: BABYLON.BaseTexture;
  68940. noiseTexture: BABYLON.BaseTexture;
  68941. fogColor: BABYLON.Color3;
  68942. speed: number;
  68943. movingSpeed: number;
  68944. lowFrequencySpeed: number;
  68945. fogDensity: number;
  68946. private _lastTime;
  68947. diffuseColor: BABYLON.Color3;
  68948. private _disableLighting;
  68949. disableLighting: boolean;
  68950. private _unlit;
  68951. unlit: boolean;
  68952. private _maxSimultaneousLights;
  68953. maxSimultaneousLights: number;
  68954. private _scaledDiffuse;
  68955. private _renderId;
  68956. constructor(name: string, scene: BABYLON.Scene);
  68957. needAlphaBlending(): boolean;
  68958. needAlphaTesting(): boolean;
  68959. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68960. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68961. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68962. getAnimatables(): BABYLON.IAnimatable[];
  68963. getActiveTextures(): BABYLON.BaseTexture[];
  68964. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68965. dispose(forceDisposeEffect?: boolean): void;
  68966. clone(name: string): LavaMaterial;
  68967. serialize(): any;
  68968. getClassName(): string;
  68969. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68970. }
  68971. }
  68972. declare module BABYLON {
  68973. /** @hidden */
  68974. export var mixPixelShader: {
  68975. name: string;
  68976. shader: string;
  68977. };
  68978. }
  68979. declare module BABYLON {
  68980. /** @hidden */
  68981. export var mixVertexShader: {
  68982. name: string;
  68983. shader: string;
  68984. };
  68985. }
  68986. declare module BABYLON {
  68987. export class MixMaterial extends BABYLON.PushMaterial {
  68988. /**
  68989. * Mix textures
  68990. */
  68991. private _mixTexture1;
  68992. mixTexture1: BABYLON.BaseTexture;
  68993. private _mixTexture2;
  68994. mixTexture2: BABYLON.BaseTexture;
  68995. /**
  68996. * Diffuse textures
  68997. */
  68998. private _diffuseTexture1;
  68999. diffuseTexture1: BABYLON.Texture;
  69000. private _diffuseTexture2;
  69001. diffuseTexture2: BABYLON.Texture;
  69002. private _diffuseTexture3;
  69003. diffuseTexture3: BABYLON.Texture;
  69004. private _diffuseTexture4;
  69005. diffuseTexture4: BABYLON.Texture;
  69006. private _diffuseTexture5;
  69007. diffuseTexture5: BABYLON.Texture;
  69008. private _diffuseTexture6;
  69009. diffuseTexture6: BABYLON.Texture;
  69010. private _diffuseTexture7;
  69011. diffuseTexture7: BABYLON.Texture;
  69012. private _diffuseTexture8;
  69013. diffuseTexture8: BABYLON.Texture;
  69014. /**
  69015. * Uniforms
  69016. */
  69017. diffuseColor: BABYLON.Color3;
  69018. specularColor: BABYLON.Color3;
  69019. specularPower: number;
  69020. private _disableLighting;
  69021. disableLighting: boolean;
  69022. private _maxSimultaneousLights;
  69023. maxSimultaneousLights: number;
  69024. private _renderId;
  69025. constructor(name: string, scene: BABYLON.Scene);
  69026. needAlphaBlending(): boolean;
  69027. needAlphaTesting(): boolean;
  69028. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69029. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69030. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69031. getAnimatables(): BABYLON.IAnimatable[];
  69032. getActiveTextures(): BABYLON.BaseTexture[];
  69033. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69034. dispose(forceDisposeEffect?: boolean): void;
  69035. clone(name: string): MixMaterial;
  69036. serialize(): any;
  69037. getClassName(): string;
  69038. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69039. }
  69040. }
  69041. declare module BABYLON {
  69042. /** @hidden */
  69043. export var normalPixelShader: {
  69044. name: string;
  69045. shader: string;
  69046. };
  69047. }
  69048. declare module BABYLON {
  69049. /** @hidden */
  69050. export var normalVertexShader: {
  69051. name: string;
  69052. shader: string;
  69053. };
  69054. }
  69055. declare module BABYLON {
  69056. export class NormalMaterial extends BABYLON.PushMaterial {
  69057. private _diffuseTexture;
  69058. diffuseTexture: BABYLON.BaseTexture;
  69059. diffuseColor: BABYLON.Color3;
  69060. private _disableLighting;
  69061. disableLighting: boolean;
  69062. private _maxSimultaneousLights;
  69063. maxSimultaneousLights: number;
  69064. private _renderId;
  69065. constructor(name: string, scene: BABYLON.Scene);
  69066. needAlphaBlending(): boolean;
  69067. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69068. needAlphaTesting(): boolean;
  69069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69070. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69072. getAnimatables(): BABYLON.IAnimatable[];
  69073. getActiveTextures(): BABYLON.BaseTexture[];
  69074. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69075. dispose(forceDisposeEffect?: boolean): void;
  69076. clone(name: string): NormalMaterial;
  69077. serialize(): any;
  69078. getClassName(): string;
  69079. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69080. }
  69081. }
  69082. declare module BABYLON {
  69083. /** @hidden */
  69084. export var shadowOnlyPixelShader: {
  69085. name: string;
  69086. shader: string;
  69087. };
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export var shadowOnlyVertexShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module BABYLON {
  69097. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69098. private _renderId;
  69099. private _activeLight;
  69100. constructor(name: string, scene: BABYLON.Scene);
  69101. shadowColor: BABYLON.Color3;
  69102. needAlphaBlending(): boolean;
  69103. needAlphaTesting(): boolean;
  69104. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69105. activeLight: BABYLON.IShadowLight;
  69106. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69107. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69108. clone(name: string): ShadowOnlyMaterial;
  69109. serialize(): any;
  69110. getClassName(): string;
  69111. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69112. }
  69113. }
  69114. declare module BABYLON {
  69115. /** @hidden */
  69116. export var simplePixelShader: {
  69117. name: string;
  69118. shader: string;
  69119. };
  69120. }
  69121. declare module BABYLON {
  69122. /** @hidden */
  69123. export var simpleVertexShader: {
  69124. name: string;
  69125. shader: string;
  69126. };
  69127. }
  69128. declare module BABYLON {
  69129. export class SimpleMaterial extends BABYLON.PushMaterial {
  69130. private _diffuseTexture;
  69131. diffuseTexture: BABYLON.BaseTexture;
  69132. diffuseColor: BABYLON.Color3;
  69133. private _disableLighting;
  69134. disableLighting: boolean;
  69135. private _maxSimultaneousLights;
  69136. maxSimultaneousLights: number;
  69137. private _renderId;
  69138. constructor(name: string, scene: BABYLON.Scene);
  69139. needAlphaBlending(): boolean;
  69140. needAlphaTesting(): boolean;
  69141. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69142. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69143. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69144. getAnimatables(): BABYLON.IAnimatable[];
  69145. getActiveTextures(): BABYLON.BaseTexture[];
  69146. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69147. dispose(forceDisposeEffect?: boolean): void;
  69148. clone(name: string): SimpleMaterial;
  69149. serialize(): any;
  69150. getClassName(): string;
  69151. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69152. }
  69153. }
  69154. declare module BABYLON {
  69155. /** @hidden */
  69156. export var skyPixelShader: {
  69157. name: string;
  69158. shader: string;
  69159. };
  69160. }
  69161. declare module BABYLON {
  69162. /** @hidden */
  69163. export var skyVertexShader: {
  69164. name: string;
  69165. shader: string;
  69166. };
  69167. }
  69168. declare module BABYLON {
  69169. /**
  69170. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69171. * @see https://doc.babylonjs.com/extensions/sky
  69172. */
  69173. export class SkyMaterial extends BABYLON.PushMaterial {
  69174. /**
  69175. * Defines the overall luminance of sky in interval ]0, 1[.
  69176. */
  69177. luminance: number;
  69178. /**
  69179. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69180. */
  69181. turbidity: number;
  69182. /**
  69183. * Defines the sky appearance (light intensity).
  69184. */
  69185. rayleigh: number;
  69186. /**
  69187. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69188. */
  69189. mieCoefficient: number;
  69190. /**
  69191. * Defines the amount of haze particles following the Mie scattering theory.
  69192. */
  69193. mieDirectionalG: number;
  69194. /**
  69195. * Defines the distance of the sun according to the active scene camera.
  69196. */
  69197. distance: number;
  69198. /**
  69199. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69200. * "inclined".
  69201. */
  69202. inclination: number;
  69203. /**
  69204. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69205. * an object direction and a reference direction.
  69206. */
  69207. azimuth: number;
  69208. /**
  69209. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69210. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69211. */
  69212. sunPosition: BABYLON.Vector3;
  69213. /**
  69214. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69215. * .sunPosition property.
  69216. */
  69217. useSunPosition: boolean;
  69218. /**
  69219. * Defines an offset vector used to get a horizon offset.
  69220. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69221. */
  69222. cameraOffset: BABYLON.Vector3;
  69223. private _cameraPosition;
  69224. private _renderId;
  69225. /**
  69226. * Instantiates a new sky material.
  69227. * This material allows to create dynamic and texture free
  69228. * effects for skyboxes by taking care of the atmosphere state.
  69229. * @see https://doc.babylonjs.com/extensions/sky
  69230. * @param name Define the name of the material in the scene
  69231. * @param scene Define the scene the material belong to
  69232. */
  69233. constructor(name: string, scene: BABYLON.Scene);
  69234. /**
  69235. * Specifies if the material will require alpha blending
  69236. * @returns a boolean specifying if alpha blending is needed
  69237. */
  69238. needAlphaBlending(): boolean;
  69239. /**
  69240. * Specifies if this material should be rendered in alpha test mode
  69241. * @returns false as the sky material doesn't need alpha testing.
  69242. */
  69243. needAlphaTesting(): boolean;
  69244. /**
  69245. * Get the texture used for alpha test purpose.
  69246. * @returns null as the sky material has no texture.
  69247. */
  69248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69249. /**
  69250. * Get if the submesh is ready to be used and all its information available.
  69251. * Child classes can use it to update shaders
  69252. * @param mesh defines the mesh to check
  69253. * @param subMesh defines which submesh to check
  69254. * @param useInstances specifies that instances should be used
  69255. * @returns a boolean indicating that the submesh is ready or not
  69256. */
  69257. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69258. /**
  69259. * Binds the submesh to this material by preparing the effect and shader to draw
  69260. * @param world defines the world transformation matrix
  69261. * @param mesh defines the mesh containing the submesh
  69262. * @param subMesh defines the submesh to bind the material to
  69263. */
  69264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69265. /**
  69266. * Get the list of animatables in the material.
  69267. * @returns the list of animatables object used in the material
  69268. */
  69269. getAnimatables(): BABYLON.IAnimatable[];
  69270. /**
  69271. * Disposes the material
  69272. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69273. */
  69274. dispose(forceDisposeEffect?: boolean): void;
  69275. /**
  69276. * Makes a duplicate of the material, and gives it a new name
  69277. * @param name defines the new name for the duplicated material
  69278. * @returns the cloned material
  69279. */
  69280. clone(name: string): SkyMaterial;
  69281. /**
  69282. * Serializes this material in a JSON representation
  69283. * @returns the serialized material object
  69284. */
  69285. serialize(): any;
  69286. /**
  69287. * Gets the current class name of the material e.g. "SkyMaterial"
  69288. * Mainly use in serialization.
  69289. * @returns the class name
  69290. */
  69291. getClassName(): string;
  69292. /**
  69293. * Creates a sky material from parsed material data
  69294. * @param source defines the JSON representation of the material
  69295. * @param scene defines the hosting scene
  69296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69297. * @returns a new sky material
  69298. */
  69299. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69300. }
  69301. }
  69302. declare module BABYLON {
  69303. /** @hidden */
  69304. export var terrainPixelShader: {
  69305. name: string;
  69306. shader: string;
  69307. };
  69308. }
  69309. declare module BABYLON {
  69310. /** @hidden */
  69311. export var terrainVertexShader: {
  69312. name: string;
  69313. shader: string;
  69314. };
  69315. }
  69316. declare module BABYLON {
  69317. export class TerrainMaterial extends BABYLON.PushMaterial {
  69318. private _mixTexture;
  69319. mixTexture: BABYLON.BaseTexture;
  69320. private _diffuseTexture1;
  69321. diffuseTexture1: BABYLON.Texture;
  69322. private _diffuseTexture2;
  69323. diffuseTexture2: BABYLON.Texture;
  69324. private _diffuseTexture3;
  69325. diffuseTexture3: BABYLON.Texture;
  69326. private _bumpTexture1;
  69327. bumpTexture1: BABYLON.Texture;
  69328. private _bumpTexture2;
  69329. bumpTexture2: BABYLON.Texture;
  69330. private _bumpTexture3;
  69331. bumpTexture3: BABYLON.Texture;
  69332. diffuseColor: BABYLON.Color3;
  69333. specularColor: BABYLON.Color3;
  69334. specularPower: number;
  69335. private _disableLighting;
  69336. disableLighting: boolean;
  69337. private _maxSimultaneousLights;
  69338. maxSimultaneousLights: number;
  69339. private _renderId;
  69340. constructor(name: string, scene: BABYLON.Scene);
  69341. needAlphaBlending(): boolean;
  69342. needAlphaTesting(): boolean;
  69343. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69344. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69345. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69346. getAnimatables(): BABYLON.IAnimatable[];
  69347. getActiveTextures(): BABYLON.BaseTexture[];
  69348. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69349. dispose(forceDisposeEffect?: boolean): void;
  69350. clone(name: string): TerrainMaterial;
  69351. serialize(): any;
  69352. getClassName(): string;
  69353. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69354. }
  69355. }
  69356. declare module BABYLON {
  69357. /** @hidden */
  69358. export var triplanarPixelShader: {
  69359. name: string;
  69360. shader: string;
  69361. };
  69362. }
  69363. declare module BABYLON {
  69364. /** @hidden */
  69365. export var triplanarVertexShader: {
  69366. name: string;
  69367. shader: string;
  69368. };
  69369. }
  69370. declare module BABYLON {
  69371. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69372. mixTexture: BABYLON.BaseTexture;
  69373. private _diffuseTextureX;
  69374. diffuseTextureX: BABYLON.BaseTexture;
  69375. private _diffuseTextureY;
  69376. diffuseTextureY: BABYLON.BaseTexture;
  69377. private _diffuseTextureZ;
  69378. diffuseTextureZ: BABYLON.BaseTexture;
  69379. private _normalTextureX;
  69380. normalTextureX: BABYLON.BaseTexture;
  69381. private _normalTextureY;
  69382. normalTextureY: BABYLON.BaseTexture;
  69383. private _normalTextureZ;
  69384. normalTextureZ: BABYLON.BaseTexture;
  69385. tileSize: number;
  69386. diffuseColor: BABYLON.Color3;
  69387. specularColor: BABYLON.Color3;
  69388. specularPower: number;
  69389. private _disableLighting;
  69390. disableLighting: boolean;
  69391. private _maxSimultaneousLights;
  69392. maxSimultaneousLights: number;
  69393. private _renderId;
  69394. constructor(name: string, scene: BABYLON.Scene);
  69395. needAlphaBlending(): boolean;
  69396. needAlphaTesting(): boolean;
  69397. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69398. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69399. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69400. getAnimatables(): BABYLON.IAnimatable[];
  69401. getActiveTextures(): BABYLON.BaseTexture[];
  69402. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69403. dispose(forceDisposeEffect?: boolean): void;
  69404. clone(name: string): TriPlanarMaterial;
  69405. serialize(): any;
  69406. getClassName(): string;
  69407. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69408. }
  69409. }
  69410. declare module BABYLON {
  69411. /** @hidden */
  69412. export var waterPixelShader: {
  69413. name: string;
  69414. shader: string;
  69415. };
  69416. }
  69417. declare module BABYLON {
  69418. /** @hidden */
  69419. export var waterVertexShader: {
  69420. name: string;
  69421. shader: string;
  69422. };
  69423. }
  69424. declare module BABYLON {
  69425. export class WaterMaterial extends BABYLON.PushMaterial {
  69426. renderTargetSize: BABYLON.Vector2;
  69427. private _bumpTexture;
  69428. bumpTexture: BABYLON.BaseTexture;
  69429. diffuseColor: BABYLON.Color3;
  69430. specularColor: BABYLON.Color3;
  69431. specularPower: number;
  69432. private _disableLighting;
  69433. disableLighting: boolean;
  69434. private _maxSimultaneousLights;
  69435. maxSimultaneousLights: number;
  69436. /**
  69437. * @param {number}: Represents the wind force
  69438. */
  69439. windForce: number;
  69440. /**
  69441. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  69442. */
  69443. windDirection: BABYLON.Vector2;
  69444. /**
  69445. * @param {number}: Wave height, represents the height of the waves
  69446. */
  69447. waveHeight: number;
  69448. /**
  69449. * @param {number}: Bump height, represents the bump height related to the bump map
  69450. */
  69451. bumpHeight: number;
  69452. /**
  69453. * @param {boolean}: Add a smaller moving bump to less steady waves.
  69454. */
  69455. private _bumpSuperimpose;
  69456. bumpSuperimpose: boolean;
  69457. /**
  69458. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  69459. */
  69460. private _fresnelSeparate;
  69461. fresnelSeparate: boolean;
  69462. /**
  69463. * @param {boolean}: bump Waves modify the reflection.
  69464. */
  69465. private _bumpAffectsReflection;
  69466. bumpAffectsReflection: boolean;
  69467. /**
  69468. * @param {number}: The water color blended with the refraction (near)
  69469. */
  69470. waterColor: BABYLON.Color3;
  69471. /**
  69472. * @param {number}: The blend factor related to the water color
  69473. */
  69474. colorBlendFactor: number;
  69475. /**
  69476. * @param {number}: The water color blended with the reflection (far)
  69477. */
  69478. waterColor2: BABYLON.Color3;
  69479. /**
  69480. * @param {number}: The blend factor related to the water color (reflection, far)
  69481. */
  69482. colorBlendFactor2: number;
  69483. /**
  69484. * @param {number}: Represents the maximum length of a wave
  69485. */
  69486. waveLength: number;
  69487. /**
  69488. * @param {number}: Defines the waves speed
  69489. */
  69490. waveSpeed: number;
  69491. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69492. private _mesh;
  69493. private _refractionRTT;
  69494. private _reflectionRTT;
  69495. private _reflectionTransform;
  69496. private _lastTime;
  69497. private _lastDeltaTime;
  69498. private _renderId;
  69499. private _useLogarithmicDepth;
  69500. private _waitingRenderList;
  69501. /**
  69502. * Gets a boolean indicating that current material needs to register RTT
  69503. */
  69504. readonly hasRenderTargetTextures: boolean;
  69505. /**
  69506. * Constructor
  69507. */
  69508. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69509. useLogarithmicDepth: boolean;
  69510. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69511. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69512. addToRenderList(node: any): void;
  69513. enableRenderTargets(enable: boolean): void;
  69514. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69515. readonly renderTargetsEnabled: boolean;
  69516. needAlphaBlending(): boolean;
  69517. needAlphaTesting(): boolean;
  69518. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69519. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69520. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69521. private _createRenderTargets;
  69522. getAnimatables(): BABYLON.IAnimatable[];
  69523. getActiveTextures(): BABYLON.BaseTexture[];
  69524. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69525. dispose(forceDisposeEffect?: boolean): void;
  69526. clone(name: string): WaterMaterial;
  69527. serialize(): any;
  69528. getClassName(): string;
  69529. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69530. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /** @hidden */
  69535. export var asciiartPixelShader: {
  69536. name: string;
  69537. shader: string;
  69538. };
  69539. }
  69540. declare module BABYLON {
  69541. /**
  69542. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69543. *
  69544. * It basically takes care rendering the font front the given font size to a texture.
  69545. * This is used later on in the postprocess.
  69546. */
  69547. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69548. private _font;
  69549. private _text;
  69550. private _charSize;
  69551. /**
  69552. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69553. */
  69554. readonly charSize: number;
  69555. /**
  69556. * Create a new instance of the Ascii Art FontTexture class
  69557. * @param name the name of the texture
  69558. * @param font the font to use, use the W3C CSS notation
  69559. * @param text the caracter set to use in the rendering.
  69560. * @param scene the scene that owns the texture
  69561. */
  69562. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69563. /**
  69564. * Gets the max char width of a font.
  69565. * @param font the font to use, use the W3C CSS notation
  69566. * @return the max char width
  69567. */
  69568. private getFontWidth;
  69569. /**
  69570. * Gets the max char height of a font.
  69571. * @param font the font to use, use the W3C CSS notation
  69572. * @return the max char height
  69573. */
  69574. private getFontHeight;
  69575. /**
  69576. * Clones the current AsciiArtTexture.
  69577. * @return the clone of the texture.
  69578. */
  69579. clone(): AsciiArtFontTexture;
  69580. /**
  69581. * Parses a json object representing the texture and returns an instance of it.
  69582. * @param source the source JSON representation
  69583. * @param scene the scene to create the texture for
  69584. * @return the parsed texture
  69585. */
  69586. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69587. }
  69588. /**
  69589. * Option available in the Ascii Art Post Process.
  69590. */
  69591. export interface IAsciiArtPostProcessOptions {
  69592. /**
  69593. * The font to use following the w3c font definition.
  69594. */
  69595. font?: string;
  69596. /**
  69597. * The character set to use in the postprocess.
  69598. */
  69599. characterSet?: string;
  69600. /**
  69601. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69602. * This number is defined between 0 and 1;
  69603. */
  69604. mixToTile?: number;
  69605. /**
  69606. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69607. * This number is defined between 0 and 1;
  69608. */
  69609. mixToNormal?: number;
  69610. }
  69611. /**
  69612. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69613. *
  69614. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69615. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69616. */
  69617. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69618. /**
  69619. * The font texture used to render the char in the post process.
  69620. */
  69621. private _asciiArtFontTexture;
  69622. /**
  69623. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69624. * This number is defined between 0 and 1;
  69625. */
  69626. mixToTile: number;
  69627. /**
  69628. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69629. * This number is defined between 0 and 1;
  69630. */
  69631. mixToNormal: number;
  69632. /**
  69633. * Instantiates a new Ascii Art Post Process.
  69634. * @param name the name to give to the postprocess
  69635. * @camera the camera to apply the post process to.
  69636. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69637. */
  69638. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69639. }
  69640. }
  69641. declare module BABYLON {
  69642. /** @hidden */
  69643. export var digitalrainPixelShader: {
  69644. name: string;
  69645. shader: string;
  69646. };
  69647. }
  69648. declare module BABYLON {
  69649. /**
  69650. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69651. *
  69652. * It basically takes care rendering the font front the given font size to a texture.
  69653. * This is used later on in the postprocess.
  69654. */
  69655. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69656. private _font;
  69657. private _text;
  69658. private _charSize;
  69659. /**
  69660. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69661. */
  69662. readonly charSize: number;
  69663. /**
  69664. * Create a new instance of the Digital Rain FontTexture class
  69665. * @param name the name of the texture
  69666. * @param font the font to use, use the W3C CSS notation
  69667. * @param text the caracter set to use in the rendering.
  69668. * @param scene the scene that owns the texture
  69669. */
  69670. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69671. /**
  69672. * Gets the max char width of a font.
  69673. * @param font the font to use, use the W3C CSS notation
  69674. * @return the max char width
  69675. */
  69676. private getFontWidth;
  69677. /**
  69678. * Gets the max char height of a font.
  69679. * @param font the font to use, use the W3C CSS notation
  69680. * @return the max char height
  69681. */
  69682. private getFontHeight;
  69683. /**
  69684. * Clones the current DigitalRainFontTexture.
  69685. * @return the clone of the texture.
  69686. */
  69687. clone(): DigitalRainFontTexture;
  69688. /**
  69689. * Parses a json object representing the texture and returns an instance of it.
  69690. * @param source the source JSON representation
  69691. * @param scene the scene to create the texture for
  69692. * @return the parsed texture
  69693. */
  69694. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69695. }
  69696. /**
  69697. * Option available in the Digital Rain Post Process.
  69698. */
  69699. export interface IDigitalRainPostProcessOptions {
  69700. /**
  69701. * The font to use following the w3c font definition.
  69702. */
  69703. font?: string;
  69704. /**
  69705. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69706. * This number is defined between 0 and 1;
  69707. */
  69708. mixToTile?: number;
  69709. /**
  69710. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69711. * This number is defined between 0 and 1;
  69712. */
  69713. mixToNormal?: number;
  69714. }
  69715. /**
  69716. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69717. *
  69718. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69719. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69720. */
  69721. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69722. /**
  69723. * The font texture used to render the char in the post process.
  69724. */
  69725. private _digitalRainFontTexture;
  69726. /**
  69727. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69728. * This number is defined between 0 and 1;
  69729. */
  69730. mixToTile: number;
  69731. /**
  69732. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69733. * This number is defined between 0 and 1;
  69734. */
  69735. mixToNormal: number;
  69736. /**
  69737. * Instantiates a new Digital Rain Post Process.
  69738. * @param name the name to give to the postprocess
  69739. * @camera the camera to apply the post process to.
  69740. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69741. */
  69742. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69743. }
  69744. }
  69745. declare module BABYLON {
  69746. /** @hidden */
  69747. export var oceanPostProcessPixelShader: {
  69748. name: string;
  69749. shader: string;
  69750. };
  69751. }
  69752. declare module BABYLON {
  69753. /**
  69754. * Option available in the Ocean Post Process.
  69755. */
  69756. export interface IOceanPostProcessOptions {
  69757. /**
  69758. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69759. */
  69760. reflectionSize?: number | {
  69761. width: number;
  69762. height: number;
  69763. } | {
  69764. ratio: number;
  69765. };
  69766. /**
  69767. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69768. */
  69769. refractionSize?: number | {
  69770. width: number;
  69771. height: number;
  69772. } | {
  69773. ratio: number;
  69774. };
  69775. }
  69776. /**
  69777. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69778. *
  69779. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69780. * Example usage:
  69781. * var pp = new OceanPostProcess("myOcean", camera);
  69782. * pp.reflectionEnabled = true;
  69783. * pp.refractionEnabled = true;
  69784. */
  69785. export class OceanPostProcess extends BABYLON.PostProcess {
  69786. /**
  69787. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69788. */
  69789. /**
  69790. * Sets weither or not the real-time reflection is enabled on the ocean.
  69791. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69792. */
  69793. reflectionEnabled: boolean;
  69794. /**
  69795. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69796. */
  69797. /**
  69798. * Sets weither or not the real-time refraction is enabled on the ocean.
  69799. * Is set to true, the refraction render target texture will be used as refraction texture.
  69800. */
  69801. refractionEnabled: boolean;
  69802. /**
  69803. * Gets wether or not the post-processes is supported by the running hardware.
  69804. * This requires draw buffer supports.
  69805. */
  69806. readonly isSupported: boolean;
  69807. /**
  69808. * This is the reflection mirror texture used to display reflections on the ocean.
  69809. * By default, render list is empty.
  69810. */
  69811. reflectionTexture: BABYLON.MirrorTexture;
  69812. /**
  69813. * This is the refraction render target texture used to display refraction on the ocean.
  69814. * By default, render list is empty.
  69815. */
  69816. refractionTexture: BABYLON.RenderTargetTexture;
  69817. private _time;
  69818. private _cameraRotation;
  69819. private _cameraViewMatrix;
  69820. private _reflectionEnabled;
  69821. private _refractionEnabled;
  69822. private _geometryRenderer;
  69823. /**
  69824. * Instantiates a new Ocean Post Process.
  69825. * @param name the name to give to the postprocess.
  69826. * @camera the camera to apply the post process to.
  69827. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69828. */
  69829. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69830. /**
  69831. * Returns the appropriate defines according to the current configuration.
  69832. */
  69833. private _getDefines;
  69834. /**
  69835. * Computes the current camera rotation as the shader requires a camera rotation.
  69836. */
  69837. private _computeCameraRotation;
  69838. }
  69839. }
  69840. declare module BABYLON {
  69841. /** @hidden */
  69842. export var brickProceduralTexturePixelShader: {
  69843. name: string;
  69844. shader: string;
  69845. };
  69846. }
  69847. declare module BABYLON {
  69848. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69849. private _numberOfBricksHeight;
  69850. private _numberOfBricksWidth;
  69851. private _jointColor;
  69852. private _brickColor;
  69853. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69854. updateShaderUniforms(): void;
  69855. numberOfBricksHeight: number;
  69856. numberOfBricksWidth: number;
  69857. jointColor: BABYLON.Color3;
  69858. brickColor: BABYLON.Color3;
  69859. /**
  69860. * Serializes this brick procedural texture
  69861. * @returns a serialized brick procedural texture object
  69862. */
  69863. serialize(): any;
  69864. /**
  69865. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69866. * @param parsedTexture defines parsed texture data
  69867. * @param scene defines the current scene
  69868. * @param rootUrl defines the root URL containing brick procedural texture information
  69869. * @returns a parsed Brick Procedural BABYLON.Texture
  69870. */
  69871. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69872. }
  69873. }
  69874. declare module BABYLON {
  69875. /** @hidden */
  69876. export var cloudProceduralTexturePixelShader: {
  69877. name: string;
  69878. shader: string;
  69879. };
  69880. }
  69881. declare module BABYLON {
  69882. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69883. private _skyColor;
  69884. private _cloudColor;
  69885. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69886. updateShaderUniforms(): void;
  69887. skyColor: BABYLON.Color4;
  69888. cloudColor: BABYLON.Color4;
  69889. /**
  69890. * Serializes this cloud procedural texture
  69891. * @returns a serialized cloud procedural texture object
  69892. */
  69893. serialize(): any;
  69894. /**
  69895. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69896. * @param parsedTexture defines parsed texture data
  69897. * @param scene defines the current scene
  69898. * @param rootUrl defines the root URL containing cloud procedural texture information
  69899. * @returns a parsed Cloud Procedural BABYLON.Texture
  69900. */
  69901. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /** @hidden */
  69906. export var fireProceduralTexturePixelShader: {
  69907. name: string;
  69908. shader: string;
  69909. };
  69910. }
  69911. declare module BABYLON {
  69912. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69913. private _time;
  69914. private _speed;
  69915. private _autoGenerateTime;
  69916. private _fireColors;
  69917. private _alphaThreshold;
  69918. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69919. updateShaderUniforms(): void;
  69920. render(useCameraPostProcess?: boolean): void;
  69921. static readonly PurpleFireColors: BABYLON.Color3[];
  69922. static readonly GreenFireColors: BABYLON.Color3[];
  69923. static readonly RedFireColors: BABYLON.Color3[];
  69924. static readonly BlueFireColors: BABYLON.Color3[];
  69925. autoGenerateTime: boolean;
  69926. fireColors: BABYLON.Color3[];
  69927. time: number;
  69928. speed: BABYLON.Vector2;
  69929. alphaThreshold: number;
  69930. /**
  69931. * Serializes this fire procedural texture
  69932. * @returns a serialized fire procedural texture object
  69933. */
  69934. serialize(): any;
  69935. /**
  69936. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69937. * @param parsedTexture defines parsed texture data
  69938. * @param scene defines the current scene
  69939. * @param rootUrl defines the root URL containing fire procedural texture information
  69940. * @returns a parsed Fire Procedural BABYLON.Texture
  69941. */
  69942. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69943. }
  69944. }
  69945. declare module BABYLON {
  69946. /** @hidden */
  69947. export var grassProceduralTexturePixelShader: {
  69948. name: string;
  69949. shader: string;
  69950. };
  69951. }
  69952. declare module BABYLON {
  69953. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69954. private _grassColors;
  69955. private _groundColor;
  69956. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69957. updateShaderUniforms(): void;
  69958. grassColors: BABYLON.Color3[];
  69959. groundColor: BABYLON.Color3;
  69960. /**
  69961. * Serializes this grass procedural texture
  69962. * @returns a serialized grass procedural texture object
  69963. */
  69964. serialize(): any;
  69965. /**
  69966. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69967. * @param parsedTexture defines parsed texture data
  69968. * @param scene defines the current scene
  69969. * @param rootUrl defines the root URL containing grass procedural texture information
  69970. * @returns a parsed Grass Procedural BABYLON.Texture
  69971. */
  69972. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69973. }
  69974. }
  69975. declare module BABYLON {
  69976. /** @hidden */
  69977. export var marbleProceduralTexturePixelShader: {
  69978. name: string;
  69979. shader: string;
  69980. };
  69981. }
  69982. declare module BABYLON {
  69983. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69984. private _numberOfTilesHeight;
  69985. private _numberOfTilesWidth;
  69986. private _amplitude;
  69987. private _jointColor;
  69988. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69989. updateShaderUniforms(): void;
  69990. numberOfTilesHeight: number;
  69991. amplitude: number;
  69992. numberOfTilesWidth: number;
  69993. jointColor: BABYLON.Color3;
  69994. /**
  69995. * Serializes this marble procedural texture
  69996. * @returns a serialized marble procedural texture object
  69997. */
  69998. serialize(): any;
  69999. /**
  70000. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70001. * @param parsedTexture defines parsed texture data
  70002. * @param scene defines the current scene
  70003. * @param rootUrl defines the root URL containing marble procedural texture information
  70004. * @returns a parsed Marble Procedural BABYLON.Texture
  70005. */
  70006. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70007. }
  70008. }
  70009. declare module BABYLON {
  70010. /** @hidden */
  70011. export var normalMapProceduralTexturePixelShader: {
  70012. name: string;
  70013. shader: string;
  70014. };
  70015. }
  70016. declare module BABYLON {
  70017. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70018. private _baseTexture;
  70019. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70020. updateShaderUniforms(): void;
  70021. render(useCameraPostProcess?: boolean): void;
  70022. resize(size: any, generateMipMaps: any): void;
  70023. baseTexture: BABYLON.Texture;
  70024. /**
  70025. * Serializes this normal map procedural texture
  70026. * @returns a serialized normal map procedural texture object
  70027. */
  70028. serialize(): any;
  70029. /**
  70030. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70031. * @param parsedTexture defines parsed texture data
  70032. * @param scene defines the current scene
  70033. * @param rootUrl defines the root URL containing normal map procedural texture information
  70034. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70035. */
  70036. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70037. }
  70038. }
  70039. declare module BABYLON {
  70040. /** @hidden */
  70041. export var perlinNoiseProceduralTexturePixelShader: {
  70042. name: string;
  70043. shader: string;
  70044. };
  70045. }
  70046. declare module BABYLON {
  70047. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70048. time: number;
  70049. timeScale: number;
  70050. translationSpeed: number;
  70051. private _currentTranslation;
  70052. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70053. updateShaderUniforms(): void;
  70054. render(useCameraPostProcess?: boolean): void;
  70055. resize(size: any, generateMipMaps: any): void;
  70056. /**
  70057. * Serializes this perlin noise procedural texture
  70058. * @returns a serialized perlin noise procedural texture object
  70059. */
  70060. serialize(): any;
  70061. /**
  70062. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70063. * @param parsedTexture defines parsed texture data
  70064. * @param scene defines the current scene
  70065. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70066. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70067. */
  70068. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70069. }
  70070. }
  70071. declare module BABYLON {
  70072. /** @hidden */
  70073. export var roadProceduralTexturePixelShader: {
  70074. name: string;
  70075. shader: string;
  70076. };
  70077. }
  70078. declare module BABYLON {
  70079. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70080. private _roadColor;
  70081. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70082. updateShaderUniforms(): void;
  70083. roadColor: BABYLON.Color3;
  70084. /**
  70085. * Serializes this road procedural texture
  70086. * @returns a serialized road procedural texture object
  70087. */
  70088. serialize(): any;
  70089. /**
  70090. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70091. * @param parsedTexture defines parsed texture data
  70092. * @param scene defines the current scene
  70093. * @param rootUrl defines the root URL containing road procedural texture information
  70094. * @returns a parsed Road Procedural BABYLON.Texture
  70095. */
  70096. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70097. }
  70098. }
  70099. declare module BABYLON {
  70100. /** @hidden */
  70101. export var starfieldProceduralTexturePixelShader: {
  70102. name: string;
  70103. shader: string;
  70104. };
  70105. }
  70106. declare module BABYLON {
  70107. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70108. private _time;
  70109. private _alpha;
  70110. private _beta;
  70111. private _zoom;
  70112. private _formuparam;
  70113. private _stepsize;
  70114. private _tile;
  70115. private _brightness;
  70116. private _darkmatter;
  70117. private _distfading;
  70118. private _saturation;
  70119. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70120. updateShaderUniforms(): void;
  70121. time: number;
  70122. alpha: number;
  70123. beta: number;
  70124. formuparam: number;
  70125. stepsize: number;
  70126. zoom: number;
  70127. tile: number;
  70128. brightness: number;
  70129. darkmatter: number;
  70130. distfading: number;
  70131. saturation: number;
  70132. /**
  70133. * Serializes this starfield procedural texture
  70134. * @returns a serialized starfield procedural texture object
  70135. */
  70136. serialize(): any;
  70137. /**
  70138. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70139. * @param parsedTexture defines parsed texture data
  70140. * @param scene defines the current scene
  70141. * @param rootUrl defines the root URL containing startfield procedural texture information
  70142. * @returns a parsed Starfield Procedural BABYLON.Texture
  70143. */
  70144. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70145. }
  70146. }
  70147. declare module BABYLON {
  70148. /** @hidden */
  70149. export var woodProceduralTexturePixelShader: {
  70150. name: string;
  70151. shader: string;
  70152. };
  70153. }
  70154. declare module BABYLON {
  70155. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70156. private _ampScale;
  70157. private _woodColor;
  70158. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70159. updateShaderUniforms(): void;
  70160. ampScale: number;
  70161. woodColor: BABYLON.Color3;
  70162. /**
  70163. * Serializes this wood procedural texture
  70164. * @returns a serialized wood procedural texture object
  70165. */
  70166. serialize(): any;
  70167. /**
  70168. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70169. * @param parsedTexture defines parsed texture data
  70170. * @param scene defines the current scene
  70171. * @param rootUrl defines the root URL containing wood procedural texture information
  70172. * @returns a parsed Wood Procedural BABYLON.Texture
  70173. */
  70174. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70175. }
  70176. }